Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local gui = require("gui")
- function findMonitor()
- local available_perphs = peripheral.getNames()
- local selected_monitor = nil
- for index, perph_name in ipairs(available_perphs) do
- if string.find(perph_name, "monitor") then
- selected_monitor = perph_name
- break
- end
- end
- return peripheral.wrap(selected_monitor)
- end
- function main()
- local monitor1 = peripheral.wrap("monitor_0")
- local monitor2 = peripheral.wrap("monitor_5")
- local buffer1 = createBuffer(monitor1, "buffer", colors.black)
- local buffer2 = createBuffer(monitor2, "buffer", colors.black)
- local start_button1 = Button:new {
- name = "start_button1",
- buffer = buffer1,
- parent = buffer1,
- x = 2,
- y = 2,
- text = "Start",
- horizontalAlignment = align.center,
- verticalAlignment = align.center,
- backgroundColor = colors.red,
- width = 5,
- height = 1,
- padding = 0,
- onClickName = "start_click",
- onClick = function(self)
- print("Clicked!")
- if (self.backgroundColor == colors.red) then
- self:setBackgroundColor(colors.green)
- else
- self:setBackgroundColor(colors.red)
- end
- end,
- }
- local start_button2 = Button:new {
- name = "start_button2",
- buffer = buffer2,
- parent = buffer2,
- x = 2,
- y = 2,
- text = "Start",
- horizontalAlignment = align.center,
- verticalAlignment = align.center,
- backgroundColor = colors.red,
- width = 5,
- height = 1,
- padding = 0,
- onClickName = "start_click",
- onClick = function(self)
- print("Clicked!")
- if (self.backgroundColor == colors.red) then
- self:setBackgroundColor(colors.green)
- else
- self:setBackgroundColor(colors.red)
- end
- end,
- }
- while true do
- buffer1:draw()
- buffer2:draw()
- parallel.waitForAny(handleInputEvents())
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement