mackpack

Untitled

Mar 26th, 2013
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.79 KB | None | 0 0
  1. box = peripheral.wrap("right")
  2. tArgs = { ... }
  3.  
  4. if #tArgs[] ~= 4 or string.lower(tArgs[4]) ~= "n" or string.lower(tArgs[4]) ~= "e" or string.lower(tArgs[4]) ~= "s" or string.lower(tArgs[4]) ~= "w" then
  5. print("Usage: <X Coord> <Y Coord> <Z Coord> <Facing direction>")
  6. else
  7. xcoord = tArgs[1]
  8. ycoord = tArgs[2]
  9. zcoord = tArgs[3]
  10. facing = targs[4]
  11. while true do
  12. event1, player, message = os.pullEvent("chat")
  13. if string.sub(string.lower(message), 1, 7) == "forward" then
  14. for i =1, tonumber(string.sub(message, 9))
  15. if turtle.forward() then
  16. if facing == "2" then
  17. zcoord = zcoord - 1
  18. elseif facing == "3" then
  19. xcoord = xcoord + 1
  20. elseif facing == "0" then
  21. zcoord = zcoord + 1
  22. elseif facing == "1" then
  23. xcoord = xcoord - 1
  24. end
  25. else
  26. box.say("Can't move forward")
  27. end
  28. end
  29. elseif string.sub(string.lower(message), 1, 8) == "backward" then
  30. for i =1, tonumber(string.sub(message, 10))
  31. if turtle.back() then
  32. if facing == "2" then
  33. zcoord = zcoord + 1
  34. elseif facing == "3" then
  35. xcoord = xcoord - 1
  36. elseif facing == "0" then
  37. zcoord = zcoord - 1
  38. elseif facing == "1" then
  39. xcoord = xcoord + 1
  40. end
  41. else
  42. box.say("Can't move backward")
  43. end
  44. end
  45. elseif string.sub(string.lower(message), 1, 2) == "up" then
  46. for i =1, tonumber(string.sub(message, 4))
  47. if turtle.up() then
  48. ycoord = ycoord + 1
  49. else
  50. box.say("Can't move up")
  51. end
  52. end
  53. elseif string.sub(string.lower(message), 1, 4) == "down" then
  54. for i =1, tonumber(string.sub(message, 6))
  55. if turtle.up() then
  56. ycoord = ycoord - 1
  57. else
  58. box.say("Can't move down")
  59. end
  60. end
  61. elseif string.sub(string.lower(message), 1, 4) == "mine" then
  62. turtle.dig()
  63. elseif string.sub(string.lower(message), 1, 6) == "mineup" then
  64. turtle.digUp()
  65. elseif string.sub(string.lower(message), 1, 8) == "minedown" then
  66. turtle.digDown()
  67. elseif string.sub(string.lower(message), 1, 6) == "refuel" then
  68. turtle.select(1)
  69. turtle.refuel(tonumber(string.sub(message, 8)))
  70. elseif string.sub(string.lower(message), 1, 4) == "suck" then
  71. turtle.suck()
  72. turtle.suckUp()
  73. turtle.suckDown()
  74. elseif string.sub(string.lower(message), 1, 4) == "sign" then
  75. turtle.select(2)
  76. turtle.place(string.sub(message, 6))
  77. turtle.select(1)
  78. elseif string.sub(string.lower(message), 1, 5) == "place" then
  79. turtle.select(3)
  80. turtle.place()
  81. turtle.select(1)
  82. elseif string.sub(string.lower(message), 1, 5) == "fuel?" then
  83. box.say(turtle.getFuelLevel())
  84. elseif string.sub(string.lower(message), 1, 7) == "coords?" then
  85. box.say("X:" .. xcoord .. " Y:" .. ycoord .. " Z:" .. zcoord .. " F:" .. facing)
  86. end
  87. sleep(1)
  88. end
  89. end
Advertisement
Add Comment
Please, Sign In to add comment