Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Require:
- -- Monitor and GPU tear 3 and PC
- -- Adapter, Redstone controller or redstone card
- -- I update this script for auto-enable reactor from redstone signal on 50% lapatron storage
- -- Owner scripts: 4GNAME
- unicode = require("unicode")
- comp = require("component")
- colors = require("colors")
- side = require("sides")
- screen = require("term")
- computer = require("computer")
- event = require("event")
- graphics = require("graphics")
- fs = require("filesystem")
- TC, RO, RN, RD, TPS = 2, 0, 0, 0
- GPU1 = comp.gpu
- lsc = comp.impact_lsc
- rs = comp.redstone
- procent = 55 -- В процентах емкость лапатрона, когда начнется заряд реактора
- fuls = 100 -- В процентах емкость лапатрона, яр заряд остановка
- screenWidth = 160
- screenHeight = 40
- GPU1.setResolution(screenWidth, screenHeight)
- function times()
- f = io.open("/tmp/TF", "w")
- f:write("test")
- f:close()
- return(fs.lastModified("/tmp/TF"))
- end
- function spam()
- RO = times()
- os.sleep(TC)
- RN = times()
- RD = RN - RO
- TPS = 20000 * TC / RD
- TPS = string.sub(TPS, 1, 5)
- nTPS = tonumber(TPS)
- GPU1.set(154, 8, " ")
- if nTPS <= 10 then
- GPU1.setForeground(0xcc4c4c)
- elseif nTPS <= 15 then
- GPU1.setForeground(0xf2b233)
- elseif nTPS > 15 then
- GPU1.setForeground(0x7fcc19)
- end
- GPU1.set(154, 8, TPS)
- end
- function rectangleAround(GPU, x, y, w, h, b, color)
- if y % 2 == 0 then
- error("Pixel position must be odd on y axis")
- end
- graphics.rectangle(GPU, x, y, w - b, b, color)
- graphics.rectangle(GPU, x + w - b, y, b, h - b + 1, color)
- graphics.rectangle(GPU, x + b - 1, y + h - b, w - b + 1, b, color)
- graphics.rectangle(GPU, x, y + b - 1, b, h - b + 1, color)
- end
- function splitNumber(number)
- number = math.floor(number)
- local formattedNumber = {}
- local string = tostring(math.abs(number))
- local sign = number / math.abs(number)
- for i = 1, #string do
- n = string:sub(i, i)
- formattedNumber[i] = n
- if ((#string - i) % 3 == 0) and (#string - i > 0) then
- formattedNumber[i] = formattedNumber[i] .. ","
- end
- end
- if (sign < 0) then
- table.insert(formattedNumber, 1, "-")
- end
- return table.concat(formattedNumber, "")
- end
- function time(number)
- local formattedTime = {}
- formattedTime[1] = math.floor(number / 3600); formattedTime[2] = " H, "
- formattedTime[3] = math.floor((number - formattedTime[1] * 3600) / 60); formattedTime[4] = " M, "
- formattedTime[5] = number % 60; formattedTime[6] = " S"
- return table.concat(formattedTime, "")
- end
- function drawCharge()
- local chargeFirst = lsc.getChargePercent()
- local stored, capacity, input, output = lsc.getStoredLSC()
- local pX = 20
- local pY = 53
- local pW = screenWidth - 2 * pX
- local pH = 8
- local charge = (pW - 2) * (lsc.getChargePercent() / 100)
- local capacityEU = "CAPACITY: " .. splitNumber(capacity) .. " EU"
- local storedEU = "STORED: " .. splitNumber(stored) .. " EU"
- local inputEU = "IN: " .. splitNumber(input) .. " EU/T"
- local outputEU = "OUT: " .. splitNumber(output) .. " EU/T "
- local chargePercent = " CHARGE: " .. math.floor(chargeFirst) .. " %"
- local differenceIO = input - output
- rectangleAround(GPU1, pX, pY, pW, pH, 2, 0x131e27)
- graphics.rectangle(GPU1, pX + 2, pY + 2, charge - 2, 4, 0x7ec7ff)
- if chargeFirst > 0 and chargeFirst < 100 then
- graphics.rectangle(GPU1, pX + charge + 1, pY + 2, pW - 2 - charge, 4, 0x294052)
- else
- if chargeFirst <= 0 then
- graphics.rectangle(GPU1, pX + 2, pY + 2, pW - 4, 4, 0x294052)
- end
- end
- local diftext = " " .. "COST: " .. splitNumber(math.abs(differenceIO)) .. " EU/T"
- if differenceIO < 0 then
- graphics.text(GPU1, pX + pW - #diftext, pY + pH, 0xff0000, diftext)
- else
- graphics.text(GPU1, pX + pW - #diftext, pY + pH, 0x33ff00, diftext)
- end
- graphics.text(GPU1, screenWidth-17, 3, 0x858585,"OFF - CTRL+C")
- graphics.text(GPU1, screenWidth-10, 15, 0x00FF00,"TPS")
- graphics.text(GPU1, pX + pW - #chargePercent, pY - 2, 0x7ec7ff, chargePercent)
- graphics.text(GPU1, pX, pY - 2, 0x7ec7ff, capacityEU .. " ")
- graphics.text(GPU1, pX, pY + pH, 0x7ec7ff, storedEU .. " ")
- graphics.text(GPU1, pX, pY + pH + 4, 0x33ff00, inputEU .. " ")
- graphics.text(GPU1, pX, pY + pH + 6, 0xff0000, outputEU .. " ")
- if math.floor(chargeFirst) <= procent then
- for b = 0, 5 do
- rs.setOutput(b, 255)
- end
- computer.beep(1000, 0.1)
- graphics.text(GPU1, screenWidth-12, 11, 0x00FF00,"REACTOR:ON_")
- end
- if differenceIO > 0 then
- fillTime = math.floor((capacity - stored) / (differenceIO * 20))
- fillTimeString = " FULL: " .. time(math.abs(fillTime))
- graphics.text(GPU1, pX + pW - #fillTimeString, pY + pH + 2, 0x7ec7ff, fillTimeString .. " ")
- else if differenceIO == 0 then
- if stored >= (capacity * fuls / 100) then
- fillTimeString = " CHARGE OK"
- for i = 0, 5 do
- rs.setOutput(i, 0)
- end
- graphics.text(GPU1, screenWidth-12, 11, 0xFF0000,"REACTOR:OFF")
- else if stored <= (capacity * 20 / 100) then
- fillTimeString = " NEED HELP"
- computer.beep(1000, 1.0)
- end
- fillTimeString = " NO CHARGE"
- end
- graphics.text(GPU1, pX + pW - #fillTimeString, pY + pH + 2, 0x7ec7ff, fillTimeString)
- else
- fillTime = math.floor((stored) / (differenceIO * 20))
- fillTimeString = " EMPTY: " .. time(math.abs(fillTime))
- graphics.text(GPU1, pX + pW - #fillTimeString, pY + pH + 2, 0x7ec7ff, fillTimeString .. " ")
- end
- end
- end
- screen.clear()
- while true do
- drawCharge()
- graphics.update()
- spam()
- os.sleep(.1)
- if event.pull(.5, "interrupted") then
- screen.clear()
- print("soft interrupt, closing")
- break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement