Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x = 0
- y = 0
- z = 0
- o = 0
- doAttack = false
- doDig = false
- function f()
- while not turtle.forward() do
- moveFail()
- end
- if o == 0 then z=z-1 end
- if o == 1 then x=x+1 end
- if o == 2 then z=z+1 end
- if o == 3 then x=x-1 end
- p()
- end
- --queue this many functions to do
- function q(func,reps)
- for i=1,reps do
- func()
- end
- end
- function b()
- if turtle.back() then
- if o == 0 then z=z+1 end
- if o == 1 then x=x-1 end
- if o == 2 then z=z+1 end
- if o == 3 then x=x+1 end
- p()
- return true
- end
- return false
- end
- function d()
- if turtle.down() then
- y = y - 1
- p()
- return true
- end
- return false
- end
- function u()
- if turtle.up() then
- y = y + 1
- p()
- return true
- end
- return false
- end
- function r()
- turtle.turnRight()
- o=(o+1)%4
- p()
- end
- function l()
- turtle.turnLeft()
- o=(o-1)%4
- p()
- end
- function moveFail(direction)
- end
- function p()
- term.clear()
- term.setCursorPos(1,1)
- io.write("x == ") print(x)
- io.write("y == ") print(y)
- io.write("z == ") print(z)
- io.write("o == ") print(o)
- end
- function turnto(odest)
- odest = odest % 4
- while not (o == odest) do
- l()
- end
- end
- function gx(xdest)
- if xdest > x then turnto(1)
- q(f,xdest-x)
- end
- if xdest < x then turnto(3)
- q(f,x-xdest)
- end
- --does nothing if x == xdest
- end
- function gy(ydest)
- if ydest > y then q(u,ydest-y) end
- if ydest < y then q(d,y-ydest) end
- end
- function gz(zdest)
- if zdest > z then turnto(2)
- q(f,zdest-z)
- end
- if zdest < z then turnto(0)
- q(f,z-zdest)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement