Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitors = {peripheral.find("monitor")}
- local mon = monitors[1]
- local turbines = {peripheral.find("BigReactors-Turbine", function(name,object)
- object.name = name
- object.rfProduced = 0
- object.rotorSpeed = 0
- object.flowRate = 0
- return true end)}
- local page = "home"
- local button={}
- local id = 0
- local filleds = {}
- local boxes = {}
- local lines = {}
- local texts = {}
- local shutdown = false
- local refresh = false
- local infosSize = {}
- local contorlsSize = {}
- local numbersSize = {}
- local currentRfTotal = 0
- local currentRfTick = 0
- local currentSpeed = 0
- local currentFlowRate = 0
- term.redirect(mon)
- mon.clear()
- mon.setTextColor(colors.white)
- mon.setBackgroundColor(colors.black)
- function clearTable()
- button = {}
- end
- function setButton(name, func, xmin, ymin, xmax, ymax, elem, p, color)
- button[name] = {}
- button[name]["func"] = func
- button[name]["active"] = false
- button[name]["xmin"] = xmin
- button[name]["ymin"] = ymin
- button[name]["xmax"] = xmax
- button[name]["ymax"] = ymax
- button[name]["color"] = color
- button[name]["elem"] = elem
- button[name]["page"] = p
- end
- function fill(text, color, bData)
- mon.setBackgroundColor(color)
- local yspot = math.floor((bData["ymin"] + bData["ymax"]) /2)
- local xspot = math.floor((bData["xmax"] - bData["xmin"] - string.len(text)) /2) +1
- for j = bData["ymin"], bData["ymax"] do
- mon.setCursorPos(bData["xmin"], j)
- if j == yspot then
- for k = 0, bData["xmax"] - bData["xmin"] - string.len(text) +1 do
- if k == xspot then
- mon.write(text)
- else
- mon.write(" ")
- end
- end
- else
- for i = bData["xmin"], bData["xmax"] do
- mon.write(" ")
- end
- end
- end
- mon.setBackgroundColor(colors.black)
- end
- function screen()
- local currColor
- for name,data in pairs(button) do
- local on = data["active"]
- currColor = data["color"]
- fill(name, currColor, data)
- end
- end
- function flash(name)
- screen()
- end
- function checkxy(x, y)
- for name, data in pairs(button) do
- if y>=data["ymin"] and y <= data["ymax"] then
- if x>=data["xmin"] and x<= data["xmax"] then
- data["func"](data["elem"], data["page"])
- flash(data['name'])
- return true
- --data["active"] = not data["active"]
- --print(name)
- end
- end
- end
- return false
- end
- function label(w, h, text)
- mon.setCursorPos(w, h)
- mon.write(text)
- end
- function draw()
- for key,value in pairs(filleds) do
- paintutils.drawFilledBox(value[1] , value[2], value[3], value[4], value[5])
- end
- for key,value in pairs(boxes) do
- paintutils.drawBox(value[1] , value[2], value[3], value[4], value[5])
- end
- for key,value in pairs(lines) do
- paintutils.drawLine(value[1] , value[2], value[3], value[4], value[5])
- end
- for key,value in pairs(texts) do
- mon.setCursorPos(value[1], value[2])
- mon.setTextColor(value[4])
- mon.setBackgroundColor(value[5])
- mon.write(value[3])
- end
- screen()
- resetDraw()
- end
- function resetDraw()
- filleds = {}
- boxes = {}
- lines = {}
- texts = {}
- end
- function resetCurrents()
- currentSpeed = 0
- currentRfTick = 0
- currentRfTotal = 0
- currentFlowRate = 0
- end
- function changepage(ids, p)
- page = p
- refresh = false
- resetDraw()
- resetCurrents()
- clearTable()
- mon.clear()
- if p == "home" then
- fillHomeTable()
- elseif p == "choiceTurbines" then
- mon.setTextScale(1)
- fillTurbineTable()
- elseif p == "singleTurbine" then
- resetCurrents()
- mon.setTextScale(0.5)
- id = ids
- addDrawHeader('choiceTurbines')
- addDrawBoxesSingleTurbine()
- else
- resetCurrents()
- mon.setTextScale(0.5)
- id = ids
- addDrawHeader('home')
- addDrawBoxesTurbines()
- end
- end
- function clickEvent()
- local myEvent={os.pullEvent("monitor_touch")}
- checkxy(myEvent[3], myEvent[4])
- end
- function powerUp(turbineId, turName)
- local turbine = peripheral.wrap("BigReactors-Turbine_" .. turbineId)
- if page == 'turbines' then
- button[turName]['func'] = powerDown
- button[turName]['color'] = colors.green
- end
- turbine.setActive(true)
- end
- function powerDown(turbineId, turName)
- local turbine = peripheral.wrap("BigReactors-Turbine_" .. turbineId)
- if page == 'turbines' then
- button[turName]['func'] = powerUp
- button[turName]['color'] = colors.red
- end
- turbine.setActive(false)
- end
- function augmentFluidflow(turbineId, number)
- local turbine = peripheral.wrap("BigReactors-Turbine_" .. turbineId)
- if turbine.getFluidFlowRate() ~= 2000 then
- turbine.setFluidFlowRateMax(math.floor(turbine.getFluidFlowRate() + number))
- end
- end
- function lowerFluidFlow(turbineId, number)
- local turbine = peripheral.wrap("BigReactors-Turbine_" .. turbineId)
- if turbine.getFluidFlowRate() ~= 0 then
- turbine.setFluidFlowRateMax(math.floor(turbine.getFluidFlowRate() - number))
- end
- end
- function addDrawHeader(pageToGo)
- local width, height = mon.getSize()
- local headerHeight = math.ceil(height/10)
- mon.setTextColor(colors.white)
- setButton("BACK", changepage, 1, 1, math.floor(width/6), headerHeight, 0, pageToGo, colors.purple)
- table.insert(filleds, {1 , 1, width, headerHeight, colors.gray})
- end
- function addDrawBoxesTurbines()
- local w, h = mon.getSize()
- local headerHeight = math.ceil(h/10)
- local margin = math.floor((w/100)*2)
- infosSize['startX'] = margin + 1
- infosSize['startY'] = headerHeight + margin + 1
- infosSize['endX'] = (((w-(margin*2))/3)*2)-margin
- infosSize['endY'] = h - margin
- infosSize['height'] = infosSize['endY']-infosSize['startY']-(margin*2)-2
- infosSize['width'] = infosSize['endX']-infosSize['startX']-(margin*2)-2
- infosSize['inX'] = infosSize['startX'] + margin +1
- infosSize['inY'] = infosSize['startY'] + margin +1
- infosSize['sectionHeight'] = math.floor(infosSize['height']/3)
- table.insert(boxes, {infosSize['startX'] , infosSize['startY'], infosSize['endX'], infosSize['endY'], colors.gray})
- local name = "INFOS"
- table.insert(lines, {infosSize['startX'] + margin , infosSize['startY'], infosSize['startX'] + (margin*2) + #name+1, infosSize['startY'], colors.black})
- table.insert(texts, {infosSize['startX'] + (margin*2), infosSize['startY'], name, colors.white, colors.black})
- local names = {}
- names[1] = 'RF STORED'
- names[2] = 'ROTOR SPEED'
- names[3] = 'FLOW RATE'
- for i=0,2,1 do
- table.insert(texts, {infosSize['inX'] + margin, infosSize['inY'] + (infosSize['sectionHeight']*i) +i, names[i+1], colors.white, colors.black})
- 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})
- end
- contorlsSize['startX'] = infosSize['endX'] + margin + 1
- contorlsSize['startY'] = headerHeight + margin + 1
- contorlsSize['endX'] = w-margin
- contorlsSize['endY'] = (((h - headerHeight -(margin*2))/3)*2) +headerHeight +1
- contorlsSize['height'] = contorlsSize['endY']-contorlsSize['startY']-(margin)-1
- contorlsSize['width'] = contorlsSize['endX']-contorlsSize['startX']-(margin*2)-2
- contorlsSize['inX'] = contorlsSize['startX'] + margin +1
- contorlsSize['inY'] = contorlsSize['startY'] + margin
- table.insert(boxes, {contorlsSize['startX'] , contorlsSize['startY'], contorlsSize['endX'], contorlsSize['endY'], colors.gray})
- name = "CONTROLS"
- table.insert(lines, {contorlsSize['startX'] + margin , contorlsSize['startY'], contorlsSize['startX'] + (margin*2) + #name+1, contorlsSize['startY'], colors.black})
- table.insert(texts, {contorlsSize['startX'] + (margin*2), contorlsSize['startY'], name, colors.white, colors.black})
- contorlsSize['sectionHeight'] = math.floor(contorlsSize['height']/#turbines)
- local tempI = 0
- for key,value in pairs(turbines) do
- local turbine = value
- local s, e = string.find(turbine.name, "Turbine")
- local turName = string.sub(turbine.name, s)
- local nameSize = #turName
- mon.setTextColor(colors.white)
- if turbine.getActive() then
- 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)
- else
- 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)
- end
- tempI = tempI+1
- end
- numbersSize['startX'] = infosSize['endX'] + margin + 1
- numbersSize['startY'] = contorlsSize['endY'] + margin + 1
- numbersSize['endX'] = w-margin
- numbersSize['endY'] = h-margin
- numbersSize['height'] = numbersSize['endY']-numbersSize['startY']-(margin)-1
- numbersSize['width'] = numbersSize['endX']-numbersSize['startX']-(margin*2)-2
- numbersSize['inX'] = numbersSize['startX'] + margin +1
- numbersSize['inY'] = numbersSize['startY'] + margin
- table.insert(boxes, {numbersSize['startX'] , numbersSize['startY'], numbersSize['endX'], numbersSize['endY'], colors.gray})
- name = "NUMBERS"
- table.insert(lines, {numbersSize['startX'] + margin , numbersSize['startY'], numbersSize['startX'] + (margin*2) + #name+1, numbersSize['startY'], colors.black})
- table.insert(texts, {numbersSize['startX'] + (margin*2), numbersSize['startY'], name, colors.white, colors.black})
- refresh = true
- while refresh do
- if page ~= 'turbines' then
- do return end
- end
- parallel.waitForAny(clickEvent, refreshTurbines)
- end
- end
- function refreshTurbines()
- local numberOfTurbines = #turbines
- local rfPerTick = 0
- local rfTotal = 0
- local flowTotal = 0
- local speedTotal = 0
- local rfPerTickMax = 30000 * numberOfTurbines
- local rfTotalMax = 1000000 * numberOfTurbines
- local flowTotalMax = 2000
- local speedTotalMax = 2000
- for key,value in pairs(turbines) do
- turbine = value
- rfTotal = rfTotal + turbine.getEnergyStored()
- rfPerTick = rfPerTick + math.floor(turbine.getEnergyProducedLastTick())
- flowTotal = flowTotal + turbine.getFluidFlowRate()
- speedTotal = speedTotal + turbine.getRotorSpeed()
- end
- flowTotal = math.floor(flowTotal/numberOfTurbines)
- speedTotal = math.floor(speedTotal/numberOfTurbines)
- local i = 0
- local infotoAdd = 'RF PER TICK : '
- if currentRfTick ~= rfPerTick then
- currentRfTick = rfPerTick
- table.insert(lines, {numbersSize['inX'] , numbersSize['inY'],numbersSize['inX'] + numbersSize['width'] , numbersSize['inY'], colors.black})
- table.insert(texts, {numbersSize['inX'], numbersSize['inY'], infotoAdd .. rfPerTick, colors.white, colors.black})
- end
- if currentRfTotal ~= rfTotal then
- currentRfTotal = rfTotal
- 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})
- width = math.floor((infosSize['width'] / rfTotalMax)*rfTotal)
- 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})
- end
- i = 1
- infotoAdd = 'ROTOR SPEED : '
- if currentSpeed ~= speedTotal then
- currentSpeed = speedTotal
- 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})
- width = math.floor((infosSize['width'] / speedTotalMax)*speedTotal)
- 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})
- table.insert(lines, {numbersSize['inX'] , numbersSize['inY']+2,numbersSize['inX'] + numbersSize['width'] , numbersSize['inY']+2, colors.black})
- table.insert(texts, {numbersSize['inX'], numbersSize['inY']+2, infotoAdd .. speedTotal, colors.white, colors.black})
- end
- i = 2
- infotoAdd = 'FLOW RATE : '
- if currentFlowRate ~= flowTotal then
- currentFlowRate = flowTotal
- 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})
- width = math.floor((infosSize['width'] / flowTotalMax)*flowTotal)
- 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})
- table.insert(lines, {numbersSize['inX'] , numbersSize['inY']+4,numbersSize['inX'] + numbersSize['width'] , numbersSize['inY']+4, colors.black})
- table.insert(texts, {numbersSize['inX'], numbersSize['inY']+4, infotoAdd .. flowTotal, colors.white, colors.black})
- end
- if page == 'turbines' then
- draw()
- end
- sleep(2)
- end
- function addDrawBoxesSingleTurbine()
- local w, h = mon.getSize()
- local headerHeight = math.ceil(h/10)
- local margin = math.floor((w/100)*2)
- infosSize['startX'] = margin + 1
- infosSize['startY'] = headerHeight + margin + 1
- infosSize['endX'] = (((w-(margin*2))/3)*2)-margin
- infosSize['endY'] = h - margin
- infosSize['height'] = infosSize['endY']-infosSize['startY']-(margin*2)-2
- infosSize['width'] = infosSize['endX']-infosSize['startX']-(margin*2)-2
- infosSize['inX'] = infosSize['startX'] + margin +1
- infosSize['inY'] = infosSize['startY'] + margin +1
- infosSize['sectionHeight'] = math.floor(infosSize['height']/3)
- table.insert(boxes, {infosSize['startX'] , infosSize['startY'], infosSize['endX'], infosSize['endY'], colors.gray})
- local name = "INFOS"
- table.insert(lines, {infosSize['startX'] + margin , infosSize['startY'], infosSize['startX'] + (margin*2) + #name+1, infosSize['startY'], colors.black})
- table.insert(texts, {infosSize['startX'] + (margin*2), infosSize['startY'], name, colors.white, colors.black})
- local names = {}
- names[1] = 'RF STORED'
- names[2] = 'ROTOR SPEED'
- names[3] = 'FLOW RATE'
- for i=0,2,1 do
- table.insert(texts, {infosSize['inX'] + margin, infosSize['inY'] + (infosSize['sectionHeight']*i) +i, names[i+1], colors.white, colors.black})
- 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})
- end
- -- Controls
- contorlsSize['startX'] = infosSize['endX'] + margin + 1
- contorlsSize['startY'] = headerHeight + margin + 1
- contorlsSize['endX'] = w-margin
- contorlsSize['endY'] = (((h - headerHeight -(margin*2))/3)*2) +headerHeight +1
- contorlsSize['height'] = contorlsSize['endY']-contorlsSize['startY']-(margin)-1
- contorlsSize['width'] = contorlsSize['endX']-contorlsSize['startX']-(margin*2)-2
- contorlsSize['inX'] = contorlsSize['startX'] + margin +1
- contorlsSize['inY'] = contorlsSize['startY'] + margin
- table.insert(boxes, {contorlsSize['startX'] , contorlsSize['startY'], contorlsSize['endX'], contorlsSize['endY'], colors.gray})
- name = "CONTROLS"
- table.insert(lines, {contorlsSize['startX'] + margin , contorlsSize['startY'], contorlsSize['startX'] + (margin*2) + #name+1, contorlsSize['startY'], colors.black})
- table.insert(texts, {contorlsSize['startX'] + (margin*2), contorlsSize['startY'], name, colors.white, colors.black})
- contorlsSize['sectionHeight'] = math.floor(contorlsSize['height']/4)
- turbine = peripheral.wrap("BigReactors-Turbine_" .. id)
- -- TOCHECK
- table.insert(texts, {contorlsSize['inX'], contorlsSize['inY'], 'POWER', colors.white, colors.black})
- 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)
- 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)
- table.insert(texts, {contorlsSize['inX'], contorlsSize['inY'] +(contorlsSize['sectionHeight']*1)+3, 'FLUID FLOW RATE', colors.white, colors.black})
- 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)
- 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)
- 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)
- 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)
- -- Numbers
- numbersSize['startX'] = infosSize['endX'] + margin + 1
- numbersSize['startY'] = contorlsSize['endY'] + margin + 1
- numbersSize['endX'] = w-margin
- numbersSize['endY'] = h-margin
- numbersSize['height'] = numbersSize['endY']-numbersSize['startY']-(margin)-1
- numbersSize['width'] = numbersSize['endX']-numbersSize['startX']-(margin*2)-2
- numbersSize['inX'] = numbersSize['startX'] + margin +1
- numbersSize['inY'] = numbersSize['startY'] + margin
- table.insert(boxes, {numbersSize['startX'] , numbersSize['startY'], numbersSize['endX'], numbersSize['endY'], colors.gray})
- name = "NUMBERS"
- table.insert(lines, {numbersSize['startX'] + margin , numbersSize['startY'], numbersSize['startX'] + (margin*2) + #name+1, numbersSize['startY'], colors.black})
- table.insert(texts, {numbersSize['startX'] + (margin*2), numbersSize['startY'], name, colors.white, colors.black})
- refresh = true
- while refresh do
- if page ~= 'singleTurbine' then
- do return end
- end
- parallel.waitForAny(refreshSingleTurbine,clickEvent)
- end
- end
- function refreshSingleTurbine()
- local numberOfTurbines = #turbines
- local rfPerTick = 0
- local rfTotal = 0
- local flowTotal = 0
- local speedTotal = 0
- local rfPerTickMax = 30000
- local rfTotalMax = 1000000
- local flowTotalMax = 2000
- local speedTotalMax = 2000
- turbine = peripheral.wrap("BigReactors-Turbine_" .. id)
- rfTotal = rfTotal + turbine.getEnergyStored()
- rfPerTick = rfPerTick + math.floor(turbine.getEnergyProducedLastTick())
- flowTotal = flowTotal + turbine.getFluidFlowRate()
- speedTotal = speedTotal + turbine.getRotorSpeed()
- local i = 0
- local infotoAdd = 'RF PER TICK : '
- if currentRfTick ~= rfPerTick then
- currentRfTick = rfPerTick
- table.insert(lines, {numbersSize['inX'] , numbersSize['inY'],numbersSize['inX'] + numbersSize['width'] , numbersSize['inY'], colors.black})
- table.insert(texts, {numbersSize['inX'], numbersSize['inY'], infotoAdd .. rfPerTick, colors.white, colors.black})
- end
- if currentRfTotal ~= rfTotal then
- currentRfTotal = rfTotal
- 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})
- width = math.floor((infosSize['width'] / rfTotalMax)*rfTotal)
- 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})
- end
- i = 1
- infotoAdd = 'ROTOR SPEED : '
- if currentSpeed ~= speedTotal then
- currentSpeed = speedTotal
- 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})
- width = math.floor((infosSize['width'] / speedTotalMax)*speedTotal)
- 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})
- table.insert(lines, {numbersSize['inX'] , numbersSize['inY']+2,numbersSize['inX'] + numbersSize['width'] , numbersSize['inY']+2, colors.black})
- table.insert(texts, {numbersSize['inX'], numbersSize['inY']+2, infotoAdd .. speedTotal, colors.white, colors.black})
- end
- i = 2
- infotoAdd = 'FLOW RATE : '
- if currentFlowRate ~= flowTotal then
- currentFlowRate = flowTotal
- 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})
- width = math.floor((infosSize['width'] / flowTotalMax)*flowTotal)
- 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})
- table.insert(lines, {numbersSize['inX'] , numbersSize['inY']+4,numbersSize['inX'] + numbersSize['width'] , numbersSize['inY']+4, colors.black})
- table.insert(texts, {numbersSize['inX'], numbersSize['inY']+4, infotoAdd .. flowTotal, colors.white, colors.black})
- end
- if page == 'singleTurbine' then
- draw()
- end
- sleep(2)
- end
- function drawMario()
- local w, h = mon.getSize()
- -- right mario
- -- line 1
- paintutils.drawPixel(w-9,6, colors.red)
- paintutils.drawPixel(w-10,6, colors.red)
- paintutils.drawPixel(w-11,6, colors.red)
- paintutils.drawPixel(w-12,6, colors.red)
- paintutils.drawPixel(w-13,6, colors.red)
- paintutils.drawPixel(w-14,6, colors.red)
- --line 2
- paintutils.drawPixel(w-8,7, colors.red)
- paintutils.drawPixel(w-9,7, colors.red)
- paintutils.drawPixel(w-10,7, colors.red)
- paintutils.drawPixel(w-11,7, colors.red)
- paintutils.drawPixel(w-12,7, colors.red)
- paintutils.drawPixel(w-13,7, colors.red)
- paintutils.drawPixel(w-14,7, colors.red)
- paintutils.drawPixel(w-15,7, colors.red)
- paintutils.drawPixel(w-16,7, colors.red)
- paintutils.drawPixel(w-17,7, colors.red)
- --line 3
- paintutils.drawPixel(w-8,8, colors.brown)
- paintutils.drawPixel(w-9,8, colors.brown)
- paintutils.drawPixel(w-10,8, colors.brown)
- paintutils.drawPixel(w-11,8, colors.pink)
- paintutils.drawPixel(w-12,8, colors.pink)
- paintutils.drawPixel(w-13,8, colors.pink)
- paintutils.drawPixel(w-14,8, colors.gray)
- paintutils.drawPixel(w-15,8, colors.pink)
- -- line 4
- paintutils.drawPixel(w-7,9, colors.brown)
- paintutils.drawPixel(w-8,9, colors.pink)
- paintutils.drawPixel(w-9,9, colors.brown)
- paintutils.drawPixel(w-10,9, colors.pink)
- paintutils.drawPixel(w-11,9, colors.pink)
- paintutils.drawPixel(w-12,9, colors.pink)
- paintutils.drawPixel(w-13,9, colors.pink)
- paintutils.drawPixel(w-14,9, colors.gray)
- paintutils.drawPixel(w-15,9, colors.pink)
- paintutils.drawPixel(w-16,9, colors.pink)
- paintutils.drawPixel(w-17,9, colors.pink)
- --line 5
- paintutils.drawPixel(w-7,10, colors.brown)
- paintutils.drawPixel(w-8,10, colors.pink)
- paintutils.drawPixel(w-9,10, colors.brown)
- paintutils.drawPixel(w-10,10, colors.brown)
- paintutils.drawPixel(w-11,10, colors.pink)
- paintutils.drawPixel(w-12,10, colors.pink)
- paintutils.drawPixel(w-13,10, colors.pink)
- paintutils.drawPixel(w-14,10, colors.pink)
- paintutils.drawPixel(w-15,10, colors.gray)
- paintutils.drawPixel(w-16,10, colors.pink)
- paintutils.drawPixel(w-17,10, colors.pink)
- paintutils.drawPixel(w-18,10, colors.pink)
- --line 6
- paintutils.drawPixel(w-7,11, colors.brown)
- paintutils.drawPixel(w-8,11, colors.brown)
- paintutils.drawPixel(w-9,11, colors.pink)
- paintutils.drawPixel(w-10,11, colors.pink)
- paintutils.drawPixel(w-11,11, colors.pink)
- paintutils.drawPixel(w-12,11, colors.pink)
- paintutils.drawPixel(w-13,11, colors.pink)
- paintutils.drawPixel(w-14,11, colors.gray)
- paintutils.drawPixel(w-15,11, colors.gray)
- paintutils.drawPixel(w-16,11, colors.gray)
- paintutils.drawPixel(w-17,11, colors.gray)
- --line 7
- paintutils.drawPixel(w-9,12, colors.pink)
- paintutils.drawPixel(w-10,12, colors.pink)
- paintutils.drawPixel(w-11,12, colors.pink)
- paintutils.drawPixel(w-12,12, colors.pink)
- paintutils.drawPixel(w-13,12, colors.pink)
- paintutils.drawPixel(w-14,12, colors.pink)
- paintutils.drawPixel(w-15,12, colors.pink)
- paintutils.drawPixel(w-16,12, colors.pink)
- -- line 8
- paintutils.drawPixel(w-8,13, colors.red)
- paintutils.drawPixel(w-9,13, colors.red)
- paintutils.drawPixel(w-10,13, colors.blue)
- paintutils.drawPixel(w-11,13, colors.red)
- paintutils.drawPixel(w-12,13, colors.red)
- paintutils.drawPixel(w-13,13, colors.red)
- paintutils.drawPixel(w-14,13, colors.red)
- --line 9
- paintutils.drawPixel(w-7,14, colors.red)
- paintutils.drawPixel(w-8,14, colors.red)
- paintutils.drawPixel(w-9,14, colors.red)
- paintutils.drawPixel(w-10,14, colors.blue)
- paintutils.drawPixel(w-11,14, colors.red)
- paintutils.drawPixel(w-12,14, colors.red)
- paintutils.drawPixel(w-13,14, colors.blue)
- paintutils.drawPixel(w-14,14, colors.red)
- paintutils.drawPixel(w-15,14, colors.red)
- paintutils.drawPixel(w-16,14, colors.red)
- --line 10
- paintutils.drawPixel(w-6,15, colors.red)
- paintutils.drawPixel(w-7,15, colors.red)
- paintutils.drawPixel(w-8,15, colors.red)
- paintutils.drawPixel(w-9,15, colors.red)
- paintutils.drawPixel(w-10,15, colors.blue)
- paintutils.drawPixel(w-11,15, colors.red)
- paintutils.drawPixel(w-12,15, colors.red)
- paintutils.drawPixel(w-13,15, colors.blue)
- paintutils.drawPixel(w-14,15, colors.red)
- paintutils.drawPixel(w-15,15, colors.red)
- paintutils.drawPixel(w-16,15, colors.red)
- paintutils.drawPixel(w-17,15, colors.red)
- --line 11
- paintutils.drawPixel(w-6,16, colors.pink)
- paintutils.drawPixel(w-7,16, colors.pink)
- paintutils.drawPixel(w-8,16, colors.red)
- paintutils.drawPixel(w-9,16, colors.blue)
- paintutils.drawPixel(w-10,16, colors.yellow)
- paintutils.drawPixel(w-11,16, colors.blue)
- paintutils.drawPixel(w-12,16, colors.blue)
- paintutils.drawPixel(w-13,16, colors.yellow)
- paintutils.drawPixel(w-14,16, colors.blue)
- paintutils.drawPixel(w-15,16, colors.red)
- paintutils.drawPixel(w-16,16, colors.pink)
- paintutils.drawPixel(w-17,16, colors.pink)
- --line 12
- paintutils.drawPixel(w-6,17, colors.pink)
- paintutils.drawPixel(w-7,17, colors.pink)
- paintutils.drawPixel(w-8,17, colors.pink)
- paintutils.drawPixel(w-9,17, colors.blue)
- paintutils.drawPixel(w-10,17, colors.blue)
- paintutils.drawPixel(w-11,17, colors.blue)
- paintutils.drawPixel(w-12,17, colors.blue)
- paintutils.drawPixel(w-13,17, colors.blue)
- paintutils.drawPixel(w-14,17, colors.blue)
- paintutils.drawPixel(w-15,17, colors.pink)
- paintutils.drawPixel(w-16,17, colors.pink)
- paintutils.drawPixel(w-17,17, colors.pink)
- --line 13
- paintutils.drawPixel(w-6,18, colors.pink)
- paintutils.drawPixel(w-7,18, colors.pink)
- paintutils.drawPixel(w-8,18, colors.blue)
- paintutils.drawPixel(w-9,18, colors.blue)
- paintutils.drawPixel(w-10,18, colors.blue)
- paintutils.drawPixel(w-11,18, colors.blue)
- paintutils.drawPixel(w-12,18, colors.blue)
- paintutils.drawPixel(w-13,18, colors.blue)
- paintutils.drawPixel(w-14,18, colors.blue)
- paintutils.drawPixel(w-15,18, colors.blue)
- paintutils.drawPixel(w-16,18, colors.pink)
- paintutils.drawPixel(w-17,18, colors.pink)
- -- line 14
- paintutils.drawPixel(w-8,19, colors.blue)
- paintutils.drawPixel(w-9,19, colors.blue)
- paintutils.drawPixel(w-10,19, colors.blue)
- paintutils.drawPixel(w-13,19, colors.blue)
- paintutils.drawPixel(w-14,19, colors.blue)
- paintutils.drawPixel(w-15,19, colors.blue)
- --line 15
- paintutils.drawPixel(w-7,20, colors.brown)
- paintutils.drawPixel(w-8,20, colors.brown)
- paintutils.drawPixel(w-9,20, colors.brown)
- paintutils.drawPixel(w-14,20, colors.brown)
- paintutils.drawPixel(w-15,20, colors.brown)
- paintutils.drawPixel(w-16,20, colors.brown)
- --line 16
- paintutils.drawPixel(w-6,21, colors.brown)
- paintutils.drawPixel(w-7,21, colors.brown)
- paintutils.drawPixel(w-8,21, colors.brown)
- paintutils.drawPixel(w-9,21, colors.brown)
- paintutils.drawPixel(w-14,21, colors.brown)
- paintutils.drawPixel(w-15,21, colors.brown)
- paintutils.drawPixel(w-16,21, colors.brown)
- paintutils.drawPixel(w-17,21, colors.brown)
- -- left mario
- -- line 1
- paintutils.drawPixel(9,6, colors.red)
- paintutils.drawPixel(10,6, colors.red)
- paintutils.drawPixel(11,6, colors.red)
- paintutils.drawPixel(12,6, colors.red)
- paintutils.drawPixel(13,6, colors.red)
- paintutils.drawPixel(14,6, colors.red)
- --line 2
- paintutils.drawPixel(8,7, colors.red)
- paintutils.drawPixel(9,7, colors.red)
- paintutils.drawPixel(10,7, colors.red)
- paintutils.drawPixel(11,7, colors.red)
- paintutils.drawPixel(12,7, colors.red)
- paintutils.drawPixel(13,7, colors.red)
- paintutils.drawPixel(14,7, colors.red)
- paintutils.drawPixel(15,7, colors.red)
- paintutils.drawPixel(16,7, colors.red)
- paintutils.drawPixel(17,7, colors.red)
- --line 3
- paintutils.drawPixel(8,8, colors.brown)
- paintutils.drawPixel(9,8, colors.brown)
- paintutils.drawPixel(10,8, colors.brown)
- paintutils.drawPixel(11,8, colors.pink)
- paintutils.drawPixel(12,8, colors.pink)
- paintutils.drawPixel(13,8, colors.pink)
- paintutils.drawPixel(14,8, colors.gray)
- paintutils.drawPixel(15,8, colors.pink)
- -- line 4
- paintutils.drawPixel(7,9, colors.brown)
- paintutils.drawPixel(8,9, colors.pink)
- paintutils.drawPixel(9,9, colors.brown)
- paintutils.drawPixel(10,9, colors.pink)
- paintutils.drawPixel(11,9, colors.pink)
- paintutils.drawPixel(12,9, colors.pink)
- paintutils.drawPixel(13,9, colors.pink)
- paintutils.drawPixel(14,9, colors.gray)
- paintutils.drawPixel(15,9, colors.pink)
- paintutils.drawPixel(16,9, colors.pink)
- paintutils.drawPixel(17,9, colors.pink)
- --line 5
- paintutils.drawPixel(7,10, colors.brown)
- paintutils.drawPixel(8,10, colors.pink)
- paintutils.drawPixel(9,10, colors.brown)
- paintutils.drawPixel(10,10, colors.brown)
- paintutils.drawPixel(11,10, colors.pink)
- paintutils.drawPixel(12,10, colors.pink)
- paintutils.drawPixel(13,10, colors.pink)
- paintutils.drawPixel(14,10, colors.pink)
- paintutils.drawPixel(15,10, colors.gray)
- paintutils.drawPixel(16,10, colors.pink)
- paintutils.drawPixel(17,10, colors.pink)
- paintutils.drawPixel(18,10, colors.pink)
- --line 6
- paintutils.drawPixel(7,11, colors.brown)
- paintutils.drawPixel(8,11, colors.brown)
- paintutils.drawPixel(9,11, colors.pink)
- paintutils.drawPixel(10,11, colors.pink)
- paintutils.drawPixel(11,11, colors.pink)
- paintutils.drawPixel(12,11, colors.pink)
- paintutils.drawPixel(13,11, colors.pink)
- paintutils.drawPixel(14,11, colors.gray)
- paintutils.drawPixel(15,11, colors.gray)
- paintutils.drawPixel(16,11, colors.gray)
- paintutils.drawPixel(17,11, colors.gray)
- --line 7
- paintutils.drawPixel(9,12, colors.pink)
- paintutils.drawPixel(10,12, colors.pink)
- paintutils.drawPixel(11,12, colors.pink)
- paintutils.drawPixel(12,12, colors.pink)
- paintutils.drawPixel(13,12, colors.pink)
- paintutils.drawPixel(14,12, colors.pink)
- paintutils.drawPixel(15,12, colors.pink)
- paintutils.drawPixel(16,12, colors.pink)
- -- line 8
- paintutils.drawPixel(8,13, colors.red)
- paintutils.drawPixel(9,13, colors.red)
- paintutils.drawPixel(10,13, colors.blue)
- paintutils.drawPixel(11,13, colors.red)
- paintutils.drawPixel(12,13, colors.red)
- paintutils.drawPixel(13,13, colors.red)
- paintutils.drawPixel(14,13, colors.red)
- --line 9
- paintutils.drawPixel(7,14, colors.red)
- paintutils.drawPixel(8,14, colors.red)
- paintutils.drawPixel(9,14, colors.red)
- paintutils.drawPixel(10,14, colors.blue)
- paintutils.drawPixel(11,14, colors.red)
- paintutils.drawPixel(12,14, colors.red)
- paintutils.drawPixel(13,14, colors.blue)
- paintutils.drawPixel(14,14, colors.red)
- paintutils.drawPixel(15,14, colors.red)
- paintutils.drawPixel(16,14, colors.red)
- --line 10
- paintutils.drawPixel(6,15, colors.red)
- paintutils.drawPixel(7,15, colors.red)
- paintutils.drawPixel(8,15, colors.red)
- paintutils.drawPixel(9,15, colors.red)
- paintutils.drawPixel(10,15, colors.blue)
- paintutils.drawPixel(11,15, colors.red)
- paintutils.drawPixel(12,15, colors.red)
- paintutils.drawPixel(13,15, colors.blue)
- paintutils.drawPixel(14,15, colors.red)
- paintutils.drawPixel(15,15, colors.red)
- paintutils.drawPixel(16,15, colors.red)
- paintutils.drawPixel(17,15, colors.red)
- --line 11
- paintutils.drawPixel(6,16, colors.pink)
- paintutils.drawPixel(7,16, colors.pink)
- paintutils.drawPixel(8,16, colors.red)
- paintutils.drawPixel(9,16, colors.blue)
- paintutils.drawPixel(10,16, colors.yellow)
- paintutils.drawPixel(11,16, colors.blue)
- paintutils.drawPixel(12,16, colors.blue)
- paintutils.drawPixel(13,16, colors.yellow)
- paintutils.drawPixel(14,16, colors.blue)
- paintutils.drawPixel(15,16, colors.red)
- paintutils.drawPixel(16,16, colors.pink)
- paintutils.drawPixel(17,16, colors.pink)
- --line 12
- paintutils.drawPixel(6,17, colors.pink)
- paintutils.drawPixel(7,17, colors.pink)
- paintutils.drawPixel(8,17, colors.pink)
- paintutils.drawPixel(9,17, colors.blue)
- paintutils.drawPixel(10,17, colors.blue)
- paintutils.drawPixel(11,17, colors.blue)
- paintutils.drawPixel(12,17, colors.blue)
- paintutils.drawPixel(13,17, colors.blue)
- paintutils.drawPixel(14,17, colors.blue)
- paintutils.drawPixel(15,17, colors.pink)
- paintutils.drawPixel(16,17, colors.pink)
- paintutils.drawPixel(17,17, colors.pink)
- --line 13
- paintutils.drawPixel(6,18, colors.pink)
- paintutils.drawPixel(7,18, colors.pink)
- paintutils.drawPixel(8,18, colors.blue)
- paintutils.drawPixel(9,18, colors.blue)
- paintutils.drawPixel(10,18, colors.blue)
- paintutils.drawPixel(11,18, colors.blue)
- paintutils.drawPixel(12,18, colors.blue)
- paintutils.drawPixel(13,18, colors.blue)
- paintutils.drawPixel(14,18, colors.blue)
- paintutils.drawPixel(15,18, colors.blue)
- paintutils.drawPixel(16,18, colors.pink)
- paintutils.drawPixel(17,18, colors.pink)
- -- line 14
- paintutils.drawPixel(8,19, colors.blue)
- paintutils.drawPixel(9,19, colors.blue)
- paintutils.drawPixel(10,19, colors.blue)
- paintutils.drawPixel(13,19, colors.blue)
- paintutils.drawPixel(14,19, colors.blue)
- paintutils.drawPixel(15,19, colors.blue)
- --line 15
- paintutils.drawPixel(7,20, colors.brown)
- paintutils.drawPixel(8,20, colors.brown)
- paintutils.drawPixel(9,20, colors.brown)
- paintutils.drawPixel(14,20, colors.brown)
- paintutils.drawPixel(15,20, colors.brown)
- paintutils.drawPixel(16,20, colors.brown)
- --line 16
- paintutils.drawPixel(6,21, colors.brown)
- paintutils.drawPixel(7,21, colors.brown)
- paintutils.drawPixel(8,21, colors.brown)
- paintutils.drawPixel(9,21, colors.brown)
- paintutils.drawPixel(14,21, colors.brown)
- paintutils.drawPixel(15,21, colors.brown)
- paintutils.drawPixel(16,21, colors.brown)
- paintutils.drawPixel(17,21, colors.brown)
- end
- function fillTurbineTable()
- mon.setTextScale(0.5)
- local w, h = mon.getSize()
- local xSections = math.floor(w/3)
- local ySections = math.ceil(h/4)
- resetDraw()
- clearTable()
- table.insert(lines, {xSections , 1,xSections , h, colors.gray})
- table.insert(lines, {xSections*2, 1,xSections*2 , h, colors.gray})
- table.insert(lines, {xSections , ySections-1, xSections*2 , ySections-1, colors.gray})
- table.insert(lines, {xSections, ySections*2, xSections*2 , ySections*2, colors.gray})
- table.insert(lines, {xSections , (ySections*3)+1, xSections*2 , (ySections*3)+1, colors.gray})
- setButton("BACK", changepage, 1, 1, w/6, h/10, 0, "home", colors.purple)
- local Xi = 1
- for key,value in pairs(turbines) do
- turbine = value
- local s, e = string.find(turbine.name, "Turbine")
- local turName = string.sub(turbine.name, s)
- setButton(turName, changepage, xSections+2, ySections*(Xi-1), (xSections*2)-2, (ySections*Xi)-(4-Xi), string.sub(turbine.name, -1), "singleTurbine", colors.blue)
- Xi = Xi + 1
- end
- drawMario()
- draw()
- refresh = true
- while refresh do
- clickEvent()
- end
- end
- function fillHomeTable()
- mon.setTextScale(0.5)
- mon.setBackgroundColor(colors.black)
- local w, h = mon.getSize()
- local xSections = math.floor(w/3)
- local ySections = math.floor(h/4)
- resetDraw()
- clearTable()
- table.insert(lines, {xSections , 1,xSections , h, colors.gray})
- table.insert(lines, {xSections*2, 1,xSections*2 , h, colors.gray})
- table.insert(lines, {xSections , ySections-1, xSections*2 , ySections-1, colors.gray})
- table.insert(lines, {xSections, ySections*2, xSections*2 , ySections*2, colors.gray})
- table.insert(lines, {xSections , (ySections*3)+1, xSections*2 , (ySections*3)+1, colors.gray})
- setButton("All Turbines", changepage, xSections+2, ySections+1, (xSections*2)-2, (ySections*2)-2, 0, "turbines", colors.blue)
- setButton("Turbine", changepage, xSections+2, (ySections*2)+2, (xSections*2)-2, (ySections*3)-1, 0, "choiceTurbines", colors.blue)
- drawMario()
- draw()
- resetDraw()
- refresh = true
- while refresh do
- clickEvent()
- end
- refresh = false
- end
- mon.setBackgroundColor(colors.black)
- mon.clear()
- fillHomeTable()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement