Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local turbine1 = peripheral.wrap("BigReactors-Turbine_13") -- gauche
- local turbine2 = peripheral.wrap("BigReactors-Turbine_14") --droite
- local wl = peripheral.wrap("back")
- local alarm = true
- local reactor1 = peripheral.wrap("BigReactors-Reactor_14")
- local reactor2 = peripheral.wrap("BigReactors-Reactor_15")
- wl.open(199)
- term.clear()
- local mon = term
- function controlleAffiche()
- while true do
- affiche(turbine1,reactor1, "left", "left")
- sleep(0.5)
- affiche(turbine2,reactor2, "right", "right")
- sleep(0.5)
- end
- end
- function affiche(turbine, reactor, tName, rName)
- wl.transmit(199,199,tostring(reactor1.getActive()).." "..tostring(reactor2.getActive()).." "..tostring(turbine1.getActive()).." "..tostring(turbine2.getActive()).." "..tostring(math.floor(turbine1.getEnergyProducedLastTick())).." "..
- tostring(math.floor(turbine2.getEnergyProducedLastTick())).." "..tostring(turbine1.getInductorEngaged()).." "..tostring(turbine2.getInductorEngaged()).." "..tostring(math.floor(turbine1.getRotorSpeed())).." "..tostring(math.floor(turbine2.getRotorSpeed())).." "..tostring(reactor1.getFuelAmount()).." "..tostring(reactor2.getFuelAmount()).." "..tostring(math.floor(turbine1.getEnergyStored())).." "..tostring(math.floor(turbine2.getEnergyStored())))
- mon.clear()
- mon.setCursorPos(1,1)
- mon.setTextColor(colors.white)
- mon.write("Reactor "..rName.." active: ")
- mon.setTextColor(colors.lime)
- mon.write(reactor.getActive())
- mon.setCursorPos(1,2)
- mon.setTextColor(colors.white)
- mon.write("Turbine "..tName.." active: ")
- mon.setTextColor(colors.lime)
- mon.write(turbine.getActive())
- mon.setCursorPos(1,3)
- mon.setTextColor(colors.white)
- mon.write("Turbine "..tName.." engage: ")
- mon.setTextColor(colors.lime)
- mon.write(turbine.getInductorEngaged())
- mon.setCursorPos(1,4)
- mon.setTextColor(colors.white)
- mon.write("RF/T: ")
- mon.setTextColor(colors.lime)
- mon.write(math.floor(turbine.getEnergyProducedLastTick()))
- mon.setCursorPos(1,5)
- mon.setTextColor(colors.white)
- mon.write("RF Stored: ")
- mon.setTextColor(colors.lime)
- mon.write(math.floor(turbine.getEnergyStored()))
- --[[mon.setCursorPos(1,6)
- mon.setTextColor(colors.white)
- mon.write("Alarm: ")
- mon.setTextColor(colors.lime)
- mon.write(alarm)]]
- end
- function receive()
- while true do
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- machine, stat = string.match(message, "(%w*)%s(%a*)")
- if isNil(machine,stat) then
- if string.match(machine, 'reactor?')=="reactor" then
- if string.match(machine, "%d")=="1" then
- if string.match(stat, "%a*")=="false" then
- reactor1.setActive(false)
- elseif string.match(stat,"%a*")=="true" then
- reactor1.setActive(true)
- end
- elseif string.match(machine,"%d")=="2" then
- if string.match(stat, "%a*")=="false" then
- reactor2.setActive(false)
- elseif string.match(stat,"%a*")=="true" then
- reactor2.setActive(true)
- end
- end
- elseif string.match(machine, 'turbine?')=="turbine" then
- if string.match(machine,'%d')=="2" then
- if string.match(stat, "%a*")=="false" then
- turbine2.setInductorEngaged(false)
- elseif string.match(stat,"%a*")=="true" then
- turbine2.setInductorEngaged(true)
- end
- elseif string.match(machine,'%d')=="1" then
- if string.match(stat, "%a*")=="false" then
- turbine1.setInductorEngaged(false)
- elseif string.match(stat,"%a*")=="true" then
- turbine1.setInductorEngaged(true)
- end
- end
- end
- end
- end
- end
- function isNil(machine, stat)
- if machine== nil then
- return false
- end
- if stat == nil then
- return false
- end
- return true
- end
- parallel.waitForAny(receive, controlleAffiche)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement