Advertisement
Guest User

rc

a guest
Mar 3rd, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.41 KB | None | 0 0
  1.  
  2. local status = "walk"
  3.  
  4. os.unloadAPI("wirelessAPI")
  5. os.loadAPI("wirelessAPI")
  6.  
  7. wirelessAPI.init(false, "right", "messendiger", status)
  8.  
  9. function fw()
  10.     if status == "mining" then
  11.         while turtle.detect() do
  12.             turtle.dig()
  13.         end
  14.     end
  15.     turtle.forward()
  16. end
  17.  
  18. function bw()
  19.     if status == "mining" then
  20.         turtle.turnLeft()
  21.         turtle.turnLeft()
  22.         fw()
  23.     else
  24.         turtle.back()
  25.     end
  26. end
  27.  
  28. function up()
  29.     if status == "mining" then
  30.         while turtle.detectUp() do
  31.             turtle.digUp()
  32.         end
  33.     end
  34.     turtle.up()
  35. end
  36.  
  37. function down()
  38.     if status == "mining" then
  39.         while turtle.detectDown() do
  40.             turtle.digDown()
  41.         end
  42.     end
  43.     turtle.down()
  44. end
  45.  
  46. function place()
  47.     for i = 1, 16, 1 do
  48.         if turtle.getItemCount(i) > 0 then
  49.             turtle.select(i)
  50.             turtle.place()
  51.             return
  52.         end
  53.     end
  54. end
  55.  
  56. repeat
  57.     local event, sID, msg, dist, prot = wirelessAPI.listen(1)
  58.    
  59.     if event == "rednet_message" then
  60.         print("Message received: "..textutils.serialize(msg))
  61.         if msg == "forward" then
  62.             fw()
  63.         end
  64.         if msg == "backward" then
  65.             bw()
  66.         end
  67.         if msg == "up" then
  68.             up()
  69.         end
  70.         if msg == "down" then
  71.             down()
  72.         end
  73.         if msg == "left" then
  74.             turtle.turnLeft()
  75.         end
  76.         if msg == "right" then
  77.             turtle.turnRight()
  78.         end
  79.         if msg == "place" then
  80.             place()
  81.         end
  82.         if msg == "mining" or msg == "walking" then
  83.             status = msg
  84.         end
  85.        
  86.     end
  87.    
  88. until msg == "offline"
  89.  
  90. os.unloadAPI("wirelessAPI")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement