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 monitor = findMonitor()
- local buffer = createBuffer(monitor, "buffer", colors.black)
- local start_button = Button:new {
- name = "start_button",
- buffer = buffer,
- parent = buffer,
- 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
- buffer:draw()
- parallel.waitForAny(handleInputEvents())
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement