Advertisement
mariodkzzzz

Tardis CC portal program

Apr 24th, 2015
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.09 KB | None | 0 0
  1. local portal = peripheral.wrap("bottom")
  2. local monitor = peripheral.wrap("monitor_0")
  3.  
  4. local w, h = monitor.getSize()
  5.  
  6. --For the Buttons & taking the names from the Dialing Device to the Touch Screen
  7. function dialLocation(i)
  8.         portal.terminate()
  9.         portal.dialStored(i - 1)
  10. end
  11.  
  12. newLine = function()
  13. local _,cY = monitor.getCursorPos()
  14. monitor.setCursorPos((w/2)-5,cY+1)
  15. end
  16.  
  17. monitor.setTextScale(1.5)
  18. local color = colors.black
  19.  
  20. monitor.setBackgroundColor(colors.black)
  21.  
  22. monitor.clear()
  23. monitor.setCursorPos(3,1)
  24.  
  25. --For the Buttons & taking the names from the Dialing Device to the Touch Screen
  26. for i=0, portal.getStoredCount()-1 do
  27. monitor.setBackgroundColor(color)
  28. color = colors.blue
  29. monitor.write(" " .. portal.getStoredName(i) .. " ")
  30. newLine()
  31. end
  32.  
  33. --for Dialing to location after touched the screen on a name
  34. address_count = portal.getStoredCount()
  35. while(true) do
  36. event, side, xPos, yPos = os.pullEvent("monitor_touch")
  37. portal.terminate()
  38. if yPos == 2 then
  39. portal.dialStored(1)
  40. end
  41. if(yPos <= address_count) then
  42.   dialLocation(yPos)
  43. end
  44. os.sleep(2)
  45. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement