Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --position remembering turtle
- t=[]
- function setup()
- if fs.exist("position") then
- getPos()
- else
- pos=[]
- print("X Position?")
- pos.x=tonumber(io.read)
- print("Y Position?")
- pos.y=tonumber(io.read)
- print("Z Position?")
- pos.z=tonumber(io.read)
- print("Heading? (N,E,S,W)")
- pos.h=io.read
- savePos()
- end
- hctohn=['N','E','S','W']
- hntohn=[]
- hntohn['N']=1
- hntohn['E']=1
- hntohn['S']=1
- hntohn['W']=1
- heading=[]
- heading['N']=1
- heading['E']=1
- heading['S']=-1
- heading['W']=-1
- end
- function t.turnRight()
- if hctohn[pos.h] then
- end
- end
- function t.forward()
- if turtle.forward() then
- end
- end
- function getVar(file, var)
- h=fs.open(file,"r")
- var=tonumber(h.readLine())
- h.close()
- end
- function saveVar(file, var)
- h=fs.open(file,"w")
- h.writeLine(var)
- h.close()
- end
- function saveArray(file, var)
- h=fs.open(file,"w")
- h.writeLine(textutils.serialize(var))
- h.close()
- end
- function getArray(file, var)
- h=fs.open(file,"r")
- var=textutils.unserialize(h.readLine())
- h.close()
- return var
- end
- function getPos()
- pos=getArray("position",pos)
- end
- function savePos()
- saveArray("position",pos)
- end
Add Comment
Please, Sign In to add comment