Advertisement
Axow01

Untitled

Aug 12th, 2023 (edited)
1,249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.55 KB | None | 0 0
  1. local directions = {north = "N", south = "S", east = "E", west = "W"}
  2. local facing = "N"
  3. local pos = {gps.locate()}
  4. local pos_moving = pos
  5.  
  6. local action = {}
  7.  
  8. action.forward = {function (times)
  9.     for i = 0, times, 1 do
  10.         turtle.forward()
  11.     end
  12.     if (facing == directions.north) then
  13.         pos[3] = pos[3] - times
  14.     elseif (facing == directions.south) then
  15.         pos[3] = pos[3] + times
  16.     elseif (facing == directions.east) then
  17.         pos[1] = pos[1] + times
  18.     elseif (facing == directions.west) then
  19.         pos[1] = pos[1] - times
  20.     end
  21.     print("New pos: " .. pos)
  22. end}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement