SHOW:
|
|
- or go back to the newest paste.
| 1 | - | --#requires |
| 1 | + | |
| 2 | - | |
| 2 | + | |
| 3 | - | local fs = require("filesystem")
|
| 3 | + | local computer = require("computer")
|
| 4 | local math = require("math")
| |
| 5 | - | local serialization = require("serialization")
|
| 5 | + | |
| 6 | local string = require("string")
| |
| 7 | local unicode = require("unicode")
| |
| 8 | local os = require("os")
| |
| 9 | - | local colors = require("colors")
|
| 9 | + | local fs = require('filesystem')
|
| 10 | - | |
| 10 | + | |
| 11 | - | --#variables |
| 11 | + | |
| 12 | gpu.setResolution(100,50) | |
| 13 | - | local config = {}
|
| 13 | + | br = component.getPrimary("br_reactor")
|
| 14 | - | local reactor = nil |
| 14 | + | |
| 15 | - | local running = true |
| 15 | + | local boucle2 = 0 |
| 16 | - | local screen = "main" |
| 16 | + | local a = 80 |
| 17 | - | --#install |
| 17 | + | local b = 1 |
| 18 | - | |
| 18 | + | local lvl |
| 19 | - | function install() |
| 19 | + | local val = 0 |
| 20 | - | screen = "install" |
| 20 | + | local rod = 1 |
| 21 | - | term.clear() |
| 21 | + | local rodmax = br.getNumberOfControlRods() |
| 22 | - | print("Requirements:")
|
| 22 | + | local maxcon = rodmax*100 |
| 23 | - | print("Tier 2 screen")
|
| 23 | + | local termset = 0 |
| 24 | - | print("Tier 2 graphics card")
|
| 24 | + | local stco=false |
| 25 | - | print("A BigReactor connected by cable from computer port to computer")
|
| 25 | + | local kp=1 |
| 26 | - | print("A keyboard for install only, optional for practical use")
|
| 26 | + | local ki=0.1 |
| 27 | - | print() |
| 27 | + | local int=0 |
| 28 | - | print("Are all requirements met? (y/n)")
|
| 28 | + | |
| 29 | - | --21,49 |
| 29 | + | local function claim(x,a,b) |
| 30 | - | local result = false |
| 30 | + | if x<a then |
| 31 | - | while not result do |
| 31 | + | return a |
| 32 | - | local name, adress, char, code, player = event.pull("key_down")
|
| 32 | + | |
| 33 | - | if code == 21 then |
| 33 | + | if x>b then |
| 34 | - | result = true |
| 34 | + | return b |
| 35 | - | elseif code == 49 then |
| 35 | + | |
| 36 | - | os.exit() |
| 36 | + | return x |
| 37 | - | else |
| 37 | + | |
| 38 | - | print("Invalid response")
|
| 38 | + | |
| 39 | - | end |
| 39 | + | local function rodcon(num,rod) |
| 40 | local x= (num-num%100)/100 | |
| 41 | - | --set resolution and continue |
| 41 | + | local y=num%100 |
| 42 | - | gpu.setResolution(80,25) |
| 42 | + | if rod<x then |
| 43 | - | gpu.setForeground(0x000000) |
| 43 | + | return 100 |
| 44 | - | term.clear() |
| 44 | + | elseif rod>x then |
| 45 | - | gpu.setBackground(0x0000BB) |
| 45 | + | return 0 |
| 46 | - | term.clear() |
| 46 | + | elseif rod==x then |
| 47 | - | gpu.setBackground(0x808080) |
| 47 | + | return y |
| 48 | - | gpu.fill(20,9,40,6," ") |
| 48 | + | |
| 49 | - | term.setCursor(20,9) |
| 49 | + | |
| 50 | - | print("Thank you for downloading")
|
| 50 | + | |
| 51 | - | term.setCursor(20,10) |
| 51 | + | local function rodcontrol() |
| 52 | - | print("OpenReactor")
|
| 52 | + | local err = termset-br.getCasingTemperature() |
| 53 | - | term.setCursor(20,11) |
| 53 | + | local pid_p = err*kp |
| 54 | - | print("press ok to continue")
|
| 54 | + | local pid_i = int*ki |
| 55 | - | term.setCursor(20,12) |
| 55 | + | local pid = claim((pid_p+pid_i),0,maxcon) |
| 56 | - | print("press cancel to cancel the installation")
|
| 56 | + | int=claim((int+err),0,maxcon/ki) |
| 57 | - | gpu.setBackground(0x008000) |
| 57 | + | pid=math.floor(pid) |
| 58 | - | gpu.fill(20,14,20,1," ") |
| 58 | + | pid= ( (pid - 0) / (maxcon - 0) ) * (0 - maxcon) + maxcon |
| 59 | - | term.setCursor(29,14) |
| 59 | + | for i=1,maxcon,1 do |
| 60 | - | print("ok")
|
| 60 | + | br.setControlRodLevel(i,rodcon(pid,i)) |
| 61 | - | gpu.setBackground(0x800000) |
| 61 | + | |
| 62 | - | gpu.fill(40,14,20,1," ") |
| 62 | + | gpu.set(22,6, string.format("%10d", pid))
|
| 63 | - | term.setCursor(48,14) |
| 63 | + | gpu.set(22,11,string.format("%10d",int))
|
| 64 | - | print("cancel")
|
| 64 | + | |
| 65 | - | local event_running = true |
| 65 | + | |
| 66 | - | while event_running do |
| 66 | + | local function setColor(bg,fg) |
| 67 | - | local name, address, x, y, button, player = event.pull("touch")
|
| 67 | + | gpu.setBackground(bg) |
| 68 | - | if x >= 20 and x <= 39 and y == 14 then |
| 68 | + | gpu.setForeground(fg) |
| 69 | - | print("ok")
|
| 69 | + | |
| 70 | - | event_running = false |
| 70 | + | |
| 71 | - | elseif x>=40 and x <= 59 and y == 14 then |
| 71 | + | local function loadbar(x,y,width,cur,text,bg,fg) |
| 72 | - | os.exit() |
| 72 | + | local raw = " " .. text ..string.rep(" ", width - unicode.len(text) - 2) .. " "
|
| 73 | - | end |
| 73 | + | local oldbg = gpu.setBackground(bg) |
| 74 | local oldfg = gpu.setForeground(fg) | |
| 75 | - | install_pick_reactor() |
| 75 | + | gpu.set(x,y,unicode.sub(raw,1,cur)) |
| 76 | - | set_color_scheme() |
| 76 | + | gpu.setBackground(oldbg) |
| 77 | - | save_config() |
| 77 | + | gpu.setForeground(oldfg) |
| 78 | - | main() |
| 78 | + | gpu.set(x+cur,y,unicode.sub(raw,cur+1,width)) |
| 79 | end | |
| 80 | - | |
| 80 | + | |
| 81 | - | --#main |
| 81 | + | local function hexa(dec) |
| 82 | - | |
| 82 | + | local B,K,OUT,I,D = 16,"0123456789ABCDEF","",0 |
| 83 | - | function main() |
| 83 | + | if dec <= 0 then |
| 84 | - | screen = "main" |
| 84 | + | OUT = "00" |
| 85 | - | gpu.setResolution(80,25) |
| 85 | + | elseif dec > 0 and dec < 16 then |
| 86 | - | read_config() |
| 86 | + | D = dec + 1 |
| 87 | - | reactor = component.proxy(config.reactor) |
| 87 | + | OUT = "0"..string.sub(K,D,D) |
| 88 | - | event.listen("touch",listen)
|
| 88 | + | elseif dec > 16 and dec < 256 then |
| 89 | - | while running do |
| 89 | + | V1 = math.modf(dec/B)+1 |
| 90 | - | if config.auto_power.enabled == true then |
| 90 | + | V2 = dec-V1*16 |
| 91 | - | if reactor.getEnergyStored()/10^5<config.auto_power.start_percent then |
| 91 | + | OUT = string.sub(K,V1,V1)..string.sub(K,V2,V2) |
| 92 | - | reactor.setActive(true) |
| 92 | + | elseif dec >= 255 then |
| 93 | - | elseif reactor.getEnergyStored()/10^5>config.auto_power.stop_percent then |
| 93 | + | OUT = "FF" |
| 94 | - | reactor.setActive(false) |
| 94 | + | |
| 95 | return OUT | |
| 96 | - | end |
| 96 | + | |
| 97 | - | gpu.setBackground(config.color_scheme.background) |
| 97 | + | |
| 98 | - | term.clear() |
| 98 | + | local function round(num, dec) |
| 99 | - | draw_menubar() |
| 99 | + | local mult = 10 ^ (dec or 0) |
| 100 | - | if screen == "main" then |
| 100 | + | return math.floor(num * mult + 0.5) / mult |
| 101 | - | draw_main() |
| 101 | + | |
| 102 | - | elseif screen == "config" then |
| 102 | + | |
| 103 | - | draw_config() |
| 103 | + | local function bargraph(x,y,length,am,cap,na,col,colpol) |
| 104 | - | end |
| 104 | + | local amount = am |
| 105 | - | os.sleep(.05) |
| 105 | + | local capacity = cap |
| 106 | local pct = amount / capacity | |
| 107 | local cur = math.floor(pct * length) | |
| 108 | - | |
| 108 | + | local color = col |
| 109 | - | --#draw_menubar |
| 109 | + | local color2 = colpol |
| 110 | - | |
| 110 | + | local name = na |
| 111 | - | function draw_menubar() |
| 111 | + | local textfrac = string.format("%s / %s", amount, capacity)
|
| 112 | - | term.setCursor(1,1) |
| 112 | + | local textpct = string.format("%.02f%%", pct*100)
|
| 113 | - | gpu.setBackground(config.color_scheme.menubar.background) |
| 113 | + | local text = textfrac .. string.rep(" ", length - string.len(textfrac) - string.len(textpct) - 6) .. " " .. textpct .. " "
|
| 114 | - | gpu.setForeground(config.color_scheme.menubar.foreground) |
| 114 | + | local text1 = " Уровень заполнения : ("..name..")"
|
| 115 | - | term.clearLine() |
| 115 | + | loadbar(x,y,length,cur,text1,color,color2) |
| 116 | - | term.setCursor(1,1) |
| 116 | + | loadbar(x,y+1,length,cur,text,color,color2) |
| 117 | - | term.write("Status: ")
|
| 117 | + | |
| 118 | - | if reactor.getActive() then |
| 118 | + | |
| 119 | - | gpu.setForeground(config.color_scheme.success) |
| 119 | + | function drawbars() |
| 120 | - | term.write("Online ")
|
| 120 | + | amFuel = br.getFuelAmount() |
| 121 | capFuel = br.getFuelAmountMax() | |
| 122 | - | gpu.setForeground(config.color_scheme.error) |
| 122 | + | naFuel = "ТОПЛИВО - Yellorium" |
| 123 | - | term.write("Offline ")
|
| 123 | + | colFuel = 0xFFFF00 |
| 124 | colpolFuel = 0x0000FF | |
| 125 | - | if config.auto_power.enabled then |
| 125 | + | bargraph(2,22,98,amFuel,capFuel,naFuel,colFuel,colpolFuel) |
| 126 | - | gpu.setForeground(config.color_scheme.menubar.foreground) |
| 126 | + | amWaste = br.getWasteAmount() |
| 127 | - | term.write("(")
|
| 127 | + | capWaste = 64000 |
| 128 | - | gpu.setForeground(config.color_scheme.info) |
| 128 | + | naWaste = "ОТХОДЫ - Cyanite" |
| 129 | - | term.write("Auto")
|
| 129 | + | colWaste = 0x00FFFF |
| 130 | - | gpu.setForeground(config.color_scheme.menubar.foreground) |
| 130 | + | colpolWaste = 0xFF00FF |
| 131 | - | term.write(") ")
|
| 131 | + | bargraph(2,25,98,amWaste,capWaste,naWaste,colWaste,colpolWaste) |
| 132 | amSteam = br.getHotFluidAmount() | |
| 133 | - | gpu.setForeground(config.color_scheme.menubar.foreground) |
| 133 | + | capSteam = br.getHotFluidAmountMax() |
| 134 | - | term.write(" Fuel Temperature: ")
|
| 134 | + | naSteam = "ПАР" |
| 135 | - | gpu.setForeground(config.color_scheme.info) |
| 135 | + | colSteam = 0x8F8F8F |
| 136 | - | term.write(round(reactor.getFuelTemperature()).."C ") |
| 136 | + | colpolSteam = 0xFFFF00 |
| 137 | - | gpu.setForeground(config.color_scheme.menubar.foreground) |
| 137 | + | bargraph(2,28,98,amSteam,capSteam,naSteam,colSteam,colpolSteam) |
| 138 | - | term.write(" Casing Temperature: ")
|
| 138 | + | amWater = br.getCoolantAmount() |
| 139 | - | gpu.setForeground(config.color_scheme.info) |
| 139 | + | capWater = br.getCoolantAmountMax() |
| 140 | - | term.write(round(reactor.getCasingTemperature()).."C ") |
| 140 | + | naWater = "ВОДА" |
| 141 | - | term.setCursor(74,1) |
| 141 | + | colWater = 0x71b6cb |
| 142 | - | gpu.setForeground(config.color_scheme.menubar.foreground) |
| 142 | + | colpolWater = 0x0000FF |
| 143 | - | term.write("[")
|
| 143 | + | bargraph(2,31,98,amWater,capWater,naWater,colWater,colpolWater) |
| 144 | - | gpu.setForeground(config.color_scheme.error) |
| 144 | + | consot = br.getFuelConsumedLastTick() |
| 145 | - | term.write("Exit")
|
| 145 | + | consos = consot * 20 |
| 146 | - | gpu.setForeground(config.color_scheme.menubar.foreground) |
| 146 | + | consoh = consos * 3.6 |
| 147 | - | term.write("]")
|
| 147 | + | consoj = consoh * 24 |
| 148 | gpu.set(2,35,string.format("% 1.03f",consot).."mb/t =>"..string.format("% 1.02f",consos).."mb/s =>"..string.format("% 3.02f",consoh).."b/h =>"..string.format("% 5.02f",consoj).."b/d")
| |
| 149 | - | |
| 149 | + | Tcore = br.getCasingTemperature() |
| 150 | - | --#save_config |
| 150 | + | Tfuel = br.getFuelTemperature() |
| 151 | - | |
| 151 | + | Reactivity = br.getFuelReactivity() |
| 152 | - | function save_config() |
| 152 | + | Prod = br.getHotFluidProducedLastTick() |
| 153 | - | local file = io.open("/etc/open-reactors.cfg","w")
|
| 153 | + | gpu.set(35,38,string.format("% 4.2f",Tcore))
|
| 154 | - | file:write(serialization.serialize(config,false)) |
| 154 | + | gpu.set(35,40,string.format("% 4.2f",Tfuel))
|
| 155 | - | file:close() |
| 155 | + | gpu.set(35,42,string.format("% 4.2f",Reactivity))
|
| 156 | gpu.set(35,44,string.format("% 4.2f",Prod))
| |
| 157 | - | |
| 157 | + | if stco then |
| 158 | - | --#read_config |
| 158 | + | rodcontrol() |
| 159 | - | |
| 159 | + | |
| 160 | - | function read_config() |
| 160 | + | |
| 161 | - | local file = io.open("/etc/open-reactors.cfg","r")
|
| 161 | + | |
| 162 | - | local c = serialization.unserialize(file:read(fs.size("/etc/open-reactors.cfg")))
|
| 162 | + | local function waste() |
| 163 | - | file:close() |
| 163 | + | local waste = br.getWasteAmount() |
| 164 | - | for k,v in pairs(c) do |
| 164 | + | if waste > 48000 then |
| 165 | - | config[k] = v |
| 165 | + | br.doEjectWaste() |
| 166 | end | |
| 167 | end | |
| 168 | - | |
| 168 | + | |
| 169 | - | --#set_color_scheme |
| 169 | + | local function marche(x,y) |
| 170 | - | |
| 170 | + | gpu.set(x,y," ") |
| 171 | - | function set_color_scheme() |
| 171 | + | gpu.set(x,y+1," ВКЛЮЧИТЬ ") |
| 172 | - | config.color_scheme = {}
|
| 172 | + | gpu.set(x,y+2," ") |
| 173 | - | config.color_scheme.background = 0x0000BB |
| 173 | + | |
| 174 | - | config.color_scheme.button = 0x606060 |
| 174 | + | |
| 175 | - | config.color_scheme.button_disabled = 0xC0C0C0 |
| 175 | + | local function arret(x,y) |
| 176 | - | config.color_scheme.foreground = 0x000000 |
| 176 | + | gpu.set(x,y," ") |
| 177 | - | config.color_scheme.progressBar = {}
|
| 177 | + | gpu.set(x,y+1," ВЫКЛЮЧИТЬ ") |
| 178 | - | config.color_scheme.progressBar.background = 0x000000 |
| 178 | + | gpu.set(x,y+2," ") |
| 179 | - | config.color_scheme.progressBar.foreground = 0xFFFFFF |
| 179 | + | |
| 180 | - | config.color_scheme.menubar={}
|
| 180 | + | |
| 181 | - | config.color_scheme.menubar.background = 0x000000 |
| 181 | + | local function start() |
| 182 | - | config.color_scheme.menubar.foreground = 0xFFFFFF |
| 182 | + | local ON = br.getActive() |
| 183 | - | config.color_scheme.success = 0x008000 |
| 183 | + | if ON == true then |
| 184 | - | config.color_scheme.error = 0x800000 |
| 184 | + | setColor(0x00FF00,0x0) |
| 185 | - | config.color_scheme.info = 0x808000 |
| 185 | + | marche(60,11) |
| 186 | - | config.auto_power = {}
|
| 186 | + | setColor(0x0,0xFF0000) |
| 187 | - | config.auto_power.enabled = false |
| 187 | + | arret(60,15) |
| 188 | - | config.auto_power.start_percent = 15 |
| 188 | + | setColor(0x0,0xFFFFFF) |
| 189 | - | config.auto_power.stop_percent = 80 |
| 189 | + | elseif ON == false then |
| 190 | setColor(0x0,0x00FF00) | |
| 191 | - | |
| 191 | + | marche(60,11) |
| 192 | - | --#install_pick_reactor |
| 192 | + | setColor(0xFF0000,0xFFFFFF) |
| 193 | - | |
| 193 | + | arret(60,15) |
| 194 | - | function install_pick_reactor() |
| 194 | + | setColor(0x0,0xFFFFFF) |
| 195 | - | gpu.setBackground(0x0000BB) |
| 195 | + | |
| 196 | - | term.clear() |
| 196 | + | |
| 197 | - | gpu.setBackground(0x808080) |
| 197 | + | |
| 198 | - | local reactors = component.list("br_reactor")
|
| 198 | + | local function scon() |
| 199 | - | local len = 3 |
| 199 | + | if stco == true then |
| 200 | - | for k,v in pairs(reactors) do |
| 200 | + | setColor(0x00FF00,0x0) |
| 201 | - | if len<#k then |
| 201 | + | marche(5,46) |
| 202 | - | len = #k |
| 202 | + | setColor(0x0,0xFF0000) |
| 203 | - | end |
| 203 | + | arret(27,46) |
| 204 | setColor(0x0,0xFFFFFF) | |
| 205 | - | local s_x = 40-len/2 |
| 205 | + | elseif stco == false then |
| 206 | - | local s_y = 13-round(countTable(reactors)/2) |
| 206 | + | setColor(0x0,0x00FF00) |
| 207 | - | gpu.fill(s_x-1,s_y-2,len+2,countTable(reactors)+3," ") |
| 207 | + | marche(5,46) |
| 208 | - | term.setCursor(s_x+9,s_y-2) |
| 208 | + | setColor(0xFF0000,0xFFFFFF) |
| 209 | - | print("select a reactor")
|
| 209 | + | arret(27,46) |
| 210 | - | local i = s_y |
| 210 | + | setColor(0x0,0xFFFFFF) |
| 211 | - | for k,v in pairs(reactors) do |
| 211 | + | |
| 212 | - | term.setCursor(s_x,i) |
| 212 | + | |
| 213 | - | print(k) |
| 213 | + | |
| 214 | - | i=i+1 |
| 214 | + | term.clear() |
| 215 | gpu.set(1,1,"╔══════════════════════════════════════════════════════════════════════════════════════════════════╗") | |
| 216 | - | local event_running = true |
| 216 | + | gpu.set(1,2,"║ ║") |
| 217 | - | while event_running do |
| 217 | + | gpu.set(1,3,"║ ███████████████████████████████████████████████ ███████████████████ ║") |
| 218 | - | local name, address, x, y, button, player = event.pull("touch")
|
| 218 | + | gpu.set(1,4,"║ ██ установка температуры ██ █ Ручной контроль █ ║") |
| 219 | - | print(y-s_y) |
| 219 | + | gpu.set(1,5,"║ ██ ██ █ всех █ ║") |
| 220 | - | if x>=s_x and x <= s_x+len and y>=s_y and y<= s_y+countTable(reactors) then |
| 220 | + | gpu.set(1,6,"║ ██ ██ █ стержней █ ║") |
| 221 | - | event_running = false |
| 221 | + | gpu.set(1,7,"║ ██ +100 -100 ██ █ █ ║") |
| 222 | - | local i = y-s_y |
| 222 | + | gpu.set(1,8,"║ ██ +10 -10 ██ ███████████████████ ║") |
| 223 | - | for k,v in pairs(reactors) do |
| 223 | + | gpu.set(1,9,"║ ██ +1 -1 ██ ║") |
| 224 | - | if i == 0 then |
| 224 | + | gpu.set(1,10,"║ ██ ██ ║") |
| 225 | - | config.reactor = k |
| 225 | + | gpu.set(1,11,"║ ██ ██ █████████████ ║") |
| 226 | - | end |
| 226 | + | gpu.set(1,12,"║ ██ ██ █ВКЛЮЧИТЬ ██ ║") |
| 227 | - | i=i-1 |
| 227 | + | gpu.set(1,13,"║ ██ ██ █████████████ ║") |
| 228 | gpu.set(1,14,"║ ██ ██ ║") | |
| 229 | - | end |
| 229 | + | gpu.set(1,15,"║ ██ ██ █████████████ ║") |
| 230 | gpu.set(1,16,"║ ██ ██ █ВЫКЛЮЧИТЬ ██ ║") | |
| 231 | gpu.set(1,17,"║ ███████████████████████████████████████████████ █████████████ ║") | |
| 232 | - | |
| 232 | + | gpu.set(1,18,"║ ║") |
| 233 | - | --#draw_main |
| 233 | + | gpu.set(1,19,"╠══════════════════════════════════════════════════════════════════════════════════════════════════╣") |
| 234 | - | |
| 234 | + | gpu.set(1,20,"║ ║") |
| 235 | - | function draw_main() |
| 235 | + | gpu.set(1,21,"╠══════════════════════════════════════════════════════════════════════════════════════════════════╣") |
| 236 | - | if config.auto_power.enabled then |
| 236 | + | gpu.set(1,22,"║ ║") |
| 237 | - | gpu.setBackground(config.color_scheme.button) |
| 237 | + | gpu.set(1,23,"║ ║") |
| 238 | - | gpu.setForeground(0xFFFFFF) |
| 238 | + | gpu.set(1,24,"╠══════════════════════════════════════════════════════════════════════════════════════════════════╣") |
| 239 | - | gpu.fill(1,2,69,3," ") |
| 239 | + | gpu.set(1,25,"║ ║") |
| 240 | - | term.setCursor(25,3) |
| 240 | + | gpu.set(1,26,"║ ║") |
| 241 | - | term.write("Disable Auto-Power")
|
| 241 | + | gpu.set(1,27,"╠══════════════════════════════════════════════════════════════════════════════════════════════════╣") |
| 242 | - | gpu.setBackground(0x153F3F) |
| 242 | + | gpu.set(1,28,"║ ║") |
| 243 | - | gpu.fill(70,2,11,3," ") |
| 243 | + | gpu.set(1,29,"║ ║") |
| 244 | - | term.setCursor(71,3) |
| 244 | + | gpu.set(1,30,"╠══════════════════════════════════════════════════════════════════════════════════════════════════╣") |
| 245 | - | term.write("Configure")
|
| 245 | + | gpu.set(1,31,"║ ║") |
| 246 | gpu.set(1,32,"║ ║") | |
| 247 | - | gpu.setBackground(config.color_scheme.button) |
| 247 | + | gpu.set(1,33,"╠════════════════════════════════════════════════╦═════════════════════════════════════════════════╣") |
| 248 | - | gpu.setForeground(0xFFFFFF) |
| 248 | + | gpu.set(1,34,"║ РАСХОД ТОПЛИВА ║ MiliBukket/second => mb/s Bukket/Hour => b/h ║") |
| 249 | - | gpu.fill(1,2,69,3," ") |
| 249 | + | gpu.set(1,35,"║ ║ MiliBukket/tick => mb/t Bukket/Day => b/d ║") |
| 250 | - | term.setCursor(25,3) |
| 250 | + | gpu.set(1,36,"╠════════════════════════════════════════════════╩══════════════════════╦══════════════════════════╣") |
| 251 | - | term.write("Enable Auto-Power")
|
| 251 | + | gpu.set(1,37,"║ ║ ║") |
| 252 | - | gpu.setBackground(0x153F3F) |
| 252 | + | gpu.set(1,38,"║ ТЕМПЕРАТУРА РЕАКТОРА : °C ║ ║") |
| 253 | - | gpu.fill(70,2,11,3," ") |
| 253 | + | gpu.set(1,39,"║ ║ ██████████████████ ║") |
| 254 | - | term.setCursor(73,3) |
| 254 | + | gpu.set(1,40,"║ ТЕМПЕРАТУРА ТОПЛИВА : °C ║ ██ ИЗВЛЕЧЬ ██ ║") |
| 255 | - | term.write("Power")
|
| 255 | + | gpu.set(1,41,"║ ║ ██ CYANITE ██ ║") |
| 256 | gpu.set(1,42,"║ РАДИОАКТИВНОСТЬ ТОПЛИВА : % ║ ██████████████████ ║") | |
| 257 | - | gpu.setForeground(0xFFFFFF) |
| 257 | + | gpu.set(1,43,"║ ║ ║") |
| 258 | - | gpu.setBackground(config.color_scheme.button) |
| 258 | + | gpu.set(1,44,"║ ПЕРЕРАБОТКА ПАРА : mb/t ║ ██████████████████ ║") |
| 259 | - | gpu.fill(1,8,13,3," ") |
| 259 | + | gpu.set(1,45,"╠═══════════════════════════════════════════════════════════════════════╣ ██ ИЗВЛЕЧЬ ██ ║") |
| 260 | - | gpu.fill(1,14,13,3," ") |
| 260 | + | gpu.set(1,46,"║ █████████████ █████████████ АВТО ТКМПЕРАТУРА ║ ██ YELLORIUM ██ ║") |
| 261 | - | gpu.fill(1,20,13,3," ") |
| 261 | + | gpu.set(1,47,"║ █ВКЛЮЧИТЬ ██ █ВЫКЛЮЧИТЬ ██ ║ ██████████████████ ║") |
| 262 | - | term.setCursor(1,9) |
| 262 | + | gpu.set(1,48,"║ █████████████ █████████████ ║ ║") |
| 263 | - | term.write("Energy Buffer")
|
| 263 | + | gpu.set(1,49,"║ ║ ║") |
| 264 | - | term.setCursor(2,15) |
| 264 | + | gpu.set(1,50,"╚═══════════════════════════════════════════════════════════════════════╩══════════════════════════╝") |
| 265 | - | term.write("Fuel Level")
|
| 265 | + | |
| 266 | - | term.setCursor(2,21) |
| 266 | + | start() |
| 267 | - | term.write("Reactivity")
|
| 267 | + | scon() |
| 268 | - | drawProgressBar(14,8,65,3,reactor.getEnergyStored()/10^7) |
| 268 | + | |
| 269 | - | drawProgressBar(14,14,65,3,reactor.getFuelAmount()/reactor.getFuelAmountMax()) |
| 269 | + | local function onTouch(event,adress,x,y,clic,pseudo) |
| 270 | - | drawProgressBar(14,20,65,3,reactor.getFuelReactivity()/10^2) |
| 270 | + | local tclic |
| 271 | - | if config.auto_power.enabled then |
| 271 | + | if clic == 0 then |
| 272 | - | gpu.setBackground(config.color_scheme.success) |
| 272 | + | tclic = "НАЖИТО ЛКМ" |
| 273 | - | gpu.fill(14+65*config.auto_power.start_percent/10^2,8,1,3," ") |
| 273 | + | elseif clic == 1 then |
| 274 | - | gpu.setBackground(config.color_scheme.error) |
| 274 | + | tclic = "НАЖИТО ПКМ" |
| 275 | - | gpu.fill(14+65*config.auto_power.stop_percent/10^2,8,1,3," ") |
| 275 | + | |
| 276 | tclic = "НАЖИТО НЕИЗВЕСТНО" | |
| 277 | end | |
| 278 | - | |
| 278 | + | gpu.set(6,20," "..tclic.." . ИГРОКОМ: "..pseudo.." ( X : "..string.format("% 3s",x).." Y: "..string.format("% 3s",y)..")")
|
| 279 | - | --#draw_config |
| 279 | + | |
| 280 | - | |
| 280 | + | if x==1 and y==1 then |
| 281 | - | function draw_config() |
| 281 | + | computer.pushSignal("quit")
|
| 282 | - | gpu.setBackground(config.color_scheme.button) |
| 282 | + | term.setCursor(1,1) |
| 283 | - | gpu.fill(5,9,71,9," ") |
| 283 | + | return false |
| 284 | - | gpu.setForeground(0xFFFFFF) |
| 284 | + | elseif x > 77 and x < 96 and y > 38 and y < 43 then |
| 285 | - | term.setCursor(36,9) |
| 285 | + | br.doEjectWaste() |
| 286 | - | term.write("Configure")
|
| 286 | + | elseif x > 77 and x < 96 and y > 43 and y < 48 then |
| 287 | - | term.setCursor(35,10) |
| 287 | + | br.doEjectFuel() |
| 288 | - | term.write("Start: "..config.auto_power.start_percent.."%")
|
| 288 | + | elseif x > 58 and x < 73 and y > 10 and y < 14 then |
| 289 | - | term.setCursor(36,11) |
| 289 | + | br.setActive(true) |
| 290 | - | term.write("Stop: "..config.auto_power.stop_percent.."%")
|
| 290 | + | start() |
| 291 | - | drawProgressBar(8,12,65,3,reactor.getEnergyStored()/10^7) |
| 291 | + | elseif x >= 5 and x <= 17 and y >= 46 and y <= 48 then |
| 292 | - | gpu.setBackground(config.color_scheme.success) |
| 292 | + | stco=true |
| 293 | - | gpu.fill(8+65*config.auto_power.start_percent/100,12,1,3," ") |
| 293 | + | scon() |
| 294 | - | gpu.setBackground(config.color_scheme.error) |
| 294 | + | elseif x >= 27 and x <= 39 and y >= 46 and y <= 48 then |
| 295 | - | gpu.fill(8+65*config.auto_power.stop_percent/100,12,1,3," ") |
| 295 | + | stco=false |
| 296 | - | gpu.setBackground(config.color_scheme.button) |
| 296 | + | scon() |
| 297 | - | gpu.setForeground(0xFFFFFF) |
| 297 | + | elseif x >= 58 and x <= 73 and y >= 14 and y <= 18 then |
| 298 | - | term.setCursor(37+#("Start: "..config.auto_power.start_percent.."%"),10)
|
| 298 | + | br.setActive(false) |
| 299 | - | term.write("[")
|
| 299 | + | start() |
| 300 | - | gpu.setForeground(config.color_scheme.error) |
| 300 | + | gpu.set(22,5, string.format("%10d", termset))
|
| 301 | - | term.write("-")
|
| 301 | + | elseif x >= 9 and x <= 13 and y == 9 then |
| 302 | - | gpu.setForeground(0xFFFFFF) |
| 302 | + | if termset >= 2999 then |
| 303 | - | term.write("] [")
|
| 303 | + | termset = 3000 |
| 304 | - | gpu.setForeground(config.color_scheme.success) |
| 304 | + | else |
| 305 | - | term.write("+")
|
| 305 | + | termset = termset + 1 |
| 306 | - | gpu.setForeground(0xFFFFFF) |
| 306 | + | |
| 307 | - | term.write("]")
|
| 307 | + | gpu.set(22,5, string.format("%10d", termset))
|
| 308 | - | term.setCursor(38+#("Stop: "..config.auto_power.stop_percent.."#"),11)
|
| 308 | + | elseif x >= 9 and x <= 13 and y == 8 then |
| 309 | - | term.write("[")
|
| 309 | + | if termset >= 2990 then |
| 310 | - | gpu.setForeground(config.color_scheme.error) |
| 310 | + | termset = 3000 |
| 311 | - | term.write("-")
|
| 311 | + | else |
| 312 | - | gpu.setForeground(0xFFFFFF) |
| 312 | + | termset = termset + 10 |
| 313 | - | term.write("] [")
|
| 313 | + | |
| 314 | - | gpu.setForeground(config.color_scheme.success) |
| 314 | + | gpu.set(22,5, string.format("%10d", termset))
|
| 315 | - | term.write("+")
|
| 315 | + | elseif x >=9 and x <= 13 and y == 7 then |
| 316 | - | gpu.setForeground(0xFFFFFF) |
| 316 | + | if termset >= 2900 then |
| 317 | - | term.write("]")
|
| 317 | + | termset = 3000 |
| 318 | - | term.setCursor(5,9) |
| 318 | + | else |
| 319 | - | term.write("[")
|
| 319 | + | termset = termset + 100 |
| 320 | - | gpu.setForeground(config.color_scheme.info) |
| 320 | + | |
| 321 | - | term.write("back")
|
| 321 | + | gpu.set(22,5, string.format("%10d", termset))
|
| 322 | - | gpu.setForeground(0xFFFFFF) |
| 322 | + | elseif x >= 38 and x <= 43 and y == 9 then |
| 323 | - | term.write("]")
|
| 323 | + | if termset <= 1 then |
| 324 | termset = 0 | |
| 325 | - | |
| 325 | + | else |
| 326 | - | --#drawProgressBar |
| 326 | + | termset = termset - 1 |
| 327 | - | |
| 327 | + | |
| 328 | - | function drawProgressBar(x,y,w,h,percent) |
| 328 | + | gpu.set(22,5, string.format("%10d", termset))
|
| 329 | - | gpu.setBackground(config.color_scheme.progressBar.background) |
| 329 | + | elseif x >= 38 and x <= 43 and y == 8 then |
| 330 | - | gpu.fill(x,y,w,h," ") |
| 330 | + | if termset <= 10 then |
| 331 | - | gpu.setBackground(config.color_scheme.progressBar.foreground) |
| 331 | + | termset = 0 |
| 332 | - | gpu.fill(x,y,w*percent,h," ") |
| 332 | + | else |
| 333 | termset = termset - 10 | |
| 334 | - | |
| 334 | + | |
| 335 | - | --#listen |
| 335 | + | gpu.set(22,5, string.format("%10d", termset))
|
| 336 | - | |
| 336 | + | elseif x >= 38 and x <= 43 and y == 7 then |
| 337 | - | function listen(name,address,x,y,button,player) |
| 337 | + | if termset <= 100 then |
| 338 | - | if x >= 74 and x <= 80 and y == 1 then |
| 338 | + | termset = 0 |
| 339 | - | running = false |
| 339 | + | else |
| 340 | termset = termset - 100 | |
| 341 | - | if screen == "main" then |
| 341 | + | end |
| 342 | - | if x >= 70 and y >=2 and x <= 80 and y <= 4 and config.auto_power.enabled ~= true then |
| 342 | + | gpu.set(22,5, string.format("%10d", termset))
|
| 343 | - | reactor.setActive(not reactor.getActive()) |
| 343 | + | |
| 344 | - | elseif x >= 1 and y >=2 and x <= 69 and y <= 4 then |
| 344 | + | |
| 345 | - | config.auto_power.enabled = not config.auto_power.enabled |
| 345 | + | |
| 346 | - | save_config() |
| 346 | + | local function onTimer(_,timer) |
| 347 | - | elseif x >= 70 and y >= 2 and x <= 80 and y <= 4 and config.auto_power.enabled then |
| 347 | + | waste() |
| 348 | - | screen = "config" |
| 348 | + | drawbars() |
| 349 | - | end |
| 349 | + | return true |
| 350 | - | elseif screen=="config" then |
| 350 | + | |
| 351 | - | if x>= 5 and x <= 10 and y == 9 then |
| 351 | + | |
| 352 | - | screen="main" |
| 352 | + | event.listen("touch",onTouch)
|
| 353 | - | elseif x >= 37 + #("Start: "..config.auto_power.start_percent.."%") and x <= 40+#("Start: "..config.auto_power.start_percent.."%") and y == 10 and config.auto_power.start_percent ~= 0 then
|
| 353 | + | local timer = event.timer(0,onTimer,math.huge) |
| 354 | - | config.auto_power.start_percent = config.auto_power.start_percent-1 |
| 354 | + | event.pull("quit")
|
| 355 | - | save_config() |
| 355 | + | event.cancel(timer) |
| 356 | - | elseif x >= 43 + #("Start: "..config.auto_power.start_percent.."%") and x <= 46+#("Start: "..config.auto_power.start_percent.."%") and y == 10 and config.auto_power.start_percent+1 ~= config.auto_power.stop_percent then
|
| 356 | + | event.ignore("touch",onTouch)
|
| 357 | - | config.auto_power.start_percent = config.auto_power.start_percent+1 |
| 357 | + | component.gpu.setResolution(160,50) |
| 358 | - | save_config() |
| 358 | + |