All pastes #3939180 Raw Edit

Someone

public unlisted text v1 · immutable
#3939180 ·published 2017-11-23 18:58 UTC
rendered paste body
--  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