Advertisement
dirkus7

In computer block

Feb 24th, 2012
8,701
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. write('Please enter the bot\'s id: ')
  2. bot = tonumber(read()) -- the ID of the turtle
  3.  
  4. shell.run('clear') --clear the screen
  5.  
  6. mode = 0 -- set the mode to dig
  7. rednet.open('right') -- open wifi port
  8. while true do -- start infinite loop
  9. event, key = os.pullEvent() -- wait for input
  10. shell.run('clear') -- clear the screen again :P
  11. if key == 's' then --if the s button is pressed
  12. rednet.send(bot, 'backward')-- send message for down button
  13. print('Backward') -- write on the screen
  14. end
  15. if key == 'a' then -- left
  16. rednet.send(bot, 'left')
  17. print('Left')
  18. end
  19. if key == 'w' then --up
  20. rednet.send(bot, 'forward')
  21. print('Forward')
  22. end
  23. if key == 'd' then -- right
  24. rednet.send(bot, 'right')
  25. print('Right')
  26. end
  27. if key == 200 then
  28. rednet.send(bot, 'up')
  29. print('Up')
  30. end
  31. if key == 208 then
  32. rednet.send(bot, 'down')
  33. print('Down')
  34. end
  35.  
  36. if key == ' ' then --if the key is the spacebar
  37. if mode == 0 then -- if on digmode
  38. rednet.send(bot, 'dig') -- send message to dig
  39. print('Dig') -- write it
  40. elseif mode == 1 then -- if on placemode
  41. rednet.send(bot, 'place') -- send message to place block
  42. print('Place') --write
  43. end
  44. end
  45. if key == 203 then --if the key is left
  46. mode = 0 -- set to digmode
  47. print('Dig mode selected.') --write it
  48. end
  49. if key == 205 then -- if right
  50. mode = 1 -- set to placemode
  51. print('Place mode selected.') --write
  52. end
  53. if key == 29 then --if the left ctrl is pressed
  54. rednet.send(bot, 'rs') -- send message to enable redstone
  55. print('Redstone activated.')-- write
  56. end
  57. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement