Posted 27 January 2013 - 12:15 PM
I can't seem to get this piece of code working. All the other files are there it just keeps saying that line 19 (the line in which i call my function) is calling a nul value
local Xsize
local Zsize
local Ysize
local file1 = fs.open("stats","r")
Xsize = tonumber(file1.readLine())
Ysize = tonumber(file1.readLine())
Zsize = tonumber(file1.readLine())
local fileName = file1.readLine()
local currentFile = 0
local currentLevel = 0
local currentX = 1
local wantedDirection = east
local currentY = 1
local face = file1.readLine()
file1.close()
local currentLine
local fileThingy
DoStuff()
function DoStuff()
m()
end
function changeSlots()
s = string.sub(currentLine,currentY,currentY)
i = 0
if s == "-" then
i = 6
if turtle.getItemCount(6) == 0 then
turtle.select(6+8)
turtle.dig()
turtle.place()
turtle.select(6)
turtle.suck()
turtle.select(6+8)
turtle.dig()
turtle.select(6)
else
i = tonumber(s)
turtle.select(i)
if turtle.getItemCount(i) == 0 then
turtle.select(i+8)
turtle.dig()
turtle.place()
turtle.select(i)
turtle.suck()
turtle.select(i+8)
turtle.dig()
turtle.select(i)
end
end
end
function m()
repeat
fileThingy = fs.open(fileName..""..currentFile,"r")
turtle.select(5)
turtle.refuel()
turtle.dig()
turtle.select(5+8)
turtle.place()
turtle.select(5)
turtle.suck()
turtle.select(13)
turtle.dig()
turtle.select(5)
for i = 0, Xsize do
currentLine = fileThingy.readLine()
for i = 0, Ysize do
turtle.digDown()
changeSlots()
turtle.placeDown()
repeat
turtle.dig()
until turtle.dig() == false
turtle.goForward()
currentY = currentY+1
end
turtle.turnLeft()
turtle.turnLeft()
for i = 0, Xsize do
repeat
turtle.dig()
until turtle.dig() == false
turtle.forward()
end
turtle.turnLeft()
turtle.forward()
turtle.turnLeft()
currentY = 0
end
currentFile = currentFile + 1
turtle.turnLeft()
for i = 0, Xsize do
turtle.dig()
turtle.forward()
end
fileThingy.close()
until currentFile == Zsize
end
end