SHOW:
|
|
- or go back to the newest paste.
1 | os.loadAPI("button") | |
2 | local m = peripheral.wrap("back") | |
3 | local mx, my = m.getSize() | |
4 | function getClick() | |
5 | local event, side, x, y = os.pullEvent() | |
6 | if event == "monitor_touch" then | |
7 | button.checkxy(x, y) | |
8 | end | |
9 | end | |
10 | function reactor1() | |
11 | button.toggleButton("Test 1") | |
12 | if button.active("Test 1") then | |
13 | -- print("now on") | |
14 | rs.setOutput("left", true) | |
15 | else | |
16 | -- print("now off") | |
17 | rs.setOutput("left", false) | |
18 | end | |
19 | button.save() | |
20 | addText() | |
21 | end | |
22 | function reactor2() | |
23 | button.toggleButton("Test 2") | |
24 | if button.active("Test 2") then | |
25 | -- print("now on") | |
26 | rs.setOutput("right", true) | |
27 | else | |
28 | -- print("now off") | |
29 | rs.setOutput("right", false) | |
30 | end | |
31 | button.save() | |
32 | addText() | |
33 | end | |
34 | function fillMainTable() | |
35 | m.clear() | |
36 | button.clearTable() | |
37 | - | button.setTable("Test 1", test11, "", 2, mx/2, 2, my-1) |
37 | + | button.setTable("Test 1", test1, "", 2, mx/2, 2, my-1) |
38 | button.setTable("Test 2", test2, "", (mx/2)+2, mx-0.5, 2, my-1) | |
39 | --2,mx/2-1 -- mx/2+2, mx-0.5 | |
40 | button.screen() | |
41 | end | |
42 | function addText() | |
43 | for i = 1,2 do | |
44 | m.setTextColor(colors.white) | |
45 | if i == 1 then | |
46 | if button.active("Test 1") then | |
47 | m.setBackgroundColor(colors.lime) | |
48 | else | |
49 | m.setBackgroundColor(colors.red) | |
50 | end | |
51 | m.setCursorPos(mx/4-#textr/2+1.75, my/2+1) | |
52 | m.write(textr) | |
53 | else | |
54 | if button.active("Test 2") then | |
55 | m.setBackgroundColor(colors.lime) | |
56 | else | |
57 | m.setBackgroundColor(colors.red) | |
58 | end | |
59 | m.setCursorPos(mx*0.75-#textr/2+1, my/2+1) | |
60 | m.write(textr) | |
61 | end | |
62 | end | |
63 | end | |
64 | fillMainTable() | |
65 | button.load() | |
66 | addText() | |
67 | while true do | |
68 | getClick() | |
69 | end |