Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sides = {'back','front','top','bottom','left','right'}
- dhd = false
- monitor = false
- locations = {}
- function closePortal()
- local result = false
- repeat
- result,value = pcall(dhd.terminate)
- os.sleep(0.3)
- until result == true
- end
- function dialLocation(i)
- print(dhd.getStoredName(2))
- outputLocations(locations[i])
- closePortal()
- local index = i - 1
- local res = false
- repeat
- res,v = pcall(dhd.dialStored, index)
- os.sleep(0.3)
- until res == true
- end
- function generateLocations()
- for i=0, address_count - 1 do
- locations[i + 1] = dhd.getStoredName(i)
- end
- end
- function outputLocations(dialled)
- monitor.clear()
- term.clear()
- monitor.setCursorPos(1,1)
- term.setCursorPos(1,1)
- for i,v in ipairs(locations) do
- monitor.write(i..". "..v)
- monitor.setCursorPos(1, i + 1)
- end
- if( not addressDialled == false) then
- monitor.write("Last Location Dialled: "..dialled)
- end
- end
- -- wrap peripherals automagically
- for i, side in ipairs(sides) do
- if(peripheral.isPresent(side)) then
- if(peripheral.getType(side) == 'ep_dialling_device') then
- dhd = peripheral.wrap(side)
- --print methods (debug)
- --for i,v in ipairs(peripheral.getMethods(side)) do print(i..". "..v) end
- elseif(peripheral.getType(side) == 'monitor') then
- monitor = peripheral.wrap(side)
- end
- end
- end
- if(not dhd or not monitor) then
- error('No portal or monitor connected to computer')
- end
- address_count = dhd.getStoredCount()
- generateLocations()
- outputLocations(false)
- --monitor bs
- while true do
- event, side, xPos, yPos = os.pullEvent("monitor_touch")
- --if address touched
- if(yPos <= address_count) then
- dialLocation(yPos)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement