Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- comp = require("component")
- miner = comp.gt_machine
- screen = require("term")
- GPU1 = comp.gpu
- computer = require("computer")
- event = require("event")
- screenWidth = 160
- screenHeight = 40
- errorColor = 0xCC0000
- idleColor = 0xc0cc00
- goodColor = 0x00cc0e
- local state = "off"
- local internet = comp.internet
- Telegram = {
- "", ""
- }
- function SendTelega(Text)
- local url ="https://api.telegram.org/bot"..Telegram[1].."/sendMessage?chat_id="..Telegram[2].."&text="..Text
- internet.request(url)
- end
- function write(x, y, text, color)
- color = color
- screen.setCursor(x, y)
- oldColor = GPU1.setForeground(color)
- screen.write(text)
- GPU1.setForeground(oldColor)
- end
- function box(x, y, w, h, color)
- local oldColor = GPU1.setBackground(color)
- GPU1.fill(x, y, w, h, " ")
- GPU1.setBackground(oldColor)
- end
- function MachineGT(step)
- x = 0
- y = 0
- maintenanceIndex = 0
- uses = 0
- for i = 1, #miner.getSensorInformation() do
- if string.match(miner.getSensorInformation()[i], "Problems") then
- maintenanceIndex = i
- end
- end
- for i = 1, #miner.getSensorInformation() do
- if string.match(miner.getSensorInformation()[i], "Probably") then
- uses = i
- end
- end
- if (miner.isMachineActive()) then
- write(x + 1, y + 2, " ", goodColor)
- write(x + 1, y + 2, "Miner Worked!", goodColor)
- if step % 1800 == 0 then
- SendTelega("Miner worked: ".. step/60 .. "min")
- end
- end
- if (maintenanceIndex == 0 or string.match(miner.getSensorInformation()[maintenanceIndex], "c0")) and miner.isWorkAllowed() then
- else
- if (miner.isWorkAllowed()) then
- write(x + 1, y + 2, " ", errorColor)
- write(x + 1, y + 2, "Needs maintenance!", errorColor)
- if step % 60 == 0 then
- SendTelega("Needs maintenance!")
- end
- else
- write(x + 1, y + 2, " ", errorColor)
- write(x + 1, y + 2, "Miner disabled!", idleColor)
- if step % 60 == 0 then
- SendTelega("Miner Not Worked")
- end
- end
- end
- end
- screen.clear()
- step = 1
- i = 1
- while (true) do
- GPU1.setResolution(20, 5)
- step = step + 1
- MachineGT(step)
- write(1, 3, "[ "..(step).." sec ]", idleColor)
- if step % 60 == 0 then
- write(1, 4, "[ "..(i).." min ]", idleColor)
- i = i + 1
- end
- -- Выключить программу ctrl+c
- os.sleep(1)
- if event.pull(.5, "interrupted") then
- screen.clear()
- break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement