SHOW:
|
|
- or go back to the newest paste.
1 | local gui = require("gui") | |
2 | ||
3 | function findMonitor() | |
4 | local available_perphs = peripheral.getNames() | |
5 | local selected_monitor = nil | |
6 | for index, perph_name in ipairs(available_perphs) do | |
7 | if string.find(perph_name, "monitor") then | |
8 | selected_monitor = perph_name | |
9 | break | |
10 | end | |
11 | end | |
12 | ||
13 | return peripheral.wrap(selected_monitor) | |
14 | end | |
15 | ||
16 | function main() | |
17 | ||
18 | - | local monitor = findMonitor() |
18 | + | local monitor1 = peripheral.wrap("monitor_0") |
19 | - | local buffer = createBuffer(monitor, "buffer", colors.black) |
19 | + | local monitor2 = peripheral.wrap("monitor_5") |
20 | local buffer1 = createBuffer(monitor1, "buffer", colors.black) | |
21 | - | local start_button = Button:new { |
21 | + | local buffer2 = createBuffer(monitor2, "buffer", colors.black) |
22 | - | name = "start_button", |
22 | + | |
23 | - | buffer = buffer, |
23 | + | local start_button1 = Button:new { |
24 | - | parent = buffer, |
24 | + | name = "start_button1", |
25 | buffer = buffer1, | |
26 | parent = buffer1, | |
27 | x = 2, | |
28 | y = 2, | |
29 | text = "Start", | |
30 | horizontalAlignment = align.center, | |
31 | verticalAlignment = align.center, | |
32 | backgroundColor = colors.red, | |
33 | width = 5, | |
34 | height = 1, | |
35 | padding = 0, | |
36 | onClickName = "start_click", | |
37 | onClick = function(self) | |
38 | print("Clicked!") | |
39 | if (self.backgroundColor == colors.red) then | |
40 | self:setBackgroundColor(colors.green) | |
41 | else | |
42 | self:setBackgroundColor(colors.red) | |
43 | end | |
44 | end, | |
45 | } | |
46 | - | buffer:draw() |
46 | + | |
47 | local start_button2 = Button:new { | |
48 | name = "start_button2", | |
49 | buffer = buffer2, | |
50 | parent = buffer2, | |
51 | x = 2, | |
52 | y = 2, | |
53 | text = "Start", | |
54 | horizontalAlignment = align.center, | |
55 | verticalAlignment = align.center, | |
56 | backgroundColor = colors.red, | |
57 | width = 5, | |
58 | height = 1, | |
59 | padding = 0, | |
60 | onClickName = "start_click", | |
61 | onClick = function(self) | |
62 | print("Clicked!") | |
63 | if (self.backgroundColor == colors.red) then | |
64 | self:setBackgroundColor(colors.green) | |
65 | else | |
66 | self:setBackgroundColor(colors.red) | |
67 | end | |
68 | end, | |
69 | } | |
70 | ||
71 | while true do | |
72 | buffer1:draw() | |
73 | buffer2:draw() | |
74 | ||
75 | parallel.waitForAny(handleInputEvents()) | |
76 | end | |
77 | end | |
78 | ||
79 | main() |