Advertisement
Guest User

startup

a guest
Feb 19th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.91 KB | None | 0 0
  1.  
  2. local THIS_FLOOR = 1
  3. local modem = peripheral.wrap("front")
  4.  
  5. local MONITORS = {"monitor_5", "monitor_6", "monitor_7", "monitor_8", "monitor_9"}
  6.  
  7. local monitor = MONITORS[THIS_FLOOR]
  8. local activeFloor = 1
  9.  
  10. modem.callRemote(monitor, "setBackgroundColor", colors.gray)
  11. modem.callRemote(monitor, "clear")
  12.  
  13. function print(x, y, text)
  14.     modem.callRemote(monitor, "setCursorPos", x, y)
  15.     modem.callRemote(monitor, "write", text)
  16. end
  17.  
  18. function color(color)
  19.     modem.callRemote(monitor, "setBackgroundColor", color)
  20. end
  21.  
  22. function setActiveFloor(floor)
  23.     if (floor == THIS_FLOOR) then
  24.         screenActive()
  25.         redstone.setOutput("top", true)
  26.         redstone.setOutput("right", true)      
  27.     else
  28.         screenInactive()
  29.         redstone.setOutput("top", false)
  30.         redstone.setOutput("right", false)
  31.     end
  32.     activeFloor = floor
  33. end
  34.  
  35. function screenInactive()
  36.     local m = MONITORS[THIS_FLOOR]
  37.     color(colors.black)
  38.     modem.callRemote(monitor, "clear")
  39.     print(1, 1, "-------")
  40.     color(colors.gray)
  41.     print(1, 4, "       ")
  42.     print(1, 5, "Tap to ")
  43.     print(1, 6, "   Call")
  44.     print(1, 7, "       ")
  45.     color(colors.black)
  46.     print(1, 12, "-------")
  47. end
  48.  
  49. function screenActive()
  50.     local m = MONITORS[THIS_FLOOR]
  51.     color(colors.gray)
  52.     modem.callRemote(monitor, "clear")
  53.     color(colors.black)
  54.     print(1, 2, "       ")
  55.     print(1, 3, "   3   ")
  56.     color(colors.gray)
  57.     print(1, 4, "       ")
  58.     print(1, 5, "   2   ")
  59.     color(colors.black)
  60.     print(1, 6, "       ")
  61.     print(1, 7, "   1   ")
  62.     color(colors.gray)
  63.     print(1, 8, "       ")
  64.     print(1, 9, "   L   ")
  65.     color(colors.black)
  66.     print(1, 10, "       ")
  67.     print(1, 11, "  -1   ")
  68. end
  69.  
  70. setActiveFloor(1)
  71. while true do
  72.     local event, monitor, x, y = os.pullEvent("monitor_touch")
  73.     floor = tonumber(string.sub(monitor, 9)) - 4
  74.     if (floor ~= activeFloor) then
  75.         setActiveFloor(floor)
  76.     else
  77.         floor = math.floor((13 - y) / 2)
  78.         if (floor > 0 and floor <= 5) then
  79.             setActiveFloor(floor)
  80.         end
  81.     end
  82.  
  83. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement