Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mon = peripheral.wrap("top")
- local ctrl = peripheral.wrap("Portal Controller_0")
- local dial = peripheral.wrap("right")
- local countTargets = dial.getStoredCount()
- function padStr(str, len)
- if #str > len then do return string.sub(str,1,len) end
- else do return str .. string.rep(' ', len - #str) end
- end
- end
- function drawUI()
- local monX, monY = mon.getSize()
- mon.setBackgroundColor(colors.blue)
- mon.clear()
- mon.setCursorPos(1,1)
- mon.write("Please choose your")
- mon.setCursorPos(1,2)
- mon.write("destination")
- countTargets = dial.getStoredCount()
- if (countTargets > 0) then
- for i = 1, countTargets do
- mon.setCursorPos(1, i + 3)
- if (i % 2 == 0) then
- mon.setBackgroundColor(colors.lightBlue)
- else
- mon.setBackgroundColor(colors.blue)
- end
- name = padStr(dial.getStoredName(i - 1),monX)
- mon.write(name)
- end
- else
- mon.setCursorPos(1, 4)
- mon.write("No Entries")
- end
- end
- function waitForInput()
- event, _, posX, posY = os.pullEvent("monitor_touch")
- if ctrl.isPortalActive() then dial.terminate() end
- if countTargets > 0 and (posY-3 > 0) and (posY-3 <= countTargets) then
- dial.dialStored(posY - 4)
- end
- end
- while true do
- drawUI()
- waitForInput()
- end
Advertisement
Add Comment
Please, Sign In to add comment