Advertisement
Guest User

miningProgram

a guest
Feb 17th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.05 KB | None | 0 0
  1. local commands = {"CIRCLE", "MINE"}
  2. local function connectModem(port)
  3.   local modem = peripheral.wrap("right")
  4.   modem.open(port)
  5.   modem.transmit(port, port, "logged on turtle")
  6.   return modem
  7. end
  8.  
  9. local function getMessages()
  10.   while (true)
  11.     do
  12.     local event, modemSide, senderChannel,
  13.       replyChannel, message, senderDistance = os.pullEvent("modem_message")  
  14.     print(senderChannel,":",message)
  15.  
  16.     executeMessage(message)  
  17.   end
  18. end
  19.  
  20. function executeMessage(message)
  21.   if message == "CIRCLE" then
  22.     circle()
  23.   end
  24.   if message == "MINE" then
  25.     mine()
  26.   end
  27.   if message == "STOP" then
  28.     stop()
  29.   end
  30.   if message == "INFO" then
  31.     info()
  32.   end
  33. end
  34.  
  35. function circle()
  36.   for i = 4,1,-1
  37.   do
  38.     turtle.forward()
  39.     turtle.turnLeft()
  40.   end
  41. end
  42.  
  43. function mine()
  44.   shell.run("excavate 10")
  45. end
  46.  
  47. function info()
  48.   for j = 16, 0, -1
  49.   do
  50.     modem.transmit(5, 5, turtle.getItemDetail(j),"\n",turtle.getItemCount(j)
  51.   end
  52. end
  53.  
  54. function stop()
  55.   os.exit()
  56. end
  57.  
  58. modem = connectModem(5)
  59. getMessages()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement