Advertisement
TyanColte

manualt

Jan 7th, 2013
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.86 KB | None | 0 0
  1. print("Spacial Controls:")
  2. print("W/S = Forward/Back")
  3. print("A/D = Turn Left/Right")
  4. print("Space/Shift = Move Up/Down")
  5. print("Other Commands:")
  6. print("ESC = Exit Program/Exit Turtle Interface")
  7. print("R = Refuel from any slot")
  8.  
  9. commands = {[17] = forward,  [31] = back,  [30] = lt,  [32] = rt, [57] = up, [42] = down, [19] = refuel, [1] = terminate}
  10.  
  11. function forward()
  12.   turtle.forward()
  13. end
  14.  
  15. function back()
  16.   turtle.back()
  17. end
  18.  
  19. function lt()
  20.   turtle.turnLeft()
  21. end
  22.  
  23. function rt()
  24.   turtle.turnRight()
  25. end
  26.  
  27. function up()
  28.   turtle.up()
  29. end
  30.  
  31. function down()
  32.   turtle.down()
  33. end
  34.  
  35. function refuel()
  36.   for i = 1, 16 do
  37.     turtle.select(i)
  38.     turtle.refuel(64)
  39.   end
  40. end
  41.  
  42. function terminate()
  43.   os.reboot()
  44. end
  45.  
  46. while true do
  47. event, button = os.pullEvent("key")
  48. fn = commands[button]
  49.  
  50.   if fn ~= nil then
  51.     fn()
  52.   end
  53. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement