Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- portals = {}
- dial = peripheral.wrap("right")
- monitor = peripheral.wrap("left")
- sign = peripheral.wrap("top")
- conwrap = sign.getLine(4)
- controller = peripheral.wrap("ep_controller_"..conwrap)
- ident = controller.getUniqueIdentifier()
- portalname = sign.getLine(1).." - "..sign.getLine(2)
- portalActive = false
- locationCount = 0
- rednet.open("back")
- function update()
- rednet.broadcast("p,"..conwrap..ident..","..portalname)
- id,message = rednet.receive(2)
- if not message == nil then
- arr = { message }
- if #arr == 3 then
- portals[#portals + 1] = { arr[2], arr[3] }
- end
- end
- portalActive = controller.isPortalActive()
- locationCount = #portals
- end
- function drawScreen()
- i = 1
- if controller.isPortalActive() == false then
- --mon2.clear()
- end
- -- monitor.setBackgroundColor(colors.green)
- -- monitor.clear()
- -- monW, monH = monitor.getSize()
- -- monitor.setCursorPos(monW / 2 - string.len("Terminate") / 2, monH / 2)
- -- monitor.write("Terminate")
- -- mon2.setBackgroundColor(colors.red)
- -- mon2.clear()
- monitor.setBackgroundColor(colors.black)
- monitor.clear()
- for index,values in pairs(portals) do
- name = values[1]
- monitor.setCursorPos(1, i)
- if (i % 2 == 0) then
- monitor.setBackgroundColor(colors.gray)
- else
- monitor.setBackgroundColor(colors.lightGray)
- end
- monW, monH = monitor.getSize()
- monitor.write(name)
- k = string.len(name)
- while (k < monW) do
- monitor.write(" ")
- k = k + 1
- end
- i = i + 1
- end
- end
- function handleInput()
- event, side, posX, posY = os.pullEvent("monitor_touch")
- if portalActive then
- dial.terminate()
- else
- if posY <= #portals then
- --mon2.setCursorPos(1,1)
- -- if unexpected_condition then error() end
- local ok,error = pcall( dial.dial, portals[posY][2])
- if not ok then
- -- //mon2.write("Whoops - Try Again")
- else
- -- // mon2.write(portals[posY][1])
- end
- end
- end
- end
- while true do
- update()
- drawScreen()
- handleInput()
- os.sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement