Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- react = peripheral.wrap("BigReactors-Reactor")
- modem = peripheral.wrap("modem")
- if not modem.isOpen(1297) then
- modem.open(1297)
- end
- function ReactorPower()
- powerMax = react.getEnergyCapacity() * 0.9
- powerMin = react.getEnergyCapacity() * 0.1
- while true do
- power = react.getEnergyStored()
- if power >= powerMax then
- onoff(false)
- end
- if power <= powerMin then
- onoff(true)
- end
- sleep(0.1)
- end
- end
- function ReactorPowerState(onoff)
- react.setActive(onoff)
- end
- function Listen()
- while true do
- local _, _, _, replyChan, m, _ = os.pullEvent("modem_message")
- if (string.find(m, string.char(12, 97)) then
- local formattedMessage = string.sub(m, 3)
- print(m .. " turned into " .. formattedMessage)
- else
- Reply("This is not the modem you are looking for!", replyChan)
- end
- end
- end
- function Reply(msg, replyChannel)
- modem.transmit(replyChannel, 1297, msg)
- end
- parallel.waitForAll(ReactorPower, Listen)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement