MysteryDump

MysteryDump's Railcraft Elevator Monitor v1.4a - FLOOR 3

Mar 16th, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.84 KB | None | 0 0
  1. --  RAILCRAFT ELEVATOR MONITOR "A" VERSION 1.4A MARCH 13TH 2014
  2. --  DESIGNED AND WRITTEN BY "MYSTERYDUMP"
  3. --  WWW.MYSTERYDUMP.COM
  4.  
  5.  
  6. --  ****IMPORTANT**** THIS IS THE "A" VERSION OF THE OVERHEAD MONITOR DISPLAY PROGRAM AND MUST BE USED WITH THE "A" VERSIONS OF THE ELEVATOR "CLIENT PROGRAMS" AND THE "A" VERSION OF THE ELEVATOR SERVER! IF YOU NEED HELP BUILDING AND/OR INSTALLING THE ELEVATOR AND THE SERVER/MONITOR/CLIENT PROGRAMS AND THEN CONFIGURING THEM, GO TO MYSTERYDUMP.COM/ELEVATOR FOR HELP.
  7.  
  8.  
  9.  
  10.  
  11. -- SET WHICH FLOOR THIS MONITOR WILL BE INSTALLED ON HERE (Enter 1 through 7)
  12.  
  13. local floorLevel = 3    -- <-----------******** CHANGE TO FLOOR LEVEL NUMBER YOU ARE INSTALLING THIS MONITOR ON ********
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20. -- SET BUNDLED CABLE TO "TOP" AND INITIALIZE IN/OUTPUTS (OFF)
  21.  
  22.     local cablePort = "top"
  23.     rs.setBundledOutput(cablePort, 0 )
  24.  
  25.  
  26.  
  27.  
  28. -- MONITOR SETUP
  29.  
  30.     mon = peripheral.wrap("back")
  31.  
  32.  
  33.  
  34.  
  35. -- SET "LOCALS"
  36.  
  37. local cartFloor = 0
  38.  
  39. local level07Detector = redstone.testBundledInput(cablePort, colors.white)
  40. local level06Detector = redstone.testBundledInput(cablePort, colors.magenta)
  41. local level05Detector = redstone.testBundledInput(cablePort, colors.yellow)
  42. local level04Detector = redstone.testBundledInput(cablePort, colors.pink)
  43. local level03Detector = redstone.testBundledInput(cablePort, colors.lightGray)
  44. local level02Detector = redstone.testBundledInput(cablePort, colors.purple)
  45. local level01Detector = redstone.testBundledInput(cablePort, colors.brown)
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56. -- TIMERS
  57.  
  58. timerA = os.startTimer(1.5)
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. -- CLEAR & INITIALIZE TERMINAL & MONITOR SCREENS
  71.  
  72. function Monitor()
  73.  
  74.     term.clear()
  75.     term.setCursorPos(1,1)
  76.     print "Elevator Monitor Program v1.4a"
  77.     term.setCursorPos(1,3)
  78.     print "System: Online"
  79.     term.setCursorPos(1,5)
  80.     print "Searching for Cart, Please wait... "
  81.     sleep(2)
  82.  
  83.     -- CLEAR & INITIALIZE MONITOR SCREEN (BACK)
  84.  
  85.     mon.clear()
  86.     mon.setTextScale(1)
  87.     mon.setTextColor(colors.white)
  88.     mon.setCursorPos(1,1)
  89.     mon.write "Floor"
  90.     mon.setCursorPos(7,1)
  91.     mon.write (tostring(floorLevel))
  92.     mon.setCursorPos(1,3)
  93.     mon.write "Startup"
  94.  
  95. end
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108. -- DETECT CART LOCATION (FUNCTION)
  109.  
  110.  
  111. detectCurrentFloor = function()
  112.  
  113.  
  114. readyBusy()
  115.  
  116.     level07Detector = redstone.testBundledInput(cablePort, colors.white)
  117.         if level07Detector == true then
  118.         cartFloor = 7
  119.         else
  120.         end
  121.  
  122.     level06Detector = redstone.testBundledInput(cablePort, colors.magenta)
  123.         if level06Detector == true then
  124.         cartFloor = 6
  125.         else
  126.         end
  127.     level05Detector = redstone.testBundledInput(cablePort, colors.yellow)
  128.         if level05Detector == true then
  129.         cartFloor = 5
  130.         else
  131.         end
  132.     level04Detector = redstone.testBundledInput(cablePort, colors.pink)
  133.         if level04Detector == true then
  134.         cartFloor = 4
  135.         else
  136.         end
  137.     level03Detector = redstone.testBundledInput(cablePort, colors.lightGray)
  138.         if level03Detector == true then
  139.         cartFloor = 3
  140.         else
  141.         end
  142.     level02Detector = redstone.testBundledInput(cablePort, colors.purple)
  143.         if level02Detector == true then
  144.         cartFloor = 2
  145.         else
  146.         end
  147.     level01Detector = redstone.testBundledInput(cablePort, colors.brown)
  148.         if level01Detector == true then
  149.         cartFloor = 1
  150.         else
  151.         end
  152.  
  153.  
  154.         if level01Detector == false and level02Detector == false and level03Detector == false and level04Detector == false and level05Detector == false and level06Detector == false and level07Detector == false then
  155.         cartFloor = 0
  156.  
  157.         mon.setTextColor(colors.red)
  158.         mon.setCursorPos(1,3)
  159.         mon.write " Busy! "
  160.  
  161.         else
  162.         end
  163.  
  164. end
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174. -- UPDATE "READY OR BUSY" ON MONITOR (FUNCTION)
  175.  
  176.  
  177. function readyBusy()
  178.  
  179.  
  180.     if cartFloor == 0 then
  181.     timerA = os.startTimer(1.5)
  182.     end
  183.  
  184.     event, completed = os.pullEvent()
  185.  
  186.     if event == "timer" then
  187.             if completed == timerA then
  188.             mon.setTextColor(colors.white)
  189.             mon.setCursorPos(1,3)
  190.             mon.write " Ready "
  191.  
  192.                
  193.         else
  194.             mon.setTextColor(colors.red)
  195.             mon.setCursorPos(1,3)
  196.             mon.write " Busy! "
  197.         end
  198.     end
  199. end
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208. -- UPDATE TERMINAL & MONITOR SCREENS (FUNCTION)
  209.  
  210. updateMonitor = function()
  211.  
  212.     term.clear()
  213.     term.setCursorPos(1,1)
  214.     print "Elevator Monitor Program v1.4a"
  215.     term.setCursorPos(1,3)
  216.     print "System: Online"
  217.     term.setCursorPos(1,5)
  218.     print ("Cart on Floor: ", (cartFloor))
  219.  
  220.  
  221.         if cartFloor == 1 then
  222.             mon.setCursorPos(1,5)
  223.             mon.setTextColor(colors.gray)
  224.             mon.write " 234567"
  225.             mon.setCursorPos(1,5)
  226.             mon.setTextColor(colors.red)
  227.             mon.write (tostring(cartFloor))
  228.         end
  229.  
  230.         if cartFloor == 2 then
  231.             mon.setCursorPos(1,5)
  232.             mon.setTextColor(colors.gray)
  233.             mon.write "1 34567"
  234.             mon.setCursorPos(2,5)
  235.             mon.setTextColor(colors.red)
  236.             mon.write (tostring(cartFloor))
  237.         end
  238.  
  239.         if cartFloor == 3 then
  240.             mon.setCursorPos(1,5)
  241.             mon.setTextColor(colors.gray)
  242.             mon.write "12 4567"
  243.             mon.setCursorPos(3,5)
  244.             mon.setTextColor(colors.red)
  245.             mon.write (tostring(cartFloor))
  246.         end
  247.  
  248.         if cartFloor == 4 then
  249.             mon.setCursorPos(1,5)
  250.             mon.setTextColor(colors.gray)
  251.             mon.write "123 567"
  252.             mon.setCursorPos(4,5)
  253.             mon.setTextColor(colors.red)
  254.             mon.write (tostring(cartFloor))
  255.         end
  256.  
  257.         if cartFloor == 5 then
  258.             mon.setCursorPos(1,5)
  259.             mon.setTextColor(colors.gray)
  260.             mon.write "1234 67"
  261.             mon.setCursorPos(5,5)
  262.             mon.setTextColor(colors.red)
  263.             mon.write (tostring(cartFloor))
  264.         end
  265.  
  266.         if cartFloor == 6 then
  267.             mon.setCursorPos(1,5)
  268.             mon.setTextColor(colors.gray)
  269.             mon.write "12345 7"
  270.             mon.setCursorPos(6,5)
  271.             mon.setTextColor(colors.red)
  272.             mon.write (tostring(cartFloor))
  273.         end
  274.  
  275.         if cartFloor == 7 then
  276.             mon.setCursorPos(1,5)
  277.             mon.setTextColor(colors.gray)
  278.             mon.write "123456 "
  279.             mon.setCursorPos(7,5)
  280.             mon.setTextColor(colors.red)
  281.             mon.write (tostring(cartFloor))
  282.         end
  283.  
  284.  
  285.  
  286. end
  287.  
  288.  
  289.  
  290.  
  291.  
  292. -- BEGIN PROGRAM
  293.  
  294.  
  295. Monitor()
  296.  
  297.  
  298. while true do
  299. sleep(0)
  300.     parallel.waitForAll (detectCurrentFloor, updateMonitor)
  301.  
  302. end
Add Comment
Please, Sign In to add comment