SHOW:
|
|
- or go back to the newest paste.
1 | -- Definition des variables | |
2 | mSide = "top" | |
3 | cellSide = "back" | |
4 | redstoneSide = "right" | |
5 | m = peripheral.wrap(mSide) | |
6 | cell = peripheral.wrap(cellSide) | |
7 | mouseWidth = 0 | |
8 | mouseHeight = 0 | |
9 | rsOut = 0 | |
10 | -- Set rs output to false | |
11 | redstone.setOutput("right", false) | |
12 | -- Affichage du moniteur | |
13 | m.clear() | |
14 | - | m.setTextScale(0.5) |
14 | + | m.setTextScale(1) |
15 | ||
16 | w, h = m.getSize() | |
17 | print(w) | |
18 | print(h) | |
19 | ||
20 | m.setBackgroundColour(colours.black) | |
21 | m.setCursorPos(w/8,h/4) | |
22 | m.write("Energy :",cell.getEnergyStored(),"/",cell.getMaxEnergyStored()) | |
23 | ||
24 | m.setCursorPos(w/8,h/2) | |
25 | m.write("Moteurs :") | |
26 | - | m.setCursorPos(w/6,h/2) |
26 | + | m.setCursorPos(w/6,h/1.5) |
27 | m.setBackgroundColour(colours.lime) | |
28 | m.write(" ON ") | |
29 | - | m.setCursorPos(w/2,h/2) |
29 | + | m.setCursorPos(w/2,h/1) |
30 | m.setBackgroundColour(colours.red) | |
31 | m.write(" OFF ") | |
32 | ||
33 | m.setBackgroundColour(colours.black) | |
34 | - | if mouseWidth > w/6 and mouseWidth < w/3 and mouseHeight == h/2 then |
34 | + | |
35 | function checkClickPosition() | |
36 | if mouseWidth > 1 and mouseWidth < w and mouseHeight == h/1.5 then | |
37 | -- button one clicked | |
38 | - | elseif mouseWidth > w/2 and mouseWidth < w and mouseHeight == h/2 then |
38 | + | |
39 | -- turns redstone connected to the right on | |
40 | elseif mouseWidth > 1 and mouseWidth < w and mouseHeight == h/1 then | |
41 | -- button two clicked | |
42 | redstone.setOutput(redstoneSide,true) | |
43 | -- turns redstone connected to the left off | |
44 | end -- ends the if loop | |
45 | end -- ends the function | |
46 | ||
47 | while true do | |
48 | m.setCursorPos(w/8,h/4) | |
49 | m.write("Energy :"..cell.getEnergyStored().."/"..cell.getMaxEnergyStored()) | |
50 | m.setCursorPos(w/8,h/2) | |
51 | event,p1,p2,p3 = os.pullEvent() | |
52 | -- this line tells the computer to wait until | |
53 | -- an event happens. We are waiting for a | |
54 | -- touchscreen event | |
55 | ||
56 | if event=="monitor_touch" then | |
57 | -- this checks to see if the event was a | |
58 | -- touchscreen event | |
59 | ||
60 | mouseWidth = p2 -- sets mouseWidth | |
61 | mouseHeight = p3 -- and mouseHeight | |
62 | checkClickPosition() -- this runs our function | |
63 | ||
64 | end | |
65 | ||
66 | end |