SHOW:
|
|
- or go back to the newest paste.
| 1 | -- BigReactor Control | |
| 2 | -- by SparkyBearBomb | |
| 3 | -- Original by jaranvil aka jared314 | |
| 4 | -- | |
| 5 | -- feel free to use and/or modify this code | |
| 6 | -- | |
| 7 | ----------------------------------------------- | |
| 8 | --Reactor Control - Version History | |
| 9 | -- | |
| 10 | -- Version 2.3 - 21 DEC 20 | |
| 11 | -- - Updated Color scheme | |
| 12 | -- - Added Power Toggle on Main Screen | |
| 13 | -- | |
| 14 | -- Version 2.2 - 20 DEC 20 | |
| 15 | -- - Updated to permit use with Minecraft 1.16.4 | |
| 16 | -- - Created Legacy offshoot of turbine and reactor programs | |
| 17 | -- | |
| 18 | -- Version 2.1 - 28 JUL 19 | |
| 19 | -- - Fixed Auto Power Increase/Decrease Alignment | |
| 20 | -- | |
| 21 | -- Version 2.0 - 02 JUN 19 | |
| 22 | -- - Fixed Okay button in auto menu | |
| 23 | -- | |
| 24 | -- Version 1.9 - 02 JUN 19 | |
| 25 | -- - Added Control rod auto to auto screen | |
| 26 | -- | |
| 27 | -- Version 1.8 - 24 MAR 17 | |
| 28 | -- - ROLLBACK TO VERSION 1.5 due to error with disabling periodic update checking | |
| 29 | -- | |
| 30 | -- Version 1.7 - 24 MAR 17 | |
| 31 | -- - disabled periodic update checking due to errors, left in in case a fix becomes known | |
| 32 | -- - error possibly caused by multishell, however, update check causes main screen to flash | |
| 33 | -- | |
| 34 | -- Version 1.6 - 23 MAR 17 | |
| 35 | -- - Added periodic update checking | |
| 36 | -- | |
| 37 | -- Version 1.5 - 23 MAR 17 | |
| 38 | -- - Updated "contact me" information | |
| 39 | -- | |
| 40 | -- Version 1.4 - 11 SEP 16 | |
| 41 | -- - Updated "Rod/Casing Heat", "Storage" and "Control Rods" bar colors | |
| 42 | -- | |
| 43 | -- Version 1.3 - 07 SEP 16 | |
| 44 | -- - Integrated waste into fuel bar | |
| 45 | -- - Put fuel consumption on main screen | |
| 46 | -- | |
| 47 | -- Version 1.2 - 17 MAR 16 | |
| 48 | -- - First Release | |
| 49 | -- | |
| 50 | -- Version 1.1 - UNKN | |
| 51 | -- - original program made by jaranvil | |
| 52 | -- | |
| 53 | ||
| 54 | - | local version = 2.1 |
| 54 | + | |
| 55 | ||
| 56 | ----------------------------------------------- | |
| 57 | ||
| 58 | local version = 2.3 | |
| 59 | --is auto power enabled | |
| 60 | local auto_string = false | |
| 61 | --auto on value | |
| 62 | local on = 0 | |
| 63 | --auto off value | |
| 64 | local off = 99 | |
| 65 | --is auto control rods enabled | |
| 66 | local auto_rods = true | |
| 67 | --control rod auto value | |
| 68 | local auto_rf = 0 | |
| 69 | ||
| 70 | --peripherals | |
| 71 | local reactor | |
| 72 | local mon | |
| 73 | ||
| 74 | --monitor size | |
| 75 | local monX | |
| 76 | local monY | |
| 77 | ||
| 78 | term.clear() | |
| 79 | -------------------FORMATTING------------------------------- | |
| 80 | function clear() | |
| 81 | mon.setBackgroundColor(colors.black) | |
| 82 | mon.clear() | |
| 83 | mon.setCursorPos(1,1) | |
| 84 | end | |
| 85 | ||
| 86 | --display text on computer's terminal screen | |
| 87 | function draw_text_term(x, y, text, text_color, bg_color) | |
| 88 | term.setTextColor(text_color) | |
| 89 | term.setBackgroundColor(bg_color) | |
| 90 | term.setCursorPos(x,y) | |
| 91 | write(text) | |
| 92 | end | |
| 93 | ||
| 94 | --display text text on monitor, "mon" peripheral | |
| 95 | function draw_text(x, y, text, text_color, bg_color) | |
| 96 | mon.setBackgroundColor(bg_color) | |
| 97 | mon.setTextColor(text_color) | |
| 98 | mon.setCursorPos(x,y) | |
| 99 | mon.write(text) | |
| 100 | end | |
| 101 | ||
| 102 | --draw line on computer terminal | |
| 103 | function draw_line(x, y, length, color) | |
| 104 | mon.setBackgroundColor(color) | |
| 105 | mon.setCursorPos(x,y) | |
| 106 | mon.write(string.rep(" ", length))
| |
| 107 | end | |
| 108 | ||
| 109 | --draw line on computer terminal | |
| 110 | function draw_line_term(x, y, length, color) | |
| 111 | term.setBackgroundColor(color) | |
| 112 | term.setCursorPos(x,y) | |
| 113 | term.write(string.rep(" ", length))
| |
| 114 | end | |
| 115 | ||
| 116 | -- Round Decimal Numbers | |
| 117 | function roundNumber(num, n) | |
| 118 | local mult = 10^(n or 0) | |
| 119 | return math.floor(num * mult + 0.5) / mult | |
| 120 | end | |
| 121 | ||
| 122 | --create progress bar | |
| 123 | --draws two overlapping lines | |
| 124 | --background line of bg_color | |
| 125 | --main line of bar_color as a percentage of minVal/maxVal | |
| 126 | function progress_bar(x, y, length, minVal, maxVal, bar_color, bg_color) | |
| 127 | draw_line(x, y, length, bg_color) --backgoround bar | |
| 128 | local barSize = math.floor((minVal/maxVal) * length) | |
| 129 | draw_line(x, y, barSize, bar_color) --progress so far | |
| 130 | end | |
| 131 | ||
| 132 | --create status bar | |
| 133 | --draws three overlapping lines | |
| 134 | --background line of bg_color | |
| 135 | function status_bar(x, y, length, minVal, medVal, maxVal, bar_color1, bar_color2, bg_color) | |
| 136 | draw_line(x, y, length, bg_color) --backgoround bar | |
| 137 | local barSize1 = math.floor((medVal/maxVal) * length) | |
| 138 | local barSize2 = math.floor((minVal/maxVal) * length) | |
| 139 | draw_line(x, y, barSize1, bar_color1) --progress so far | |
| 140 | draw_line(x, y, barSize2, bar_color2) --progress so far | |
| 141 | end | |
| 142 | ||
| 143 | --same as above but on the computer terminal | |
| 144 | function progress_bar_term(x, y, length, minVal, maxVal, bar_color, bg_color) | |
| 145 | draw_line_term(x, y, length, bg_color) --backgoround bar | |
| 146 | local barSize = math.floor((minVal/maxVal) * length) | |
| 147 | draw_line_term(x, y, barSize, bar_color) --progress so far | |
| 148 | end | |
| 149 | ||
| 150 | --create button on monitor | |
| 151 | function button(x, y, length, text, txt_color, bg_color) | |
| 152 | draw_line(x, y, length, bg_color) | |
| 153 | draw_text((x+2), y, text, txt_color, bg_color) | |
| 154 | - | draw_line(1, 1, monX, colors.blue) |
| 154 | + | |
| 155 | - | draw_text(2, 1, "Power Tools Settings", colors.white, colors.blue) |
| 155 | + | |
| 156 | - | draw_line(1, 26, monX, colors.blue) |
| 156 | + | |
| 157 | - | draw_text(2, 26, " Reactor Control", colors.white, colors.blue) |
| 157 | + | |
| 158 | draw_line(1, 1, monX, colors.purple) | |
| 159 | draw_text(2, 1, "Power Tools Settings", colors.white, colors.purple) | |
| 160 | draw_line(1, 26, monX, colors.purple) | |
| 161 | draw_text(2, 26, " Reactor Control", colors.white, colors.purple) | |
| 162 | end | |
| 163 | ||
| 164 | --dropdown menu for power options | |
| 165 | function power_menu() | |
| 166 | draw_line(1, 2, 9, colors.gray) | |
| 167 | draw_line(1, 3, 9, colors.gray) | |
| 168 | draw_line(1, 4, 9, colors.gray) | |
| 169 | if active then | |
| 170 | draw_text(2, 2, "ON", colors.lightGray, colors.gray) | |
| 171 | draw_text(2, 3, "OFF", colors.white, colors.gray) | |
| 172 | else | |
| 173 | draw_text(2, 2, "ON", colors.white, colors.gray) | |
| 174 | draw_text(2, 3, "OFF", colors.lightGray, colors.gray) | |
| 175 | end | |
| 176 | draw_text(2, 4, "Auto", colors.white, colors.gray) | |
| 177 | end | |
| 178 | ||
| 179 | --dropbox menu for tools | |
| 180 | function tools_menu() | |
| 181 | draw_line(10, 2, 14, colors.gray) | |
| 182 | draw_line(10, 3, 14, colors.gray) | |
| 183 | draw_line(10, 4, 14, colors.gray) | |
| 184 | draw_line(10, 5, 14, colors.gray) | |
| 185 | draw_text(11, 2, "Control Rods", colors.white, colors.gray) | |
| 186 | draw_text(11, 3, "Efficiency", colors.white, colors.gray) | |
| 187 | draw_text(11, 4, "Fuel", colors.white, colors.gray) | |
| 188 | draw_text(11, 5, "Waste", colors.white, colors.gray) | |
| 189 | end | |
| 190 | ||
| 191 | --dropdown menu for settings | |
| 192 | function settings_menu() | |
| 193 | draw_line(12, 2, 18, colors.gray) | |
| 194 | draw_line(12, 3, 18, colors.gray) | |
| 195 | draw_text(13, 2, "Check for Updates", colors.white, colors.gray) | |
| 196 | draw_text(13, 3, "Reset peripherals", colors.white, colors.gray) | |
| 197 | end | |
| 198 | ||
| 199 | --basic popup screen with title bar and exit button | |
| 200 | - | draw_line(4, y, 22, colors.blue) |
| 200 | + | |
| 201 | clear() | |
| 202 | menu_bar() | |
| 203 | ||
| 204 | draw_line(4, y, 22, colors.purple) | |
| 205 | draw_line(25, y, 1, colors.red) | |
| 206 | ||
| 207 | for counter = y+1, height+y do | |
| 208 | - | draw_text(5, y, title, colors.white, colors.blue) |
| 208 | + | |
| 209 | end | |
| 210 | ||
| 211 | draw_text(25, y, "X", colors.white, colors.red) | |
| 212 | draw_text(5, y, title, colors.white, colors.purple) | |
| 213 | end | |
| 214 | ||
| 215 | --write settings to config file | |
| 216 | function save_config() | |
| 217 | sw = fs.open("config.txt", "w")
| |
| 218 | sw.writeLine(version) | |
| 219 | sw.writeLine(auto_string) | |
| 220 | sw.writeLine(on) | |
| 221 | sw.writeLine(off) | |
| 222 | sw.writeLine(auto_rods) | |
| 223 | sw.writeLine(auto_rf) | |
| 224 | sw.close() | |
| 225 | end | |
| 226 | ||
| 227 | --read settings from file | |
| 228 | function load_config() | |
| 229 | sr = fs.open("config.txt", "r")
| |
| 230 | version = tonumber(sr.readLine()) | |
| 231 | auto_string = sr.readLine() | |
| 232 | on = tonumber(sr.readLine()) | |
| 233 | off = tonumber(sr.readLine()) | |
| 234 | auto_rods = sr.readLine() | |
| 235 | auto_rf = tonumber(sr.readLine()) | |
| 236 | sr.close() | |
| 237 | end | |
| 238 | ||
| 239 | ------------------------END FORMATTING-------------------------- | |
| 240 | ||
| 241 | -- | |
| 242 | function homepage() | |
| 243 | while true do | |
| 244 | clear() | |
| 245 | menu_bar() | |
| 246 | terminal_screen() | |
| 247 | - | draw_text(2, 3, "Power:", colors.yellow, colors.black) |
| 247 | + | |
| 248 | energy_stored = reactor.getEnergyStored() | |
| 249 | ||
| 250 | - | draw_text(10, 3, "ONLINE", colors.lime, colors.black) |
| 250 | + | |
| 251 | draw_text(2, 3, "Power:", colors.lightGray, colors.black) | |
| 252 | - | draw_text(10, 3, "OFFLINE", colors.red, colors.black) |
| 252 | + | |
| 253 | if active then | |
| 254 | draw_text(9, 3, " ONLINE ", colors.gray, colors.green) | |
| 255 | draw_text(17, 3, " OFFLINE ", colors.black, colors.gray) | |
| 256 | else | |
| 257 | - | draw_text(2, 5, "Fuel Level:", colors.yellow, colors.black) |
| 257 | + | draw_text(9, 3, " ONLINE ", colors.black, colors.gray) |
| 258 | draw_text(17, 3, " OFFLINE ", colors.gray, colors.red) | |
| 259 | end | |
| 260 | ||
| 261 | ||
| 262 | -----------FUEL--------------------- | |
| 263 | draw_text(2, 5, "Fuel Level:", colors.lightGray, colors.black) | |
| 264 | local maxVal = reactor.getFuelAmountMax() | |
| 265 | - | if percent < 25 then |
| 265 | + | |
| 266 | local minVal = reactor.getFuelAmount() | |
| 267 | - | else if percent < 50 then |
| 267 | + | |
| 268 | local percent = math.floor((minVal/maxVal)*100) | |
| 269 | - | else if percent < 75 then |
| 269 | + | |
| 270 | ||
| 271 | if percent < 20 then | |
| 272 | status_bar(2, 6, monX-2, minVal, medVal, maxVal, colors.blue, colors.red, colors.gray) | |
| 273 | else if percent < 40 then | |
| 274 | status_bar(2, 6, monX-2, minVal, medVal, maxVal, colors.blue, colors.orange, colors.gray) | |
| 275 | else if percent < 60 then | |
| 276 | status_bar(2, 6, monX-2, minVal, medVal, maxVal, colors.blue, colors.yellow, colors.gray) | |
| 277 | else if percent <= 80 then | |
| 278 | status_bar(2, 6, monX-2, minVal, medVal, maxVal, colors.blue, colors.lime, colors.gray) | |
| 279 | - | draw_text(2, 8, "Fuel Temp:", colors.yellow, colors.black) |
| 279 | + | |
| 280 | status_bar(2, 6, monX-2, minVal, medVal, maxVal, colors.blue, colors.green, colors.gray) | |
| 281 | end | |
| 282 | end | |
| 283 | end | |
| 284 | end | |
| 285 | end | |
| 286 | ||
| 287 | -----------ROD HEAT--------------- | |
| 288 | draw_text(2, 8, "Fuel Temp:", colors.lightGray, colors.black) | |
| 289 | local maxVal = 2000 | |
| 290 | local minVal = math.floor(reactor.getFuelTemperature()) | |
| 291 | ||
| 292 | if minVal < 500 then | |
| 293 | progress_bar(2, 9, monX-2, minVal, maxVal, colors.cyan, colors.gray) | |
| 294 | else if minVal < 1000 then | |
| 295 | progress_bar(2, 9, monX-2, minVal, maxVal, colors.lime, colors.gray) | |
| 296 | else if minVal < 1500 then | |
| 297 | progress_bar(2, 9, monX-2, minVal, maxVal, colors.yellow, colors.gray) | |
| 298 | else if minVal < 2000 then | |
| 299 | progress_bar(2, 9, monX-2, minVal, maxVal, colors.orange, colors.gray) | |
| 300 | else if minVal >= 2000 then | |
| 301 | progress_bar(2, 9, monX-2, 2000, maxVal, colors.red, colors.gray) | |
| 302 | - | draw_text(2, 11, "Casing Temp:", colors.yellow, colors.black) |
| 302 | + | |
| 303 | end | |
| 304 | end | |
| 305 | end | |
| 306 | end | |
| 307 | ||
| 308 | draw_text(15, 8, math.floor(minVal).." C", colors.white, colors.black) | |
| 309 | ||
| 310 | -----------CASING HEAT--------------- | |
| 311 | draw_text(2, 11, "Casing Temp:", colors.lightGray, colors.black) | |
| 312 | local maxVal = 2000 | |
| 313 | local minVal = math.floor(reactor.getCasingTemperature()) | |
| 314 | if minVal < 500 then | |
| 315 | progress_bar(2, 12, monX-2, minVal, maxVal, colors.cyan, colors.gray) | |
| 316 | else if minVal < 1000 then | |
| 317 | progress_bar(2, 12, monX-2, minVal, maxVal, colors.lime, colors.gray) | |
| 318 | else if minVal < 1500 then | |
| 319 | progress_bar(2, 12, monX-2, minVal, maxVal, colors.yellow, colors.gray) | |
| 320 | else if minVal < 2000 then | |
| 321 | progress_bar(2, 12, monX-2, minVal, maxVal, colors.orange, colors.gray) | |
| 322 | else if minVal >= 2000 then | |
| 323 | progress_bar(2, 12, monX-2, 2000, maxVal, colors.red, colors.gray) | |
| 324 | - | draw_text(2, 14, "Fuel/Tick:", colors.yellow, colors.black) |
| 324 | + | |
| 325 | end | |
| 326 | end | |
| 327 | end | |
| 328 | end | |
| 329 | draw_text(15, 11, math.floor(minVal).." C", colors.white, colors.black) | |
| 330 | ||
| 331 | -------------FUEL CONSUMPTION------------------- | |
| 332 | - | draw_text(2, 16, "mB/tick:", colors.yellow, colors.black) |
| 332 | + | |
| 333 | draw_text(2, 14, "Fuel/Tick:", colors.lightGray, colors.black) | |
| 334 | fuel_usage = reactor.getFuelConsumedLastTick() | |
| 335 | fuelConsumed = roundNumber(fuel_usage, 5) | |
| 336 | draw_text(13, 14, fuelConsumed.." mB/T", colors.white, colors.black) | |
| 337 | ||
| 338 | - | draw_text(2, 16, "RF/Tick:", colors.yellow, colors.black) |
| 338 | + | |
| 339 | if reactor.isActivelyCooled() then | |
| 340 | ||
| 341 | draw_text(2, 16, "mB/tick:", colors.lightGray, colors.black) | |
| 342 | mbt = math.floor(reactor.getHotFluidProducedLastTick()) | |
| 343 | draw_text(13, 16, mbt.." mB/t", colors.white, colors.black) | |
| 344 | ||
| 345 | else | |
| 346 | ||
| 347 | - | draw_text(2, 18, "mB Stored:", colors.yellow, colors.black) |
| 347 | + | draw_text(2, 16, "RF/Tick:", colors.lightGray, colors.black) |
| 348 | rft = math.floor(reactor.getEnergyProducedLastTick()) | |
| 349 | draw_text(13, 16, rft.." RF/T", colors.white, colors.black) | |
| 350 | ||
| 351 | end | |
| 352 | ||
| 353 | ------------STORAGE------------ | |
| 354 | if reactor.isActivelyCooled() then | |
| 355 | - | draw_text(2, 18, "RF Stored:", colors.yellow, colors.black) |
| 355 | + | |
| 356 | draw_text(2, 18, "mB Stored:", colors.lightGray, colors.black) | |
| 357 | fluid_stored = reactor.getHotFluidAmount() | |
| 358 | fluid_max = reactor.getHotFluidAmountMax() | |
| 359 | fluid_stored_percent = math.floor((fluid_stored/fluid_max)*100) | |
| 360 | draw_text(13, 18, fluid_stored_percent.."% ("..fluid_stored.." mB)", colors.white, colors.black)
| |
| 361 | - | progress_bar(2, 19, monX-2, minVal, maxVal, colors.lime, colors.gray) |
| 361 | + | |
| 362 | else | |
| 363 | ||
| 364 | draw_text(2, 18, "RF Stored:", colors.lightGray, colors.black) | |
| 365 | energy_stored_percent = math.floor((energy_stored/10000000)*100) | |
| 366 | local maxVal = 100 | |
| 367 | local minVal = energy_stored_percent | |
| 368 | draw_text(13, 18, energy_stored_percent.."% ("..energy_stored.." RF)", colors.white, colors.black)
| |
| 369 | ||
| 370 | - | draw_text(2, 21, "Control Rods:", colors.yellow, colors.black) |
| 370 | + | progress_bar(2, 19, monX-2, minVal, maxVal, colors.green, colors.gray) |
| 371 | end | |
| 372 | ||
| 373 | ||
| 374 | -------------AUTO CONTROL RODS----------------------- | |
| 375 | auto_rods_bool = auto_rods == "true" | |
| 376 | insertion_percent = reactor.getControlRodLevel(0) | |
| 377 | ||
| 378 | if reactor.isActivelyCooled() then | |
| 379 | - | draw_text(2, 21, "Control Rods:", colors.yellow, colors.black) |
| 379 | + | draw_text(2, 21, "Control Rods:", colors.lightGray, colors.black) |
| 380 | draw_text(16, 21, insertion_percent.."%", colors.white, colors.black) | |
| 381 | else | |
| 382 | ||
| 383 | if auto_rods_bool then | |
| 384 | if active then | |
| 385 | reactor.setAllControlRodLevels(energy_stored_percent) | |
| 386 | end | |
| 387 | - | draw_text(2, 21, "Control Rods:", colors.yellow, colors.black) |
| 387 | + | |
| 388 | draw_text(2, 21, "Control Rods:", colors.lightGray, colors.black) | |
| 389 | draw_text(16, 21, insertion_percent.."%", colors.white, colors.black) | |
| 390 | local maxVal = 100 | |
| 391 | local minVal = insertion_percent | |
| 392 | ||
| 393 | progress_bar(2, 22, monX-2, minVal, maxVal, colors.cyan, colors.gray) | |
| 394 | ||
| 395 | else | |
| 396 | draw_text(2, 21, "Control Rods:", colors.lightGray, colors.black) | |
| 397 | draw_text(16, 21, insertion_percent.."%", colors.white, colors.black) local maxVal = 100 | |
| 398 | local minVal = insertion_percent | |
| 399 | ||
| 400 | progress_bar(2, 22, monX-2, minVal, maxVal, colors.yellow, colors.gray) | |
| 401 | ||
| 402 | end | |
| 403 | end | |
| 404 | ||
| 405 | ||
| 406 | - | draw_text(2, 24, "Auto:", colors.yellow, colors.black) |
| 406 | + | |
| 407 | if reactor.isActivelyCooled() then | |
| 408 | ||
| 409 | --i dont know what I should do here | |
| 410 | ||
| 411 | - | draw_text(2, 24, "Auto off:", colors.yellow, colors.black) |
| 411 | + | |
| 412 | else | |
| 413 | auto = auto_string == "true" | |
| 414 | if auto_rods == "true" then | |
| 415 | draw_text(2, 24, "Auto:", colors.lightGray, colors.black) | |
| 416 | draw_text(13, 24, "Control Rods", colors.white, colors.black) | |
| 417 | else | |
| 418 | - | draw_text(2, 24, "Auto on:", colors.yellow, colors.black) |
| 418 | + | |
| 419 | if active then | |
| 420 | draw_text(2, 24, "Auto off:", colors.lightGray, colors.black) | |
| 421 | draw_text(13, 24, off.."% RF Stored", colors.white, colors.black) | |
| 422 | if energy_stored_percent >= off then | |
| 423 | reactor.setActive(false) | |
| 424 | call_homepage() | |
| 425 | end | |
| 426 | - | draw_text(2, 24, "Auto power:", colors.yellow, colors.black) |
| 426 | + | |
| 427 | draw_text(2, 24, "Auto on:", colors.lightGray, colors.black) | |
| 428 | draw_text(13, 24, on.."% RF Stored", colors.white, colors.black) | |
| 429 | if energy_stored_percent <= on then | |
| 430 | reactor.setActive(true) | |
| 431 | call_homepage() | |
| 432 | end | |
| 433 | end | |
| 434 | else | |
| 435 | draw_text(2, 24, "Auto power:", colors.lightGray, colors.black) | |
| 436 | draw_text(14, 24, "disabled", colors.red, colors.black) | |
| 437 | end | |
| 438 | end | |
| 439 | end | |
| 440 | ||
| 441 | sleep(0.5) | |
| 442 | end | |
| 443 | end | |
| 444 | ||
| 445 | --------------MENU SCREENS-------------- | |
| 446 | ||
| 447 | - | draw_text(5, 7, "Power", colors.lime, colors.white) |
| 447 | + | |
| 448 | function auto_off() | |
| 449 | ||
| 450 | auto = auto_string == "true" | |
| 451 | if auto then --auto power enabled | |
| 452 | ||
| 453 | popup_screen(3, "Auto Management", 13) | |
| 454 | draw_text(5, 5, "Energy", colors.red, colors.white) | |
| 455 | draw_text(15, 5, " enable ", colors.white, colors.gray) | |
| 456 | draw_text(5, 7, "Power", colors.green, colors.white) | |
| 457 | draw_text(15, 7, " disable ", colors.white, colors.black) | |
| 458 | ||
| 459 | draw_text(5, 9, "ON when storage =", colors.gray, colors.white) | |
| 460 | draw_text(5, 10, " - ", colors.white, colors.black) | |
| 461 | draw_text(13, 10, on.."% RF", colors.black, colors.white) | |
| 462 | draw_text(22, 10, " + ", colors.white, colors.black) | |
| 463 | ||
| 464 | draw_text(5, 12, "OFF when storage =", colors.gray, colors.white) | |
| 465 | draw_text(5, 13, " - ", colors.white, colors.black) | |
| 466 | draw_text(13, 13, off.."% RF", colors.black, colors.white) | |
| 467 | draw_text(22, 13, " + ", colors.white, colors.black) | |
| 468 | ||
| 469 | draw_text(11, 15, " Save ", colors.white, colors.black) | |
| 470 | ||
| 471 | local event, side, xPos, yPos = os.pullEvent("monitor_touch")
| |
| 472 | ||
| 473 | ||
| 474 | --enable rods | |
| 475 | if yPos == 5 then | |
| 476 | if xPos >= 15 and xPos <= 21 then | |
| 477 | auto_string = "false" | |
| 478 | auto_rods = "true" | |
| 479 | reactor.setActive(true) | |
| 480 | save_config() | |
| 481 | auto_off() | |
| 482 | control_rods() | |
| 483 | else | |
| 484 | auto_off() | |
| 485 | control_rods() | |
| 486 | end | |
| 487 | end | |
| 488 | ||
| 489 | --disable auto | |
| 490 | if yPos == 7 then | |
| 491 | if xPos >= 15 and xPos <= 21 then | |
| 492 | auto_string = "false" | |
| 493 | save_config() | |
| 494 | auto_off() | |
| 495 | else | |
| 496 | auto_off() | |
| 497 | end | |
| 498 | end | |
| 499 | ||
| 500 | ||
| 501 | --increase/decrease auto on % | |
| 502 | if yPos == 10 then | |
| 503 | if xPos >= 5 and xPos <= 8 then | |
| 504 | previous_on = on | |
| 505 | on = on-1 | |
| 506 | end | |
| 507 | if xPos >= 22 and xPos <= 25 then | |
| 508 | previous_on = on | |
| 509 | on = on+1 | |
| 510 | end | |
| 511 | end | |
| 512 | ||
| 513 | --increase/decrease auto off % | |
| 514 | if yPos == 13 then | |
| 515 | if xPos >= 5 and xPos <= 8 then | |
| 516 | previous_off = off | |
| 517 | off = off-1 | |
| 518 | end | |
| 519 | if xPos >= 22 and xPos <= 25 then | |
| 520 | previous_off = off | |
| 521 | off = off+1 | |
| 522 | end | |
| 523 | end | |
| 524 | ||
| 525 | if on < 0 then on = 0 end | |
| 526 | if off >99 then off = 99 end | |
| 527 | ||
| 528 | if on == off or on > off then | |
| 529 | on = previous_on | |
| 530 | off = previous_off | |
| 531 | popup_screen(5, "Error", 6) | |
| 532 | draw_text(5, 7, "Auto On value must be", colors.black, colors.white) | |
| 533 | draw_text(5, 8, "lower then auto off", colors.black, colors.white) | |
| 534 | draw_text(11, 10, "Okay", colors.white, colors.black) | |
| 535 | local event, side, xPos, yPos = os.pullEvent("monitor_touch")
| |
| 536 | ||
| 537 | auto_off() | |
| 538 | end | |
| 539 | ||
| 540 | --Okay button | |
| 541 | if yPos == 15 and xPos >= 11 and xPos <= 17 then | |
| 542 | save_config() | |
| 543 | call_homepage() | |
| 544 | end | |
| 545 | ||
| 546 | --Exit button | |
| 547 | - | draw_text(5, 5, "Energy", colors.lime, colors.white) |
| 547 | + | |
| 548 | call_homepage() | |
| 549 | end | |
| 550 | ||
| 551 | auto_off() | |
| 552 | ||
| 553 | elseif auto_rods == "true" then --auto rods enabled | |
| 554 | ||
| 555 | popup_screen(3, "Auto Management", 7) | |
| 556 | draw_text(5, 5, "Energy", colors.green, colors.white) | |
| 557 | draw_text(15, 5, " disable ", colors.white, colors.black) | |
| 558 | draw_text(5, 7, "Power", colors.red, colors.white) | |
| 559 | draw_text(15, 7, " enable ", colors.white, colors.gray) | |
| 560 | draw_text(11, 9, "Okay", colors.white, colors.black) | |
| 561 | ||
| 562 | local event, side, xPos, yPos = os.pullEvent("monitor_touch")
| |
| 563 | ||
| 564 | --Okay button | |
| 565 | if yPos == 9 and xPos >= 11 and xPos <= 17 then | |
| 566 | call_homepage() | |
| 567 | end | |
| 568 | ||
| 569 | if yPos == 5 then | |
| 570 | if xPos >= 15 and xPos <= 21 then | |
| 571 | auto_string = "false" | |
| 572 | auto_rods = "false" | |
| 573 | reactor.setAllControlRodLevels(0) | |
| 574 | save_config() | |
| 575 | auto_off() | |
| 576 | control_rods() | |
| 577 | else | |
| 578 | auto_off() | |
| 579 | control_rods() | |
| 580 | end | |
| 581 | end | |
| 582 | ||
| 583 | if yPos == 7 then | |
| 584 | if xPos >= 15 and xPos <= 21 then | |
| 585 | auto_string = "true" | |
| 586 | auto_rods = "false" | |
| 587 | reactor.setAllControlRodLevels(0) | |
| 588 | save_config() | |
| 589 | auto_off() | |
| 590 | control_rods() | |
| 591 | else | |
| 592 | auto_off() | |
| 593 | control_rods() | |
| 594 | end | |
| 595 | else | |
| 596 | auto_off() | |
| 597 | control_rods() | |
| 598 | end | |
| 599 | ||
| 600 | else | |
| 601 | popup_screen(3, "Auto Management", 7) | |
| 602 | draw_text(5, 5, "Energy", colors.red, colors.white) | |
| 603 | draw_text(15, 5, " enable ", colors.white, colors.gray) | |
| 604 | draw_text(5, 7, "Power", colors.red, colors.white) | |
| 605 | draw_text(15, 7, " enable ", colors.white, colors.gray) | |
| 606 | draw_text(11, 9, "Okay", colors.white, colors.black) | |
| 607 | ||
| 608 | local event, side, xPos, yPos = os.pullEvent("monitor_touch")
| |
| 609 | ||
| 610 | --Okay button | |
| 611 | if yPos == 9 and xPos >= 11 and xPos <= 17 then | |
| 612 | call_homepage() | |
| 613 | end | |
| 614 | ||
| 615 | if yPos == 5 then | |
| 616 | if xPos >= 15 and xPos <= 21 then | |
| 617 | auto_string = "false" | |
| 618 | auto_rods = "true" | |
| 619 | reactor.setActive(true) | |
| 620 | save_config() | |
| 621 | auto_off() | |
| 622 | control_rods() | |
| 623 | else | |
| 624 | auto_off() | |
| 625 | control_rods() | |
| 626 | end | |
| 627 | end | |
| 628 | ||
| 629 | if yPos == 7 then | |
| 630 | if xPos >= 15 and xPos <= 21 then | |
| 631 | auto_string = "true" | |
| 632 | auto_rods = "false" | |
| 633 | reactor.setAllControlRodLevels(0) | |
| 634 | save_config() | |
| 635 | auto_off() | |
| 636 | control_rods() | |
| 637 | else | |
| 638 | auto_off() | |
| 639 | control_rods() | |
| 640 | end | |
| 641 | else | |
| 642 | auto_off() | |
| 643 | control_rods() | |
| 644 | end | |
| 645 | end | |
| 646 | end | |
| 647 | - | draw_text(5, 5, "Fuel Consumption: ", colors.lime, colors.white) |
| 647 | + | |
| 648 | --efficiency menu | |
| 649 | - | draw_text(5, 8, "Energy per mB: ", colors.lime, colors.white) |
| 649 | + | |
| 650 | popup_screen(3, "Efficiency", 12) | |
| 651 | fuel_usage = reactor.getFuelConsumedLastTick() | |
| 652 | - | draw_text(5, 11, "RF/tick:", colors.lime, colors.white) |
| 652 | + | |
| 653 | ||
| 654 | rfmb = rft / fuel_usage | |
| 655 | ||
| 656 | draw_text(5, 5, "Fuel Consumption: ", colors.green, colors.white) | |
| 657 | draw_text(5, 6, fuel_usage.." mB/t", colors.black, colors.white) | |
| 658 | draw_text(5, 8, "Energy per mB: ", colors.green, colors.white) | |
| 659 | draw_text(5, 9, rfmb.." RF/mB", colors.black, colors.white) | |
| 660 | ||
| 661 | draw_text(5, 11, "RF/tick:", colors.green, colors.white) | |
| 662 | draw_text(5, 12, rft.." RF/T", colors.black, colors.white) | |
| 663 | ||
| 664 | draw_text(11, 14, " Okay ", colors.white, colors.black) | |
| 665 | ||
| 666 | local event, side, xPos, yPos = os.pullEvent("monitor_touch")
| |
| 667 | ||
| 668 | --Okay button | |
| 669 | if yPos == 14 and xPos >= 11 and xPos <= 17 then | |
| 670 | call_homepage() | |
| 671 | end | |
| 672 | ||
| 673 | --Exit button | |
| 674 | if yPos == 3 and xPos == 25 then | |
| 675 | call_homepage() | |
| 676 | end | |
| 677 | ||
| 678 | efficiency() | |
| 679 | end | |
| 680 | - | draw_text(5, 5, "Fuel Level: ", colors.lime, colors.white) |
| 680 | + | |
| 681 | ||
| 682 | function fuel() | |
| 683 | - | draw_text(5, 8, "Reactivity: ", colors.lime, colors.white) |
| 683 | + | |
| 684 | ||
| 685 | fuel_max = reactor.getFuelAmountMax() | |
| 686 | fuel_level = reactor.getFuelAmount() | |
| 687 | fuel_reactivity = math.floor(reactor.getFuelReactivity()) | |
| 688 | ||
| 689 | draw_text(5, 5, "Fuel Level: ", colors.green, colors.white) | |
| 690 | draw_text(5, 6, fuel_level.."/"..fuel_max, colors.black, colors.white) | |
| 691 | ||
| 692 | draw_text(5, 8, "Reactivity: ", colors.green, colors.white) | |
| 693 | draw_text(5, 9, fuel_reactivity.."%", colors.black, colors.white) | |
| 694 | ||
| 695 | draw_text(11, 11, " Okay ", colors.white, colors.black) | |
| 696 | ||
| 697 | local event, side, xPos, yPos = os.pullEvent("monitor_touch")
| |
| 698 | ||
| 699 | ||
| 700 | --Okay button | |
| 701 | if yPos == 11 and xPos >= 11 and xPos <= 17 then | |
| 702 | call_homepage() | |
| 703 | end | |
| 704 | ||
| 705 | --Exit button | |
| 706 | if yPos == 3 and xPos == 25 then | |
| 707 | call_homepage() | |
| 708 | - | draw_text(5, 5, "Waste Amount: ", colors.lime, colors.white) |
| 708 | + | |
| 709 | ||
| 710 | fuel() | |
| 711 | end | |
| 712 | ||
| 713 | function waste() | |
| 714 | popup_screen(3, "Waste", 8) | |
| 715 | ||
| 716 | waste_amount = reactor.getWasteAmount() | |
| 717 | draw_text(5, 5, "Waste Amount: ", colors.green, colors.white) | |
| 718 | draw_text(5, 6, waste_amount.." mB", colors.black, colors.white) | |
| 719 | draw_text(8, 8, " Eject Waste ", colors.white, colors.red) | |
| 720 | draw_text(11, 10, " Close ", colors.white, colors.black) | |
| 721 | ||
| 722 | local event, side, xPos, yPos = os.pullEvent("monitor_touch")
| |
| 723 | ||
| 724 | --eject button | |
| 725 | if yPos == 8 and xPos >= 8 and xPos <= 21 then | |
| 726 | reactor.doEjectWaste() | |
| 727 | popup_screen(5, "Waste Eject", 5) | |
| 728 | draw_text(5, 7, "Waste Ejeceted.", colors.black, colors.white) | |
| 729 | draw_text(11, 9, " Close ", colors.white, colors.black) | |
| 730 | local event, side, xPos, yPos = os.pullEvent("monitor_touch")
| |
| 731 | --Okay button | |
| 732 | if yPos == 7 and xPos >= 11 and xPos <= 17 then | |
| 733 | call_homepage() | |
| 734 | end | |
| 735 | ||
| 736 | --Exit button | |
| 737 | if yPos == 3 and xPos == 25 then | |
| 738 | call_homepage() | |
| 739 | end | |
| 740 | end | |
| 741 | ||
| 742 | --Okay button | |
| 743 | if yPos == 10 and xPos >= 11 and xPos <= 17 then | |
| 744 | call_homepage() | |
| 745 | end | |
| 746 | ||
| 747 | --Exit button | |
| 748 | if yPos == 3 and xPos == 25 then | |
| 749 | call_homepage() | |
| 750 | end | |
| 751 | waste() | |
| 752 | end | |
| 753 | ||
| 754 | function set_auto_rf() | |
| 755 | popup_screen(5, "Auto Adjust", 11) | |
| 756 | draw_text(5, 7, "Try to maintain:", colors.black, colors.white) | |
| 757 | ||
| 758 | draw_text(13, 9, " ^ ", colors.white, colors.gray) | |
| 759 | draw_text(10, 11, auto_rf.." RF/t", colors.black, colors.white) | |
| 760 | draw_text(13, 13, " v ", colors.white, colors.gray) | |
| 761 | draw_text(11, 15, " Okay ", colors.white, colors.gray) | |
| 762 | ||
| 763 | local event, side, xPos, yPos = os.pullEvent("monitor_touch")
| |
| 764 | ||
| 765 | --increase button | |
| 766 | if yPos == 9 then | |
| 767 | auto_rf = auto_rf + 100 | |
| 768 | save_config() | |
| 769 | set_auto_rf() | |
| 770 | end | |
| 771 | ||
| 772 | --decrease button | |
| 773 | if yPos == 13 then | |
| 774 | auto_rf = auto_rf - 100 | |
| 775 | if auto_rf < 0 then auto_rf = 0 end | |
| 776 | save_config() | |
| 777 | set_auto_rf() | |
| 778 | end | |
| 779 | ||
| 780 | if yPos == 15 then | |
| 781 | control_rods() | |
| 782 | end | |
| 783 | ||
| 784 | set_auto_rf() | |
| 785 | end | |
| 786 | - | progress_bar(5, 7, 20, insertion_percent, 100, colors.yellow, colors.gray) |
| 786 | + | |
| 787 | function control_rods() | |
| 788 | ||
| 789 | if reactor.isActivelyCooled() then | |
| 790 | ||
| 791 | popup_screen(3, "Control Rods", 13) | |
| 792 | insertion_percent = reactor.getControlRodLevel(0) | |
| 793 | ||
| 794 | draw_text(5, 5, "Inserted: "..insertion_percent.."%", colors.black, colors.white) | |
| 795 | progress_bar(5, 7, 20, insertion_percent, 100, colors.lightGray, colors.gray) | |
| 796 | ||
| 797 | draw_text(5, 9, " << ", colors.white, colors.black) | |
| 798 | draw_text(10, 9, " < ", colors.white, colors.black) | |
| 799 | draw_text(17, 9, " > ", colors.white, colors.black) | |
| 800 | draw_text(21, 9, " >> ", colors.white, colors.black) | |
| 801 | ||
| 802 | draw_text(5, 11, "Auto:", colors.black, colors.white) | |
| 803 | draw_text(5, 13, "unavilable for", colors.red, colors.white) | |
| 804 | draw_text(5, 14, "active cooling", colors.red, colors.white) | |
| 805 | ||
| 806 | draw_text(11, 16, " Close ", colors.white, colors.gray) | |
| 807 | ||
| 808 | local event, side, xPos, yPos = os.pullEvent("monitor_touch")
| |
| 809 | ||
| 810 | if yPos == 9 and xPos >= 5 and xPos <= 15 then | |
| 811 | reactor.setAllControlRodLevels(insertion_percent-10) | |
| 812 | end | |
| 813 | ||
| 814 | if yPos == 9 and xPos >= 10 and xPos <= 13 then | |
| 815 | reactor.setAllControlRodLevels(insertion_percent-1) | |
| 816 | end | |
| 817 | ||
| 818 | if yPos == 9 and xPos >= 17 and xPos <= 20 then | |
| 819 | reactor.setAllControlRodLevels(insertion_percent+1) | |
| 820 | end | |
| 821 | ||
| 822 | if yPos == 9 and xPos >= 21 and xPos <= 25 then | |
| 823 | reactor.setAllControlRodLevels(insertion_percent+10) | |
| 824 | end | |
| 825 | ||
| 826 | ------Close button------- | |
| 827 | if yPos == 16 and xPos >= 11 and xPos <= 17 then | |
| 828 | call_homepage() | |
| 829 | end | |
| 830 | ||
| 831 | ------Exit button------------ | |
| 832 | if yPos == 5 and xPos == 25 then | |
| 833 | call_homepage() | |
| 834 | - | progress_bar(5, 7, 20, insertion_percent, 100, colors.yellow, colors.gray) |
| 834 | + | |
| 835 | control_rods() | |
| 836 | ||
| 837 | else | |
| 838 | ||
| 839 | popup_screen(3, "Control Rods", 13) | |
| 840 | insertion_percent = reactor.getControlRodLevel(0) | |
| 841 | ||
| 842 | draw_text(5, 5, "Inserted: "..insertion_percent.."%", colors.black, colors.white) | |
| 843 | progress_bar(5, 7, 20, insertion_percent, 100, colors.lightGray, colors.gray) | |
| 844 | ||
| 845 | draw_text(5, 9, " << ", colors.white, colors.black) | |
| 846 | draw_text(10, 9, " < ", colors.white, colors.black) | |
| 847 | draw_text(17, 9, " > ", colors.white, colors.black) | |
| 848 | draw_text(21, 9, " >> ", colors.white, colors.black) | |
| 849 | ||
| 850 | draw_text(5, 11, "Auto:", colors.black, colors.white) | |
| 851 | draw_text(16, 11, " disable ", colors.white, colors.black) | |
| 852 | ||
| 853 | auto_rods_bool = auto_rods == "true" | |
| 854 | if auto_rods_bool then | |
| 855 | ||
| 856 | draw_text(16, 11, " enable ", colors.white, colors.black) | |
| 857 | draw_text(5, 13, "enabled", colors.green, colors.white) | |
| 858 | else | |
| 859 | draw_text(16, 11, " enable ", colors.white, colors.black) | |
| 860 | draw_text(5, 13, "disabled", colors.red, colors.white) | |
| 861 | end | |
| 862 | ||
| 863 | draw_text(11, 15, " Close ", colors.white, colors.gray) | |
| 864 | ||
| 865 | local event, side, xPos, yPos = os.pullEvent("monitor_touch")
| |
| 866 | ||
| 867 | -----manual adjust buttons------------ | |
| 868 | if yPos == 9 and xPos >= 5 and xPos <= 15 then | |
| 869 | reactor.setAllControlRodLevels(insertion_percent-10) | |
| 870 | end | |
| 871 | ||
| 872 | if yPos == 9 and xPos >= 10 and xPos <= 13 then | |
| 873 | reactor.setAllControlRodLevels(insertion_percent-1) | |
| 874 | end | |
| 875 | ||
| 876 | if yPos == 9 and xPos >= 17 and xPos <= 20 then | |
| 877 | reactor.setAllControlRodLevels(insertion_percent+1) | |
| 878 | end | |
| 879 | ||
| 880 | if yPos == 9 and xPos >= 21 and xPos <= 25 then | |
| 881 | reactor.setAllControlRodLevels(insertion_percent+10) | |
| 882 | end | |
| 883 | ||
| 884 | ||
| 885 | ------auto buttons----------------- | |
| 886 | if yPos == 11 and xPos >= 16 then | |
| 887 | if auto_rods_bool then | |
| 888 | auto_rods = "false" | |
| 889 | save_config() | |
| 890 | control_rods() | |
| 891 | else | |
| 892 | auto_rods = "true" | |
| 893 | save_config() | |
| 894 | control_rods() | |
| 895 | end | |
| 896 | end | |
| 897 | ||
| 898 | ------Close button------- | |
| 899 | if yPos == 15 and xPos >= 11 and xPos <= 17 then | |
| 900 | call_homepage() | |
| 901 | end | |
| 902 | ||
| 903 | ------Exit button------------ | |
| 904 | if yPos == 5 and xPos == 25 then | |
| 905 | call_homepage() | |
| 906 | end | |
| 907 | control_rods() | |
| 908 | ||
| 909 | end | |
| 910 | end | |
| 911 | ||
| 912 | -----------------------Settings-------------------------------- | |
| 913 | ||
| 914 | ||
| 915 | function rf_mode() | |
| 916 | - | draw_line(4, 5, 22, colors.blue) |
| 916 | + | |
| 917 | end | |
| 918 | ||
| 919 | function steam_mode() | |
| 920 | wait = read() | |
| 921 | end | |
| 922 | - | draw_text(5, 5, "Updating...", colors.white, colors.blue) |
| 922 | + | |
| 923 | function install_update(program, pastebin) | |
| 924 | clear() | |
| 925 | draw_line(4, 5, 22, colors.purple) | |
| 926 | ||
| 927 | for counter = 6, 10 do | |
| 928 | draw_line(4, counter, 22, colors.white) | |
| 929 | end | |
| 930 | ||
| 931 | draw_text(5, 5, "Updating...", colors.white, colors.purple) | |
| 932 | draw_text(5, 7, "Open computer", colors.black, colors.white) | |
| 933 | draw_text(5, 8, "terminal.", colors.black, colors.white) | |
| 934 | ||
| 935 | if fs.exists("install") then fs.delete("install") end
| |
| 936 | shell.run("pastebin get ELJptBRk install")
| |
| 937 | shell.run("install")
| |
| 938 | end | |
| 939 | ||
| 940 | function update() | |
| 941 | popup_screen(5, "Updates", 4) | |
| 942 | draw_text(5, 7, "Connecting to", colors.black, colors.white) | |
| 943 | draw_text(5, 8, "pastebin...", colors.black, colors.white) | |
| 944 | ||
| 945 | sleep(0.5) | |
| 946 | ||
| 947 | shell.run("pastebin get KWdzfSbG current_version.txt")
| |
| 948 | sr = fs.open("current_version.txt", "r")
| |
| 949 | current_version = tonumber(sr.readLine()) | |
| 950 | sr.close() | |
| 951 | fs.delete("current_version.txt")
| |
| 952 | terminal_screen() | |
| 953 | ||
| 954 | if current_version > version then | |
| 955 | ||
| 956 | popup_screen(5, "Updates", 7) | |
| 957 | draw_text(5, 7, "Update Available!", colors.black, colors.white) | |
| 958 | draw_text(11, 9, " Install ", colors.white, colors.black) | |
| 959 | draw_text(11, 11, " Ignore ", colors.white, colors.black) | |
| 960 | ||
| 961 | local event, side, xPos, yPos = os.pullEvent("monitor_touch")
| |
| 962 | ||
| 963 | --Instatll button | |
| 964 | if yPos == 9 and xPos >= 11 and xPos <= 17 then | |
| 965 | install_update() | |
| 966 | end | |
| 967 | ||
| 968 | --Exit button | |
| 969 | if yPos == 5 and xPos == 25 then | |
| 970 | call_homepage() | |
| 971 | end | |
| 972 | call_homepage() | |
| 973 | ||
| 974 | else | |
| 975 | popup_screen(5, "Updates", 5) | |
| 976 | draw_text(5, 7, "You are up to date!", colors.black, colors.white) | |
| 977 | draw_text(11, 9, " Okay ", colors.white, colors.black) | |
| 978 | ||
| 979 | local event, side, xPos, yPos = os.pullEvent("monitor_touch")
| |
| 980 | ||
| 981 | --Okay button | |
| 982 | if yPos == 9 and xPos >= 11 and xPos <= 17 then | |
| 983 | call_homepage() | |
| 984 | end | |
| 985 | ||
| 986 | --Exit button | |
| 987 | if yPos == 5 and xPos == 25 then | |
| 988 | call_homepage() | |
| 989 | end | |
| 990 | - | draw_line(4, 5, 22, colors.blue) |
| 990 | + | |
| 991 | end | |
| 992 | ||
| 993 | ||
| 994 | ||
| 995 | end | |
| 996 | - | draw_text(5, 5, "Reset Peripherals", colors.white, colors.blue) |
| 996 | + | |
| 997 | function reset_peripherals() | |
| 998 | clear() | |
| 999 | draw_line(4, 5, 22, colors.purple) | |
| 1000 | ||
| 1001 | for counter = 6, 10 do | |
| 1002 | draw_line(4, counter, 22, colors.white) | |
| 1003 | end | |
| 1004 | ||
| 1005 | draw_text(5, 5, "Reset Peripherals", colors.white, colors.purple) | |
| 1006 | draw_text(5, 7, "Open computer", colors.black, colors.white) | |
| 1007 | draw_text(5, 8, "terminal.", colors.black, colors.white) | |
| 1008 | setup_wizard() | |
| 1009 | ||
| 1010 | end | |
| 1011 | ||
| 1012 | --stop running status screen if monitors was touched | |
| 1013 | function stop() | |
| 1014 | while true do | |
| 1015 | local event, side, xPos, yPos = os.pullEvent("monitor_touch")
| |
| 1016 | x = xPos | |
| 1017 | y = yPos | |
| 1018 | stop_function = "monitor_touch" | |
| 1019 | return | |
| 1020 | end | |
| 1021 | end | |
| 1022 | ||
| 1023 | function mon_touch() | |
| 1024 | --when the monitor is touch on the homepage | |
| 1025 | if y == 1 then | |
| 1026 | if x < monX/3 then | |
| 1027 | power_menu() | |
| 1028 | local event, side, xPos, yPos = os.pullEvent("monitor_touch")
| |
| 1029 | if xPos < 9 then | |
| 1030 | if yPos == 2 then | |
| 1031 | reactor.setActive(true) | |
| 1032 | timer = 0 --reset anytime the reactor is turned on/off | |
| 1033 | call_homepage() | |
| 1034 | else if yPos == 3 then | |
| 1035 | reactor.setActive(false) | |
| 1036 | timer = 0 --reset anytime the reactor is turned on/off | |
| 1037 | call_homepage() | |
| 1038 | else if yPos == 4 then | |
| 1039 | auto_off() | |
| 1040 | else | |
| 1041 | call_homepage() | |
| 1042 | end | |
| 1043 | end | |
| 1044 | end | |
| 1045 | else | |
| 1046 | call_homepage() | |
| 1047 | end | |
| 1048 | ||
| 1049 | else if x < 20 then | |
| 1050 | tools_menu() | |
| 1051 | local event, side, xPos, yPos = os.pullEvent("monitor_touch")
| |
| 1052 | if xPos < 25 and xPos > 10 then | |
| 1053 | if yPos == 2 then | |
| 1054 | control_rods() | |
| 1055 | else if yPos == 3 then | |
| 1056 | efficiency() | |
| 1057 | else if yPos == 4 then | |
| 1058 | fuel() | |
| 1059 | else if yPos == 5 then | |
| 1060 | waste() | |
| 1061 | else | |
| 1062 | call_homepage() | |
| 1063 | end | |
| 1064 | end | |
| 1065 | end | |
| 1066 | end | |
| 1067 | else | |
| 1068 | call_homepage() | |
| 1069 | end | |
| 1070 | else if x < monX then | |
| 1071 | settings_menu() | |
| 1072 | local event, side, xPos, yPos = os.pullEvent("monitor_touch")
| |
| 1073 | if xPos > 13 then | |
| 1074 | if yPos == 2 then | |
| 1075 | update() | |
| 1076 | else if yPos == 3 then | |
| 1077 | reset_peripherals() | |
| 1078 | else | |
| 1079 | call_homepage() | |
| 1080 | end | |
| 1081 | end | |
| 1082 | else | |
| 1083 | call_homepage() | |
| 1084 | end | |
| 1085 | else | |
| 1086 | - | draw_line_term(1, 1, 55, colors.blue) |
| 1086 | + | call_homepage() |
| 1087 | - | draw_text_term(13, 1, "BigReactor Controls", colors.white, colors.blue) |
| 1087 | + | |
| 1088 | - | draw_line_term(1, 19, 55, colors.blue) |
| 1088 | + | |
| 1089 | - | draw_text_term(13, 19, "by SparkyBearBomb", colors.white, colors.blue) |
| 1089 | + | |
| 1090 | ||
| 1091 | else if y == 3 then | |
| 1092 | if x > 9 and x < 17 then | |
| 1093 | reactor.setActive(true) | |
| 1094 | timer = 0 --reset anytime the reactor is turned on/off | |
| 1095 | call_homepage() | |
| 1096 | else if x > 17 and x < 26 then | |
| 1097 | reactor.setActive(false) | |
| 1098 | timer = 0 --reset anytime the reactor is turned on/off | |
| 1099 | call_homepage() | |
| 1100 | else | |
| 1101 | call_homepage() | |
| 1102 | end | |
| 1103 | end | |
| 1104 | else | |
| 1105 | call_homepage() | |
| 1106 | end | |
| 1107 | end | |
| 1108 | end | |
| 1109 | ||
| 1110 | ||
| 1111 | function terminal_screen() | |
| 1112 | term.clear() | |
| 1113 | draw_line_term(1, 1, 55, colors.purple) | |
| 1114 | draw_text_term(13, 1, "BigReactor Controls", colors.white, colors.purple) | |
| 1115 | draw_line_term(1, 19, 55, colors.purple) | |
| 1116 | draw_text_term(13, 19, "by SparkyBearBomb", colors.white, colors.purple) | |
| 1117 | ||
| 1118 | draw_text_term(1, 3, "Current program:", colors.white, colors.black) | |
| 1119 | draw_text_term(1, 4, "Reactor Control v"..version, colors.blue, colors.black) | |
| 1120 | ||
| 1121 | draw_text_term(1, 6, "Installer:", colors.white, colors.black) | |
| 1122 | - | draw_line_term(1, 1, 55, colors.blue) |
| 1122 | + | |
| 1123 | - | draw_text_term(10, 1, "BigReactors Controls", colors.white, colors.blue) |
| 1123 | + | |
| 1124 | draw_text_term(1, 9, "Please give me your feedback, suggestions,", colors.white, colors.black) | |
| 1125 | - | draw_line_term(1, 19, 55, colors.blue) |
| 1125 | + | |
| 1126 | - | draw_text_term(10, 19, "by SparkyBearBomb", colors.white, colors.blue) |
| 1126 | + | |
| 1127 | draw_text_term(1, 11, "http://pastebin.com/u/Sparkybearbomb", colors.blue, colors.black) | |
| 1128 | end | |
| 1129 | ||
| 1130 | --run both homepage() and stop() until one returns | |
| 1131 | function call_homepage() | |
| 1132 | clear() | |
| 1133 | parallel.waitForAny(homepage, stop) | |
| 1134 | ||
| 1135 | if stop_function == "terminal_screen" then | |
| 1136 | stop_function = "nothing" | |
| 1137 | setup_wizard() | |
| 1138 | else if stop_function == "monitor_touch" then | |
| 1139 | stop_function = "nothing" | |
| 1140 | mon_touch() | |
| 1141 | end | |
| 1142 | end | |
| 1143 | end | |
| 1144 | ||
| 1145 | --test if the entered monitor and reactor can be wrapped | |
| 1146 | function test_configs() | |
| 1147 | - | draw_text_term(27, 5, "success", colors.lime, colors.black) |
| 1147 | + | |
| 1148 | ||
| 1149 | draw_line_term(1, 1, 55, colors.purple) | |
| 1150 | draw_text_term(10, 1, "BigReactors Controls", colors.white, colors.purple) | |
| 1151 | ||
| 1152 | draw_line_term(1, 19, 55, colors.purple) | |
| 1153 | draw_text_term(10, 19, "by SparkyBearBomb", colors.white, colors.purple) | |
| 1154 | ||
| 1155 | draw_text_term(1, 3, "Searching for a peripherals...", colors.white, colors.black) | |
| 1156 | sleep(1) | |
| 1157 | ||
| 1158 | reactor = reactorSearch() | |
| 1159 | mon = monitorSearch() | |
| 1160 | ||
| 1161 | - | draw_text_term(27, 6, "success", colors.lime, colors.black) |
| 1161 | + | |
| 1162 | draw_text_term(2, 5, "Connecting to reactor...", colors.white, colors.black) | |
| 1163 | sleep(0.5) | |
| 1164 | if reactor == null then | |
| 1165 | draw_text_term(1, 8, "Error:", colors.red, colors.black) | |
| 1166 | draw_text_term(1, 9, "Could not connect to reactor", colors.red, colors.black) | |
| 1167 | draw_text_term(1, 10, "Reactor must be connected with networking cable", colors.white, colors.black) | |
| 1168 | draw_text_term(1, 11, "and modems or the computer is directly beside", colors.white, colors.black) | |
| 1169 | - | draw_text_term(1, 9, "Setup Complete!", colors.lime, colors.black) |
| 1169 | + | |
| 1170 | draw_text_term(1, 14, "Press Enter to continue...", colors.gray, colors.black) | |
| 1171 | wait = read() | |
| 1172 | setup_wizard() | |
| 1173 | else | |
| 1174 | draw_text_term(27, 5, "success", colors.green, colors.black) | |
| 1175 | sleep(0.5) | |
| 1176 | end | |
| 1177 | ||
| 1178 | draw_text_term(2, 6, "Connecting to monitor...", colors.white, colors.black) | |
| 1179 | sleep(0.5) | |
| 1180 | if mon == null then | |
| 1181 | draw_text_term(1, 7, "Error:", colors.red, colors.black) | |
| 1182 | draw_text_term(1, 8, "Could not connect to a monitor. Place a 3x4 advanced monitor", colors.red, colors.black) | |
| 1183 | - | draw_text_term(1, 1, "BigReactor Controls v"..version, colors.lime, colors.black) |
| 1183 | + | |
| 1184 | wait = read() | |
| 1185 | - | draw_text_term(1, 4, "Step 1:", colors.lime, colors.black) |
| 1185 | + | |
| 1186 | else | |
| 1187 | - | draw_text_term(1, 7, "Step 2:", colors.lime, colors.black) |
| 1187 | + | |
| 1188 | draw_text_term(27, 6, "success", colors.green, colors.black) | |
| 1189 | sleep(0.5) | |
| 1190 | end | |
| 1191 | draw_text_term(2, 7, "saving configuration...", colors.white, colors.black) | |
| 1192 | ||
| 1193 | save_config() | |
| 1194 | ||
| 1195 | sleep(0.1) | |
| 1196 | draw_text_term(1, 9, "Setup Complete!", colors.green, colors.black) | |
| 1197 | sleep(1) | |
| 1198 | ||
| 1199 | auto = auto_string == "true" | |
| 1200 | call_homepage() | |
| 1201 | ||
| 1202 | end | |
| 1203 | ----------------SETUP------------------------------- | |
| 1204 | ||
| 1205 | - | if peripheral.getType(name) == "BigReactors-Reactor" then |
| 1205 | + | |
| 1206 | ||
| 1207 | term.clear() | |
| 1208 | ||
| 1209 | ||
| 1210 | draw_text_term(1, 1, "BigReactor Controls v"..version, colors.green, colors.black) | |
| 1211 | draw_text_term(1, 2, "Peripheral setup", colors.white, colors.black) | |
| 1212 | draw_text_term(1, 4, "Step 1:", colors.green, colors.black) | |
| 1213 | draw_text_term(1, 5, "-Place 3 wide x 4 tall advanced monitors next to computer.", colors.white, colors.black) | |
| 1214 | draw_text_term(1, 7, "Step 2:", colors.green, colors.black) | |
| 1215 | draw_text_term(1, 8, "-Place a wired modem on this computer and on the ", colors.white, colors.black) | |
| 1216 | draw_text_term(1, 9, " computer port of the reactor.", colors.white, colors.black) | |
| 1217 | draw_text_term(1, 10, "-connect modems with network cable.", colors.white, colors.black) | |
| 1218 | draw_text_term(1, 11, "-right click modems to activate.", colors.white, colors.black) | |
| 1219 | draw_text_term(1, 13, "Press Enter when ready...", colors.gray, colors.black) | |
| 1220 | ||
| 1221 | wait = read() | |
| 1222 | test_configs() | |
| 1223 | ||
| 1224 | ||
| 1225 | end | |
| 1226 | ||
| 1227 | -- peripheral searching thanks to /u/kla_sch | |
| 1228 | function reactorSearch() | |
| 1229 | local names = peripheral.getNames() | |
| 1230 | local i, name | |
| 1231 | for i, name in pairs(names) do | |
| 1232 | if peripheral.getType(name) == "bigger-reactor" then | |
| 1233 | return peripheral.wrap(name) | |
| 1234 | else | |
| 1235 | --return null | |
| 1236 | end | |
| 1237 | end | |
| 1238 | end | |
| 1239 | ||
| 1240 | function monitorSearch() | |
| 1241 | local names = peripheral.getNames() | |
| 1242 | local i, name | |
| 1243 | for i, name in pairs(names) do | |
| 1244 | if peripheral.getType(name) == "monitor" then | |
| 1245 | test = name | |
| 1246 | return peripheral.wrap(name) | |
| 1247 | else | |
| 1248 | --return null | |
| 1249 | end | |
| 1250 | end | |
| 1251 | end | |
| 1252 | ||
| 1253 | function start() | |
| 1254 | --if configs exists, load values and test | |
| 1255 | if fs.exists("config.txt") then
| |
| 1256 | load_config() | |
| 1257 | test_configs() | |
| 1258 | else | |
| 1259 | setup_wizard() | |
| 1260 | end | |
| 1261 | end | |
| 1262 | ||
| 1263 | start() |