Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shell.run "rm t"
- shell.run "pastebin get TPT3gpNF t"
- os.loadAPI "t"
- local pos = {gps.locate()}
- local function configure_modem(channels)
- t.on_all_modems(t.wireless, "closeAll")
- for _, c in pairs(channels) do t.on_all_modems(t.wireless, "open", c) end
- end
- print(textutils.serialise(pos))
- configure_modem({})
- t.on_all_modems(t.wired, "open", t.command_channel)
- local function process_command(c)
- if c.type == "set_channels" and c.channels and #c.channels <= 128 then
- configure_modem(c.channels)
- end
- end
- while true do
- local _, _, chan, reply_chan, message, distance = os.pullEvent "modem_message"
- if chan == t.command_channel or chan == t.message_channel then process_command(message)
- else
- t.on_all_modems(t.wired, "transmit", t.message_channel, t.command_channel, {
- channel = chan,
- reply_channel = reply_chan,
- message = message,
- distance = distance,
- time = os.day() + (os.time() / 24),
- position = pos,
- ID = os.getComputerID()
- })
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement