Gintarus

Reactor

Jan 9th, 2026 (edited)
5
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.81 KB | None | 0 0
  1. local event = require("event")
  2. local term = require("term")
  3. local os = require("os")
  4. local com = require("component")
  5. local keyb = require("keyboard")
  6. local gpu = com.gpu
  7.  
  8. local fileName = "/home/gtadrs15.txt"
  9. local cfgName = "/home/DracReactorConfig.cfg"
  10.  
  11. local function parseNum(str)
  12. local n = ""
  13. for i=1,#str do
  14. local ch = str:byte(i,i)
  15. if ch >= 48 and ch <= 57 or ch == 46 then
  16. n = n..string.char(ch)
  17. end
  18. end
  19. if n ~= "" then
  20. return tonumber(n)
  21. else return n
  22. end
  23. end
  24.  
  25. local cfg = {}
  26. local confnames =
  27. {
  28. [1] = "default_interval",
  29. [2] = "ctrl_interval",
  30. [3] = "shift_interval",
  31. [4] = "ctrlShift_interval",
  32. [5] = "shield",
  33. [6] = "tempCriticalEdge",
  34. [7] = "forceModeTempLowEdge",
  35. [8] = "forceModeStepCase",
  36. [9] = "forceModeStep",
  37. [10] = "safeModeTempWaitEdge",
  38. [11] = "safeModeTempToWaitEdge",
  39. [12] = "safeModeStepCase",
  40. [13] = "safemodeStep"
  41. }
  42.  
  43. local function readParse(name)
  44. local file = io.open(name,"r")
  45. if file then
  46. local tab = {}
  47. local i = 1
  48. while true do
  49. local str = file:read("*l")
  50. if str == nil then
  51. break
  52. end
  53. if parseNum(str) ~= "" then
  54. tab[i] = parseNum(str)
  55. i=i+1
  56. end
  57. end
  58. return tab
  59. else
  60. return false
  61. end
  62. end
  63.  
  64. local function configWrite(name)
  65. if not readParse(name) then
  66. local file = io.open(name,"w")
  67. file:write([[
  68. -- Интервалы для кнопок +/-
  69. default_interval = 1000
  70. ctrl_interval = 5000
  71. shift_interval = 10000
  72. ctrlShift_interval = 20000
  73. -- Автономный режим:
  74. -- Основные константы
  75. shield = 25 - Щиты будут автоматически поддерживаться на этом уровне ( в %)
  76. tempCriticalEdge = 8100 -- Если температура превысит это значение, программа экстренно понизит поток вывода;
  77. -- Форсированный режим
  78. forceModeTempLowEdge = 7500 -- Пока температура не превысит это значение, программа будет работать в форсированном режиме, иначе - перейдет в безопасный режим;
  79. forceModeStepCase = 5000 -- Если разница между текущей выработкой энергии и выставленным потоком превысит это значение, то к потоку добавится
  80. forceModeStep = 20000 -- это значение
  81. -- безопасный режим
  82. safeModeTempWaitEdge = 8000 -- Если температура превысит это значение, программа будет ожидать,
  83. safeModeTempToWaitEdge = 7850 -- пока температура не понизится до этого значения;
  84. safeModeStepCase = 0 -- Если разница между текущей выработкой энергии и выставленным потоком превысит это значение, то к потоку добавится
  85. safemodeStep = 8000 -- это значение]])
  86. file:close()
  87. elseif #readParse(name) < 13 then
  88. local file = io.open(name,"w")
  89. file:write([[
  90. -- Интервалы для кнопок +/-
  91. default_interval = 1000
  92. ctrl_interval = 5000
  93. shift_interval = 10000
  94. ctrlShift_interval = 20000
  95. -- Автономный режим:
  96. -- Основные константы
  97. shield = 25 - Щиты будут автоматически поддерживаться на этом уровне ( в %)
  98. tempCriticalEdge = 8100 -- Если температура превысит это значение, программа экстренно понизит поток вывода;
  99. -- Форсированный режим
  100. forceModeTempLowEdge = 7500 -- Пока температура не превысит это значение, программа будет работать в форсированном режиме, иначе - перейдет в безопасный режим;
  101. forceModeStepCase = 5000 -- Если разница между текущей выработкой энергии и выставленным потоком превысит это значение, то к потоку добавится
  102. forceModeStep = 20000 -- это значение
  103. -- безопасный режим
  104. safeModeTempWaitEdge = 8000 -- Если температура превысит это значение, программа будет ожидать,
  105. safeModeTempToWaitEdge = 7850 -- пока температура не понизится до этого значения;
  106. safeModeStepCase = 0 -- Если разница между текущей выработкой энергии и выставленным потоком превысит это значение, то к потоку добавится
  107. safemodeStep = 8000 -- это значение]])
  108. file:close()
  109. elseif cfg.default_interval ~= nil and
  110. cfg.ctrl_interval ~= nil and
  111. cfg.shift_interval ~= nil and
  112. cfg.ctrlShift_interval ~= nil and
  113. cfg.shield ~= nil and
  114. cfg.tempCriticalEdge ~= nil and
  115. cfg.forceModeTempLowEdge ~= nil and
  116. cfg.forceModeStepCase ~= nil and
  117. cfg.forceModeStep ~= nil and
  118. cfg.safeModeTempWaitEdge ~= nil and
  119. cfg.safeModeTempToWaitEdge ~= nil and
  120. cfg.safeModeStepCase ~= nil and
  121. cfg.safemodeStep ~= nil then
  122.  
  123. local file = io.open(name,"w")
  124. file:write(string.format(
  125. [[
  126. -- Интервалы для кнопок +/-
  127. default_interval = %d
  128. ctrl_interval = %d
  129. shift_interval = %d
  130. ctrlShift_interval = %d
  131. -- Автономный режим:
  132. -- Основные константы
  133. shield = %0.2f - Щиты будут автоматически поддерживаться на этом уровне ( в %)
  134. tempCriticalEdge = %d -- Если температура превысит это значение, программа экстренно понизит поток вывода;
  135. -- Форсированный режим
  136. forceModeTempLowEdge = %d -- Пока температура не превысит это значение, программа будет работать в форсированном режиме, иначе - перейдет в безопасный режим;
  137. forceModeStepCase = %d -- Если разница между текущей выработкой энергии и выставленным потоком превысит это значение, то к потоку добавится
  138. forceModeStep = %d -- это значение
  139. -- Безопасный режим
  140. safeModeTempWaitEdge = %d -- Если температура превысит это значение, программа будет ожидать,
  141. safeModeTempToWaitEdge = %d -- пока температура не понизится до этого значения;
  142. safeModeStepCase = %d -- Если разница между текущей выработкой энергии и выставленным потоком превысит это значение, то к потоку добавится
  143. safemodeStep = %d -- это значение]],
  144. cfg.default_interval,
  145. cfg.ctrl_interval,
  146. cfg.shift_interval,
  147. cfg.ctrlShift_interval,
  148. cfg.shield,
  149. cfg.tempCriticalEdge,
  150. cfg.forceModeTempLowEdge,
  151. cfg.forceModeStepCase,
  152. cfg.forceModeStep,
  153. cfg.safeModeTempWaitEdge,
  154. cfg.safeModeTempToWaitEdge,
  155. cfg.safeModeStepCase,
  156. cfg.safemodeStep
  157. ))
  158. file:close()
  159. end
  160. end
  161.  
  162. local function makeConfig(tab,tab2)
  163. local config = {}
  164. for i=1,#tab do
  165. config[i] = i
  166. end
  167. local iter = 1
  168. for k,v in pairs(config) do
  169. k = tab[iter]
  170. v = tab2[iter]
  171. config[tostring(k)] = v
  172. iter = iter + 1
  173. end
  174. for i=1,#tab do
  175. config[i] = nil
  176. end
  177. return config
  178. end
  179.  
  180. local function fileCreate(name)
  181. local file = io.open(name,"a")
  182. file:close()
  183. end
  184.  
  185. configWrite(cfgName)
  186. cfg = makeConfig(confnames,readParse(cfgName))
  187.  
  188. local function fileWrite(name,uadr,dadr)
  189. local file = io.open(name,"w")
  190. file:write(uadr.."\n"..dadr.."\n")
  191. file:close()
  192. end
  193.  
  194. local function fileRead(name)
  195. local file = io.open(name,"r")
  196. local uadr,dadr = file:read("*l","*l")
  197. file:close()
  198. return uadr,dadr
  199. end
  200.  
  201. local color = { }
  202. color["red"] = 0xFF0000
  203. color["green"] = 0x00FF00
  204. color["yellow"] = 0xFFFF00
  205. color["skyblue"] = 0x00FFFF
  206. color["black"] = 0x000000
  207. color["grey"] = 0xC0C0C0
  208. color["blue"] = 0x000080
  209. color["white"] = 0xFFFFFF
  210.  
  211. local rback = gpu.getBackground()
  212. local rfore = gpu.getForeground()
  213.  
  214. local handleMain
  215. local handleOptions
  216. local handleStart
  217.  
  218. local menuItem = {}
  219. menuItem["options"] =
  220. {
  221. ["name"] ="Настройки |",
  222. ["x"] = 1,
  223. ["y"] = 2
  224. }
  225. menuItem["save"] =
  226. {
  227. ["name"] ="Сохранить |",
  228. ["x"] = 1,
  229. ["y"] = 2
  230. }
  231. menuItem["cancel"] =
  232. {
  233. ["name"] =" Отменить",
  234. ["x"] = 12,
  235. ["y"] = 2
  236. }
  237.  
  238. local xz,yz = gpu.maxResolution()
  239. gpu.setResolution(80,25)
  240.  
  241. gpu.setBackground(0xF0F0F0)
  242. gpu.setForeground(0x000000)
  243.  
  244. local prog = true
  245. local addCord = {}
  246. local subCord = {}
  247. local num = {}
  248. num["name"] = "Число : "
  249. num["value"] = 0
  250. local OptionDefault = {}
  251. local OptionCtrl = {}
  252. local OptionShift = {}
  253. local OptionCtrlShift = {}
  254. local OptionShield = {}
  255. OptionDefault["value"] = cfg.default_interval
  256. OptionCtrl["value"] = cfg.ctrl_interval
  257. OptionShift["value"] = cfg.shift_interval
  258. OptionCtrlShift["value"] = cfg.ctrlShift_interval
  259. OptionShield["value"] = cfg.shield
  260.  
  261. local flux = {}
  262. flux["up"] =
  263. {
  264. ["adr"] = nil,
  265. ["x"] = nil,
  266. ["y"] = nil
  267. }
  268. flux["down"] =
  269. {
  270. ["adr"] = nil,
  271. ["x"] = nil,
  272. ["y"] = nil
  273. }
  274.  
  275. local infcord =
  276. {
  277. ["status"] =
  278. {
  279. ["value"] = nil,
  280. ["x"] = nil,
  281. ["y"] = nil
  282. },
  283. ["temp"] =
  284. {
  285. ["value"] = nil,
  286. ["x"] = nil,
  287. ["y"] = nil
  288. },
  289. ["generation"] =
  290. {
  291. ["value"] = nil,
  292. ["x"] = nil,
  293. ["y"] = nil
  294. },
  295. ["maxgen"] =
  296. {
  297. ["value"] = nil,
  298. ["x"] = nil,
  299. ["y"] = nil
  300. },
  301. ["flow"] =
  302. {
  303. ["value"] = nil,
  304. ["x"] = nil,
  305. ["y"] = nil
  306. },
  307. ["puregen"] =
  308. {
  309. ["value"] = nil,
  310. ["x"] = nil,
  311. ["y"] = nil
  312. },
  313. ["drain"] =
  314. {
  315. ["value"] = nil,
  316. ["x"] = nil,
  317. ["y"] = nil
  318. },
  319. ["fstrth"] =
  320. {
  321. ["value"] = nil,
  322. ["x"] = nil,
  323. ["y"] = nil
  324. },
  325. ["esturn"] =
  326. {
  327. ["value"] = nil,
  328. ["x"] = nil,
  329. ["y"] = nil
  330. },
  331. ["fuel"] =
  332. {
  333. ["value"] = nil,
  334. ["x"] = nil,
  335. ["y"] = nil
  336. },
  337. ["fuelconv"] =
  338. {
  339. ["value"] = nil,
  340. ["x"] = nil,
  341. ["y"] = nil
  342. },
  343. ["core"] =
  344. {
  345. ["value"] = nil,
  346. ["x"] = nil,
  347. ["y"] = nil
  348. }
  349. }
  350.  
  351. local button =
  352. {
  353. ["continue"] =
  354. {
  355. ["name"] = "Продолжить",
  356. ["x"] = nil,
  357. ["y"] = nil
  358. },
  359. ["change"] =
  360. {
  361. ["name"] = "Изменить",
  362. ["x"] = nil,
  363. ["y"] = nil
  364. },
  365. ["add"] =
  366. {
  367. ["name"] = " + ",
  368. ["x"] = nil,
  369. ["y"] = nil
  370. },
  371. ["sub"] =
  372. {
  373. ["name"] = " - ",
  374. ["x"] = nil,
  375. ["y"] = nil
  376. },
  377. ["start"] =
  378. {
  379. ["name"] = "Запустить реактор",
  380. ["x"] = nil,
  381. ["y"] = nil,
  382. ["visible"] = nil
  383. },
  384. ["stop"] =
  385. {
  386. ["name"] = "Выключить реактор",
  387. ["x"] = nil,
  388. ["y"] = nil,
  389. ["visible"] = nil
  390. },
  391. ["charge"] =
  392. {
  393. ["name"] = "Зарядить реактор ",
  394. ["x"] = nil,
  395. ["y"] = nil,
  396. ["visible"] = nil
  397. },
  398. ["autoon"] =
  399. {
  400. ["name"] = "Включен",
  401. ["x"] = nil,
  402. ["y"] = nil,
  403. },
  404. ["autooff"] =
  405. {
  406. ["name"] = "Выключен",
  407. ["x"] = nil,
  408. ["y"] = nil,
  409. }
  410. }
  411.  
  412. local ops = true
  413. local upchoose = true
  414. local downchoose = true
  415. local conf = false
  416. local buts = false
  417. local canedit = true
  418. local canclose = true
  419. local temprise
  420. local autostate = false
  421. local maxGenerationRate = 0
  422.  
  423. local upadr = nil
  424. local downadr = nil
  425.  
  426. printf = function (s,...)
  427. return io.write(s:format(...))
  428. end
  429.  
  430. local function guiWrite(x,y,cf,cb,s,...)
  431. term.setCursor(x,y)
  432. if cf >=0 and cb >=0 then
  433. local fg = gpu.getForeground()
  434. local bg = gpu.getBackground()
  435. gpu.setForeground(cf)
  436. gpu.setBackground(cb)
  437. printf(s,...)
  438. gpu.setForeground(fg)
  439. gpu.setBackground(bg)
  440. elseif cb <0 and cf>=0 then
  441. local fg = gpu.getForeground()
  442. gpu.setForeground(cf)
  443. printf(s,...)
  444. gpu.setForeground(fg)
  445. elseif cf < 0 and cb >= 0 then
  446. local bg = gpu.getBackground()
  447. printf(s,...)
  448. gpu.setBackground(bg)
  449. else
  450. printf(s,...)
  451. end
  452. end
  453.  
  454. local function getCord(param)
  455. param.x,param.y = term.getCursor()
  456. return param.x,param.y
  457. end
  458.  
  459. local function guiClear(y)
  460. local fg = gpu.getForeground()
  461. local bg = gpu.getBackground()
  462. gpu.setForeground(color.black)
  463. gpu.setBackground(color.grey)
  464. for i=y+3,3,-1 do
  465. term.setCursor(1,i)
  466. term.clearLine()
  467. end
  468. gpu.setForeground(fg)
  469. gpu.setBackground(bg)
  470. end
  471.  
  472. local function makeButton(x,y,text)
  473. term.setCursor(x,y)
  474. local fg = gpu.getForeground()
  475. local bg = gpu.getBackground()
  476. gpu.setBackground(0x000000)
  477. gpu.setForeground(0xFFFFFF)
  478. printf(text)
  479. gpu.setBackground(bg)
  480. gpu.setForeground(fg)
  481.  
  482. end
  483.  
  484. local function show(fc,bc,param)
  485. local fg = gpu.getForeground()
  486. local bg = gpu.getBackground()
  487. term.setCursor(param.x,param.y)
  488. gpu.setForeground(fc)
  489. gpu.setBackground(bc)
  490. local st = " "
  491. for i = 0,#tostring(param.value) do
  492. st=st.." "
  493. end
  494. gpu.set(param.x,param.y,st)
  495. printf("%d",param.value)
  496. gpu.setForeground(fg)
  497. gpu.setBackground(bg)
  498. end
  499.  
  500. local function numformat(n)
  501. local s = tostring(n)
  502. if n >= 1000 and n < 1000000 then
  503. local t = s:sub(1,#s-3)
  504. local e = s:sub(#s-2)
  505. s = t.." "..e.." "
  506. return s
  507. elseif n >= 1000000 then
  508. local m = s:sub(1,#s-6)
  509. local t = s:sub(#s-5,#s-3)
  510. local e = s:sub(#s-2)
  511. s = m.." "..t.." "..e.." "
  512. return s
  513. else
  514. s=s.." "
  515. return s
  516. end
  517. end
  518.  
  519. local function coreformat()
  520. local num = com.draconic_rf_storage.getEnergyStored()
  521. if num > 10^12 then
  522. return string.format(" Накоплено в ядре: %0.3f T \n",num/10^12)
  523. elseif num > 10^9 then
  524. return string.format(" Накоплено в ядре: %0.3f B \n",num/10^9)
  525. elseif num > 10^6 then
  526. return string.format(" Накоплено в ядре: %0.3f M \n",num/10^6)
  527. elseif num > 10^3 then
  528. return string.format(" Накоплено в ядре: %0.3f K \n",num/10^3)
  529. else
  530. return string.format(" Накоплено в ядре: %d \n",num)
  531. end
  532. end
  533.  
  534. -- Анализ и корректировка запомненных адресов
  535. local function proxyCheck()
  536. flux.up.adr,flux.down.adr = fileRead(fileName)
  537. if flux.up.adr ~= nil and flux.down.adr ~= nil then
  538. if com.get(flux.up.adr) ~= nil and com.get(flux.down.adr) ~=nil then
  539. return true
  540. elseif com.get(flux.up.adr) == nil and com.get(flux.down.adr) == nil then
  541. flux.up.adr = nil
  542. flux.down.adr = nil
  543. return false
  544. elseif com.get(flux.up.adr) == nil then
  545. for adrs in com.list("flux_gate") do
  546. if adrs ~= flux.down.adr then
  547. flux.up.adr = adrs
  548. end
  549. end
  550. fileWrite(fileName,flux.up.adr,flux.down.adr)
  551. return true
  552. elseif com.get(flux.down.adr) == nil then
  553. for adrs in com.list("flux_gate") do
  554. if adrs ~= flux.up.adr then
  555. flux.down.adr = adrs
  556. end
  557. end
  558. fileWrite(fileName,flux.up.adr,flux.down.adr)
  559. return true
  560. end
  561. end
  562. end
  563.  
  564. local function checkButtons()
  565. local inf = reactor.getReactorInfo()
  566. infcord.status.value = inf.status
  567. if infcord.status.value == "offline" then
  568. guiWrite(button.charge.x,button.charge.y,color.skyblue,color.black,"%s",button.charge.name)
  569. button.charge.visible = true
  570. elseif infcord.status.value == "stopping" then
  571. if (inf.energySaturation/inf.maxEnergySaturation)*100 >=50 and (inf.fieldStrength/inf.maxFieldStrength)*100 >= 50 and inf.temperature > 2000 then
  572. guiWrite(button.start.x,button.start.y,color.green,color.black,"%s",button.start.name)
  573. button.start.visible = true
  574. elseif infcord.status.value ~= "charging" then
  575. guiWrite(button.charge.x,button.charge.y,color.skyblue,color.black,"%s",button.charge.name)
  576. button.charge.visible = true
  577. end
  578. elseif infcord.status.value == "online" or infcord.status.value == "charging" then
  579. guiWrite(button.stop.x,button.stop.y,color.red,color.black,"%s",button.stop.name)
  580. button.stop.visible = true
  581. elseif infcord.status.value == "charged" then
  582. guiWrite(button.start.x,button.start.y,color.green,color.black,"%s",button.start.name)
  583. button.start.visible = true
  584. guiWrite(button.stop.x,button.stop.y,color.red,color.black,"%s",button.stop.name)
  585. button.stop.visible = true
  586. end
  587. end
  588. -- Инициализация программы, анализ и настройка всей технической белеберды
  589. local function screenStart()
  590. handleMain = false
  591. handleOptions = false
  592. handleStart = true
  593. local x,y = gpu.getResolution()
  594. gpu.setBackground(0xC0C0C0)
  595. gpu.setForeground(0x000000)
  596. term.clear()
  597. gpu.setBackground(0x000080)
  598. gpu.setForeground(0xFFFFFF)
  599. term.clearLine()
  600. printf("Draconic reactor control made by Freeazzy from McSkill.ru (Preparation)\n")
  601. gpu.setBackground(0xFFFFFF)
  602. gpu.setForeground(0x000000)
  603. term.clearLine()
  604. printf("Это страница для настройки программы при первом запуске или после сбоя")
  605. gpu.setBackground(0xFF0000)
  606. gpu.set(x-2,1," X ")
  607. gpu.setBackground(0xC0C0C0)
  608. term.setCursor(1,4)
  609. if not com.isAvailable("draconic_reactor") then
  610. printf("подключите адаптер к стабилизатору реактора")
  611. while not com.isAvailable("draconic_reactor") do
  612. os.sleep(0)
  613. if not ops then return end
  614. end
  615. guiClear(2)
  616. end
  617. reactor = com.draconic_reactor
  618. local i = 0
  619. for address in com.list("flux_gate") do
  620. i=i+1
  621. end
  622. if i<2 then
  623. printf("Подключите адаптеры к обоим флюкс-гейтам")
  624.  
  625. while true do
  626. if not ops then return end
  627. i=0
  628. for address in com.list("flux_gate") do
  629. i=i+1
  630. end
  631. if i == 2 then
  632. break
  633. end
  634. os.sleep(0)
  635. end
  636. guiClear(2)
  637. end
  638. proxyCheck()
  639. if flux.up.adr == nil or flux.down.adr == nil then
  640. while not conf do
  641. buts = false
  642. if not ops then return end
  643. i=1
  644. flux[1]=
  645. {
  646. ["adr"]=nil,
  647. ["x"]=nil,
  648. ["y"]=nil
  649. }
  650. flux[2]=
  651. {
  652. ["adr"]=nil,
  653. ["x"]=nil,
  654. ["y"]=nil
  655. }
  656. printf(" Адреса подключенных флюкс-гейтов\n\n")
  657. for adr in com.list("flux_gate") do
  658. flux[i].x,flux[i].y = term.getCursor()
  659. flux[i].adr = adr
  660. printf (" "..flux[i].adr.."\n\n")
  661. i=i+1
  662. end
  663. printf(" Выберите адрес флюкс-гейта, отвечающего за выработку энергии\n")
  664.  
  665. while upchoose do
  666. os.sleep(0)
  667. if not ops then return end
  668. end
  669. printf(" Выберите адрес флюкс-гейта, отвечающего за стабилизацию реактора\n")
  670.  
  671. while downchoose do
  672. os.sleep(0)
  673. if not ops then return end
  674. end
  675. printf("\n адрес энергетического гейта : %s\n",flux.up.adr)
  676. printf(" адрес стабилизирующего гейта : %s\n",flux.down.adr)
  677.  
  678. if reactor.getReactorInfo().status == "offline" then
  679. com.proxy(com.get(flux.up.adr)).setSignalHighFlow(0)
  680. com.proxy(com.get(flux.up.adr)).setSignalLowFlow(535000)
  681. com.proxy(com.get(flux.down.adr)).setOverrideEnabled(true)
  682. end
  683.  
  684. button.continue.x,button.continue.y = term.getCursor()
  685. makeButton(button.continue.x+8,button.continue.y+1,button.continue.name)
  686. button.change.x,button.change.y = term.getCursor()
  687. makeButton(button.change.x+2,button.change.y,button.change.name)
  688. while not buts do
  689. os.sleep(0)
  690. if not ops then return end
  691. end
  692. if flux.up.adr ~= nil and flux.down.adr ~= nil then
  693. upgate = com.proxy(com.get(flux.up.adr))
  694. downgate = com.proxy(com.get(flux.down.adr))
  695. fileWrite(fileName,flux.up.adr,flux.down.adr)
  696. end
  697. end
  698. else
  699. upgate = com.proxy(com.get(flux.up.adr))
  700. downgate = com.proxy(com.get(flux.down.adr))
  701. end
  702.  
  703. end
  704. -- Экран настроек
  705. local function screenOptions()
  706. handleMain = false
  707. handleStart = false
  708. handleOptions = true
  709. local x,y = gpu.getResolution()
  710. gpu.setBackground(0xC0C0C0)
  711. gpu.setForeground(0x000000)
  712. term.clear()
  713. gpu.setBackground(0x000080)
  714. gpu.setForeground(0xFFFFFF)
  715. term.clearLine()
  716. printf("Draconic reactor control made by Freeazzy from McSkill.ru (Options)\n")
  717. gpu.setBackground(0xFFFFFF)
  718. gpu.setForeground(0x000000)
  719. term.clearLine()
  720. menuItem.save.x,menuItem.save.y =term.getCursor()
  721. printf(menuItem.save.name)
  722. menuItem.cancel.x,menuItem.cancel.y =term.getCursor()
  723. printf(menuItem.cancel.name)
  724. gpu.setBackground(0xFF0000)
  725. gpu.set(x-2,1," X ")
  726. gpu.setBackground(0xC0C0C0)
  727. term.setCursor(1,4)
  728. printf(" Интервал для щелчка: ")
  729. OptionDefault["x"],OptionDefault["y"] = term.getCursor()
  730. printf("%d\n",OptionDefault.value)
  731. printf(" Интервал для CTRL: ")
  732. OptionCtrl["x"],OptionCtrl["y"] = term.getCursor()
  733. printf("%d\n",OptionCtrl.value)
  734. printf(" Интервал для SHIFT: ")
  735. OptionShift["x"],OptionShift["y"] = term.getCursor()
  736. printf("%d\n",OptionShift.value)
  737. printf(" Интервал для CTRL+SHIFT: ")
  738. OptionCtrlShift["x"],OptionCtrlShift["y"] = term.getCursor()
  739. printf("%d\n",OptionCtrlShift.value)
  740. printf(" Уровень щитов: ")
  741. OptionShield["x"],OptionShield["y"] = term.getCursor()
  742. printf("%d\n",OptionShield.value)
  743. end
  744. -- Инициализация главного экрана
  745. local function screenMain()
  746. handleOptions = false
  747. handleStart = false
  748. handleMain = true
  749. local x,y = gpu.getResolution()
  750. local inf = reactor.getReactorInfo()
  751. infcord.status.value = inf.status
  752. gpu.setBackground(0xC0C0C0)
  753. gpu.setForeground(0x000000)
  754. term.clear()
  755. gpu.setBackground(0x000080)
  756. gpu.setForeground(0xFFFFFF)
  757. term.clearLine()
  758. printf("GintaRus THE BEST!!!")
  759. gpu.setBackground(0xFFFFFF)
  760. gpu.setForeground(0x000000)
  761. term.clearLine()
  762. menuItem.options.x,menuItem.options.y =term.getCursor()
  763. printf(menuItem.options.name)
  764. gpu.setBackground(0xFF0000)
  765. gpu.set(x-2,1," X ")
  766. gpu.setBackground(0xC0C0C0)
  767. term.setCursor(1,4)
  768. gpu.setBackground(0x909090)
  769. printf(" Температура: ")
  770. gpu.setBackground(0xC0C0C0)
  771. printf(" ")
  772. getCord(infcord.temp)
  773. guiWrite(infcord.temp.x,infcord.temp.y,-1,-1,"%0.2f\n",inf.temperature)
  774. printf(" Вырабатывает: ")
  775. getCord(infcord.generation)
  776. guiWrite(infcord.generation.x,infcord.generation.y,-1,-1,"%s \n",numformat(inf.generationRate))
  777. printf(" Max gen rate: ")
  778. getCord(infcord.maxgen)
  779. if inf.generationRate > maxGenerationRate then
  780. maxGenerationRate = inf.generationRate
  781. end
  782. guiWrite(infcord.maxgen.x,infcord.maxgen.y,-1,-1,"%s \n",numformat(maxGenerationRate))
  783. gpu.setBackground(0x909090)
  784. printf (" Поток: ")
  785. gpu.setBackground(0xC0C0C0)
  786. printf(" ")
  787. getCord(infcord.flow)
  788. infcord.flow.value = upgate.getFlow()
  789. guiWrite(infcord.flow.x,infcord.flow.y,-1,-1,"%s ",numformat(infcord.flow.value))
  790. getCord(button.add)
  791. makeButton(button.add.x + 4, button.add.y ,button.add.name)
  792. getCord(button.sub)
  793. makeButton(button.sub.x+2,button.sub.y,button.sub.name)
  794.  
  795. printf("\n")
  796. printf (" Итоговая мосч: ")
  797. getCord(infcord.puregen)
  798. guiWrite(infcord.puregen.x,infcord.puregen.y,-1,-1,"%s \n",numformat(inf.generationRate - downgate.getFlow()))
  799. gpu.setBackground(0x909090)
  800. printf (" Поглощает: ")
  801. gpu.setBackground(0xC0C0C0)
  802. printf(" ")
  803. getCord(infcord.drain)
  804. guiWrite(infcord.drain.x,infcord.drain.y,-1,-1,"%s \n",numformat(downgate.getFlow()))
  805.  
  806. printf (" Мощность поля: ")
  807. getCord(infcord.fstrth)
  808. if inf.maxFieldStrength > 0 then
  809. guiWrite(infcord.fstrth.x,infcord.fstrth.y,-1,-1,"%d / %d (%0.2f %%) \n",inf.fieldStrength -inf.fieldDrainRate,inf.maxFieldStrength,((inf.fieldStrength-inf.fieldDrainRate)/inf.maxFieldStrength)*100)
  810. else
  811. guiWrite(infcord.fstrth.x,infcord.fstrth.y,-1,-1,"0 / 0 (0 %%) \n")
  812. end
  813. gpu.setBackground(0x909090)
  814. printf (" Насыщенность: ")
  815. gpu.setBackground(0xC0C0C0)
  816. printf(" ")
  817. getCord(infcord.esturn)
  818. if inf.maxEnergySaturation > 0 then
  819. guiWrite(infcord.esturn.x,infcord.esturn.y,-1,-1,"%d / %d (%0.2f %%) \n",inf.energySaturation,inf.maxEnergySaturation,(inf.energySaturation/inf.maxEnergySaturation)*100)
  820. else
  821. guiWrite(infcord.esturn.x,infcord.esturn.y,-1,-1,"0 / 0 (0 %%) \n")
  822. end
  823. printf (" топливо: ")
  824. getCord(infcord.fuel)
  825.  
  826. if inf.fuelConversion/inf.maxFuelConversion < 0.78 then
  827. guiWrite(infcord.fuel.x,infcord.fuel.y,-1,-1,"%d / %d (%0.2f %%) \n",inf.fuelConversion,inf.maxFuelConversion,(inf.fuelConversion/inf.maxFuelConversion)*100)
  828. else
  829. if inf.maxFuelConversion > 0 then
  830. if inf.status == "online" or inf.status == "charging" or inf.status == "charged" then
  831. guiWrite(infcord.fuel.x,infcord.fuel.y,color.red,-1,"%d / %d (%0.2f %%) Критический уровень топлива\n",inf.fuelConversion,inf.maxFuelConversion,(inf.fuelConversion/inf.maxFuelConversion)*100)
  832. else
  833. guiWrite(infcord.fuel.x,infcord.fuel.y,-1,-1,"%d / %d (%0.2f %%) Критический уровень топлива\n",inf.fuelConversion,inf.maxFuelConversion,(inf.fuelConversion/inf.maxFuelConversion)*100)
  834. end
  835. else
  836. guiWrite(infcord.fuel.x,infcord.fuel.y,-1,-1,"0 / 0 (0 %%) \n")
  837. end
  838. end
  839. gpu.setBackground(0x909090)
  840. printf (" расход топлива: ")
  841. gpu.setBackground(0xC0C0C0)
  842. printf(" ")
  843. getCord(infcord.fuelconv)
  844. guiWrite(infcord.fuelconv.x,infcord.fuelconv.y,-1,-1,"%d\n",inf.fuelConversionRate)
  845.  
  846. getCord(infcord.core)
  847. if com.isAvailable("draconic_rf_storage") then
  848. guiWrite(infcord.core.x,infcord.core.y,-1,-1,coreformat())
  849. end
  850. printf("\n")
  851. getCord(button.stop)
  852. getCord(button.start)
  853. getCord(button.charge)
  854. button.start.y = button.stop.y+2
  855. button.charge.y = button.stop.y +2
  856. printf(" Автономный режим: ")
  857. getCord(button.autoon)
  858. getCord(button.autooff)
  859. if not autostate then
  860. guiWrite(button.autooff.x,button.autooff.y,color.red,color.black,"%s\n",button.autooff.name)
  861. else
  862. guiWrite(button.autoon.x,button.autoon.y,color.green,color.black,"%s\n",button.autoon.name)
  863. end
  864. checkButtons()
  865.  
  866. end
  867. local screen = {}
  868. screen["main"] = screenMain
  869. screen["options"] = screenOptions
  870.  
  871. local function editOption(param)
  872. local rd = true
  873. while rd do
  874. gpu.fill(param.x, param.y, #tostring(param.value), 1, " ")
  875. term.setCursor(param.x,param.y)
  876.  
  877. param.value = term.read(false,false)
  878. local val = tonumber(param.value)
  879. if val then
  880. show(color.black,color.grey,param)
  881. rd = false
  882. end
  883. end
  884. canedit = true
  885. canclose = true
  886. screen.options()
  887. end
  888.  
  889. local function add(n,i)
  890. n.value=n.value+i
  891. upgate.setSignalLowFlow(n.value)
  892. return n.value
  893. end
  894.  
  895. local function sub(n,i)
  896. term.setCursor(n.x,n.y)
  897. n.value=n.value-i
  898. return n.value
  899. end
  900. -- Обновление информации на экране + анализ поведения температуры
  901. local function refreshInfo()
  902. local inf = reactor.getReactorInfo()
  903. infcord.status.value = inf.status
  904. local tbuf1 = inf.temperature
  905. os.sleep(0.1)
  906. local tbuf2 = reactor.getReactorInfo().temperature
  907. if handleMain then
  908. if tbuf2>tbuf1 then
  909. guiWrite(infcord.temp.x,infcord.temp.y,color.red,-1,"%0.2f \n",inf.temperature)
  910. temprise = true
  911. elseif tbuf2<tbuf1 then
  912. guiWrite(infcord.temp.x,infcord.temp.y,color.blue,-1,"%0.2f \n",inf.temperature)
  913. temprise = false
  914. else
  915. if inf.temperature == 2000 then
  916. guiWrite(infcord.temp.x,infcord.temp.y,-1,-1,"%0.2f \n",inf.temperature)
  917. end
  918. end
  919. guiWrite(infcord.generation.x,infcord.generation.y,-1,-1,"%s\n",numformat(inf.generationRate))
  920. if inf.generationRate > maxGenerationRate then
  921. maxGenerationRate = inf.generationRate
  922. end
  923. guiWrite(infcord.maxgen.x,infcord.maxgen.y,-1,-1,"%s\n",numformat(maxGenerationRate))
  924. infcord.flow.value = upgate.getFlow()
  925. guiWrite(infcord.flow.x,infcord.flow.y,-1,-1,"%s",numformat(infcord.flow.value))
  926. guiWrite(infcord.puregen.x,infcord.puregen.y,-1,-1,"%s\n",numformat(inf.generationRate - downgate.getFlow()))
  927. infcord.drain.value = inf.fieldDrainRate
  928. guiWrite(infcord.drain.x,infcord.drain.y,-1,-1,"%s\n",numformat(downgate.getFlow()))
  929. if inf.maxFieldStrength > 0 then
  930. guiWrite(infcord.fstrth.x,infcord.fstrth.y,-1,-1,"%d / %d (%0.2f %%) \n",inf.fieldStrength-inf.fieldDrainRate,inf.maxFieldStrength,((inf.fieldStrength-inf.fieldDrainRate)/inf.maxFieldStrength)*100)
  931. else
  932. guiWrite(infcord.fstrth.x,infcord.fstrth.y,-1,-1,"0 / 0 (0 %%) \n")
  933. end
  934. if inf.maxEnergySaturation > 0 then
  935. guiWrite(infcord.esturn.x,infcord.esturn.y,-1,-1,"%d / %d (%0.2f %%) \n",inf.energySaturation,inf.maxEnergySaturation,(inf.energySaturation/inf.maxEnergySaturation)*100)
  936. else
  937. guiWrite(infcord.esturn.x,infcord.esturn.y,-1,-1,"0 / 0 (0 %%) \n")
  938. end
  939. if inf.fuelConversion/inf.maxFuelConversion < 0.78 then
  940. guiWrite(infcord.fuel.x,infcord.fuel.y,-1,-1,"%d / %d (%0.2f %%) \n",inf.fuelConversion,inf.maxFuelConversion,(inf.fuelConversion/inf.maxFuelConversion)*100)
  941. else
  942. if inf.maxFuelConversion > 0 then
  943. if inf.status == "online" or inf.status == "charging" or inf.status == "charged" then
  944. guiWrite(infcord.fuel.x,infcord.fuel.y,color.red,-1,"%d / %d (%0.2f %%) Критический уровень топлива\n",inf.fuelConversion,inf.maxFuelConversion,(inf.fuelConversion/inf.maxFuelConversion)*100)
  945. else
  946. guiWrite(infcord.fuel.x,infcord.fuel.y,-1,-1,"%d / %d (%0.2f %%) Критический уровень топлива\n",inf.fuelConversion,inf.maxFuelConversion,(inf.fuelConversion/inf.maxFuelConversion)*100)
  947. end
  948. else
  949. guiWrite(infcord.fuel.x,infcord.fuel.y,-1,-1,"0 / 0 (0 %%)\n")
  950. end
  951. end
  952. guiWrite(infcord.fuelconv.x,infcord.fuelconv.y,-1,-1,"%d\n",inf.fuelConversionRate)
  953. com.proxy(com.get(flux.down.adr))
  954. if com.isAvailable("draconic_rf_storage") then
  955. guiWrite(infcord.core.x,infcord.core.y,-1,-1,coreformat())
  956. if button.stop.y ~= infcord.core.y + 2 then
  957. screenMain()
  958. end
  959. elseif button.stop.y ~= infcord.fuelconv.y + 2 then
  960. screenMain()
  961. end
  962. checkButtons()
  963. end
  964. end
  965. -- Алгоритм автономного режима
  966. local waittemp
  967. local function auto(state)
  968.  
  969. if state then
  970. local inf = reactor.getReactorInfo()
  971. downflow = inf.fieldDrainRate / (1 - (cfg.shield/100))
  972. downgate.setOverrideEnabled(true)
  973. downgate.setFlowOverride(downflow)
  974.  
  975. if inf.temperature < cfg.forceModeTempLowEdge then
  976. if infcord.flow.value - inf.generationRate <= cfg.forceModeStepCase then
  977. upgate.setSignalLowFlow(infcord.flow.value + cfg.forceModeStep)
  978. guiWrite(infcord.flow.x,infcord.flow.y,color.red,color.grey,"%s",numformat(infcord.flow.value))
  979. end
  980. elseif infcord.flow.value - inf.generationRate <= cfg.safeModeStepCase and inf.temperature >= cfg.forceModeTempLowEdge then
  981. if not waittemp and not waitfield then
  982. upgate.setSignalLowFlow(upgate.getSignalLowFlow() + cfg.safemodeStep)
  983. guiWrite(infcord.flow.x,infcord.flow.y,color.red,color.grey,"%s",numformat(infcord.flow.value))
  984. elseif inf.temperature < cfg.safeModeTempToWaitEdge then
  985. waittemp = false
  986. end
  987.  
  988. elseif temprise and inf.temperature >= cfg.safeModeTempWaitEdge then
  989. if inf.temperature > cfg.safeModeTempWaitEdge then
  990. waittemp = true
  991. end
  992. if inf.temperature > cfg.tempCriticalEdge then
  993. upgate.setSignalLowFlow(inf.generationRate - 1000)
  994. end
  995. end
  996. else
  997. if infcord.status.value == "charging" then
  998. downflow = 900000
  999. else
  1000. downflow = infcord.drain.value / (1 - (cfg.shield/100))
  1001. end
  1002. downgate.setOverrideEnabled(false)
  1003. downgate.setSignalHighFlow(downflow)
  1004. downgate.setSignalLowFlow(downflow)
  1005. end
  1006. end
  1007. -- Обработчик событий
  1008. local function tcall(type,scrnAdr,x,y,btn,player)
  1009. local rx,ry = gpu.getResolution()
  1010. --выход
  1011. if x >= rx-2 and x<=rx and y == 1 then
  1012. event.ignore("touch",tcall)
  1013. prog = false
  1014. ops = false
  1015. end
  1016. -- Стартовый экран
  1017. if handleStart then
  1018. if x>=flux[1].x and x<= flux[1].x+#flux[1].adr-1 and y==flux[1].y and upchoose then
  1019. flux.up.adr = flux[1].adr
  1020.  
  1021. upchoose = false
  1022. return
  1023. end
  1024. if x>=flux[2].x and x<= flux[2].x+#flux[2].adr-1 and y==flux[2].y and upchoose then
  1025. flux.up.adr= flux[2].adr
  1026. upchoose = false
  1027. return
  1028. end
  1029.  
  1030. if x>=flux[1].x and x<= flux[1].x+#flux[1].adr-1 and y==flux[1].y and downchoose then
  1031. flux.down.adr = flux[1].adr
  1032. downchoose = false
  1033. return
  1034. end
  1035. if x>=flux[2].x and x<= flux[2].x+#flux[2].adr-1 and y==flux[2].y and downchoose then
  1036. flux.down.adr= flux[2].adr
  1037. downchoose = false
  1038. return
  1039. end
  1040. if x >= button.continue.x+8 and x <= button.continue.x+7+#button.continue.name/2 and y == button.continue.y+1 and flux.up.adr ~= nil and flux.down.adr ~= nil then
  1041. conf = true
  1042. buts = true
  1043. screenMain()
  1044. return
  1045. end
  1046. if x >= button.change.x+2 and x <= button.change.x+1+#button.change.name/2-1 and y == button.change.y and flux.up.adr ~= nil and flux.down.adr ~= nil then
  1047. conf = false
  1048. buts = true
  1049. com.proxy(com.get(flux.down.adr)).setOverrideEnabled(false)
  1050. flux.up.adr=nil
  1051. flux.down.adr=nil
  1052. upchoose = true
  1053. downchoose = true
  1054. guiClear(16)
  1055. return
  1056. end
  1057. end
  1058. -- Главный экран
  1059. if handleMain then
  1060. -- Увеличение
  1061. if x >= button.add.x+4 and x <= button.add.x+3+#button.add.name and y == button.add.y then
  1062. if keyb.isShiftDown() then
  1063. if keyb.isControlDown() then
  1064. upgate.setSignalLowFlow(add(infcord.flow,cfg.ctrlShift_interval))
  1065. else
  1066. upgate.setSignalLowFlow(add(infcord.flow,cfg.shift_interval))
  1067. end
  1068. else
  1069. if keyb.isControlDown() then
  1070. upgate.setSignalLowFlow(add(infcord.flow,cfg.ctrl_interval))
  1071. else
  1072. upgate.setSignalLowFlow(add(infcord.flow,cfg.default_interval))
  1073. end
  1074. end
  1075. guiWrite(infcord.flow.x,infcord.flow.y,color.red,color.grey,"%s",numformat(infcord.flow.value))
  1076. end
  1077. --Уменьшение
  1078. if x >= button.sub.x+2 and x <= button.sub.x+1+#button.sub.name and y == button.sub.y then
  1079. if keyb.isShiftDown() then
  1080. if keyb.isControlDown() then
  1081. upgate.setSignalLowFlow(sub(infcord.flow,cfg.ctrlShift_interval))
  1082. else
  1083. upgate.setSignalLowFlow(sub(infcord.flow,cfg.shift_interval))
  1084. end
  1085. else
  1086. if keyb.isControlDown() then
  1087. upgate.setSignalLowFlow(sub(infcord.flow,cfg.ctrl_interval))
  1088. else
  1089. upgate.setSignalLowFlow(sub(infcord.flow,cfg.default_interval))
  1090. end
  1091. end
  1092. guiWrite(infcord.flow.x,infcord.flow.y,color.blue,color.grey,"%s",numformat(infcord.flow.value))
  1093. end
  1094.  
  1095. if not autostate then
  1096. if x >= button.autooff.x and x <= button.autooff.x+#button.autooff.name/2-1 and y == button.autooff.y then
  1097. gpu.set(button.autooff.x, button.autooff.y," ")
  1098. autostate = true
  1099. guiWrite(button.autoon.x,button.autoon.y,color.green,color.black,"%s\n",button.autoon.name)
  1100. end
  1101. else
  1102. if x >= button.autoon.x and x <= button.autoon.x+#button.autoon.name/2-1 and y == button.autoon.y then
  1103. gpu.set(button.autoon.x, button.autoon.y," ")
  1104. autostate = false
  1105. guiWrite(button.autooff.x,button.autooff.y,color.red,color.black,"%s\n",button.autooff.name)
  1106. end
  1107. end
  1108. if button.charge.visible then
  1109. if x >= button.charge.x and x <= button.charge.x+#button.charge.name/2 and y == button.charge.y then
  1110. reactor.chargeReactor()
  1111. guiWrite(button.charge.x,button.charge.y,-1,color.grey," ",button.charge.name)
  1112. button.charge.visible = false
  1113. end
  1114. end
  1115. if button.start.visible then
  1116. if x >= button.start.x and x <= button.start.x+#button.start.name/2-1 and y == button.start.y then
  1117. reactor.activateReactor()
  1118. guiWrite(button.start.x,button.start.y,-1,color.grey," ",button.start.name)
  1119. button.start.visible = false
  1120. end
  1121. end
  1122. if button.stop.visible then
  1123. if x >= button.stop.x and x <= button.stop.x+#button.stop.name/2-1 and y == button.stop.y then
  1124. reactor.stopReactor()
  1125. guiWrite(button.stop.x,button.stop.y,-1,color.grey," ",button.stop.name)
  1126. button.stop.visible = false
  1127. end
  1128. end
  1129. --меню
  1130. if x>= menuItem.options.x and x <= (menuItem.options.x + #menuItem.options.name/2-1) and y == menuItem.options.y then
  1131. screenOptions()
  1132. return
  1133. end
  1134. if x == 1 and y == 1 then
  1135. event.ignore("touch",tcall)
  1136. prog = false
  1137. end
  1138. end
  1139. -- Экран настроек
  1140. if handleOptions then
  1141. -- Работа со значениями
  1142. if canedit then
  1143. if x >= OptionDefault.x and x <= OptionDefault.x + #tostring(OptionDefault.value)-1 and y == OptionDefault.y then
  1144. canclose = false
  1145. canedit = false
  1146. editOption(OptionDefault)
  1147. end
  1148. if x >= OptionCtrl.x and x <= OptionCtrl.x + #tostring(OptionCtrl.value)-1 and y == OptionCtrl.y then
  1149. canclose = false
  1150. canedit = false
  1151. editOption(OptionCtrl)
  1152. end
  1153. if x >= OptionShift.x and x <= OptionShift.x + #tostring(OptionShift.value)-1 and y == OptionShift.y then
  1154. canclose = false
  1155. canedit = false
  1156. editOption(OptionShift)
  1157. end
  1158. if x >= OptionCtrlShift.x and x <= OptionCtrlShift.x + #tostring(OptionCtrlShift.value)-1 and y == OptionCtrlShift.y then
  1159. canclose = false
  1160. canedit = false
  1161. editOption(OptionCtrlShift)
  1162. end
  1163. if x >= OptionShield.x and x <= OptionShield.x + #tostring(OptionShield.value)-1 and y == OptionShield.y then
  1164. canclose = false
  1165. canedit = false
  1166. editOption(OptionShield)
  1167. end
  1168. end
  1169. -- меню
  1170. if canclose then
  1171. if x>= menuItem.save.x and x <= (menuItem.save.x + #menuItem.save.name/2-1) and y == menuItem.save.y then
  1172. cfg.default_interval = OptionDefault.value
  1173. cfg.ctrl_interval = OptionCtrl.value
  1174. cfg.shift_interval = OptionShift.value
  1175. cfg.ctrlShift_interval = OptionCtrlShift.value
  1176. cfg.shield = OptionShield.value
  1177. configWrite(cfgName)
  1178. screenMain()
  1179. end
  1180. if x>= menuItem.cancel.x and x <= (menuItem.cancel.x + #menuItem.cancel.name/2-1) and y == menuItem.cancel.y then
  1181. OptionDefault.value = cfg.default_interval
  1182. OptionCtrl.value = cfg.ctrl_interval
  1183. OptionShift.value = cfg.shift_interval
  1184. OptionCtrlShift.value = cfg.ctrlShift_interval
  1185. OptionShield.value = cfg.ctrlShift_interval
  1186. screenMain()
  1187. return
  1188. end
  1189. end
  1190. end
  1191. end
  1192.  
  1193. event.listen("touch",tcall)
  1194. fileCreate(fileName)
  1195. flux.up.adr,flux.down.adr = fileRead(fileName)
  1196. screenStart()
  1197. if upgate ~= nil and downgate ~= nil then
  1198. screen.main()
  1199. end
  1200. while prog do
  1201. if not pcall(refreshInfo) then
  1202. autostate = false
  1203. if not pcall (screenStart) then
  1204. break
  1205. end
  1206. if not pcall(screenMain) then
  1207. screenStart()
  1208. if not pcall(screenMain) then
  1209. break
  1210. end
  1211. end
  1212. end
  1213. auto(autostate)
  1214. os.sleep(0)
  1215. end
  1216. gpu.setBackground(rback)
  1217. gpu.setForeground(rfore)
  1218. gpu.setResolution(xz,yz)
  1219. term.clear()
  1220.  
Advertisement
Add Comment
Please, Sign In to add comment