Posted 05 June 2013 - 01:47 AM
So i am attempting to make a coordinates system for a mining turtle and came across a problem when testing one of the basic functions that record when the turtle moves.
I have seen the writeLine used before to store coordinates and have no idea why it isn't working. Any help would be appreciated.
function file()
if not fs.exists("coord") then
w = fs.open("coord","w")
w.writeLine("0")
w.close()
end
end
-- this is where my problem is it erases anything that was in
-- the file
function save()
s = fs.open("coord","w")
s.writeLine(x)
s.close()
end
local x = tonumber(0)
if turtle.forward()==true then
file()
x = x+1
save()
end
print(x)
I have seen the writeLine used before to store coordinates and have no idea why it isn't working. Any help would be appreciated.