Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function back()
- turnLeft()
- turnLeft()
- forward()
- end
- function forward()
- file = io.open("tortoise/tortoiseDir","r")
- direction = file:read()
- file:close()
- file = io.open("tortoise/tortoiseX","r")
- x = file:read()
- file:close()
- file = io.open("tortoise/tortoiseY","r")
- y = file:read()
- file:close()
- file = io.open("tortoise/tortoiseZ","r")
- z = file:read()
- file:close()
- lawl = turtle.forward()
- if lawl == true then
- if direction == "north" then
- shell.run("rm","tortoise/tortoiseZ")
- file = io.open("tortoise/tortoiseZ","w")
- z = tonumber(z)
- file:write(z-1)
- file:close()
- end
- if direction == "west" then
- shell.run("rm","tortoise/tortoiseX")
- file = io.open("tortoise/tortoiseX","w")
- x = tonumber(x)
- file:write(x-1)
- file:close()
- end
- if direction == "south" then
- shell.run("rm","tortoise/tortoiseZ")
- file = io.open("tortoise/tortoiseZ","w")
- z = tonumber(z)
- file:write(z+1)
- file:close()
- end
- if direction == "east" then
- shell.run("rm","tortoise/tortoiseX")
- file = io.open("tortoise/tortoiseX","w")
- x = tonumber(x)
- file:write(x+1)
- file:close()
- end
- end
- end
- function getXYZD()
- file = io.open("tortoise/tortoiseDir","r")
- direction = file:read()
- file:close()
- file = io.open("tortoise/tortoiseX","r")
- x = tonumber(file:read())
- file:close()
- file = io.open("tortoise/tortoiseY","r")
- y = tonumber(file:read())
- file:close()
- file = io.open("tortoise/tortoiseZ","r")
- z = tonumber(file:read())
- file:close()
- return x,y,z,direction
- end
- function printXYZD()
- file = io.open("tortoise/tortoiseDir","r")
- direction = file:read()
- file:close()
- file = io.open("tortoise/tortoiseX","r")
- x = tonumber(file:read())
- file:close()
- file = io.open("tortoise/tortoiseY","r")
- y = tonumber(file:read())
- file:close()
- file = io.open("tortoise/tortoiseZ","r")
- z = tonumber(file:read())
- file:close()
- print(x.." "..y.." "..z.." "..direction)
- end
- function up()
- file = io.open("tortoise/tortoiseY","r")
- y = file:read()
- y = tonumber(y)
- file:close()
- lawl = turtle.up()
- if lawl == true then
- shell.run("rm","tortoise/tortoiseY")
- file = io.open("tortoise/tortoiseY","w")
- if y < 126 and y >= 1 then
- file:write(y+1)
- else
- file:write(y)
- end
- file:close()
- end
- end
- function turnLeft()
- file = io.open("tortoise/tortoiseDir","r")
- direction = file:read()
- file:close()
- shell.run("rm","tortoise/tortoiseDir","r")
- turtle.turnLeft()
- file = io.open("tortoise/tortoiseDir","w")
- if direction == "west" then
- file:write("south")
- end
- if direction == "east" then
- file:write("north")
- end
- if direction == "south" then
- file:write("east")
- end
- if direction == "north" then
- file:write("west")
- end
- file:close()
- end
- function turnRight()
- file = io.open("tortoise/tortoiseDir","r")
- direction = file:read()
- file:close()
- shell.run("rm","tortoise/tortoiseDir","r")
- turtle.turnRight()
- file = io.open("tortoise/tortoiseDir","w")
- if direction == "west" then
- file:write("north")
- end
- if direction == "east" then
- file:write("south")
- end
- if direction == "south" then
- file:write("west")
- end
- if direction == "north" then
- file:write("east")
- end
- file:close()
- end
- function setUp()
- shell.run("mkdir","tortoise")
- shell.run("clear")
- print("What direction is your turtle currently facing? (lower case)")
- out = read()
- file = io.open("tortoise/tortoiseDir","w")
- file:write(out)
- file:close()
- print("Current X Coord?")
- out = read()
- file = io.open("tortoise/tortoiseX","w")
- file:write(out)
- file:close()
- print("Current Z Coord?")
- out = read()
- file = io.open("tortoise/tortoiseZ","w")
- file:write(out)
- file:close()
- print("Current Y Coord?")
- out = read()
- file = io.open("tortoise/tortoiseY","w")
- file:write(out)
- file:close()
- shell.run("clear")
- print("Finished")
- end
- function down()
- file = io.open("tortoise/tortoiseY","r")
- y = file:read()
- y = tonumber(y)
- file:close()
- lawl = turtle.down()
- shell.run("rm","tortoise/tortoiseY")
- if lawl == true then
- file = io.open("tortoise/tortoiseY","w")
- if y <= 126 and y > 1 then
- file:write(y-1)
- end
- else
- file = io.open("tortoise/tortoiseY","w")
- file:write(y)
- end
- file:close()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement