Advertisement
krakaen

[Krakaen] Turbines (4 Max)

Mar 6th, 2015
1,862
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 37.22 KB | None | 0 0
  1. local monitors = {peripheral.find("monitor")}
  2. local mon = monitors[1]
  3. local turbines = {peripheral.find("BigReactors-Turbine", function(name,object)
  4.         object.name = name
  5.         object.rfProduced = 0
  6.         object.rotorSpeed = 0
  7.         object.flowRate = 0
  8.         return true end)}
  9. local page = "home"
  10. local button={}
  11. local id = 0
  12. local filleds = {}
  13. local boxes = {}
  14. local lines = {}
  15. local texts = {}
  16. local shutdown = false
  17. local refresh = false
  18.  
  19. local infosSize = {}
  20. local contorlsSize = {}
  21. local numbersSize = {}
  22. local currentRfTotal = 0
  23. local currentRfTick = 0
  24. local currentSpeed = 0
  25. local currentFlowRate = 0
  26.  
  27. term.redirect(mon)
  28. mon.clear()
  29. mon.setTextColor(colors.white)
  30. mon.setBackgroundColor(colors.black)
  31.  
  32. function clearTable()
  33.     button = {}
  34. end
  35.  
  36. function setButton(name, func, xmin, ymin, xmax, ymax, elem, p, color)
  37.     button[name] = {}
  38.     button[name]["func"] = func
  39.     button[name]["active"] = false
  40.     button[name]["xmin"] = xmin
  41.     button[name]["ymin"] = ymin
  42.     button[name]["xmax"] = xmax
  43.     button[name]["ymax"] = ymax
  44.     button[name]["color"] = color
  45.     button[name]["elem"] = elem
  46.     button[name]["page"] = p
  47. end
  48.  
  49. function fill(text, color, bData)
  50.    mon.setBackgroundColor(color)
  51.    local yspot = math.floor((bData["ymin"] + bData["ymax"]) /2)
  52.    local xspot = math.floor((bData["xmax"] - bData["xmin"] - string.len(text)) /2) +1
  53.    for j = bData["ymin"], bData["ymax"] do
  54.       mon.setCursorPos(bData["xmin"], j)
  55.       if j == yspot then
  56.          for k = 0, bData["xmax"] - bData["xmin"] - string.len(text) +1 do
  57.             if k == xspot then
  58.                mon.write(text)
  59.             else
  60.                mon.write(" ")
  61.             end
  62.          end
  63.       else
  64.          for i = bData["xmin"], bData["xmax"] do
  65.             mon.write(" ")
  66.          end
  67.       end
  68.    end
  69.    mon.setBackgroundColor(colors.black)
  70. end
  71.  
  72. function screen()
  73.    local currColor
  74.    for name,data in pairs(button) do
  75.       local on = data["active"]
  76.       currColor = data["color"]
  77.       fill(name, currColor, data)
  78.    end
  79. end
  80.  
  81. function flash(name)
  82.    screen()
  83.  
  84. end
  85.  
  86. function checkxy(x, y)
  87.    for name, data in pairs(button) do
  88.       if y>=data["ymin"] and  y <= data["ymax"] then
  89.          if x>=data["xmin"] and x<= data["xmax"] then
  90.             data["func"](data["elem"], data["page"])
  91.             flash(data['name'])
  92.             return true
  93.             --data["active"] = not data["active"]
  94.             --print(name)
  95.          end
  96.       end
  97.    end
  98.    return false
  99. end
  100.  
  101. function label(w, h, text)
  102.    mon.setCursorPos(w, h)
  103.    mon.write(text)
  104. end
  105.  
  106. function draw()
  107.    
  108.     for key,value in pairs(filleds) do
  109.         paintutils.drawFilledBox(value[1] , value[2], value[3], value[4], value[5])
  110.     end
  111.  
  112.     for key,value in pairs(boxes) do
  113.         paintutils.drawBox(value[1] , value[2], value[3], value[4], value[5])
  114.     end
  115.  
  116.     for key,value in pairs(lines) do
  117.         paintutils.drawLine(value[1] , value[2], value[3], value[4], value[5])
  118.     end
  119.  
  120.     for key,value in pairs(texts) do
  121.         mon.setCursorPos(value[1], value[2])
  122.         mon.setTextColor(value[4])
  123.         mon.setBackgroundColor(value[5])
  124.         mon.write(value[3])
  125.     end
  126.     screen()
  127.     resetDraw()
  128. end
  129.  
  130. function resetDraw()
  131.     filleds = {}
  132.     boxes = {}
  133.     lines = {}
  134.     texts = {}
  135. end
  136.  
  137. function resetCurrents()
  138.     currentSpeed = 0
  139.     currentRfTick = 0
  140.     currentRfTotal = 0
  141.     currentFlowRate = 0
  142. end
  143.  
  144. function changepage(ids, p)
  145.     page = p
  146.     refresh = false
  147.    
  148.     resetDraw()
  149.     resetCurrents()
  150.     clearTable()
  151.     mon.clear()
  152.  
  153.  
  154.     if p == "home" then
  155.         fillHomeTable()
  156.     elseif p == "choiceTurbines" then
  157.         mon.setTextScale(1)
  158.         fillTurbineTable()
  159.     elseif p == "singleTurbine" then
  160.         resetCurrents()
  161.         mon.setTextScale(0.5)
  162.         id = ids
  163.         addDrawHeader('choiceTurbines')
  164.         addDrawBoxesSingleTurbine()
  165.     else
  166.         resetCurrents()
  167.         mon.setTextScale(0.5)
  168.         id = ids
  169.         addDrawHeader('home')
  170.         addDrawBoxesTurbines()
  171.     end
  172. end
  173.  
  174. function clickEvent()
  175.     local myEvent={os.pullEvent("monitor_touch")}
  176.     checkxy(myEvent[3], myEvent[4])
  177. end
  178.  
  179. function powerUp(turbineId, turName)
  180.     local turbine = peripheral.wrap("BigReactors-Turbine_" .. turbineId)
  181.     if page == 'turbines' then
  182.         button[turName]['func'] = powerDown
  183.         button[turName]['color'] = colors.green
  184.     end
  185.     turbine.setActive(true)
  186. end
  187.  
  188. function powerDown(turbineId, turName)
  189.     local turbine = peripheral.wrap("BigReactors-Turbine_" .. turbineId)
  190.     if page == 'turbines' then
  191.         button[turName]['func'] = powerUp
  192.         button[turName]['color'] = colors.red
  193.     end
  194.     turbine.setActive(false)
  195. end
  196.  
  197. function augmentFluidflow(turbineId, number)
  198.     local turbine = peripheral.wrap("BigReactors-Turbine_" .. turbineId)
  199.  
  200.     if turbine.getFluidFlowRate() ~= 2000 then
  201.         turbine.setFluidFlowRateMax(math.floor(turbine.getFluidFlowRate() + number))
  202.     end
  203.  
  204. end
  205.  
  206. function lowerFluidFlow(turbineId, number)
  207.     local turbine = peripheral.wrap("BigReactors-Turbine_" .. turbineId)
  208.  
  209.     if turbine.getFluidFlowRate() ~= 0 then
  210.         turbine.setFluidFlowRateMax(math.floor(turbine.getFluidFlowRate() - number))
  211.     end
  212. end
  213.  
  214. function addDrawHeader(pageToGo)
  215.     local width, height = mon.getSize()
  216.     local headerHeight = math.ceil(height/10)
  217.  
  218.     mon.setTextColor(colors.white)
  219.     setButton("BACK", changepage, 1, 1, math.floor(width/6), headerHeight, 0, pageToGo, colors.purple)
  220.     table.insert(filleds, {1 , 1, width, headerHeight, colors.gray})
  221. end
  222.  
  223. function addDrawBoxesTurbines()
  224.     local w, h = mon.getSize()
  225.     local headerHeight = math.ceil(h/10)
  226.     local margin = math.floor((w/100)*2)
  227.  
  228.  
  229.     infosSize['startX'] = margin + 1
  230.     infosSize['startY'] = headerHeight + margin + 1
  231.     infosSize['endX'] = (((w-(margin*2))/3)*2)-margin
  232.     infosSize['endY'] = h - margin
  233.     infosSize['height'] = infosSize['endY']-infosSize['startY']-(margin*2)-2
  234.     infosSize['width'] = infosSize['endX']-infosSize['startX']-(margin*2)-2
  235.     infosSize['inX'] = infosSize['startX'] + margin +1
  236.     infosSize['inY'] = infosSize['startY'] + margin +1
  237.     infosSize['sectionHeight'] = math.floor(infosSize['height']/3)
  238.  
  239.     table.insert(boxes, {infosSize['startX'] , infosSize['startY'], infosSize['endX'], infosSize['endY'], colors.gray})
  240.     local name = "INFOS"
  241.     table.insert(lines, {infosSize['startX'] + margin , infosSize['startY'], infosSize['startX'] + (margin*2) + #name+1, infosSize['startY'], colors.black})
  242.     table.insert(texts, {infosSize['startX'] + (margin*2), infosSize['startY'], name, colors.white, colors.black})
  243.  
  244.     local names = {}
  245.     names[1] = 'RF STORED'
  246.     names[2] = 'ROTOR SPEED'
  247.     names[3] = 'FLOW RATE'
  248.    
  249.     for i=0,2,1 do
  250.         table.insert(texts, {infosSize['inX'] + margin, infosSize['inY'] + (infosSize['sectionHeight']*i) +i, names[i+1], colors.white, colors.black})
  251.         table.insert(filleds, {infosSize['inX'] , infosSize['inY'] + 2 + (infosSize['sectionHeight']*i) +i, infosSize['inX'] + infosSize['width'], infosSize['inY'] + (infosSize['sectionHeight']*(i+1))-1 +i, colors.lightGray})
  252.     end
  253.  
  254.     contorlsSize['startX'] = infosSize['endX'] + margin + 1
  255.     contorlsSize['startY'] = headerHeight + margin + 1
  256.     contorlsSize['endX'] = w-margin
  257.     contorlsSize['endY'] = (((h - headerHeight -(margin*2))/3)*2) +headerHeight +1
  258.     contorlsSize['height'] = contorlsSize['endY']-contorlsSize['startY']-(margin)-1
  259.     contorlsSize['width'] = contorlsSize['endX']-contorlsSize['startX']-(margin*2)-2
  260.     contorlsSize['inX'] = contorlsSize['startX'] + margin +1
  261.     contorlsSize['inY'] = contorlsSize['startY'] + margin
  262.  
  263.     table.insert(boxes, {contorlsSize['startX'] , contorlsSize['startY'], contorlsSize['endX'], contorlsSize['endY'], colors.gray})
  264.     name = "CONTROLS"
  265.     table.insert(lines, {contorlsSize['startX'] + margin , contorlsSize['startY'], contorlsSize['startX'] + (margin*2) + #name+1, contorlsSize['startY'], colors.black})
  266.     table.insert(texts, {contorlsSize['startX'] + (margin*2), contorlsSize['startY'], name, colors.white, colors.black})
  267.    
  268.     contorlsSize['sectionHeight'] = math.floor(contorlsSize['height']/#turbines)
  269.     local tempI  = 0
  270.     for key,value in pairs(turbines) do
  271.         local turbine = value
  272.         local s, e = string.find(turbine.name, "Turbine")
  273.         local turName = string.sub(turbine.name, s)
  274.         local nameSize = #turName
  275.         mon.setTextColor(colors.white)
  276.         if turbine.getActive() then
  277.             setButton(turName, powerDown, contorlsSize['inX'], contorlsSize['inY'] + (tempI*contorlsSize['sectionHeight'])+tempI, contorlsSize['inX'] + contorlsSize['width'] , contorlsSize['inY'] + ((tempI+1)*contorlsSize['sectionHeight']) +tempI -1, string.sub(turbine.name, -1), turName, colors.green)
  278.         else
  279.             setButton(turName, powerUp, contorlsSize['inX'], contorlsSize['inY'] + (tempI*contorlsSize['sectionHeight'])+tempI, contorlsSize['inX'] + contorlsSize['width'] , contorlsSize['inY'] + ((tempI+1)*contorlsSize['sectionHeight']) +tempI -1, string.sub(turbine.name, -1), turName, colors.red)
  280.         end
  281.         tempI = tempI+1
  282.     end
  283.  
  284.     numbersSize['startX'] = infosSize['endX'] + margin + 1
  285.     numbersSize['startY'] = contorlsSize['endY'] + margin + 1
  286.     numbersSize['endX'] = w-margin
  287.     numbersSize['endY'] = h-margin
  288.     numbersSize['height'] = numbersSize['endY']-numbersSize['startY']-(margin)-1
  289.     numbersSize['width'] = numbersSize['endX']-numbersSize['startX']-(margin*2)-2
  290.     numbersSize['inX'] = numbersSize['startX'] + margin +1
  291.     numbersSize['inY'] = numbersSize['startY'] + margin
  292.  
  293.     table.insert(boxes, {numbersSize['startX'] , numbersSize['startY'], numbersSize['endX'], numbersSize['endY'], colors.gray})
  294.     name = "NUMBERS"
  295.     table.insert(lines, {numbersSize['startX'] + margin , numbersSize['startY'], numbersSize['startX'] + (margin*2) + #name+1, numbersSize['startY'], colors.black})
  296.     table.insert(texts, {numbersSize['startX'] + (margin*2), numbersSize['startY'], name, colors.white, colors.black})
  297.  
  298.     refresh = true
  299.     while refresh do
  300.         if page ~= 'turbines' then
  301.             do return end
  302.         end
  303.         parallel.waitForAny(clickEvent, refreshTurbines)
  304.     end
  305. end
  306.  
  307. function refreshTurbines()
  308.  
  309.     local numberOfTurbines = #turbines
  310.     local rfPerTick = 0
  311.     local rfTotal = 0
  312.     local flowTotal = 0
  313.     local speedTotal = 0
  314.     local rfPerTickMax = 30000 * numberOfTurbines
  315.     local rfTotalMax = 1000000 * numberOfTurbines
  316.     local flowTotalMax = 2000
  317.     local speedTotalMax = 2000
  318.     for key,value in pairs(turbines) do
  319.         turbine = value
  320.         rfTotal = rfTotal + turbine.getEnergyStored()
  321.         rfPerTick = rfPerTick +  math.floor(turbine.getEnergyProducedLastTick())
  322.         flowTotal = flowTotal + turbine.getFluidFlowRate()
  323.         speedTotal = speedTotal + turbine.getRotorSpeed()
  324.     end
  325.     flowTotal = math.floor(flowTotal/numberOfTurbines)
  326.     speedTotal = math.floor(speedTotal/numberOfTurbines)
  327.  
  328.  
  329.     local i = 0
  330.     local infotoAdd = 'RF PER TICK : '
  331.  
  332.     if currentRfTick ~= rfPerTick then
  333.         currentRfTick = rfPerTick
  334.  
  335.         table.insert(lines, {numbersSize['inX'] , numbersSize['inY'],numbersSize['inX'] + numbersSize['width'] , numbersSize['inY'], colors.black})
  336.         table.insert(texts, {numbersSize['inX'], numbersSize['inY'], infotoAdd .. rfPerTick, colors.white, colors.black})
  337.  
  338.     end
  339.     if currentRfTotal ~= rfTotal then
  340.         currentRfTotal = rfTotal
  341.  
  342.         table.insert(filleds, {infosSize['inX'] , infosSize['inY'] + 2 + (infosSize['sectionHeight']*i) +i, infosSize['inX'] + infosSize['width'], infosSize['inY'] + (infosSize['sectionHeight']*(i+1))-1 +i, colors.lightGray})
  343.    
  344.         width = math.floor((infosSize['width'] / rfTotalMax)*rfTotal)
  345.         table.insert(filleds, {infosSize['inX'] , infosSize['inY'] + 2 + (infosSize['sectionHeight']*i) +i, infosSize['inX'] + width, infosSize['inY'] + (infosSize['sectionHeight']*(i+1))-1 +i, colors.green})
  346.     end
  347.  
  348.     i = 1
  349.     infotoAdd = 'ROTOR SPEED : '
  350.     if currentSpeed ~= speedTotal then
  351.         currentSpeed = speedTotal
  352.  
  353.         table.insert(filleds, {infosSize['inX'] , infosSize['inY'] + 2 + (infosSize['sectionHeight']*i) +i, infosSize['inX'] + infosSize['width'], infosSize['inY'] + (infosSize['sectionHeight']*(i+1))-1 +i, colors.lightGray})
  354.        
  355.         width = math.floor((infosSize['width'] / speedTotalMax)*speedTotal)
  356.         table.insert(filleds, {infosSize['inX'] , infosSize['inY'] + 2 + (infosSize['sectionHeight']*i) +i, infosSize['inX'] + width, infosSize['inY'] + (infosSize['sectionHeight']*(i+1))-1 +i, colors.lightBlue})
  357.        
  358.         table.insert(lines, {numbersSize['inX'] , numbersSize['inY']+2,numbersSize['inX'] + numbersSize['width'] , numbersSize['inY']+2, colors.black})
  359.         table.insert(texts, {numbersSize['inX'], numbersSize['inY']+2, infotoAdd .. speedTotal, colors.white, colors.black})
  360.     end
  361.    
  362.     i = 2
  363.     infotoAdd = 'FLOW RATE : '
  364.     if currentFlowRate ~= flowTotal then
  365.         currentFlowRate = flowTotal
  366.        
  367.         table.insert(filleds, {infosSize['inX'] , infosSize['inY'] + 2 + (infosSize['sectionHeight']*i) +i, infosSize['inX'] + infosSize['width'], infosSize['inY'] + (infosSize['sectionHeight']*(i+1))-1 +i, colors.lightGray})
  368.  
  369.         width = math.floor((infosSize['width'] / flowTotalMax)*flowTotal)
  370.         table.insert(filleds, {infosSize['inX'] , infosSize['inY'] + 2 + (infosSize['sectionHeight']*i) +i, infosSize['inX'] + width, infosSize['inY'] + (infosSize['sectionHeight']*(i+1))-1 +i, colors.yellow})
  371.        
  372.         table.insert(lines, {numbersSize['inX'] , numbersSize['inY']+4,numbersSize['inX'] + numbersSize['width'] , numbersSize['inY']+4, colors.black})
  373.         table.insert(texts, {numbersSize['inX'], numbersSize['inY']+4, infotoAdd .. flowTotal, colors.white, colors.black})
  374.     end
  375.     if page == 'turbines' then
  376.         draw()
  377.     end
  378.     sleep(2)
  379. end
  380.  
  381. function addDrawBoxesSingleTurbine()
  382.     local w, h = mon.getSize()
  383.     local headerHeight = math.ceil(h/10)
  384.     local margin = math.floor((w/100)*2)
  385.  
  386.  
  387.     infosSize['startX'] = margin + 1
  388.     infosSize['startY'] = headerHeight + margin + 1
  389.     infosSize['endX'] = (((w-(margin*2))/3)*2)-margin
  390.     infosSize['endY'] = h - margin
  391.     infosSize['height'] = infosSize['endY']-infosSize['startY']-(margin*2)-2
  392.     infosSize['width'] = infosSize['endX']-infosSize['startX']-(margin*2)-2
  393.     infosSize['inX'] = infosSize['startX'] + margin +1
  394.     infosSize['inY'] = infosSize['startY'] + margin +1
  395.     infosSize['sectionHeight'] = math.floor(infosSize['height']/3)
  396.  
  397.     table.insert(boxes, {infosSize['startX'] , infosSize['startY'], infosSize['endX'], infosSize['endY'], colors.gray})
  398.     local name = "INFOS"
  399.     table.insert(lines, {infosSize['startX'] + margin , infosSize['startY'], infosSize['startX'] + (margin*2) + #name+1, infosSize['startY'], colors.black})
  400.     table.insert(texts, {infosSize['startX'] + (margin*2), infosSize['startY'], name, colors.white, colors.black})
  401.  
  402.     local names = {}
  403.     names[1] = 'RF STORED'
  404.     names[2] = 'ROTOR SPEED'
  405.     names[3] = 'FLOW RATE'
  406.  
  407.     for i=0,2,1 do
  408.         table.insert(texts, {infosSize['inX'] + margin, infosSize['inY'] + (infosSize['sectionHeight']*i) +i, names[i+1], colors.white, colors.black})
  409.         table.insert(filleds, {infosSize['inX'] , infosSize['inY'] + 2 + (infosSize['sectionHeight']*i) +i, infosSize['inX'] + infosSize['width'], infosSize['inY'] + (infosSize['sectionHeight']*(i+1))-1 +i, colors.lightGray})
  410.     end
  411.  
  412.  
  413.     -- Controls
  414.  
  415.     contorlsSize['startX'] = infosSize['endX'] + margin + 1
  416.     contorlsSize['startY'] = headerHeight + margin + 1
  417.     contorlsSize['endX'] = w-margin
  418.     contorlsSize['endY'] = (((h - headerHeight -(margin*2))/3)*2) +headerHeight +1
  419.     contorlsSize['height'] = contorlsSize['endY']-contorlsSize['startY']-(margin)-1
  420.     contorlsSize['width'] = contorlsSize['endX']-contorlsSize['startX']-(margin*2)-2
  421.     contorlsSize['inX'] = contorlsSize['startX'] + margin +1
  422.     contorlsSize['inY'] = contorlsSize['startY'] + margin
  423.  
  424.     table.insert(boxes, {contorlsSize['startX'] , contorlsSize['startY'], contorlsSize['endX'], contorlsSize['endY'], colors.gray})
  425.     name = "CONTROLS"
  426.     table.insert(lines, {contorlsSize['startX'] + margin , contorlsSize['startY'], contorlsSize['startX'] + (margin*2) + #name+1, contorlsSize['startY'], colors.black})
  427.     table.insert(texts, {contorlsSize['startX'] + (margin*2), contorlsSize['startY'], name, colors.white, colors.black})
  428.    
  429.     contorlsSize['sectionHeight'] = math.floor(contorlsSize['height']/4)
  430.  
  431.     turbine = peripheral.wrap("BigReactors-Turbine_" .. id)
  432.  
  433.     -- TOCHECK
  434.  
  435.     table.insert(texts, {contorlsSize['inX'], contorlsSize['inY'], 'POWER', colors.white, colors.black})
  436.    
  437.     setButton("ON", powerUp, contorlsSize['inX'], contorlsSize['inY']+2, contorlsSize['inX'] + math.floor(contorlsSize['width']/2) -1, contorlsSize['inY'] +contorlsSize['sectionHeight']+1, id, 'pageToGo', colors.green)
  438.     setButton("OFF", powerDown, contorlsSize['inX'] + math.floor(contorlsSize['width']/2) +1, contorlsSize['inY']+2, contorlsSize['inX'] + contorlsSize['width'], contorlsSize['inY'] +contorlsSize['sectionHeight']+1, id, 'pageToGo', colors.red)
  439.  
  440.     table.insert(texts, {contorlsSize['inX'], contorlsSize['inY'] +(contorlsSize['sectionHeight']*1)+3, 'FLUID FLOW RATE', colors.white, colors.black})
  441.  
  442.  
  443.     setButton("-1", lowerFluidFlow, contorlsSize['inX'], contorlsSize['inY'] +(contorlsSize['sectionHeight']*2)+2, contorlsSize['inX'] + math.floor(contorlsSize['width']/2) -1, contorlsSize['inY'] +(contorlsSize['sectionHeight']*3)+1, id, 1, colors.yellow)
  444.     setButton("+1", augmentFluidflow, contorlsSize['inX'] + math.floor(contorlsSize['width']/2) +1, contorlsSize['inY'] +(contorlsSize['sectionHeight']*2)+2, contorlsSize['inX'] + contorlsSize['width'], contorlsSize['inY'] +(contorlsSize['sectionHeight']*3)+1, id, 1, colors.yellow) 
  445.  
  446.     setButton("-10", lowerFluidFlow, contorlsSize['inX'], contorlsSize['inY'] +(contorlsSize['sectionHeight']*3)+3, contorlsSize['inX'] + math.floor(contorlsSize['width']/2) -1, contorlsSize['inY'] +(contorlsSize['sectionHeight']*4)+2, id, 10, colors.orange)
  447.     setButton("+10", augmentFluidflow, contorlsSize['inX'] + math.floor(contorlsSize['width']/2) +1, contorlsSize['inY'] +(contorlsSize['sectionHeight']*3)+3, contorlsSize['inX'] + contorlsSize['width'], contorlsSize['inY'] +(contorlsSize['sectionHeight']*4)+2, id, 10, colors.orange)   
  448.  
  449.     -- Numbers
  450.  
  451.     numbersSize['startX'] = infosSize['endX'] + margin + 1
  452.     numbersSize['startY'] = contorlsSize['endY'] + margin + 1
  453.     numbersSize['endX'] = w-margin
  454.     numbersSize['endY'] = h-margin
  455.     numbersSize['height'] = numbersSize['endY']-numbersSize['startY']-(margin)-1
  456.     numbersSize['width'] = numbersSize['endX']-numbersSize['startX']-(margin*2)-2
  457.     numbersSize['inX'] = numbersSize['startX'] + margin +1
  458.     numbersSize['inY'] = numbersSize['startY'] + margin
  459.  
  460.     table.insert(boxes, {numbersSize['startX'] , numbersSize['startY'], numbersSize['endX'], numbersSize['endY'], colors.gray})
  461.     name = "NUMBERS"
  462.     table.insert(lines, {numbersSize['startX'] + margin , numbersSize['startY'], numbersSize['startX'] + (margin*2) + #name+1, numbersSize['startY'], colors.black})
  463.     table.insert(texts, {numbersSize['startX'] + (margin*2), numbersSize['startY'], name, colors.white, colors.black})
  464.  
  465.     refresh = true
  466.     while refresh do
  467.         if page ~= 'singleTurbine' then
  468.             do return end
  469.         end
  470.         parallel.waitForAny(refreshSingleTurbine,clickEvent)
  471.     end
  472. end
  473.  
  474. function refreshSingleTurbine()
  475.  
  476.     local numberOfTurbines = #turbines
  477.     local rfPerTick = 0
  478.     local rfTotal = 0
  479.     local flowTotal = 0
  480.     local speedTotal = 0
  481.     local rfPerTickMax = 30000
  482.     local rfTotalMax = 1000000
  483.     local flowTotalMax = 2000
  484.     local speedTotalMax = 2000
  485.     turbine = peripheral.wrap("BigReactors-Turbine_" .. id)
  486.     rfTotal = rfTotal + turbine.getEnergyStored()
  487.     rfPerTick = rfPerTick +  math.floor(turbine.getEnergyProducedLastTick())
  488.     flowTotal = flowTotal + turbine.getFluidFlowRate()
  489.     speedTotal = speedTotal + turbine.getRotorSpeed()
  490.  
  491.  
  492.     local i = 0
  493.     local infotoAdd = 'RF PER TICK : '
  494.  
  495.     if currentRfTick ~= rfPerTick then
  496.         currentRfTick = rfPerTick
  497.  
  498.         table.insert(lines, {numbersSize['inX'] , numbersSize['inY'],numbersSize['inX'] + numbersSize['width'] , numbersSize['inY'], colors.black})
  499.         table.insert(texts, {numbersSize['inX'], numbersSize['inY'], infotoAdd .. rfPerTick, colors.white, colors.black})
  500.  
  501.     end
  502.     if currentRfTotal ~= rfTotal then
  503.         currentRfTotal = rfTotal
  504.  
  505.         table.insert(filleds, {infosSize['inX'] , infosSize['inY'] + 2 + (infosSize['sectionHeight']*i) +i, infosSize['inX'] + infosSize['width'], infosSize['inY'] + (infosSize['sectionHeight']*(i+1))-1 +i, colors.lightGray})
  506.    
  507.         width = math.floor((infosSize['width'] / rfTotalMax)*rfTotal)
  508.         table.insert(filleds, {infosSize['inX'] , infosSize['inY'] + 2 + (infosSize['sectionHeight']*i) +i, infosSize['inX'] + width, infosSize['inY'] + (infosSize['sectionHeight']*(i+1))-1 +i, colors.green})
  509.     end
  510.  
  511.     i = 1
  512.     infotoAdd = 'ROTOR SPEED : '
  513.     if currentSpeed ~= speedTotal then
  514.         currentSpeed = speedTotal
  515.  
  516.         table.insert(filleds, {infosSize['inX'] , infosSize['inY'] + 2 + (infosSize['sectionHeight']*i) +i, infosSize['inX'] + infosSize['width'], infosSize['inY'] + (infosSize['sectionHeight']*(i+1))-1 +i, colors.lightGray})
  517.        
  518.         width = math.floor((infosSize['width'] / speedTotalMax)*speedTotal)
  519.         table.insert(filleds, {infosSize['inX'] , infosSize['inY'] + 2 + (infosSize['sectionHeight']*i) +i, infosSize['inX'] + width, infosSize['inY'] + (infosSize['sectionHeight']*(i+1))-1 +i, colors.lightBlue})
  520.        
  521.         table.insert(lines, {numbersSize['inX'] , numbersSize['inY']+2,numbersSize['inX'] + numbersSize['width'] , numbersSize['inY']+2, colors.black})
  522.         table.insert(texts, {numbersSize['inX'], numbersSize['inY']+2, infotoAdd .. speedTotal, colors.white, colors.black})
  523.     end
  524.    
  525.     i = 2
  526.     infotoAdd = 'FLOW RATE : '
  527.     if currentFlowRate ~= flowTotal then
  528.         currentFlowRate = flowTotal
  529.        
  530.         table.insert(filleds, {infosSize['inX'] , infosSize['inY'] + 2 + (infosSize['sectionHeight']*i) +i, infosSize['inX'] + infosSize['width'], infosSize['inY'] + (infosSize['sectionHeight']*(i+1))-1 +i, colors.lightGray})
  531.  
  532.         width = math.floor((infosSize['width'] / flowTotalMax)*flowTotal)
  533.         table.insert(filleds, {infosSize['inX'] , infosSize['inY'] + 2 + (infosSize['sectionHeight']*i) +i, infosSize['inX'] + width, infosSize['inY'] + (infosSize['sectionHeight']*(i+1))-1 +i, colors.yellow})
  534.        
  535.         table.insert(lines, {numbersSize['inX'] , numbersSize['inY']+4,numbersSize['inX'] + numbersSize['width'] , numbersSize['inY']+4, colors.black})
  536.         table.insert(texts, {numbersSize['inX'], numbersSize['inY']+4, infotoAdd .. flowTotal, colors.white, colors.black})
  537.     end
  538.  
  539.     if page == 'singleTurbine' then
  540.         draw()
  541.     end
  542.     sleep(2)
  543. end
  544.  
  545. function drawMario()
  546.  
  547.     local w, h = mon.getSize()
  548.  
  549.     -- right mario 
  550.     -- line 1
  551.     paintutils.drawPixel(w-9,6, colors.red)
  552.     paintutils.drawPixel(w-10,6, colors.red)
  553.     paintutils.drawPixel(w-11,6, colors.red)
  554.     paintutils.drawPixel(w-12,6, colors.red)
  555.     paintutils.drawPixel(w-13,6, colors.red)
  556.     paintutils.drawPixel(w-14,6, colors.red)
  557.     --line 2
  558.     paintutils.drawPixel(w-8,7, colors.red)
  559.     paintutils.drawPixel(w-9,7, colors.red)
  560.     paintutils.drawPixel(w-10,7, colors.red)
  561.     paintutils.drawPixel(w-11,7, colors.red)
  562.     paintutils.drawPixel(w-12,7, colors.red)
  563.     paintutils.drawPixel(w-13,7, colors.red)
  564.     paintutils.drawPixel(w-14,7, colors.red)
  565.     paintutils.drawPixel(w-15,7, colors.red)
  566.     paintutils.drawPixel(w-16,7, colors.red)
  567.     paintutils.drawPixel(w-17,7, colors.red)
  568.     --line 3
  569.     paintutils.drawPixel(w-8,8, colors.brown)
  570.     paintutils.drawPixel(w-9,8, colors.brown)
  571.     paintutils.drawPixel(w-10,8, colors.brown)
  572.     paintutils.drawPixel(w-11,8, colors.pink)
  573.     paintutils.drawPixel(w-12,8, colors.pink)
  574.     paintutils.drawPixel(w-13,8, colors.pink)
  575.     paintutils.drawPixel(w-14,8, colors.gray)
  576.     paintutils.drawPixel(w-15,8, colors.pink)
  577.     -- line 4
  578.     paintutils.drawPixel(w-7,9, colors.brown)
  579.     paintutils.drawPixel(w-8,9, colors.pink)
  580.     paintutils.drawPixel(w-9,9, colors.brown)
  581.     paintutils.drawPixel(w-10,9, colors.pink)
  582.     paintutils.drawPixel(w-11,9, colors.pink)
  583.     paintutils.drawPixel(w-12,9, colors.pink)
  584.     paintutils.drawPixel(w-13,9, colors.pink)
  585.     paintutils.drawPixel(w-14,9, colors.gray)
  586.     paintutils.drawPixel(w-15,9, colors.pink)
  587.     paintutils.drawPixel(w-16,9, colors.pink)
  588.     paintutils.drawPixel(w-17,9, colors.pink)
  589.     --line 5
  590.     paintutils.drawPixel(w-7,10, colors.brown)
  591.     paintutils.drawPixel(w-8,10, colors.pink)
  592.     paintutils.drawPixel(w-9,10, colors.brown)
  593.     paintutils.drawPixel(w-10,10, colors.brown)
  594.     paintutils.drawPixel(w-11,10, colors.pink)
  595.     paintutils.drawPixel(w-12,10, colors.pink)
  596.     paintutils.drawPixel(w-13,10, colors.pink)
  597.     paintutils.drawPixel(w-14,10, colors.pink)
  598.     paintutils.drawPixel(w-15,10, colors.gray)
  599.     paintutils.drawPixel(w-16,10, colors.pink)
  600.     paintutils.drawPixel(w-17,10, colors.pink)
  601.     paintutils.drawPixel(w-18,10, colors.pink)
  602.     --line 6
  603.     paintutils.drawPixel(w-7,11, colors.brown)
  604.     paintutils.drawPixel(w-8,11, colors.brown)
  605.     paintutils.drawPixel(w-9,11, colors.pink)
  606.     paintutils.drawPixel(w-10,11, colors.pink)
  607.     paintutils.drawPixel(w-11,11, colors.pink)
  608.     paintutils.drawPixel(w-12,11, colors.pink)
  609.     paintutils.drawPixel(w-13,11, colors.pink)
  610.     paintutils.drawPixel(w-14,11, colors.gray)
  611.     paintutils.drawPixel(w-15,11, colors.gray)
  612.     paintutils.drawPixel(w-16,11, colors.gray)
  613.     paintutils.drawPixel(w-17,11, colors.gray)
  614.     --line 7
  615.     paintutils.drawPixel(w-9,12, colors.pink)
  616.     paintutils.drawPixel(w-10,12, colors.pink)
  617.     paintutils.drawPixel(w-11,12, colors.pink)
  618.     paintutils.drawPixel(w-12,12, colors.pink)
  619.     paintutils.drawPixel(w-13,12, colors.pink)
  620.     paintutils.drawPixel(w-14,12, colors.pink)
  621.     paintutils.drawPixel(w-15,12, colors.pink)
  622.     paintutils.drawPixel(w-16,12, colors.pink)
  623.     -- line 8
  624.     paintutils.drawPixel(w-8,13, colors.red)
  625.     paintutils.drawPixel(w-9,13, colors.red)
  626.     paintutils.drawPixel(w-10,13, colors.blue)
  627.     paintutils.drawPixel(w-11,13, colors.red)
  628.     paintutils.drawPixel(w-12,13, colors.red)
  629.     paintutils.drawPixel(w-13,13, colors.red)
  630.     paintutils.drawPixel(w-14,13, colors.red)
  631.     --line 9
  632.     paintutils.drawPixel(w-7,14, colors.red)
  633.     paintutils.drawPixel(w-8,14, colors.red)
  634.     paintutils.drawPixel(w-9,14, colors.red)
  635.     paintutils.drawPixel(w-10,14, colors.blue)
  636.     paintutils.drawPixel(w-11,14, colors.red)
  637.     paintutils.drawPixel(w-12,14, colors.red)
  638.     paintutils.drawPixel(w-13,14, colors.blue)
  639.     paintutils.drawPixel(w-14,14, colors.red)
  640.     paintutils.drawPixel(w-15,14, colors.red)
  641.     paintutils.drawPixel(w-16,14, colors.red)
  642.     --line 10
  643.     paintutils.drawPixel(w-6,15, colors.red)
  644.     paintutils.drawPixel(w-7,15, colors.red)
  645.     paintutils.drawPixel(w-8,15, colors.red)
  646.     paintutils.drawPixel(w-9,15, colors.red)
  647.     paintutils.drawPixel(w-10,15, colors.blue)
  648.     paintutils.drawPixel(w-11,15, colors.red)
  649.     paintutils.drawPixel(w-12,15, colors.red)
  650.     paintutils.drawPixel(w-13,15, colors.blue)
  651.     paintutils.drawPixel(w-14,15, colors.red)
  652.     paintutils.drawPixel(w-15,15, colors.red)
  653.     paintutils.drawPixel(w-16,15, colors.red)
  654.     paintutils.drawPixel(w-17,15, colors.red)
  655.     --line 11
  656.     paintutils.drawPixel(w-6,16, colors.pink)
  657.     paintutils.drawPixel(w-7,16, colors.pink)
  658.     paintutils.drawPixel(w-8,16, colors.red)
  659.     paintutils.drawPixel(w-9,16, colors.blue)
  660.     paintutils.drawPixel(w-10,16, colors.yellow)
  661.     paintutils.drawPixel(w-11,16, colors.blue)
  662.     paintutils.drawPixel(w-12,16, colors.blue)
  663.     paintutils.drawPixel(w-13,16, colors.yellow)
  664.     paintutils.drawPixel(w-14,16, colors.blue)
  665.     paintutils.drawPixel(w-15,16, colors.red)
  666.     paintutils.drawPixel(w-16,16, colors.pink)
  667.     paintutils.drawPixel(w-17,16, colors.pink)
  668.     --line 12
  669.     paintutils.drawPixel(w-6,17, colors.pink)
  670.     paintutils.drawPixel(w-7,17, colors.pink)
  671.     paintutils.drawPixel(w-8,17, colors.pink)
  672.     paintutils.drawPixel(w-9,17, colors.blue)
  673.     paintutils.drawPixel(w-10,17, colors.blue)
  674.     paintutils.drawPixel(w-11,17, colors.blue)
  675.     paintutils.drawPixel(w-12,17, colors.blue)
  676.     paintutils.drawPixel(w-13,17, colors.blue)
  677.     paintutils.drawPixel(w-14,17, colors.blue)
  678.     paintutils.drawPixel(w-15,17, colors.pink)
  679.     paintutils.drawPixel(w-16,17, colors.pink)
  680.     paintutils.drawPixel(w-17,17, colors.pink)
  681.     --line 13
  682.     paintutils.drawPixel(w-6,18, colors.pink)
  683.     paintutils.drawPixel(w-7,18, colors.pink)
  684.     paintutils.drawPixel(w-8,18, colors.blue)
  685.     paintutils.drawPixel(w-9,18, colors.blue)
  686.     paintutils.drawPixel(w-10,18, colors.blue)
  687.     paintutils.drawPixel(w-11,18, colors.blue)
  688.     paintutils.drawPixel(w-12,18, colors.blue)
  689.     paintutils.drawPixel(w-13,18, colors.blue)
  690.     paintutils.drawPixel(w-14,18, colors.blue)
  691.     paintutils.drawPixel(w-15,18, colors.blue)
  692.     paintutils.drawPixel(w-16,18, colors.pink)
  693.     paintutils.drawPixel(w-17,18, colors.pink)
  694.     -- line 14
  695.     paintutils.drawPixel(w-8,19, colors.blue)
  696.     paintutils.drawPixel(w-9,19, colors.blue)
  697.     paintutils.drawPixel(w-10,19, colors.blue)
  698.     paintutils.drawPixel(w-13,19, colors.blue)
  699.     paintutils.drawPixel(w-14,19, colors.blue)
  700.     paintutils.drawPixel(w-15,19, colors.blue)
  701.     --line 15
  702.     paintutils.drawPixel(w-7,20, colors.brown)
  703.     paintutils.drawPixel(w-8,20, colors.brown)
  704.     paintutils.drawPixel(w-9,20, colors.brown)
  705.     paintutils.drawPixel(w-14,20, colors.brown)
  706.     paintutils.drawPixel(w-15,20, colors.brown)
  707.     paintutils.drawPixel(w-16,20, colors.brown)
  708.     --line 16
  709.     paintutils.drawPixel(w-6,21, colors.brown)
  710.     paintutils.drawPixel(w-7,21, colors.brown)
  711.     paintutils.drawPixel(w-8,21, colors.brown)
  712.     paintutils.drawPixel(w-9,21, colors.brown)
  713.     paintutils.drawPixel(w-14,21, colors.brown)
  714.     paintutils.drawPixel(w-15,21, colors.brown)
  715.     paintutils.drawPixel(w-16,21, colors.brown)
  716.     paintutils.drawPixel(w-17,21, colors.brown)
  717.  
  718.     -- left mario
  719.  
  720.     -- line 1
  721.     paintutils.drawPixel(9,6, colors.red)
  722.     paintutils.drawPixel(10,6, colors.red)
  723.     paintutils.drawPixel(11,6, colors.red)
  724.     paintutils.drawPixel(12,6, colors.red)
  725.     paintutils.drawPixel(13,6, colors.red)
  726.     paintutils.drawPixel(14,6, colors.red)
  727.     --line 2
  728.     paintutils.drawPixel(8,7, colors.red)
  729.     paintutils.drawPixel(9,7, colors.red)
  730.     paintutils.drawPixel(10,7, colors.red)
  731.     paintutils.drawPixel(11,7, colors.red)
  732.     paintutils.drawPixel(12,7, colors.red)
  733.     paintutils.drawPixel(13,7, colors.red)
  734.     paintutils.drawPixel(14,7, colors.red)
  735.     paintutils.drawPixel(15,7, colors.red)
  736.     paintutils.drawPixel(16,7, colors.red)
  737.     paintutils.drawPixel(17,7, colors.red)
  738.     --line 3
  739.     paintutils.drawPixel(8,8, colors.brown)
  740.     paintutils.drawPixel(9,8, colors.brown)
  741.     paintutils.drawPixel(10,8, colors.brown)
  742.     paintutils.drawPixel(11,8, colors.pink)
  743.     paintutils.drawPixel(12,8, colors.pink)
  744.     paintutils.drawPixel(13,8, colors.pink)
  745.     paintutils.drawPixel(14,8, colors.gray)
  746.     paintutils.drawPixel(15,8, colors.pink)
  747.     -- line 4
  748.     paintutils.drawPixel(7,9, colors.brown)
  749.     paintutils.drawPixel(8,9, colors.pink)
  750.     paintutils.drawPixel(9,9, colors.brown)
  751.     paintutils.drawPixel(10,9, colors.pink)
  752.     paintutils.drawPixel(11,9, colors.pink)
  753.     paintutils.drawPixel(12,9, colors.pink)
  754.     paintutils.drawPixel(13,9, colors.pink)
  755.     paintutils.drawPixel(14,9, colors.gray)
  756.     paintutils.drawPixel(15,9, colors.pink)
  757.     paintutils.drawPixel(16,9, colors.pink)
  758.     paintutils.drawPixel(17,9, colors.pink)
  759.     --line 5
  760.     paintutils.drawPixel(7,10, colors.brown)
  761.     paintutils.drawPixel(8,10, colors.pink)
  762.     paintutils.drawPixel(9,10, colors.brown)
  763.     paintutils.drawPixel(10,10, colors.brown)
  764.     paintutils.drawPixel(11,10, colors.pink)
  765.     paintutils.drawPixel(12,10, colors.pink)
  766.     paintutils.drawPixel(13,10, colors.pink)
  767.     paintutils.drawPixel(14,10, colors.pink)
  768.     paintutils.drawPixel(15,10, colors.gray)
  769.     paintutils.drawPixel(16,10, colors.pink)
  770.     paintutils.drawPixel(17,10, colors.pink)
  771.     paintutils.drawPixel(18,10, colors.pink)
  772.     --line 6
  773.     paintutils.drawPixel(7,11, colors.brown)
  774.     paintutils.drawPixel(8,11, colors.brown)
  775.     paintutils.drawPixel(9,11, colors.pink)
  776.     paintutils.drawPixel(10,11, colors.pink)
  777.     paintutils.drawPixel(11,11, colors.pink)
  778.     paintutils.drawPixel(12,11, colors.pink)
  779.     paintutils.drawPixel(13,11, colors.pink)
  780.     paintutils.drawPixel(14,11, colors.gray)
  781.     paintutils.drawPixel(15,11, colors.gray)
  782.     paintutils.drawPixel(16,11, colors.gray)
  783.     paintutils.drawPixel(17,11, colors.gray)
  784.     --line 7
  785.     paintutils.drawPixel(9,12, colors.pink)
  786.     paintutils.drawPixel(10,12, colors.pink)
  787.     paintutils.drawPixel(11,12, colors.pink)
  788.     paintutils.drawPixel(12,12, colors.pink)
  789.     paintutils.drawPixel(13,12, colors.pink)
  790.     paintutils.drawPixel(14,12, colors.pink)
  791.     paintutils.drawPixel(15,12, colors.pink)
  792.     paintutils.drawPixel(16,12, colors.pink)
  793.     -- line 8
  794.     paintutils.drawPixel(8,13, colors.red)
  795.     paintutils.drawPixel(9,13, colors.red)
  796.     paintutils.drawPixel(10,13, colors.blue)
  797.     paintutils.drawPixel(11,13, colors.red)
  798.     paintutils.drawPixel(12,13, colors.red)
  799.     paintutils.drawPixel(13,13, colors.red)
  800.     paintutils.drawPixel(14,13, colors.red)
  801.     --line 9
  802.     paintutils.drawPixel(7,14, colors.red)
  803.     paintutils.drawPixel(8,14, colors.red)
  804.     paintutils.drawPixel(9,14, colors.red)
  805.     paintutils.drawPixel(10,14, colors.blue)
  806.     paintutils.drawPixel(11,14, colors.red)
  807.     paintutils.drawPixel(12,14, colors.red)
  808.     paintutils.drawPixel(13,14, colors.blue)
  809.     paintutils.drawPixel(14,14, colors.red)
  810.     paintutils.drawPixel(15,14, colors.red)
  811.     paintutils.drawPixel(16,14, colors.red)
  812.     --line 10
  813.     paintutils.drawPixel(6,15, colors.red)
  814.     paintutils.drawPixel(7,15, colors.red)
  815.     paintutils.drawPixel(8,15, colors.red)
  816.     paintutils.drawPixel(9,15, colors.red)
  817.     paintutils.drawPixel(10,15, colors.blue)
  818.     paintutils.drawPixel(11,15, colors.red)
  819.     paintutils.drawPixel(12,15, colors.red)
  820.     paintutils.drawPixel(13,15, colors.blue)
  821.     paintutils.drawPixel(14,15, colors.red)
  822.     paintutils.drawPixel(15,15, colors.red)
  823.     paintutils.drawPixel(16,15, colors.red)
  824.     paintutils.drawPixel(17,15, colors.red)
  825.     --line 11
  826.     paintutils.drawPixel(6,16, colors.pink)
  827.     paintutils.drawPixel(7,16, colors.pink)
  828.     paintutils.drawPixel(8,16, colors.red)
  829.     paintutils.drawPixel(9,16, colors.blue)
  830.     paintutils.drawPixel(10,16, colors.yellow)
  831.     paintutils.drawPixel(11,16, colors.blue)
  832.     paintutils.drawPixel(12,16, colors.blue)
  833.     paintutils.drawPixel(13,16, colors.yellow)
  834.     paintutils.drawPixel(14,16, colors.blue)
  835.     paintutils.drawPixel(15,16, colors.red)
  836.     paintutils.drawPixel(16,16, colors.pink)
  837.     paintutils.drawPixel(17,16, colors.pink)
  838.     --line 12
  839.     paintutils.drawPixel(6,17, colors.pink)
  840.     paintutils.drawPixel(7,17, colors.pink)
  841.     paintutils.drawPixel(8,17, colors.pink)
  842.     paintutils.drawPixel(9,17, colors.blue)
  843.     paintutils.drawPixel(10,17, colors.blue)
  844.     paintutils.drawPixel(11,17, colors.blue)
  845.     paintutils.drawPixel(12,17, colors.blue)
  846.     paintutils.drawPixel(13,17, colors.blue)
  847.     paintutils.drawPixel(14,17, colors.blue)
  848.     paintutils.drawPixel(15,17, colors.pink)
  849.     paintutils.drawPixel(16,17, colors.pink)
  850.     paintutils.drawPixel(17,17, colors.pink)
  851.     --line 13
  852.     paintutils.drawPixel(6,18, colors.pink)
  853.     paintutils.drawPixel(7,18, colors.pink)
  854.     paintutils.drawPixel(8,18, colors.blue)
  855.     paintutils.drawPixel(9,18, colors.blue)
  856.     paintutils.drawPixel(10,18, colors.blue)
  857.     paintutils.drawPixel(11,18, colors.blue)
  858.     paintutils.drawPixel(12,18, colors.blue)
  859.     paintutils.drawPixel(13,18, colors.blue)
  860.     paintutils.drawPixel(14,18, colors.blue)
  861.     paintutils.drawPixel(15,18, colors.blue)
  862.     paintutils.drawPixel(16,18, colors.pink)
  863.     paintutils.drawPixel(17,18, colors.pink)
  864.     -- line 14
  865.     paintutils.drawPixel(8,19, colors.blue)
  866.     paintutils.drawPixel(9,19, colors.blue)
  867.     paintutils.drawPixel(10,19, colors.blue)
  868.     paintutils.drawPixel(13,19, colors.blue)
  869.     paintutils.drawPixel(14,19, colors.blue)
  870.     paintutils.drawPixel(15,19, colors.blue)
  871.     --line 15
  872.     paintutils.drawPixel(7,20, colors.brown)
  873.     paintutils.drawPixel(8,20, colors.brown)
  874.     paintutils.drawPixel(9,20, colors.brown)
  875.     paintutils.drawPixel(14,20, colors.brown)
  876.     paintutils.drawPixel(15,20, colors.brown)
  877.     paintutils.drawPixel(16,20, colors.brown)
  878.     --line 16
  879.     paintutils.drawPixel(6,21, colors.brown)
  880.     paintutils.drawPixel(7,21, colors.brown)
  881.     paintutils.drawPixel(8,21, colors.brown)
  882.     paintutils.drawPixel(9,21, colors.brown)
  883.     paintutils.drawPixel(14,21, colors.brown)
  884.     paintutils.drawPixel(15,21, colors.brown)
  885.     paintutils.drawPixel(16,21, colors.brown)
  886.     paintutils.drawPixel(17,21, colors.brown)
  887.  
  888. end
  889.  
  890. function fillTurbineTable()
  891.     mon.setTextScale(0.5)
  892.     local w, h = mon.getSize()
  893.  
  894.     local xSections = math.floor(w/3)
  895.     local ySections = math.ceil(h/4)
  896.  
  897.     resetDraw()
  898.     clearTable()
  899.  
  900.     table.insert(lines, {xSections , 1,xSections , h, colors.gray})
  901.     table.insert(lines, {xSections*2, 1,xSections*2 , h, colors.gray})
  902.  
  903.     table.insert(lines, {xSections , ySections-1, xSections*2 , ySections-1, colors.gray})
  904.     table.insert(lines, {xSections, ySections*2, xSections*2 , ySections*2, colors.gray})
  905.     table.insert(lines, {xSections , (ySections*3)+1, xSections*2 , (ySections*3)+1, colors.gray})
  906.  
  907.     setButton("BACK", changepage, 1, 1, w/6, h/10, 0, "home", colors.purple)
  908.     local Xi = 1
  909.     for key,value in pairs(turbines) do
  910.         turbine = value
  911.         local s, e = string.find(turbine.name, "Turbine")
  912.         local turName = string.sub(turbine.name, s)
  913.  
  914.         setButton(turName, changepage, xSections+2, ySections*(Xi-1), (xSections*2)-2, (ySections*Xi)-(4-Xi), string.sub(turbine.name, -1), "singleTurbine", colors.blue)
  915.         Xi = Xi + 1
  916.     end
  917.    
  918.     drawMario()
  919.    
  920.     draw()
  921.     refresh = true
  922.     while refresh do
  923.         clickEvent()
  924.     end
  925. end
  926.  
  927. function fillHomeTable()
  928.     mon.setTextScale(0.5)
  929.    
  930.     mon.setBackgroundColor(colors.black)
  931.     local w, h = mon.getSize()
  932.  
  933.     local xSections = math.floor(w/3)
  934.     local ySections = math.floor(h/4)
  935.  
  936.     resetDraw()
  937.     clearTable()
  938.    
  939.     table.insert(lines, {xSections , 1,xSections , h, colors.gray})
  940.     table.insert(lines, {xSections*2, 1,xSections*2 , h, colors.gray})
  941.  
  942.     table.insert(lines, {xSections , ySections-1, xSections*2 , ySections-1, colors.gray})
  943.     table.insert(lines, {xSections, ySections*2, xSections*2 , ySections*2, colors.gray})
  944.     table.insert(lines, {xSections , (ySections*3)+1, xSections*2 , (ySections*3)+1, colors.gray})
  945.    
  946.     setButton("All Turbines", changepage, xSections+2, ySections+1, (xSections*2)-2, (ySections*2)-2, 0, "turbines", colors.blue)
  947.     setButton("Turbine", changepage, xSections+2, (ySections*2)+2, (xSections*2)-2, (ySections*3)-1, 0, "choiceTurbines", colors.blue)
  948.  
  949.     drawMario()
  950.  
  951.     draw()
  952.     resetDraw()
  953.     refresh = true
  954.     while refresh do
  955.         clickEvent()
  956.     end
  957.     refresh = false
  958. end
  959.  
  960. mon.setBackgroundColor(colors.black)
  961.  
  962. mon.clear()
  963. fillHomeTable()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement