mariodkzzzz

Portal stuff

Apr 17th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. local portal = peripheral.wrap("back")
  2. local monitor = peripheral.wrap("monitor_0")
  3. term.redirect(peripheral.wrap("monitor_0"))
  4. local w, h = monitor.getSize()
  5. --For the Buttons & taking the names from the Dialing Device to the Touch Screen
  6.  
  7. function find(t, v)
  8. for k, l in pairs(t) do
  9. if l == v then
  10. return k
  11. end
  12. end
  13. end
  14.  
  15. function dialLocation(i)
  16. portal.terminate()
  17. portal.dialStored(i - 1)
  18. end
  19. os.loadAPI( "simpleButton" )
  20. os.sleep(2)
  21. buttonNames = {};
  22. for i=0, portal.getStoredCount()-1 do
  23. table.insert(buttonNames, portal.getStoredName(i))
  24. end
  25. local t = simpleButton.makeButtonPages( colors.black, colors.red, colors.white, unpack(buttonNames))
  26. t:render()
  27.  
  28. --for Dialing to location after touched the screen on a name
  29. address_count = portal.getStoredCount()
  30.  
  31.  
  32. while true do
  33. local event = {t:handleEvents( os.pullEvent() )}
  34. if event[1] == "button_click" then
  35. dialLocation(find(buttonNames, event[2]))
  36. os.sleep(2)
  37. t:render()
  38. end
  39. end
Advertisement
Add Comment
Please, Sign In to add comment