/nano.lua Secret
Created
June 12, 2016 17:21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local c = require("component") | |
local event = require("event") | |
local args = {...} | |
local command = args[1] | |
local function printResponse(e, _, _, _, _, header, command, ...) | |
print("Captured event " .. e .. " header " .. header) | |
if header == "nanomachines" then | |
for _, v in ipairs({...}) do | |
print(v) | |
end | |
end | |
-- else | |
-- print("Caught event " .. e) | |
-- end | |
return | |
end | |
c.modem.open(1) | |
event.listen("modem_message", printResponse) | |
if args[2] ~= nil then | |
local arg1 = args[1] | |
if args[3] ~= nil then | |
local arg2 = args[2] | |
end | |
end | |
--c.modem.broadcast(1,"nanomachines","setResponsePort", 2) | |
if arg1 and arg2 then | |
c.modem.broadcast(1,"nanomachines", command, arg1, arg2) | |
print("Send command " .. command .. " with 2 args") | |
else | |
if arg1 then | |
c.modem.broadcast(1,"nanomachines", command, arg1) | |
print("Send command " .. command .. " with 1 arg") | |
else | |
c.modem.broadcast(1,"nanomachines", command) | |
print("Send command " .. command) | |
end | |
end | |
local run = true | |
while run do | |
local evnt = event.pull(1, "interrupted") | |
if evnt then | |
print("Program was interrupted") | |
return | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment