Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- local verbose = args[1] == "true" and true or false
- local p = peripheral
- function vprint(...)
- if verbose == true then
- print("[INIT] ", ...)
- end
- end
- function wrapWiredModem()
- local modems = {}
- local sides = {"front","back","right","left","top","bottom"}
- for n,side in ipairs(sides) do
- if (p.isPresent(side))
- and (p.getType(side) == "modem"
- and (not p.call(side, "isWireless")))
- then modems[#modems+1] = side end
- end
- if #modems ~= 1 then
- if #modems > 1 then
- printError("[INIT] More than one wired modem found!\n[INIT] Please only connect one wired modem and reboot.")
- do return end
- end
- if #modems < 1 then
- printError("[INIT] No wired modems found!\n[INIT] Please connect a wired modem and reboot.")
- do return end
- end
- end
- vprint("found modem on the ", modems[1], " side")
- return p.wrap(modems[1])
- end
- _modem = wrapWiredModem()
- _reactors = {}
- _turbines = {}
- vprint("Registering connected devices")
- for i,v in pairs(_modem.getNamesRemote()) do
- local t = _modem.getTypeRemote(v)
- if string.find(t, "BigReactors") ~= nil then
- if t == "BigReactors-Reactor" then
- _reactors[#_reactors+1] = p.wrap(v)
- end
- if t == "BigReactors-Turbine" then
- _turbines[#_turbines+1] = p.wrap(v)
- end
- end
- end
- vprint("All ", #_reactors + #_turbines, " peripherals registered.")
- _init_has_run = true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement