Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- back = 2
- -- white = 0
- -- blue = 11
- --local component = require("component")
- local d = component.proxy(component.list("react")())
- local m = component.proxy(component.list("modem")())
- local hasModem = false
- local doDebug = false
- local microName = "testReactorBuddy"
- function sleep(timeout)
- local deadline = computer.uptime() + (timeout or 0)
- repeat
- getAndProcessSignal()
- until computer.uptime() >= deadline
- end
- function getFuelStatus()
- local ret = {}
- ret.fuel = d.getFuelAmount()
- ret.fuelMax = d.getFuelAmountMax()
- ret.waste = d.getWasteAmount()
- return ret
- end
- function getEnergyStatus()
- local ret = {}
- ret.lastEnergy = d.getEnergyStored()
- ret.energy = d.getEnergyStored() -- Pulls a second time to get delta
- ret.delta = ret.energy - ret.lastEnergy
- ret.energyMax = 10000000
- return ret
- end
- function getAndProcessSignal()
- local sigName,localaddr,from,port,_,message = computer.pullSignal(1)
- if sigName ~= nil then
- if sigName == "modem_message" then
- if message == "WHO IS: " .. microName then
- m.send(from,440,"I AM: " .. microName)
- --m.broadcast(440,"I AM: " .. microName)
- elseif message == "status: fuel" then
- m.send(from,440, getFuelStatus())
- elseif message == "status: energy" then
- m.send(from,440, getEnergyStatus())
- elseif message == "squak: " then
- --m.broadcast(440, message)
- m.send(from,440,message)
- end
- end
- end
- end
- m.open(440)
- hasModem = m.isOpen(440)
- while true do
- -- getAndProcessSignal()
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement