Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- args = {...}
- x = 1
- y = 1
- z = 1
- f = 1
- tasks = {[1] = 3,3,3}
- m_table = {
- ["fd"] = function()
- turtle.forward()
- if (f == 1) then
- z = z+1
- elseif (f == 2) then
- x = x+1
- elseif (f == 3) then
- z = z-1
- elseif (f == 4) then
- x = x-1
- end
- end,
- ["bk"] = function()
- turtle.back()
- if (f == 1) then
- z = z-1
- elseif (f == 2) then
- x = x-1
- elseif (f == 3) then
- z = z+1
- elseif (f == 4) then
- x = x+1
- end
- end,
- ["rt"] = function()
- turtle.turnRight()
- if (f < 4) then
- f = f+1
- else
- f = 1
- end
- end,
- ["lt"] = function()
- turtle.turnLeft()
- if (f > 1) then
- f = f-1
- else
- f = 4
- end
- end,
- ["up"] = function()
- turtle.up()
- y = y + 1
- end,
- ["dn"] = function()
- turtle.down()
- y = y - 1
- end
- }
- function move(direction)
- local _move = m_table[direction]
- if (_move) then
- _move()
- end
- end
- function moveCoords(_x,_y,_z)
- if (y < _y) then
- repeat
- move("up")
- until(y == _y)
- else
- repeat
- move("dn")
- until(y == _y)
- end
- repeat
- move("rt")
- until(f == 2)
- if (x < _x) then
- repeat
- move("fd")
- until(x == _x)
- else
- repeat
- move("bk")
- until(x == _x)
- end
- repeat
- move("lt")
- until(f == 1)
- if (z < _z) then
- repeat
- move("fd")
- until(z == _z)
- else
- repeat
- move("bk")
- until(z == _z)
- end
- end
- moveCoords(tasks[1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement