Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Tylko monitor w=5, h=3 (width, height)
- API = require("buttonAPI")
- local component = require("component")
- local term = require("term")
- local event = require("event")
- local keyboard = require("keyboard")
- local sides = require("sides")
- local computer = require("computer")
- term.clear() --Czyszczenie napisow wstepnych
- local kolor = { pomaranczowy = 0xEBB329, zielony = 0x008000, czerwony = 0xFF0000, czarny = 0x000000, bialy = 0xFFFFFF, niebieski = 0x0000FF, szary = 0x808080, morski = 0x008080, zolty = 0xFFFF00, fioletowy = 0x800080, cyjan = 0x00FFFF, fuksja = 0xFF00FF, limonka = 0x00FF00, wisniowy = 0x800000, granatowy = 0x000080, oliwkowy = 0x808000, srebrny = 0xC0C0C0}
- --Zmienne urzadzen
- local screen = component.proxy(component.list("screen")())
- local gpu = component.proxy(component.list("gpu")())
- local rs = component.proxy(component.list("redstone")())
- --Pojemniki na energie
- local acell = component.proxy("cea06e0f-4403-4059-9c63-b044ba6c11ca")
- local bcell = component.proxy("5ea0c33b-49b6-463c-ae08-ec9b2ed3a5ca")
- local ccell = component.proxy("ccb99ddc-d82c-4e79-9fd1-0921004880f3")
- local dcell = component.proxy("ea95d063-e8b1-4344-b6c1-c477547ee9da")
- local ecell = component.proxy("eab4e092-6d51-4304-b1ca-648a5da03e39")
- local aredstone = component.proxy("baf998e6-968c-4089-b7ea-6e9c247ebfda")
- local bredstone = component.proxy("c7c26a9b-0f69-4fe0-a32b-de00d94467da")
- local credstone = component.proxy("bf1cdb44-d497-46fc-9ba5-80a3678868df")
- local dredstone = component.proxy("d6e88e76-bafa-44da-83ac-c6d7d45dd34b")
- local eredstone = component.proxy("47516274-8453-43a3-98b3-84371b276da9")
- function round(val, decimal)
- if (decimal) then
- return math.floor((val*10^decimal)+0.5)/(10^decimal)
- else
- return math.floor(val+0.5)
- end
- end
- function adjustUnit(value) --Funkcja do wyzszych jednostek
- if value >= 1000000000000 then
- return tostring(round(value/1000000000000, 2) .. " TRF")
- elseif value >= 1000000000 then
- return tostring(round(value/1000000000, 2) .. " GRF")
- elseif value >= 1000000 then
- return tostring(round(value/1000000, 2) .. " MRF")
- elseif value >= 1000 then
- return tostring(round(value/1000, 2) .. " kRF")
- else
- return tostring(round(value) .. " RF")
- end
- end
- function hBar(x, y, size, val, maxval) --Pasek postepu (poziomy)
- val = tonumber(val)
- maxval = tonumber(maxval)
- if val < 0 then val = 0 end
- if val > maxval then val = maxval end
- local pct = round((val/maxval)*100, 1)
- local scale = 100/size
- local fill = pct/scale
- local spos = math.floor(fill)
- for i = 1, spos do
- gpu.setBackground(kolor.czerwony) -- Kolor wypelnienia wartosci
- gpu.set(x+i, y, " ")
- gpu.setBackground(kolor.czarny)
- end
- for i = spos + 1, size do
- gpu.setBackground(kolor.szary) -- Kolor wypelnienia reszty
- gpu.set(x + i, y, " ")
- gpu.setBackground(kolor.czarny)
- end
- gpu.set(x + size + 1, y, string.rep(" ", 4 - string.len(pct)) .. string.format(pct) .. "%")
- end
- function drawScreen() --Ramka na dane
- gpu.setResolution(104, 30)
- gpu.setBackground(kolor.szary)
- x, y = gpu.getResolution()
- for i = 1, x do
- gpu.set(i, 1, " ")
- end
- for i = 1, y do
- gpu.set(1, i, " ")
- end
- for i = 1, x do
- gpu.set(i, y, " ")
- end
- for i = 1, y do
- gpu.set(x, i, " ")
- end
- for i = 1, y do
- gpu.set(math.floor(x/3), i, " ")
- end
- for i = 1,y do
- gpu.set(math.floor(x/1.5), i, " ")
- end
- for i = 1,x do
- gpu.set(i, math.floor(y/2), " ")
- end
- end
- function aredstoneOn() --Wlaczanie przesylu energii
- aredstone.setOutput(sides.bottom, 15)
- end
- function bredstoneOn()
- bredstone.setOutput(sides.bottom, 15)
- end
- function credstoneOn()
- credstone.setOutput(sides.bottom, 15)
- end
- function dredstoneOn()
- dredstone.setOutput(sides.bottom, 15)
- end
- function eredstoneOn()
- eredstone.setOutput(sides.bottom, 15)
- end
- function aredstoneOff() --Wylaczanie przesylu energii
- aredstone.setOutput(sides.bottom, 0)
- end
- function bredstoneOff()
- bredstone.setOutput(sides.bottom, 0)
- end
- function credstoneOff()
- credstone.setOutput(sides.bottom, 0)
- end
- function dredstoneOff()
- dredstone.setOutput(sides.bottom, 0)
- end
- function eredstoneOff()
- eredstone.setOutput(sides.bottom, 0)
- end
- function allredstoneOn()
- aredstone.setOutput(sides.bottom, 15)
- bredstone.setOutput(sides.bottom, 15)
- credstone.setOutput(sides.bottom, 15)
- dredstone.setOutput(sides.bottom, 15)
- eredstone.setOutput(sides.bottom, 15)
- end
- function allredstoneOff()
- aredstone.setOutput(sides.bottom, 0)
- bredstone.setOutput(sides.bottom, 0)
- credstone.setOutput(sides.bottom, 0)
- dredstone.setOutput(sides.bottom, 0)
- eredstone.setOutput(sides.bottom, 0)
- end
- function setButtons() --Funkcja do wyswietlania przyciskow
- API.setTable("aredstoneOn", aredstoneOn, 3, 11, 15, 13,"ON", {on = kolor.zielony, off = kolor.zielony})
- API.setTable("aredstoneOff", aredstoneOff, 20, 11, 32, 13,"OFF", {on = kolor.czerwony, off = kolor.czerwony})
- API.setTable("bredstoneOn", bredstoneOn, 36, 11, 49, 13,"ON", {on = kolor.zielony, off = kolor.zielony})
- API.setTable("bredstoneOff", bredstoneOff, 54, 11, 67, 13,"OFF", {on = kolor.czerwony, off = kolor.czerwony})
- API.setTable("credstoneOn", credstoneOn, 71, 11, 84, 13,"ON", {on = kolor.zielony, off = kolor.zielony})
- API.setTable("credstoneOff", credstoneOff, 89, 11, 102, 13,"OFF", {on = kolor.czerwony, off = kolor.czerwony})
- API.setTable("dredstoneOn", dredstoneOn, 3, 26, 15, 28,"ON", {on = kolor.zielony, off = kolor.zielony})
- API.setTable("dredstoneOff", dredstoneOff, 20, 26, 32, 28,"OFF", {on = kolor.czerwony, off = kolor.czerwony})
- API.setTable("eredstoneOn", eredstoneOn, 36, 26, 49, 28,"ON", {on = kolor.zielony, off = kolor.zielony})
- API.setTable("eredstoneOff", eredstoneOff, 54, 26, 67, 28,"OFF", {on = kolor.czerwony, off = kolor.czerwony})
- API.setTable("allredstoneOn", allredstoneOn, 71, 26, 84, 28,"ON", {on = kolor.zielony, off = kolor.zielony})
- API.setTable("allredstoneOff", allredstoneOff, 89, 26, 102, 28,"OFF", {on = kolor.czerwony, off = kolor.czerwony})
- end
- function drawData() --Wyświetlanie danych
- gpu.setBackground(kolor.czarny)
- local astorage = acell.getEnergyStored()
- local amstorage = acell.getMaxEnergyStored()
- local bstorage = bcell.getEnergyStored()
- local bmstorage = bcell.getMaxEnergyStored()
- local cstorage = ccell.getEnergyStored()
- local cmstorage = ccell.getMaxEnergyStored()
- local dstorage = dcell.getEnergyStored()
- local dmstorage = dcell.getMaxEnergyStored()
- local estorage = ecell.getEnergyStored()
- local emstorage = ecell.getMaxEnergyStored()
- local sumstorage = math.floor(astorage+bstorage+cstorage+dstorage+estorage)
- local summstorage = math.floor(amstorage+bmstorage+cmstorage+dmstorage+emstorage)
- --Tekst z danymi
- gpu.set(10, 2, "BANK ENERGII #1")
- gpu.set(43, 2, "BANK ENERGII #2")
- gpu.set(79, 2, "BANK ENERGII #3")
- gpu.set(10, 16, "BANK ENERGII #4")
- gpu.set(43, 16, "BANK ENERGII #5")
- gpu.set(75, 16, "WSZYSTKIE BANKI ENERGII")
- gpu.set(4, 5, "POJEMNOSC: ".. string.rep(" ", 9 - string.len(adjustUnit(astorage)))..adjustUnit(astorage))
- gpu.set(37, 5, "POJEMNOSC: ".. string.rep(" ", 9 - string.len(adjustUnit(bstorage)))..adjustUnit(bstorage))
- gpu.set(72, 5, "POJEMNOSC: ".. string.rep(" ", 9 - string.len(adjustUnit(cstorage)))..adjustUnit(cstorage))
- gpu.set(4, 19, "POJEMNOSC: ".. string.rep(" ", 9 - string.len(adjustUnit(dstorage)))..adjustUnit(dstorage))
- gpu.set(37, 19, "POJEMNOSC: ".. string.rep(" ", 9 - string.len(adjustUnit(estorage)))..adjustUnit(estorage))
- gpu.set(4, 7, "MAKS. POJEMNOSC: "..adjustUnit(amstorage))
- gpu.set(37, 7, "MAKS. POJEMNOSC: "..adjustUnit(bmstorage))
- gpu.set(72, 7, "MAKS. POJEMNOSC: "..adjustUnit(cmstorage))
- gpu.set(4, 21, "MAKS. POJEMNOSC: "..adjustUnit(dmstorage))
- gpu.set(37, 21, "MAKS. POJEMNOSC: "..adjustUnit(emstorage))
- gpu.set(72, 19, "POJEMNOSC: ".. string.rep(" ", 9 - string.len(sumstorage))..adjustUnit(sumstorage))
- gpu.set(72, 21, "MAKS. POJEMNOSC: "..adjustUnit(summstorage))
- hBar(4, 9, 20, astorage, amstorage)
- hBar(37, 9, 20, bstorage, bmstorage)
- hBar(72, 9, 20, cstorage, cmstorage)
- hBar(4, 23, 20, dstorage, dmstorage)
- hBar(37, 23, 20, estorage, emstorage)
- hBar(72, 23, 20, sumstorage, summstorage)
- end
- while true do --Petla wyswietlajaca
- drawScreen()
- setButtons()
- API.screen()
- event.listen("touch", API.checkxy)
- drawData()
- local event, address, arg1, arg2, arg3 = event.pull(1) --Wyjscie z programu za pomoca "Q"
- if type(address) == "string" and component.isPrimary(address) then
- if event == "key_down" and arg2 == keyboard.keys.q then
- term.clear()
- os.exit()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement