SHOW:
|
|
- or go back to the newest paste.
1 | - | local m=component.proxy(component.list("modem")(1) |
1 | + | local m=component.proxy(component.list("modem")) |
2 | - | m.open(2412) |
2 | + | m.open(2412) |
3 | - | local function respond(...) |
3 | + | local function respond(...) |
4 | - | local args=table.pack(...) |
4 | + | local args=table.pack(...) |
5 | - | pcall(function() m.broadcast(2412, table.unpack(args)) end) |
5 | + | pcall(function() m.broadcast(2412, table.unpack(args)) end) |
6 | end | |
7 | - | local function receive() |
7 | + | local function receive() |
8 | - | while true do |
8 | + | while true do |
9 | - | local evt,_,_,_,_,cmd=computer.pullSignal() |
9 | + | local evt,_,_,_,_,cmd=computer.pullSignal() |
10 | - | if evt=="modem_message" then return load(cmd) end |
10 | + | if evt=="modem_message" then return load(cmd) end |
11 | end | |
12 | end | |
13 | - | while true do |
13 | + | while true do |
14 | - | local result,reason=pcall(function() |
14 | + | local result,reason=pcall(function() |
15 | - | local result,reason=receive() |
15 | + | local result,reason=receive() |
16 | - | if not result then return respond(reason) end |
16 | + | if not result then return respond(reason) end |
17 | - | respond(result()) |
17 | + | respond(result()) |
18 | - | end) |
18 | + | end) |
19 | - | if not result then respond(reason) end |
19 | + | if not result then respond(reason) end |
20 | end |