Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local reactor = {}
- local function reactor.findReactors(reactor_protocol)
- local lookup = {rednet.lookup(reactor_protocol)}
- local reactors = {}
- for i=1,#lookup do
- reactors[i] = {id = lookup[i]}
- end
- print("Found Reactors: ")
- for i,#reactors do
- print("Reactor %d:", reactor[i])
- for key, print(key .. ": " .. value)
- end
- return reactors
- end
- local function reactor.getReactorInfo(reactorID, reactor_protocol)
- rednet.send(reactorID, "getInfo", reactor_protocol)
- local id, message = rednet.receive(reactor_protocol, 1)
- if id == reactors[i]["id"] then
- for key, value in pairs(message) do
- reactors[i][key] = value
- end
- end
- return reactors
- end
- local function reactor.setReactorState(reactorID, state, reactor_protocol)
- rednet.send(reactorID, "setState", reactor_protocol)
- local id, message = rednet.receive(reactor_protocol, 1)
- if id == reactorID && message == state then
- return true
- else
- return false
- end
- end
- return reactor -- {findReactors = findReactors, getReactorInfo = getReactorInfo, setReactorState = setReactorState}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement