View difference between Paste ID: 8VbppyF8 and PZ2hWaLW
SHOW: | | - or go back to the newest paste.
1-
--btn = require("buttonAPI")
1+
--btn = require("buttonAPI")
2-
local component = require("component")
2+
local component = require("component")
3-
local keyboard = require("keyboard")
3+
local keyboard = require("keyboard")
4-
local event = require("event")
4+
local event = require("event")
5-
local gpu = component.gpu
5+
local gpu = component.gpu
6-
local sides = require("sides")
6+
local sides = require("sides")
7-
local sysinfo = {}
7+
local sysinfo = {}
8-
8+
9-
local g = component.ie_diesel_generator
9+
local g = component.ie_diesel_generator
10-
local f = component.ie_fermenter
10+
local f = component.ie_fermenter
11-
local s = component.ie_squeezer
11+
local s = component.ie_squeezer
12-
local r = component.ie_refinery
12+
local r = component.ie_refinery
13-
local red = component.redstone
13+
local red = component.redstone
14-
14+
15-
local colours = {black = 0x000000, white = 0xFFFFFF, yellow = 0xFFFF55, blue = 0x0000AA, green = 0x00AA00, grey = 0xAAAAAA, red = 0xAA0000}
15+
local colours = {black = 0x000000, white = 0xFFFFFF, yellow = 0xFFFF55, blue = 0x0000AA, green = 0x00AA00, grey = 0xAAAAAA, red = 0xAA0000}
16-
local sections = {}
16+
local sections = {}
17-
local graphs = {}
17+
local graphs = {}
18-
local info = {}
18+
local info = {}
19-
local applications = {}
19+
local applications = {}
20-
20+
21-
local currentDiesel = 0
21+
local currentDiesel = 0
22-
local currentFEthanol = 0
22+
local currentFEthanol = 0
23-
local currentPotato = 0
23+
local currentPotato = 0
24-
local currentSPlantOil = 0
24+
local currentSPlantOil = 0
25-
local currnetPumpkin = 0
25+
local currnetPumpkin = 0
26-
local currentREthanol=0
26+
local currentREthanol=0
27-
local currentRPlantOil = 0
27+
local currentRPlantOil = 0
28-
local currentRDiesel = 0
28+
local currentRDiesel = 0
29-
29+
local currentenaFer = false
30-
gpu.setResolution(132,38)
30+
local currentenaGen = false
31-
--gpu.setResolution(98,32)
31+
local currentenaRef = false
32-
local w,h = gpu.getResolution() -- lol
32+
local currentenaSqu = false
33-
33+
34-
-- define sections
34+
gpu.setResolution(132,38)
35-
function setSections()
35+
--gpu.setResolution(98,32)
36-
  sections["tanks"] = { x = 5, y = 26, width = 123, height = 6, title = "[ Tanks ]"}
36+
local w,h = gpu.getResolution() -- lol
37-
  sections["status"] = { x = 88, y = 4, width = 40, height = 20, title = "[ Status ]"}
37+
38-
  sections["details"] = { x = 5, y = 4, width = 78, height = 20, title = "[ Details ]"}
38+
-- define sections
39
function setSections()
40-
-- define graphs to display
40+
  sections["tanks"] = { x = 5, y = 26, width = 123, height = 6, title = "[ Tanks ]"}
41-
function setGraphs()
41+
  sections["status"] = { x = 88, y = 4, width = 40, height = 20, title = "[ Status ]"}
42-
  graphs["diesel"] = { x = 8, y = 29, width = 118, height = 2, title = "Diesel"}
42+
  sections["details"] = { x = 5, y = 4, width = 78, height = 20, title = "[ Details ]"}
43
end
44-
-- define info to display
44+
-- define graphs to display
45-
function setInfo()
45+
function setGraphs()
46-
  info["diesel"]      = { x = 8, y = 6, width = 73, height= 1, title  = "Generator Diesel: ", unit = " mB"}
46+
  graphs["diesel"] = { x = 8, y = 29, width = 118, height = 2, title = "Diesel"}
47-
  info["fethanol"]    = { x = 8, y = 8, width = 73, height = 1, title = "Ethanol: ", unit = " mB"}
47+
end
48-
  info["potato"]      = { x = 8, y = 10, width = 73, height= 1, title = "Potatoes: ", unit = " potatoes"}
48+
-- define info to display
49-
  info["splantoil"]   = { x = 8, y = 12, width = 73, height= 1, title = "Plant Oil: ", unit = " mB"}
49+
function setInfo()
50-
  info["pumpkin"]     = { x = 8, y = 14, width = 73, height= 1, title = "Pumpkins: ", unit = " pumpkins"}
50+
  info["diesel"]      = { x = 8, y = 6, width = 73, height= 1, title  = "Generator Diesel: ", unit = " mB"}
51-
  info["rethanol"]    = { x = 8, y = 16, width = 73, height= 1, title = "Refinery Ethanol: ", unit = " mB"}
51+
  info["fethanol"]    = { x = 8, y = 8, width = 73, height = 1, title = "Ethanol: ", unit = " mB"}
52-
  info["rplantoil"]   = { x = 8, y = 18, width = 73, height= 1, title = "Refinery Plant Oil: ", unit = " mB"}
52+
  info["potato"]      = { x = 8, y = 10, width = 73, height= 1, title = "Potatoes: ", unit = " potatoes"}
53-
  info["rdiesel"]     = { x = 8, y = 20, width = 73, height= 1, title = "Refinery Diesel: ", unit = " mB"}
53+
  info["splantoil"]   = { x = 8, y = 12, width = 73, height= 1, title = "Plant Oil: ", unit = " mB"}
54
  info["pumpkin"]     = { x = 8, y = 14, width = 73, height= 1, title = "Pumpkin: ", unit = " seeds"}
55-
-- define applications
55+
  info["rethanol"]    = { x = 8, y = 16, width = 73, height= 1, title = "Refinery Ethanol: ", unit = " mB"}
56-
function setApplications()
56+
  info["rplantoil"]   = { x = 8, y = 18, width = 73, height= 1, title = "Refinery Plant Oil: ", unit = " mB"}
57-
  applications["main"] = {x = 3, y = 2, width = 128, height = 32, title = "[ Power Generation Control Panel ]"}
57+
  info["rdiesel"]     = { x = 8, y = 20, width = 73, height= 1, title = "Refinery Diesel: ", unit = " mB"}
58
59-
59+
  info["enaGen"]      = { x = 91, y = 6, width = 73, height= 1, title = "Generator Enabled: ", unit = ""}
60-
60+
  info["enaFer"]      = { x = 91, y = 6, width = 73, height= 1, title = "Fermenter Enabled: ", unit = ""}
61-
------------------------ Button Stuff -------------------------------------------
61+
  info["enaSqu"]      = { x = 91, y = 6, width = 73, height= 1, title = "Squeezer Enabled: ", unit = ""}
62-
local btn = {}
62+
  info["enaRef"]      = { x = 91, y = 6, width = 73, height= 1, title = "Refinery Enabled: ", unit = ""}
63-
local button = {}
63+
end
64-
function btn.clearTable()
64+
-- define applications
65-
  button = {}
65+
function setApplications()
66
  applications["main"] = {x = 3, y = 2, width = 128, height = 32, title = "[ Power Generation Control Panel ]"}
67-
67+
end
68-
function btn.setTable(name, func, xmin, ymin, xmax, ymax, text, colors, active) -- color is an object { on : 0x000000, off 0xAAAAAA}
68+
69-
  button[name] = {}
69+
70-
  button[name]["text"] = text
70+
------------------------ Button Stuff -------------------------------------------
71-
  button[name]["func"] = func
71+
local btn = {}
72-
  button[name]["active"] = active
72+
local button = {}
73-
  button[name]["xmin"] = xmin
73+
function btn.clearTable()
74-
  button[name]["ymin"] = ymin
74+
  button = {}
75-
  button[name]["xmax"] = xmax
75+
end
76-
  button[name]["ymax"] = ymax
76+
77-
  button[name]["colors"] = colors
77+
function btn.setTable(name, func, xmin, ymin, xmax, ymax, text, colors, active) -- color is an object { on : 0x000000, off 0xAAAAAA}
78
  button[name] = {}
79-
79+
  button[name]["text"] = text
80-
function btn.fill(bData)
80+
  button[name]["func"] = func
81-
81+
  button[name]["active"] = active
82-
  local yspot = math.floor((bData["ymin"] + bData["ymax"]) /2)
82+
  button[name]["xmin"] = xmin
83-
  local xspot = math.floor((bData["xmin"] + bData["xmax"]) /2) - math.floor((string.len(bData["text"])/2))
83+
  button[name]["ymin"] = ymin
84-
  local oldColor = gpu.getBackground()
84+
  button[name]["xmax"] = xmax
85-
  local curColor = bData["colors"].on
85+
  button[name]["ymax"] = ymax
86-
86+
  button[name]["colors"] = colors
87-
  if bData["active"] then
87+
end
88-
    curColor = bData["colors"].on
88+
89-
  else
89+
function btn.fill(bData)
90-
    curColor = bData["colors"].off
90+
91-
  end
91+
  local yspot = math.floor((bData["ymin"] + bData["ymax"]) /2)
92-
  gpu.setBackground(curColor)
92+
  local xspot = math.floor((bData["xmin"] + bData["xmax"]) /2) - math.floor((string.len(bData["text"])/2))
93-
  gpu.fill(bData["xmin"], bData["ymin"], bData["xmax"] - bData["xmin"] + 1, bData["ymax"] - bData["ymin"] + 1, " ")
93+
  local oldColor = gpu.getBackground()
94-
  gpu.set(xspot, yspot, bData["text"])
94+
  local curColor = bData["colors"].on
95-
  gpu.setBackground(oldColor)
95+
96
  if bData["active"] then
97-
97+
    curColor = bData["colors"].on
98-
function btn.screen()
98+
  else
99-
  for name,data in pairs(button) do
99+
    curColor = bData["colors"].off
100-
     btn.fill(data)
100+
  end
101-
  end
101+
  gpu.setBackground(curColor)
102
  gpu.fill(bData["xmin"], bData["ymin"], bData["xmax"] - bData["xmin"] + 1, bData["ymax"] - bData["ymin"] + 1, " ")
103-
103+
  gpu.set(xspot, yspot, bData["text"])
104-
function btn.toggleButton(name)
104+
  gpu.setBackground(oldColor)
105-
  button[name]["active"] = not button[name]["active"]
105+
end
106-
  btn.screen() -- not sure about this one here
106+
107-
  return button[name]["active"]
107+
function btn.screen()
108
  for name,data in pairs(button) do
109-
109+
     btn.fill(data)
110-
function btn.flash(name)
110+
  end
111-
  _ = btn.toggleButton(name)
111+
end
112-
  btn.screen() -- or here
112+
113-
  os.sleep(0.1)
113+
function btn.toggleButton(name)
114-
  _ = btn.toggleButton(name)
114+
  button[name]["active"] = not button[name]["active"]
115-
  btn.screen()
115+
  btn.screen() -- not sure about this one here
116
  return button[name]["active"]
117-
117+
end
118-
function btn.checkxy(_, _, x, y, _, _)
118+
119-
  os.sleep(0)
119+
function btn.flash(name)
120-
  for name, data in pairs(button) do
120+
  _ = btn.toggleButton(name)
121-
    if y >= data["ymin"] and y <= data["ymax"] then
121+
  btn.screen() -- or here
122-
      if x >= data["xmin"] and x <= data["xmax"] then
122+
  os.sleep(0.1)
123-
        data["func"]()
123+
  _ = btn.toggleButton(name)
124-
        return true
124+
  btn.screen()
125-
      end
125+
end
126-
    end
126+
127-
  end
127+
function btn.checkxy(_, _, x, y, _, _)
128-
  return false
128+
  os.sleep(0)
129
  for name, data in pairs(button) do
130-
130+
    if y >= data["ymin"] and y <= data["ymax"] then
131-
----------------------------------------------------------------------------------
131+
      if x >= data["xmin"] and x <= data["xmax"] then
132-
132+
        data["func"]()
133-
function setButtons()
133+
        return true
134-
--  btn.setTable("power", power, 91, 6, 106, 8, "power", {on = colours.green, off = colours.red},false)
134+
      end
135-
--  btn.setTable("test", testBtn, 108, 6, 123, 8, "test", {on = colours.green, off = colours.red},false)
135+
    end
136-
  --btn.setTable("OFF", powerOff, 109, 6, 125, 8,"OFF", {on = colours.red, off = colours.red})
136+
  end
137-
137+
  return false
138-
  --btn.setTable("lowerMinLimit", lowerMinLimit, 91, 15, 106, 17,"-10", {on = colours.blue, off = colours.blue})
138+
end
139-
  --btn.setTable("lowerMaxLimit", lowerMaxLimit, 109, 15, 125, 17,"-10", {on = colours.purple, off = colours.purple})
139+
140-
140+
----------------------------------------------------------------------------------
141-
  --btn.setTable("augmentMinLimit", augmentMinLimit, 91, 19, 106, 21,"+10", {on = colours.blue, off = colours.blue})
141+
142-
  --btn.setTable("augmentMaxLimit", augmentMaxLimit, 109, 19, 125, 21,"+10", {on = colours.purple, off = colours.purple})
142+
function setButtons()
143
--  btn.setTable("power", power, 91, 6, 106, 8, "power", {on = colours.green, off = colours.red},false)
144-
144+
--  btn.setTable("test", testBtn, 108, 6, 123, 8, "test", {on = colours.green, off = colours.red},false)
145-
function printBG()
145+
  --btn.setTable("OFF", powerOff, 109, 6, 125, 8,"OFF", {on = colours.red, off = colours.red})
146-
  gpu.setBackground(colours.black)
146+
147-
  gpu.fill(1,1,w,h," ")
147+
  --btn.setTable("lowerMinLimit", lowerMinLimit, 91, 15, 106, 17,"-10", {on = colours.blue, off = colours.blue})
148-
  gpu.setBackground(colours.grey)
148+
  --btn.setTable("lowerMaxLimit", lowerMaxLimit, 109, 15, 125, 17,"-10", {on = colours.purple, off = colours.purple})
149-
  gpu.fill(1,h,w,1," ")
149+
150-
  gpu.setForeground(colours.white)
150+
  --btn.setTable("augmentMinLimit", augmentMinLimit, 91, 19, 106, 21,"+10", {on = colours.blue, off = colours.blue})
151-
  local bottomText = "Copyright (c) 1996 - 2009 New DPKR Tech. Inc. All Rights Reserved."
151+
  --btn.setTable("augmentMaxLimit", augmentMaxLimit, 109, 19, 125, 21,"+10", {on = colours.purple, off = colours.purple})
152-
  gpu.set(w/2 - string.len(bottomText)/2,h,bottomText)
152+
end
153
154-
-- application + borders
154+
function printBG()
155-
function printApplication(appName)
155+
  gpu.setBackground(colours.black)
156-
  local a = applications[appName]
156+
  gpu.fill(1,1,w,h," ")
157-
157+
  gpu.setBackground(colours.grey)
158-
  --gpu.setBackground(colours.black)
158+
  gpu.fill(1,h,w,1," ")
159-
  --gpu.fill(a.x-2,a.y-1,a.width-2,a.height-1, " ")
159+
  gpu.setForeground(colours.white)
160-
  gpu.setBackground(colours.blue)
160+
  local bottomText = "Copyright (c) 1996 - 2009 New DPKR Tech. Inc. All Rights Reserved."
161-
  gpu.fill(a.x,a.y,a.width,a.height," ")
161+
  gpu.set(w/2 - string.len(bottomText)/2,h,bottomText)
162-
  
162+
end
163-
  -- fill borders
163+
-- application + borders
164-
  gpu.setBackground(colours.blue)
164+
function printApplication(appName)
165-
  gpu.setForeground(colours.white)
165+
  local a = applications[appName]
166-
  gpu.fill(a.x, a.y, a.width, 1, "─")
166+
167-
  gpu.fill(a.x, a.y, 1, a.height, "│")
167+
  --gpu.setBackground(colours.black)
168-
  gpu.fill(a.x, a.y + a.height, a.width, 1, "─")
168+
  --gpu.fill(a.x-2,a.y-1,a.width-2,a.height-1, " ")
169-
  gpu.fill(a.x + a.width, a.y, 1, a.height + 1, "│")
169+
  gpu.setBackground(colours.blue)
170-
   -- fill corners
170+
  gpu.fill(a.x,a.y,a.width,a.height," ")
171-
  gpu.set(a.x,a.y,"┌")
171+
  
172-
  gpu.set(a.x + a.width,a.y,"┐")
172+
  -- fill borders
173-
  gpu.set(a.x,a.y + a.height,"└")
173+
  gpu.setBackground(colours.blue)
174-
  gpu.set(a.x + a.width,a.y + a.height,"┘")
174+
  gpu.setForeground(colours.white)
175-
  -- set title
175+
  gpu.fill(a.x, a.y, a.width, 1, "─")
176-
  gpu.setBackground(colours.blue)
176+
  gpu.fill(a.x, a.y, 1, a.height, "│")
177-
  gpu.setForeground(colours.white)
177+
  gpu.fill(a.x, a.y + a.height, a.width, 1, "─")
178-
  gpu.set(a.x + a.width/2 - string.len(a.title)/2, a.y, a.title)
178+
  gpu.fill(a.x + a.width, a.y, 1, a.height + 1, "│")
179-
  gpu.setForeground(colours.white)
179+
   -- fill corners
180-
180+
  gpu.set(a.x,a.y,"┌")
181
  gpu.set(a.x + a.width,a.y,"┐")
182-
-- section borders
182+
  gpu.set(a.x,a.y + a.height,"└")
183-
function printBorders(sectionName)
183+
  gpu.set(a.x + a.width,a.y + a.height,"┘")
184-
  local s = sections[sectionName]
184+
  -- set title
185-
  -- ─ │ ║ ═
185+
  gpu.setBackground(colours.blue)
186-
  -- ┐ └ ┴ ┬ ├ ─ ┼ │ ┤ ┘ ┌
186+
  gpu.setForeground(colours.white)
187-
  -- set border
187+
  gpu.set(a.x + a.width/2 - string.len(a.title)/2, a.y, a.title)
188-
  gpu.setBackground(colours.blue)
188+
  gpu.setForeground(colours.white)
189-
  gpu.fill(s.x, s.y, s.width, 1, "─")
189+
190-
  gpu.fill(s.x, s.y, 1, s.height, "│")
190+
end
191-
  gpu.fill(s.x, s.y + s.height, s.width, 1, "─")
191+
-- section borders
192-
  gpu.fill(s.x + s.width, s.y, 1, s.height + 1, "│")
192+
function printBorders(sectionName)
193-
193+
  local s = sections[sectionName]
194-
  gpu.set(s.x,s.y,"┌")
194+
  -- ─ │ ║ ═
195-
  gpu.set(s.x + s.width,s.y,"┐")
195+
  -- ┐ └ ┴ ┬ ├ ─ ┼ │ ┤ ┘ ┌
196-
  gpu.set(s.x,s.y + s.height,"└")
196+
  -- set border
197-
  gpu.set(s.x + s.width,s.y + s.height,"┘")
197+
  gpu.setBackground(colours.blue)
198-
198+
  gpu.fill(s.x, s.y, s.width, 1, "─")
199-
  -- set title
199+
  gpu.fill(s.x, s.y, 1, s.height, "│")
200-
  gpu.setBackground(colours.blue)
200+
  gpu.fill(s.x, s.y + s.height, s.width, 1, "─")
201-
  gpu.setForeground(colours.white)
201+
  gpu.fill(s.x + s.width, s.y, 1, s.height + 1, "│")
202-
  gpu.set(s.x + s.width/2 - string.len(s.title)/2, s.y, s.title)
202+
203
  gpu.set(s.x,s.y,"┌")
204-
204+
  gpu.set(s.x + s.width,s.y,"┐")
205-
function power()
205+
  gpu.set(s.x,s.y + s.height,"└")
206-
  buttonStatus = btn.toggleButton("power",buttonStatus)
206+
  gpu.set(s.x + s.width,s.y + s.height,"┘")
207-
  if buttonStatus == true then
207+
208-
    print("On!")
208+
  -- set title
209-
  else
209+
  gpu.setBackground(colours.blue)
210-
    print("Off!")
210+
  gpu.setForeground(colours.white)
211-
  end
211+
  gpu.set(s.x + s.width/2 - string.len(s.title)/2, s.y, s.title)
212
end
213-
213+
214-
function testBtn()
214+
function power()
215-
  buttonStatus = btn.flash("test")
215+
  buttonStatus = btn.toggleButton("power",buttonStatus)
216
  if buttonStatus == true then
217-
217+
    print("On!")
218-
function startup()
218+
  else
219-
 -- print("Enabling computer control...")
219+
    print("Off!")
220-
  g.enableComputerControl(true)
220+
  end
221-
  f.enableComputerControl(true)
221+
end
222-
  s.enableComputerControl(true)
222+
223-
  r.enableComputerControl(true)
223+
function testBtn()
224-
  g.setEnabled(false)
224+
  buttonStatus = btn.flash("test")
225-
  f.setEnabled(false)
225+
end
226-
  s.setEnabled(false)
226+
227-
  r.setEnabled(false)
227+
function startup()
228
 -- print("Enabling computer control...")
229-
229+
  g.enableComputerControl(true)
230-
function getSysInfo()
230+
  f.enableComputerControl(true)
231-
  -- check how much diesel we have
231+
  s.enableComputerControl(true)
232-
  dTank = g.getTankInfo()
232+
  r.enableComputerControl(true)
233-
  -- reset input count
233+
  g.setEnabled(false)
234-
  fInputSize = 0
234+
  f.setEnabled(false)
235-
  sInputSize = 0
235+
  s.setEnabled(false)
236-
  -- get size of each stack in fermenter and squeezer
236+
  r.setEnabled(false)
237-
  for i = 1,6 do
237+
end
238-
    fInputSize = fInputSize + f.getInputStack(i)["size"]
238+
239-
    sInputSize = sInputSize + s.getInputStack(i)["size"]
239+
function getSysInfo()
240-
  end
240+
  -- check how much diesel we have
241-
  -- fermenter and squeezer fluid output
241+
  dTank = g.getTankInfo()
242-
  fTank = f.getFluid()
242+
  -- reset input count
243-
  sTank = s.getFluid()
243+
  fInputSize = 0
244-
  -- refinery io
244+
  sInputSize = 0
245-
  rInTank = r.getInputFluidTanks()
245+
  -- get size of each stack in fermenter and squeezer
246-
  rOutTank = r.getOutputTank()
246+
  for i = 1,6 do
247-
247+
    fInputSize = fInputSize + f.getInputStack(i)["size"]
248-
  sysinfo["diesel"]       = dTank["amount"]
248+
    sInputSize = sInputSize + s.getInputStack(i)["size"]
249-
  sysinfo["dieselCap"]    = dTank["capacity"]
249+
  end
250-
  sysinfo["fethanol"]     = fTank["amount"]
250+
  -- fermenter and squeezer fluid output
251-
  sysinfo["fethanolCap"]  = fTank["capacity"]
251+
  fTank = f.getFluid()
252-
  sysinfo["potato"]       = fInputSize
252+
  sTank = s.getFluid()
253-
  sysinfo["potatoCap"]    = 384
253+
  -- refinery io
254-
  sysinfo["splantoil"]    = sTank["amount"]
254+
  rInTank = r.getInputFluidTanks()
255-
  sysinfo["splantoilCap"] = sTank["capacity"]
255+
  rOutTank = r.getOutputTank()
256-
  sysinfo["pumpkin"]      = sInputSize
256+
257-
  sysinfo["pumpkinCap"]   = 384
257+
  sysinfo["diesel"]       = dTank["amount"]
258-
  sysinfo["rethanol"]     = rInTank["input1"]["amount"]
258+
  sysinfo["dieselCap"]    = dTank["capacity"]
259-
  sysinfo["rethanolCap"]  = rInTank["input1"]["capacity"]
259+
  sysinfo["fethanol"]     = fTank["amount"]
260-
  sysinfo["rplantoil"]    = rInTank["input2"]["amount"]
260+
  sysinfo["fethanolCap"]  = fTank["capacity"]
261-
  sysinfo["rplantoilCap"] = rInTank["input2"]["capacity"]
261+
  sysinfo["potato"]       = fInputSize
262-
  sysinfo["rdiesel"]      = rOutTank["amount"]
262+
  sysinfo["potatoCap"]    = 384
263-
  sysinfo["rdieselCap"]   = rOutTank["capacity"]
263+
  sysinfo["splantoil"]    = sTank["amount"]
264
  sysinfo["splantoilCap"] = sTank["capacity"]
265-
265+
  sysinfo["pumpkin"]      = sInputSize
266-
function logicCheck()
266+
  sysinfo["pumpkinCap"]   = 384
267-
--  print("checking logic")
267+
  sysinfo["rethanol"]     = rInTank["input1"]["amount"]
268-
  -- if filled by >50% activate the squeezer/fermenter
268+
  sysinfo["rethanolCap"]  = rInTank["input1"]["capacity"]
269-
  if fTank["amount"]/fTank["capacity"] <= 0.5 then
269+
  sysinfo["rplantoil"]    = rInTank["input2"]["amount"]
270-
    f.setEnabled(true)
270+
  sysinfo["rplantoilCap"] = rInTank["input2"]["capacity"]
271-
  else
271+
  sysinfo["rdiesel"]      = rOutTank["amount"]
272-
    f.setEnabled(false)
272+
  sysinfo["rdieselCap"]   = rOutTank["capacity"] 
273-
  end
273+
274-
  -- if filled by >50% activate the squeezer/fermenter
274+
  sysinfo["enaGen"] = tostring(g.isActive())
275-
  if sTank["amount"]/sTank["capacity"] <= 0.5 then
275+
  sysinfo["enaFer"] = tostring(f.isActive())
276-
    s.setEnabled(true)
276+
  sysinfo["enaSqu"] = tostring(s.isActive())
277-
  else
277+
  --sysinfo["enaRef"] = "NYE"
278-
    s.setEnabled(false)
278+
end
279-
  end
279+
280-
280+
function logicCheck()
281-
  if rOutTank["amount"]/rOutTank["capacity"] < 0.5 then
281+
--  print("checking logic")
282-
    r.setEnabled(true)
282+
  -- if filled by >50% activate the squeezer/fermenter
283-
    s.setEnabled(true)
283+
  if fTank["amount"]/fTank["capacity"] <= 0.5 then
284-
    f.setEnabled(true)
284+
    f.setEnabled(true)
285-
  else
285+
  else
286-
    r.setEnabled(false)
286+
    f.setEnabled(false)
287-
  end
287+
  end
288-
  
288+
  -- if filled by >50% activate the squeezer/fermenter
289-
  if red.getBundledInput(sides.left)[0] > 0 then
289+
  if sTank["amount"]/sTank["capacity"] <= 0.5 then
290-
  --if dTank["amount"]/dTank["capacity"] > 0.5 then
290+
    s.setEnabled(true)
291-
    g.setEnabled(true)
291+
  else
292-
  else
292+
    s.setEnabled(false)
293-
    g.setEnabled(false)
293+
  end
294-
  end
294+
295
  if rOutTank["amount"]/rOutTank["capacity"] < 0.5 then
296-
296+
    r.setEnabled(true)
297-
-- progress bar bg
297+
    sysinfo["enaRef"] = "true"
298-
function printGraphs(graphName)
298+
    s.setEnabled(true)
299-
  local g = graphs[graphName]
299+
    f.setEnabled(true)
300-
300+
  else
301-
  -- set graph
301+
    r.setEnabled(false)
302-
  gpu.setBackground(colours.grey)
302+
    sysinfo["enaRef"] = "false"
303-
  gpu.fill(g.x, g.y, g.width, g.height, " ")
303+
  end
304-
304+
  
305-
  -- set title
305+
  if red.getBundledInput(sides.left)[0] > 0 then
306-
  gpu.setBackground(colours.blue)
306+
  --if dTank["amount"]/dTank["capacity"] > 0.5 then
307-
  gpu.setForeground(colours.yellow)
307+
    g.setEnabled(true)
308-
  gpu.set(g.x, g.y - 1, g.title)
308+
  else
309
    g.setEnabled(false)
310-
-- progressbar
310+
  end
311-
function printGraphBar(activeGraph)
311+
end
312-
  local g = activeGraph
312+
313-
313+
-- progress bar bg
314-
  -- set graph
314+
function printGraphs(graphName)
315-
  gpu.setBackground(colours.green)
315+
  local g = graphs[graphName]
316-
  gpu.fill(g.x, g.y, g.width, g.height, " ")
316+
317-
  --gpu.setBackground(colours.black)
317+
  -- set graph
318
  gpu.setBackground(colours.grey)
319-
-- info to display
319+
  gpu.fill(g.x, g.y, g.width, g.height, " ")
320-
function printInfo(infoName)
320+
321-
  local maxLength = 15
321+
  -- set title
322-
  local i = info[infoName]
322+
  gpu.setBackground(colours.blue)
323-
  local spaces = string.rep(" ", maxLength - string.len(sysinfo[infoName] .. i.unit))
323+
  gpu.setForeground(colours.yellow)
324-
  gpu.setForeground(colours.yellow)
324+
  gpu.set(g.x, g.y - 1, g.title)
325-
  gpu.setBackground(colours.blue)
325+
end
326-
  gpu.set(i.x, i.y , i.title .. sysinfo[infoName] .. i.unit .. spaces)
326+
-- progressbar
327
function printGraphBar(activeGraph)
328-
328+
  local g = activeGraph
329-
setApplications()
329+
330-
setSections()
330+
  -- set graph
331-
setGraphs()
331+
  gpu.setBackground(colours.green)
332-
setInfo()
332+
  gpu.fill(g.x, g.y, g.width, g.height, " ")
333-
setButtons()
333+
  --gpu.setBackground(colours.black)
334-
334+
end
335-
printBG()
335+
-- info to display
336-
printApplication("main")
336+
function printInfo(infoName)
337-
printBorders("status")
337+
  local maxLength = 15
338-
printBorders("details")
338+
  local i = info[infoName]
339-
printBorders("tanks")
339+
  local spaces = string.rep(" ", maxLength - string.len(sysinfo[infoName] .. i.unit))
340-
340+
  gpu.setForeground(colours.yellow)
341-
printGraphs("diesel")
341+
  gpu.setBackground(colours.blue)
342-
342+
  gpu.set(i.x, i.y , i.title .. sysinfo[infoName] .. i.unit .. spaces)
343-
function draw()
343+
end
344-
344+
345-
  if currentDiesel ~= sysinfo["diesel"] then
345+
setApplications()
346-
    currentDiesel = sysinfo["diesel"]
346+
setSections()
347-
    maxDiesel = sysinfo["dieselCap"]
347+
setGraphs()
348-
    local dieselFrac = math.ceil(graphs["diesel"].width * (currentDiesel/maxDiesel))
348+
setInfo()
349-
    local dGraphUpdate = {x = graphs["diesel"].x, y = graphs["diesel"].y, width = dieselFrac, height = graphs["diesel"].height}
349+
setButtons()
350-
350+
351-
    printGraphs("diesel")
351+
printBG()
352-
    printGraphBar(dGraphUpdate)
352+
printApplication("main")
353-
    printInfo("diesel")
353+
printBorders("status")
354-
  end
354+
printBorders("details")
355-
  if currentFEthanol ~= sysinfo["fethanol"] then
355+
printBorders("tanks")
356-
    currentFEthanol = sysinfo["fethanol"]
356+
357-
    printInfo("fethanol")
357+
printGraphs("diesel")
358-
  end
358+
359-
  if currentPotato ~= sysinfo["potato"] then
359+
function draw()
360-
    currentPotato = sysinfo["potato"]
360+
361-
    printInfo("potato")
361+
  if currentDiesel ~= sysinfo["diesel"] then
362-
  end
362+
    currentDiesel = sysinfo["diesel"]
363-
  if currentSPlantOil ~= sysinfo["splantoil"] then
363+
    maxDiesel = sysinfo["dieselCap"]
364-
    currentSPlantOil = sysinfo["splantoil"]
364+
    local dieselFrac = math.ceil(graphs["diesel"].width * (currentDiesel/maxDiesel))
365-
    printInfo("splantoil")
365+
    local dGraphUpdate = {x = graphs["diesel"].x, y = graphs["diesel"].y, width = dieselFrac, height = graphs["diesel"].height}
366-
  end
366+
367-
  if currnetPumpkin ~= sysinfo["pumpkin"] then
367+
    printGraphs("diesel")
368-
    currentPumpkin = sysinfo["pumpkin"]
368+
    printGraphBar(dGraphUpdate)
369-
    printInfo("pumpkin")
369+
    printInfo("diesel")
370-
  end
370+
  end
371-
  if currentREthanol ~= sysinfo["rethanol"] then
371+
  if currentFEthanol ~= sysinfo["fethanol"] then
372-
    currentREthanol = sysinfo["rethanol"]
372+
    currentFEthanol = sysinfo["fethanol"]
373-
    printInfo("rethanol")
373+
    printInfo("fethanol")
374-
  end
374+
  end
375-
  if currentRPlantOil ~= sysinfo["rplantoil"] then
375+
  if currentPotato ~= sysinfo["potato"] then
376-
    currentRPlantOil = sysinfo["rplantoil"]
376+
    currentPotato = sysinfo["potato"]
377-
    printInfo("rplantoil")
377+
    printInfo("potato")
378-
  end
378+
  end
379-
  if currentRDiesel ~= sysinfo["rdiesel"] then
379+
  if currentSPlantOil ~= sysinfo["splantoil"] then
380-
    currentRDiesel = sysinfo["rdiesel"]
380+
    currentSPlantOil = sysinfo["splantoil"]
381-
    printInfo("rdiesel")
381+
    printInfo("splantoil")
382-
  end
382+
  end
383-
  os.sleep(0)
383+
  if currnetPumpkin ~= sysinfo["pumpkin"] then
384
    currentPumpkin = sysinfo["pumpkin"]
385-
385+
    printInfo("pumpkin")
386-
btn.screen()
386+
  end
387-
startup()
387+
  if currentREthanol ~= sysinfo["rethanol"] then
388-
while event.pull(0.1, "interrupted") == nil do
388+
    currentREthanol = sysinfo["rethanol"]
389-
  -- get info
389+
    printInfo("rethanol")
390-
  event.listen("touch", btn.checkxy)
390+
  end
391-
  getSysInfo()
391+
  if currentRPlantOil ~= sysinfo["rplantoil"] then
392-
  logicCheck()
392+
    currentRPlantOil = sysinfo["rplantoil"]
393-
  draw()
393+
    printInfo("rplantoil")
394-
  os.sleep(0)
394+
  end
395-
  local event, address, arg1, arg2, arg3 = event.pull(1)
395+
  if currentRDiesel ~= sysinfo["rdiesel"] then
396-
  if type(address) == "string" and component.isPrimary(address) then
396+
    currentRDiesel = sysinfo["rdiesel"]
397-
    if event == "key_down" and arg2 == keyboard.keys.q then
397+
    printInfo("rdiesel")
398-
      os.exit()
398+
  end
399-
    end
399+
400-
  end
400+
  if currentenaFer ~= sysinfo["enaFer"] then
401
    currentenaFer = sysinfo["enaFer"]
402
    printInfo("enaFer")
403
  end
404
  if currentenaGen ~= sysinfo["enaGen"] then
405
    currentenaGen = sysinfo["enaGen"]
406
    printInfo("enaGen")
407
  end
408
  if currentenaSqu ~= sysinfo["enaSqu"] then
409
    currentenaSqu = sysinfo["enaSqu"]
410
    printInfo("enaSqu")
411
  end
412
  if currentenaRef ~= sysinfo["enaRef"] then
413
    currentenaRef = sysinfo["enaRef"]
414
    printInfo("enaRef")
415
  end
416
  
417
  os.sleep(0)
418
end
419
420
btn.screen()
421
startup()
422
while event.pull(0.1, "interrupted") == nil do
423
  -- get info
424
  event.listen("touch", btn.checkxy)
425
  getSysInfo()
426
  logicCheck()
427
  draw()
428
  os.sleep(0)
429
  local event, address, arg1, arg2, arg3 = event.pull(1)
430
  if type(address) == "string" and component.isPrimary(address) then
431
    if event == "key_down" and arg2 == keyboard.keys.q then
432
      os.exit()
433
    end
434
  end
435
end