Advertisement
NeonJ

RedstoneCONTROL - Server PC [WIP]

Jan 15th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.03 KB | None | 0 0
  1. --[[
  2.  
  3. RedstoneControl Main PC
  4.  
  5. The goal is to have this main PC handle Rednet signals directed at it, and do actions depending on the signal.
  6. Also it has a huge monitor. Because why not?
  7.  
  8. 0 123456789012345678901234567
  9.  +---------------------------+
  10. 1| ---- |   System Status    |
  11. 2| |  | |--------------------|
  12. 3| |##| |Lift: Stopped - B1F |
  13. 4| |##| |Storage: Pipe Jam   |
  14. 5| |##| |                    |  <-- Looks plain, needs more detection.
  15. 6| |##| |BT: Moderate        |
  16. 7| |##| |Mchn Room: Pipe Jam |
  17. 8| |##| |BC Engines: No Power|
  18. 9| |##| |Farms: Working      |
  19. 0| ---- |                    |
  20. 1|  EU  |                    |
  21.  +---------------------------+
  22.  
  23. EU meter depends on BatBox ability to give off a redstone signal when not empty.
  24. Requires 8 BatBoxes / MFEs / MFSUs to work.
  25. Constantly send PC signals and check for ping to see if PCs are OK
  26. Use Item Detector in Stuffed Mode to check if storage has a pipe jam   []TR==ID==>
  27. The computer itself handles lift redstone signals, so it'll always know.
  28.  
  29. EU will show as full when EUBats[8] still has power, but is not full.
  30. EU will show with 1 pip when EUBats[1] still has power, but is not full.
  31. EU will show with 0 pips when no EUBats have any energy left.
  32.  
  33. Lift controlled by PC - PC always knows where it is.
  34. Storage managed by Item Detectors, if there's a permanent power going out, something's stuck
  35. BT.. no clue
  36. Machine Room same as storage
  37. BC Engines.. no clue
  38. Farms using Item Detectors again, *should* work.
  39.  
  40. --]]
  41.  
  42. -- * * * VARIABLES * * *
  43.  
  44. detectSide = "bottom" -- Detect EU and Storage
  45. rednetSide = "top"
  46. monSide = "back"
  47. outputSide = "left"   -- Output lift movement.
  48.  
  49. floorSize = 8
  50. liftFloor = 4
  51. targetLiftFloor = 0
  52.  
  53. -- * * * CODE * * *
  54.  
  55. rednet.open(rednetSide)
  56.  
  57. function moveLift()
  58.   print("Moving Lift..")
  59.   local moveLift = true
  60.   while moveLift do
  61.     if liftFloor < targetLiftFloor then
  62.       print("Going up!")
  63.       for i=1,floorSize do
  64.         rs.setBundledOutput(outputSide, colors.white)
  65.         sleep(0.1)
  66.         rs.setBundledOutput(outputSide, colors.white + colors.red)
  67.         sleep(0.4)
  68.         rs.setBundledOutput(outputSide, 0)
  69.         sleep(0.5)
  70.       end
  71.       liftFloor = liftFloor + 1
  72.     elseif liftFloor > targetLiftFloor then
  73.       print("Going down!")
  74.       for i=1,floorSize do
  75.         rs.setBundledOutput(outputSide, colors.orange)
  76.         sleep(0.1)
  77.         rs.setBundledOutput(outputSide, colors.orange + colors.yellow)
  78.         sleep(0.4)
  79.         rs.setBundledOutput(outputSide, 0)
  80.         sleep(0.5)
  81.       end
  82.       liftFloor = liftFloor - 1
  83.     else
  84.       moveLift = false
  85.       print("Going nowhere!")
  86.     end
  87.   end
  88. end
  89.  
  90. moveLift()
  91. rednet.broadcast("[RedCTRL] liftMoved B1F !")
  92.  
  93. while true do
  94.   local events = {os.pullEvent()}
  95.   if events[1] == "rednet_message" then
  96.     if events[3] == "[RedCTRL] moveLift B1F !" then
  97.       targetLiftFloor = 0
  98.       rednet.broadcast("[RedCTRL] liftMoving !")
  99.       moveLift()
  100.       rednet.broadcast("[RedCTRL] liftMoved B1F !")
  101.     elseif events[3] == "[RedCTRL] moveLift 1F !" then
  102.       targetLiftFloor = 1
  103.       rednet.broadcast("[RedCTRL] liftMoving !")
  104.       moveLift()
  105.       rednet.broadcast("[RedCTRL] liftMoved 1F !")
  106.     elseif events[3] == "[RedCTRL] moveLift 2F !" then
  107.       targetLiftFloor = 2
  108.       rednet.broadcast("[RedCTRL] liftMoving !")
  109.       moveLift()
  110.       rednet.broadcast("[RedCTRL] liftMoved 2F !")
  111.     elseif events[3] == "[RedCTRL] moveLift 3F !" then
  112.       targetLiftFloor = 3
  113.       rednet.broadcast("[RedCTRL] liftMoving !")
  114.       moveLift()
  115.       rednet.broadcast("[RedCTRL] liftMoved 3F !")
  116.     elseif events[3] == "[RedCTRL] moveLift 4F !" then
  117.       targetLiftFloor = 4
  118.       rednet.broadcast("[RedCTRL] liftMoving !")
  119.       moveLift()
  120.       rednet.broadcast("[RedCTRL] liftMoved 4F !")
  121.     elseif events[3] == "[RedCTRL] sendMeLift !" then
  122.       if liftFloor == 0 then
  123.         rednet.broadcast("[RedCTRL] liftMoved B1F !")
  124.       else
  125.         rednet.broadcast("[RedCTRL] liftMoved "..liftFloor.."F !")
  126.       end
  127.     end
  128.   end
  129. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement