Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local g_modem = peripheral.find("modem")
- local impetus = peripheral.wrap("bottom")
- local g_modem_ID = peripheral.getName(g_modem)
- local ID = os.getComputerID()
- local g_Protocal = "iotaServer_"..ID
- local g_hostName = "iotaServer "..ID
- -- iotaServer_0
- local g_iota_list = {}
- local function init()
- rednet.open(g_modem_ID)
- print("my Proc is:\n ",g_Protocal)
- rednet.host(g_Protocal,g_hostName)
- end
- local function checkIotaList()
- g_iota_list = fs.list("iota")
- end
- local function compileLoop(filename)
- shell.run("hex ".."iota/"..filename)
- sleep(1)
- impetus.activateCircle()
- sleep(1)
- end
- local function net_listener()
- init()
- while true do
- local msgBoxPack = {["cmd"] ="",["msg"] = {}}
- local event, sender, iMsgBox, protocol = os.pullEvent("rednet_message")
- if(protocol == g_Protocal) then
- local cmd = iMsgBox["cmd"]
- local msg = iMsgBox["msg"]
- if(cmd == "get_list")then
- checkIotaList()
- msgBoxPack["cmd"] = "ret_list"
- msgBoxPack["msg"] = g_iota_list
- rednet.send(sender, msgBoxPack,protocol)
- sleep(1)
- end
- if(iMsgBox["cmd"] == "compile")then
- compileLoop(msg)
- end
- end
- end
- end
- local function mainloop()
- net_listener()
- end
- mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement