Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tank = peripheral.wrap("rcirontankvalvetile_0")
- local modem = peripheral.wrap("back")
- local wifi = peripheral.wrap("top")
- local reactor = peripheral.wrap("BigReactors-Reactor_2")
- local turbine = peripheral.wrap("BigReactors-Turbine_4")
- local turbine2 = peripheral.wrap("BigReactors-Turbine_5")
- local capacitor = peripheral.wrap("tile_blockcapacitorbank_name_2")
- local cap -- Tank capacity
- local amount -- Amount liquid in tank
- local percentfull -- Percent liquid in tank
- local rodLevel = 0
- local minRodLevel = 55
- local maxRodLevel = 65
- local enderMonitorRedstone = false
- local rpmTurbine = 0
- local minRpmTurbine = 1700
- local maxRpmTurbine = 1800
- local nbSlot = 120
- function getTank(tankPeriph)
- local tableInfo = tankPeriph.getTankInfo("unknown") -- Local to the getTank function.
- fluidRaw = nil
- fluidName = nil
- fluidAmount = nil
- fluidCapacity = nil
- for k,v in pairs(tableInfo) do
- fluidCapacity = v.capacity
- if v.contents then
- for i,w in pairs(v.contents) do
- if i == "rawName" then
- fluidRaw = w
- elseif i == "amount" then
- fluidAmount = w
- elseif i == "name" then
- fluidName = w
- end
- end
- end
- end
- return fluidRaw, fluidName, fluidAmount, fluidCapacity -- Returning the values of global variables (which are nil).
- end
- --// Programme de controle reacteur
- while true do
- local fluidRaw, fluidName, fluidAmount, fluidCapacity = getTank(tank)
- if fluidName then
- -- Get values for tank capacity and amount
- fluidName = string.gsub(fluidName, "^%l", string.upper)
- cap = fluidCapacity / 1000
- amount = fluidAmount
- end
- if amount == nil then
- amount = 0
- percentfull = 0
- else
- -- Use math.floor to convert to integers
- amount = math.floor(amount / 1000)
- percentfull = math.floor(100 * amount / cap)
- end
- if percentfull < 40 then
- reactor.setActive(true)
- rodLevel = minRodLevel
- reactor.setAllControlRodLevels(rodLevel)
- end
- if percentfull > 60 then
- rodLevel = maxRodLevel
- reactor.setAllControlRodLevels(rodLevel)
- end
- if percentfull > 75 then
- reactor.setActive(false)
- end
- enderMonitorRedstone = redstone.getInput("right")
- if enderMonitorRedstone then
- turbine.setInductorEngaged (true)
- turbine2.setInductorEngaged (true)
- else
- turbine.setInductorEngaged (false)
- turbine2.setInductorEngaged (false)
- end
- rpmTurbine = turbine.getRotorSpeed()
- if rpmTurbine < minRpmTurbine then
- turbine.setActive(true)
- end
- if rpmTurbine > maxRpmTurbine then
- turbine.setActive(false)
- end
- rpmTurbine2 = turbine2.getRotorSpeed()
- if rpmTurbine2 < minRpmTurbine then
- turbine2.setActive(true)
- end
- if rpmTurbine2 > maxRpmTurbine then
- turbine2.setActive(false)
- end
- capacitorEnergy = capacitor.getEnergyStored("unknown") * nbSlot
- capacitorEnergyMax = capacitor.getMaxEnergyStored("unknown") * nbSlot
- percentcelule = math.floor(100 * capacitorEnergy / capacitorEnergyMax )
- local tableau = {reacteur = reactor.getActive(), barreLevel = reactor.getControlRodLevel(1),conso = reactor.getFuelConsumedLastTick() ,steam = amount , capacity = cap , percent = percentfull, turbine = turbine.getActive() , rpm = rpmTurbine , electroAimant = turbine.getInductorEngaged() , energy = capacitorEnergy, energyMax = capacitorEnergyMax , celpercent = percentcelule , energyProduct = turbine.getEnergyProducedLastTick()+turbine2.getEnergyProducedLastTick()}
- local sendmsg = textutils.serialize(tableau)
- wifi.transmit(2,0,sendmsg)
- sleep(2)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement