Advertisement
Guest User

startup

a guest
Aug 1st, 2014
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.52 KB | None | 0 0
  1. portals = {}
  2. portals[1] = { "Ground Floor" , "1-1-1" }
  3. portals[2] = { "Floor 1 - ME Control Room" , "0-0-0" }
  4. portals[3] = { "Floor 2 - Utilities Factory" , "3-3-3" }
  5. portals[4] = { "Floor 3 - Ingot Processing" , "4-4-4" }
  6. portals[5] = { "Floor 4 - Spare Floor" , "5-5-5" }
  7. portals[6] = { "Floor 5 - Chemical Processing", "2-2-2" }
  8. portals[7] = { "Floor 6 - Ore Processing", "6-6-6" }
  9. portals[8] = { "Floor 7 - Smeltery" , "7-7-7" }
  10. portals[9] = { "Floor 8 - Tinkermania", "8-8-8"}
  11. --table.sort(portals)
  12. --local myTimer
  13. mon2 = peripheral.wrap('top')
  14. --mon2.clear()
  15. dial = peripheral.wrap("right")
  16. monitor = peripheral.wrap("left")
  17. controller = peripheral.wrap("ep_controller_1")
  18. portalActive = false
  19. locationCount = 0
  20.  
  21.  
  22. function update()
  23.   portalActive = controller.isPortalActive()
  24.   locationCount = #portals
  25. end
  26.  
  27. function drawScreen()
  28. i = 1
  29. if not portalActive ==  true then
  30.  
  31. mon2.clear()
  32. end
  33. --   monitor.setBackgroundColor(colors.green)
  34. --    monitor.clear()
  35.  --   monW, monH = monitor.getSize()
  36.   --  monitor.setCursorPos(monW / 2 - string.len("Terminate") / 2, monH / 2)
  37.  --   monitor.write("Terminate")
  38. --    mon2.setBackgroundColor(colors.red)
  39. --  mon2.clear()
  40.       monitor.setBackgroundColor(colors.black)  
  41.     monitor.clear()
  42.  
  43.          for index,values in pairs(portals) do
  44.           name = values[1]
  45.           monitor.setCursorPos(1, i)
  46.      
  47.         if (i % 2 == 0) then
  48.           monitor.setBackgroundColor(colors.gray)
  49.         else
  50.           monitor.setBackgroundColor(colors.lightGray)
  51.         end
  52.    
  53.            monW, monH = monitor.getSize()
  54.      
  55.         monitor.write(name)      
  56.         k = string.len(name)
  57.      
  58.         while (k < monW) do
  59.           monitor.write(" ")
  60.           k = k + 1
  61.         end
  62.  i = i + 1      
  63.       end
  64.    
  65.    
  66.   end
  67.  
  68.  
  69. function handleInput()
  70.   event, side, posX, posY = os.pullEvent("monitor_touch")
  71.  
  72.   if portalActive then
  73.     dial.terminate()
  74.   else
  75. if posY <= #portals then  
  76. mon2.setCursorPos(1,1)
  77.               -- if unexpected_condition then error() end
  78.      local ok,error = pcall( dial.dial, portals[posY][2])
  79.    if not ok then
  80.    mon2.write("Whoops - Try Again")
  81.    else
  82.    mon2.write(portals[posY][1])
  83.    end
  84. -- myTimer = os.startTimer(8)
  85. --local event,timerID= os.pullEvent("timer")
  86.  
  87.          --os.sleep(10)
  88.    --mon2.clear()
  89.   end
  90. end
  91. end
  92. while true do
  93.   update()
  94.   drawScreen()
  95.   handleInput()
  96.   os.sleep(1)
  97. -- event, timerID = os.pullEvent("timer")
  98. --if timerID == myTimer then
  99. --mon2.clear()
  100. --end
  101. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement