Advertisement
dveth

wireless

Nov 25th, 2020 (edited)
830
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.23 KB | None | 0 0
  1. local SERVER_PORT = 56
  2.  
  3. function detectAndDig()
  4.     while turtle.detect() do
  5.         turtle.dig()
  6.     end
  7. end
  8.  
  9. function digAndMove()
  10.     turtle.dig()
  11.     turtle.forward()
  12. end
  13.  
  14. -- I STOLE --
  15. function split (inputstr, sep)
  16.     if sep == nil then
  17.             sep = "%s"
  18.     end
  19.     local t={}
  20.     for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
  21.             table.insert(t, str)
  22.     end
  23.     return t
  24. end
  25.  
  26. local modem = peripheral.wrap("left")
  27.  
  28. local running = true
  29.  
  30.  
  31. modem.open(SERVER_PORT)
  32.  
  33. while running do
  34.     print("Waiting to receive...")
  35.     local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  36.     local args = split(message, " ")
  37.     local command = args[1]
  38.     for i = 1, #args do
  39.         print(args[i])
  40.     end
  41.     if command == "dig" then
  42.         digAndMove()
  43.     elseif command == "shellrun" then
  44.         shell.run(args[2])
  45.     elseif command == "stop" then
  46.         running = false
  47.     elseif command == "stripmine" then
  48.         if #args ~=3 then
  49.             print("Usage:stripmine <length> <tunnels>")
  50.         else
  51.             shell.run("stripmine", args[2], args[3])
  52.         end
  53.     else
  54.         print("Invalid command")
  55.     end
  56. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement