SHOW:
|
|
- or go back to the newest paste.
| 1 | m = peripheral.wrap("right")
| |
| 2 | r = peripheral.wrap("back")
| |
| 3 | image = paintutils.loadImage("hud")
| |
| 4 | ||
| 5 | m.setBackgroundColor(colors.black) | |
| 6 | m.clear() | |
| 7 | paintutils.drawImage(image,1,1) | |
| 8 | m.setCursorPos(40,16) | |
| 9 | m.write("Reacteur")
| |
| 10 | ||
| 11 | function mo_touch() | |
| 12 | while true do | |
| 13 | event, side, xpos, ypos = os.pullEvent("monitor_touch")
| |
| 14 | if xpos == 3 or xpos == 4 and ypos == 2 then | |
| 15 | r.setActive(true) | |
| 16 | elseif xpos == 45 or xpos == 46 and ypos == 2 then | |
| 17 | r.setActive(false) | |
| 18 | end | |
| 19 | end | |
| 20 | end | |
| 21 | ||
| 22 | function test_r() | |
| 23 | while true do | |
| 24 | if r.getActive() then | |
| 25 | e = r.getEnergyStored() | |
| 26 | ep = r.getEnergyProducedLastTick() | |
| 27 | paintutils.drawBox(3,15,5,16,colors.green) | |
| 28 | paintutils.drawFilledBox(3,3,47,13,colors.black) | |
| 29 | paintutils.drawBox(4,4,46,12,colors.gray) | |
| 30 | m.setCursorPos(6,6) | |
| 31 | m.setTextColor(colors.green) | |
| 32 | m.setBackgroundColor(colors.black) | |
| 33 | m.write("Energie Stored : "..e.." RF")
| |
| 34 | m.setCursorPos(6,8) | |
| 35 | m.write("Energie Produite : "..ep.." RF/t")
| |
| 36 | if e == 10000000 then | |
| 37 | os.sleep(3) | |
| 38 | r.setActive(false) | |
| 39 | end | |
| 40 | os.sleep(0.1) | |
| 41 | elseif r.getActive() == false then | |
| 42 | e = r.getEnergyStored() | |
| 43 | paintutils.drawBox(3,15,5,16,colors.red) | |
| 44 | paintutils.drawFilledBox(3,3,47,13,colors.black) | |
| 45 | paintutils.drawBox(4,4,46,10,colors.gray) | |
| 46 | m.setCursorPos(6,6) | |
| 47 | m.setTextColor(colors.red) | |
| 48 | m.setBackgroundColor(colors.black) | |
| 49 | m.write("Energie Stored : "..e.." RF")
| |
| 50 | os.sleep(0.1) | |
| 51 | end | |
| 52 | ||
| 53 | os.sleep(0.1) | |
| 54 | end | |
| 55 | end | |
| 56 | ||
| 57 | function hud() | |
| 58 | paintutils.drawImage(image, 1, 1) | |
| 59 | end | |
| 60 | ||
| 61 | hud() | |
| 62 | ||
| 63 | parallel.waitForAny(test_r, mo_touch) |