Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dial = peripheral.wrap("ep_dialling_device_2")
- monitor = peripheral.wrap("monitor_1")
- controller = peripheral.wrap("ep_controller_1")
- portalActive = false
- locationCount = 0
- function update()
- portalActive = controller.isPortalActive()
- locationCount = dial.getStoredCount()
- end
- function drawScreen()
- if portalActive then
- monitor.setBackgroundColor(colors.green)
- monitor.clear()
- monW, monH = monitor.getSize()
- monitor.setCursorPos(monW / 2 - string.len("Closing in...5") / 2, monH / 2)
- i = 5
- while i > 0 do
- monitor.clear()
- monitor.setCursorPos(monW / 2 - string.len("Closing in...5") / 2, monH / 2)
- monitor.write("Closing in..."..i)
- i = i - 1
- sleep(1)
- end
- dial.terminate()
- portalActive = false
- drawScreen()
- else
- monitor.setBackgroundColor(colors.black)
- monitor.clear()
- if (locationCount - 1 > 0) then
- for i = 1, locationCount do
- monitor.setCursorPos(1, i)
- if (i % 2 == 0) then
- monitor.setBackgroundColor(colors.gray)
- else
- monitor.setBackgroundColor(colors.lightGray)
- end
- name = dial.getStoredName(i - 1)
- monW, monH = monitor.getSize()
- monitor.write(name)
- k = string.len(name)
- while (k < monW) do
- monitor.write(" ")
- k = k + 1
- end
- end
- else
- monitor.setCursorPos(1, 1)
- monitor.write("No Entries")
- end
- end
- end
- function handleInput()
- event, side, posX, posY = os.pullEvent("monitor_touch")
- if portalActive then
- dial.terminate()
- else
- if (posY <= locationCount) then
- dial.dialStored(posY - 1)
- end
- end
- end
- while true do
- update()
- drawScreen()
- handleInput()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement