Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local gpu = component.gpu
- local w,h = gpu.getResolution()
- print("Initialising...")
- local dGenAddr = component.ie_diesel_generator.address
- local fermAddr = component.ie_fermenter.address
- local squeAddr = component.ie_squeezer.address
- local refiAddr = component.ie_refinery.address
- --print("Generator address: ", dGenAddr)
- local g = component.proxy(dGenAddr)
- local f = component.proxy(fermAddr)
- local s = component.proxy(squeAddr)
- local r = component.proxy(refiAddr)
- print("Enabling computer control...")
- g.enableComputerControl(true)
- f.enableComputerControl(true)
- s.enableComputerControl(true)
- r.enableComputerControl(true)
- g.setEnabled(false)
- f.setEnabled(false)
- s.setEnabled(false)
- r.setEnabled(false)
- function getInfo()
- -- check how much diesel we have
- dTank = g.getTankInfo()
- -- reset input count
- fInputSize = 0
- sInputSize = 0
- -- get size of each stack in fermenter and squeezer
- for i = 1,6 do
- fInputSize = fInputSize + f.getInputStack(i)["size"]
- sInputSize = sInputSize + s.getInputStack(i)["size"]
- gpu.set(1,15,tostring(fInputSize))
- end
- -- fermenter and squeezer fluid output
- fTank = f.getFluid()
- sTank = s.getFluid()
- -- refinery io
- rInTank = r.getInputFluidTanks()
- rOutTank = r.getOutputTank()
- end
- function updateScreen()
- gpu.setBackground(0x000000,false)
- gpu.fill(1,1,w,h, " ")
- gpu.set(1,1,"Generator:")
- gpu.set(11,1,tostring(g.isActive()))
- gpu.set(1,2,"Tank: ")
- gpu.set(7,2,tostring(dTank["amount"]))
- gpu.set(14,2,"/")
- gpu.set(15,2,tostring(dTank["capacity"]))
- gpu.set(1,3,"Fermenter")
- gpu.set(10,3,tostring(f.isActive()))
- gpu.set(1,4,"Ethanol:")
- gpu.set(9,4,tostring(fTank["amount"]))
- gpu.set(17,4,"/")
- gpu.set(19,4,tostring(fTank["capacity"]))
- gpu.set(1,5,"Potato:")
- gpu.set(9,5,tostring(fInputSize))
- gpu.set(14,5,"/")
- gpu.set(15,5,"384.0")
- gpu.set(1,6,"Squeezer")
- gpu.set(9,6,tostring(s.isActive()))
- gpu.set(1,7,"Plant Oil:")
- gpu.set(11,7,tostring(sTank["amount"]))
- gpu.set(19,7,"/")
- gpu.set(21,7,tostring(sTank["capacity"]))
- gpu.set(1,8,"Weed:")
- gpu.set(6,8,tostring(sInputSize))
- gpu.set(12,8,"/")
- gpu.set(13,8,"384.0")
- gpu.set(1,9,"Fermenter")
- gpu.set(9,9,tostring(f.isActive()))
- gpu.set(1,10,"Ethanol:")
- gpu.set(9,10,tostring(rInTank["input1"]["amount"]))
- gpu.set(17,10,"/")
- gpu.set(19,10,tostring(rInTank["input1"]["capacity"]))
- gpu.set(1,11,"Plant Oil:")
- gpu.set(11,11,tostring(rInTank["input2"]["amount"]))
- gpu.set(18,11,"/")
- gpu.set(19,11,tostring(rInTank["input2"]["capacity"]))
- gpu.set(1,12,"Biodiesel:")
- gpu.set(11,12,tostring(rOutTank["amount"]))
- gpu.set(19,12,"/")
- gpu.set(20,12,tostring(rOutTank["capacity"]))
- end
- function logicCheck()
- -- if filled by >50% activate the squeezer/fermenter
- if fTank["amount"]/fTank["capacity"] >= 0.5 then
- f.setEnabled(true)
- else
- f.setEnabled(false)
- end
- -- if filled by >50% activate the squeezer/fermenter
- if sTank["amount"]/sTank["capacity"] >= 0.5 then
- s.setEnabled(true)
- else
- s.setEnabled(false)
- end
- if rInTank["input1"]["amount"]/rInTank["input1"]["capacity"] > 0.5 and rInTank["input2"]["amount"]/rInTank["input2"]["capacity"] > 0.5 then
- r.setEnabled(true)
- else
- r.setEnabled(false)
- end
- if dTank["amount"]/dTank["capacity"] > 0.5 then
- g.setEnabled(true)
- else
- g.setEnabled(false)
- end
- end
- function wait(seconds)
- local start = os.time()
- repeat until os.time() > start + seconds
- end
- while true do
- getInfo()
- logicCheck()
- updateScreen()
- wait(1)
- --print(tostring(i))
- end
Advertisement
Add Comment
Please, Sign In to add comment