Untitled
unknown
plain_text
17 days ago
2.5 kB
4
Indexable
local comp = require("component")
local event = require("event")
local term = require("term")
local os = require("os")
local core_computer = require("computer")
local gpu = comp.gpu
-- Прокси для Redstone I/O (S-A 128V Switcher)
local rs = comp.proxy("ba91dfa5-d6aa-4236-82f9-aff904e1684b")
if not rs then
error("Error: Redstone I/O with specified ID not found!")
end
local relay_on = false -- По умолчанию выключено при старте
local function updateRelay()
if relay_on then
for s = 0, 5 do pcall(rs.setOutput, s, 15) end -- 15 на все стороны при ON
else
for s = 0, 5 do pcall(rs.setOutput, s, 0) end -- 0 на все стороны при OFF
end
end
-- При запуске ставим дефолтное состояние
updateRelay()
local w, h = gpu.getResolution()
gpu.setBackground(0x000000)
gpu.fill(1, 1, w, h, " ")
local function redrawScreen()
gpu.fill(1, 1, w, 19, " ")
gpu.setForeground(0xFFCC00)
gpu.set(1, 1, "=== HORIZON SYSTEMS TEC. Interface ===")
gpu.setForeground(0x00FFFF)
gpu.set(1, 2, "Redstone Power Control System")
gpu.set(1, 3, "----------------------------------------------------------")
gpu.setForeground(0x00FF00)
gpu.set(1, 4, "Сектор: S-A (128V Line)")
gpu.setForeground(0x00FFFF)
gpu.set(1, 5, "Реле статус: ")
if relay_on then
gpu.setBackground(0x005500)
gpu.setForeground(0x00FF00)
gpu.set(14, 5, " ON ")
else
gpu.setBackground(0x550000)
gpu.setForeground(0xFF2222)
gpu.set(14, 5, " OFF ")
end
gpu.setBackground(0x000000)
gpu.setForeground(0x00FFFF)
gpu.set(1, 6, "----------------------------------------------------------")
gpu.set(1, 7, "==========================================================")
gpu.setForeground(0x555555)
gpu.set(1, 9, "Press Ctrl+C to close program.")
end
redrawScreen()
while true do
local e_id, _, x, y = event.pull(0.01)
if e_id == "interrupted" then
gpu.setForeground(0xFFFFFF)
term.clear()
-- Полностью убран сброс в 0. Состояние сохраняется на физическом блоке Redstone I/O
print("Program closed. Redstone state preserved.")
return
elseif e_id == "touch" then
if y == 5 and x >= 14 and x <= 19 then
relay_on = not relay_on
updateRelay()
redrawScreen()
end
end
end
Editor is loading...
Leave a Comment