Advertisement
Guest User

human-controlled turret

a guest
Feb 3rd, 2013
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. turtle.select(2)
  2. ref = turtle.refuel()
  3. if ref == false then
  4. print("I couldn't find any kind of fuel! Have you put it in the 2nd slot?")
  5. sleep(2)
  6. os.reboot()
  7. end
  8. turtle.select(1)
  9. print("GET READY...GO!")
  10. print("Arrow keys, control arrow direction!")
  11. print("A-D keys, turn the turtle!")
  12. print("SPACE key, shoot!!")
  13. print("Q key, quit!")
  14. print("U key, + shoot charge!")
  15. print("J key, - shoot charge!")
  16. bow = peripheral.wrap("left")
  17. xDir = 0
  18. Pw = 0.1
  19. yDir = 0
  20. while true do
  21. event, key = os.pullEvent("key")
  22. if key == 57 then
  23. bow.shoot(Pw,xDir,yDir)
  24. elseif key == 30 then
  25. turtle.turnLeft()
  26. elseif key == 32 then
  27. turtle.turnRight()
  28. elseif key == 16 then
  29. os.reboot()
  30. elseif key == 200 then
  31. yDir = yDir + 1
  32. elseif key == 208 then
  33. yDir = yDir - 1
  34. elseif key == 203 then
  35. xDir = xDir - 1
  36. elseif key == 205 then
  37. xDir = xDir + 1
  38. elseif key == 22 then
  39. if Pw < 1 then
  40. Pw = Pw + 0.1
  41. end
  42. elseif key == 36 then
  43. if Pw > 0.1 then
  44. Pw = Pw - 0.1
  45. end
  46. end
  47. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement