Advertisement
WhiteFire_Sondergaar

turtle master

Apr 20th, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.77 KB | None | 0 0
  1. -- Turtle Slave Master
  2. -- By Fenthis
  3.  
  4. slave_channel = 6969
  5. status_channel = 2069
  6.  
  7. local modem = peripheral.wrap("right")
  8.  
  9.  
  10. -- Send a command
  11. local function send_command(message, group)
  12.     x, y, z = gps.locate()
  13.     if x then
  14.         message.location = vector.new(x,y,z)
  15.     end
  16.     message.sender = os.getComputerLabel()
  17.     message.group = group
  18.     modem.transmit(slave_channel, status_channel,
  19.         textutils.serialize(message))
  20. end
  21.  
  22. args = {...}
  23. if #args < 2 then
  24.     print("Usage: master group command [args...]")
  25.     return
  26. end
  27.  
  28. message = {
  29.     ["message_type"] = "slave_command",
  30.     ["command"] = args[2],
  31.     ["args"] = select(3, args)
  32. }
  33.  
  34. send_command(message, args[1])
  35.  
  36. print("Sent command \"" .. args[2] .. "\" to slave group " .. args[1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement