midnightstrider

send

Mar 24th, 2021 (edited)
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. -- Computer script to send wireless commands to mining turtle
  2.  
  3. args = { ... }
  4. -- turtleid unload|finish|pause|restart [top|left|right|back]
  5.  
  6. local turtleId = 0
  7. local cmd = ""
  8. local position = "top"
  9. local ack = nil
  10.  
  11. if args[1] == nil or args[2] == nil then
  12. print("turtleId unload|finish|pause|restart [top|left|right|back]")
  13. return
  14. end
  15.  
  16.  
  17. turtleId = tonumber(args[1])
  18. cmd = args[2]
  19.  
  20. if args[3] ~= nil then
  21. position = args[3]
  22. end
  23.  
  24. cmd = cmd .. "Mining"
  25.  
  26. print("Sending command " .. cmd .. " to turtle " .. turtleId .. " on " .. position .. " modem.")
  27. rednet.open(position)
  28.  
  29. while true do
  30. rednet.send(turtleId, cmd)
  31. local senderId, message = rednet.receive(0.5)
  32. if message == "acknowledged" then
  33. break
  34. end
  35.  
  36. os.sleep(0.1)
  37. end
  38.  
Advertisement
Add Comment
Please, Sign In to add comment