-- Example usage
local function receive()
while true do
local evt,_,_,_,_,cmd = computer.pullSignal(5)
if evt == "modem_message" then
return load(cmd)
end
end
end
modem.open(controlPort)
while true do
local result,reason = pcall(function()
local result,reason = receive()
if not result then return respond(reason) end
respond(result())
end)
if not result then respond(reason) end
end
-- My usage
function runCommands()
for i=1,#commandList do
result, reason = load(commandList[i])
if not result then modem.broadcast(commandServerPort, "Couldn't execute [" .. commandList[i] .. "] because [" .. reason .. "]") end
end
end