Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Little LUA code by PiggyWhiskey
- This will work for any Extra Utilites Generator that has a linear fuel calculation
- High-Temp Furnace Generator won't work
- Potion Generator will only work if they have the same level of potion etc etc
- Please feel free to use however you want...but let me have the original credit :)
- --]]
- local gen = peripheral.wrap("left") --Redstone Generator
- local eCell = peripheral.wrap("back") --Energy Cell
- local productionTime = 250 -- Fuel Burn Time (Furnace = 15, Molten Redstone = 250)
- local energyPerTick = 320 -- Fuel RF/t (Furnace = 80, Molten Redstone = 320)
- local energyProduced = productionTime * energyPerTick * 20 -- Total RF Generated
- --t1 = Time burn started
- --t2 = Current time
- local t1 = os.clock()
- local t2
- local burning = false
- local needBurn = false
- local genMax = 0
- local genCur = 0
- local cellMax = 0
- local cellCur = 0
- local so = redstone.setOutput
- function getEnergyValues()
- genMax = tonumber(gen.getMaxEnergyStored("left"))
- genCur = tonumber(gen.getEnergyStored("left"))
- cellMax = tonumber(eCell.getMaxEnergyStored("left"))
- cellCur = tonumber(eCell.getEnergyStored("left"))
- end
- function checkNeedBurn()
- getEnergyValues()
- if ((genMax + cellMax) - (genCur + cellCur)) >= energyProduced then
- needBurn = true
- else
- needBurn = false
- end
- end
- function burn()
- so("top",true)
- sleep(0.1)
- so("top",false)
- burning=true
- end
- while true do
- t2 = os.clock()
- --If I'm not burning...do I need to be?
- if not burning then
- --Do I Need more fuel?
- checkNeedBurn()
- if needBurn then
- --Burn another lot of Fuel and reset burn timer
- burn()
- t1=os.clock()
- end
- end
- --Burn has finished...reset the variable
- if (t2 - t1) >= productionTime then
- burning = false
- end
- --Print current timer
- print("Time: "..t2-t1)
- print("Burning: "..tostring(burning))
- print("Need Burn: "..tostring(needBurn))
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement