SHOW:
|
|
- or go back to the newest paste.
| 1 | - | dial = peripheral.wrap("top")
|
| 1 | + | dial = peripheral.wrap("ep_dialling_device_2")
|
| 2 | - | monitor = peripheral.wrap("left")
|
| 2 | + | monitor = peripheral.wrap("monitor_1")
|
| 3 | - | controller = peripheral.wrap("right")
|
| 3 | + | controller = peripheral.wrap("ep_controller_1")
|
| 4 | portalActive = false | |
| 5 | locationCount = 0 | |
| 6 | ||
| 7 | function update() | |
| 8 | portalActive = controller.isPortalActive() | |
| 9 | locationCount = dial.getStoredCount() | |
| 10 | end | |
| 11 | ||
| 12 | function drawScreen() | |
| 13 | if portalActive then | |
| 14 | monitor.setBackgroundColor(colors.green) | |
| 15 | monitor.clear() | |
| 16 | monW, monH = monitor.getSize() | |
| 17 | monitor.setCursorPos(monW / 2 - string.len("Terminate") / 2, monH / 2)
| |
| 18 | monitor.write("Terminate")
| |
| 19 | else | |
| 20 | monitor.setBackgroundColor(colors.black) | |
| 21 | monitor.clear() | |
| 22 | ||
| 23 | if (locationCount - 1 > 0) then | |
| 24 | for i = 1, locationCount do | |
| 25 | monitor.setCursorPos(1, i) | |
| 26 | ||
| 27 | if (i % 2 == 0) then | |
| 28 | monitor.setBackgroundColor(colors.gray) | |
| 29 | else | |
| 30 | monitor.setBackgroundColor(colors.lightGray) | |
| 31 | end | |
| 32 | ||
| 33 | name = dial.getStoredName(i - 1) | |
| 34 | monW, monH = monitor.getSize() | |
| 35 | ||
| 36 | monitor.write(name) | |
| 37 | k = string.len(name) | |
| 38 | ||
| 39 | while (k < monW) do | |
| 40 | monitor.write(" ")
| |
| 41 | k = k + 1 | |
| 42 | end | |
| 43 | ||
| 44 | end | |
| 45 | else | |
| 46 | monitor.setCursorPos(1, 1) | |
| 47 | monitor.write("No Entries")
| |
| 48 | end | |
| 49 | end | |
| 50 | end | |
| 51 | ||
| 52 | function handleInput() | |
| 53 | event, side, posX, posY = os.pullEvent("monitor_touch")
| |
| 54 | ||
| 55 | if portalActive then | |
| 56 | dial.terminate() | |
| 57 | else | |
| 58 | if (posY <= locationCount) then | |
| 59 | dial.dialStored(posY - 1) | |
| 60 | end | |
| 61 | end | |
| 62 | end | |
| 63 | ||
| 64 | while true do | |
| 65 | update() | |
| 66 | drawScreen() | |
| 67 | handleInput() | |
| 68 | end |