Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local redstoneOutput = true
- local function findMonitors()
- local monitors = {}
- for _, name in pairs(peripheral.getNames()) do
- if string.match(name, "^monitor_") then
- local monitor = peripheral.wrap("right")
- table.insert(monitors, monitor)
- end
- end
- return monitors
- end
- local monitors = findMonitors()
- local monitor = monitors[1]
- local modem = peripheral.find("modem")
- local function drawBar()
- local w, h = monitor.getSize()
- term.redirect(monitor)
- paintutils.drawLine(3, 3, 4, 3, colors.cyan)
- paintutils.drawLine(16, 3, w - 2, 3, colors.cyan)
- paintutils.drawLine(3, 3, 3, h - 1, colors.cyan)
- paintutils.drawLine(w - 2, 3, w - 2, h - 1, colors.cyan)
- paintutils.drawLine(w - 2, h - 1, 3, h - 1, colors.cyan)
- paintutils.drawLine(6, 4, 14, 4, colors.lightGray)
- paintutils.drawLine(6, 3, 14, 3, colors.lightGray)
- paintutils.drawLine(6, 2, 14, 2, colors.lightGray)
- paintutils.drawLine(16, 2, 16, 4, colors.cyan)
- monitor.setBackgroundColor(colors.lightGray)
- monitor.setTextColor(colors.black)
- monitor.setCursorPos(7, 3)
- monitor.write("[LIGHT]")
- monitor.setBackgroundColor(colors.gray)
- end
- drawBar()
- while true do
- local event, side, x, y = os.pullEvent("monitor_touch")
- monitor.setBackgroundColor(colors.gray) -- Arka plan rengini gri olarak ayarla
- if x >= 10 and x <= 19 and y >= 6 and y <= 8 then
- if redstoneOutput then
- paintutils.drawLine(9, 6, 20, 6, colors.green)
- paintutils.drawLine(9, 7, 20, 7, colors.green)
- paintutils.drawLine(9, 8, 20, 8, colors.green)
- monitor.setCursorPos(10, 7)
- monitor.setBackgroundColor(colors.green)
- monitor.setTextColor(colors.black)
- monitor.write(" [ ON ] ")
- redstone.setOutput("back", true)
- redstoneOutput = false
- else
- paintutils.drawLine(9, 6, 20, 6, colors.red)
- paintutils.drawLine(9, 7, 20, 7, colors.red)
- paintutils.drawLine(9, 8, 20, 8, colors.red)
- monitor.setCursorPos(10, 7)
- monitor.setBackgroundColor(colors.red)
- monitor.setTextColor(colors.black)
- monitor.write(" [ OFF ] ")
- redstone.setOutput("back", false)
- redstoneOutput = true
- end
- end
- drawBar()
- os.sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement