SHARE
TWEET

Station

a guest Aug 25th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CableBundleSide = "right"
  2.  
  3. Timer = 0
  4. MineTimer = 3000
  5. MineNeedsTrain = false
  6. TrainToMine = false
  7.  
  8. -----------------------------------------------------------------------------
  9. function GetSignal(Color)
  10.     return redstone.testBundledInput(CableBundleSide, Color)
  11. end
  12.  
  13. function SetSignal(Color)
  14.     redstone.setBundledOutput(CableBundleSide, Color)
  15. end
  16.  
  17. function ResetSignals()
  18.     redstone.setBundledOutput(CableBundleSide, 0)
  19. end
  20.  
  21. -----------------------------------------------------------------------------
  22.  
  23. function TrainReturn()
  24.     print("Checking if Train is returning...")
  25.     if GetSignal(colors.gray) == true then
  26.         print("Train is returning from the powerplant.")
  27.         print("Starting entering station...")
  28.        
  29.         SetSignal(colors.black + colors.brown)
  30.        
  31.         while GetSignal(colors.yellow) == false do
  32.             sleep(1)
  33.         end
  34.         sleep(2)
  35.         Timer = 0
  36.         ResetSignals()
  37.     elseif GetSignal(colors.red) == true then
  38.         print("Train is returning from the mine.")
  39.         print("Starting entering station...")
  40.        
  41.         SetSignal(colors.white)
  42.  
  43.         while GetSignal(colors.yellow) == false do
  44.             sleep(1)
  45.         end
  46.   sleep(2)
  47.         TrainToMine = false
  48.         MineTimer = 0
  49.         ResetSignals()
  50.     end
  51. end
  52.  
  53. function TrainLeave()
  54.     print("Checking if Train is ready to leave...")
  55.     if Timer == 180 then
  56.         print("Train is leaving to the powerplant.")
  57.         print("Starting leaving station...")
  58.        
  59.         SetSignal(colors.black + colors.brown + colors.green)
  60.        
  61.         while GetSignal(colors.gray) == false do
  62.             sleep(1)
  63.         end
  64.         sleep(2)
  65.         Timer = 0
  66.         ResetSignals()
  67.     elseif (MineNeedsTrain == true) and (TrainToMine == false) then
  68.         print("Train is leaving to the mine.")
  69.         print("Starting leaving station...")
  70.        
  71.         SetSignal(colors.white + colors.green)
  72.  
  73.         while GetSignal(colors.red) == false do
  74.             sleep(1)
  75.         end
  76.         sleep(2)
  77.         TrainToMine = true
  78.         MineTimer = 0
  79.         ResetSignals()
  80.     elseif TrainToMine == true then
  81.         MineNeedsTrain = false
  82.         MineTimer = 0
  83.     end
  84. end
  85.  
  86. function Timers()
  87.     if MineTimer >= 3600 then
  88.         MineNeedsTrain = true
  89.         Timer = 0
  90.     elseif GetSignal(colors.lightGray) == true then
  91.         Timer = Timer + 1
  92.     end
  93.  MineTimer = MineTimer + 1
  94.  print("MineTimer = "..MineTimer)
  95.  print("MainTimer = "..Timer)
  96. end
  97.  
  98. -----------------------------------------------------------------------------
  99.  
  100. while true do
  101.     term.clear()
  102.     TrainReturn()
  103.     TrainLeave()
  104.     Timers()
  105.     sleep(1)
  106. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top