FairfaxGamingYT

Test Fire HAWK

Jul 10th, 2024 (edited)
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.11 KB | None | 0 0
  1. local component = require("component");
  2. local traffic = component.traffic_light_card
  3. local os = require("os")
  4. local thread = require("thread")
  5.  
  6. local sides = require("sides")
  7. local computer = require("computer")
  8.  
  9. -- Warning this script contains bulbs from a custom edited version of traffic control to use this script fine Left2 and Right2 for yellows and remove the 2 from that and it will work
  10.  
  11. local colors = require("colors")
  12.  
  13. local rs = component.redstone
  14.  
  15.  
  16. function setBundledOutput(color, state)
  17.  
  18.  
  19.     rs.setBundledOutput(sides.back, {[color] = state})
  20.  
  21.  
  22.  
  23.   end
  24.  
  25.  
  26.   function getBundledoutput(color)
  27.  
  28.    return  rs.getBundledInput(sides.back, color);
  29.  
  30.   end
  31.  
  32.   setBundledOutput(colors.white, 200)
  33.  
  34. trafficLight = {}
  35. lightPOS = traffic.listBlockPos()
  36.  
  37. for i = 1, #lightPOS do
  38.   trafficLight[i] = lightPOS[i]
  39. end
  40.  
  41.  
  42.  
  43. function setLights(id,state,mode,forceClear)
  44.   -- F is the boolean for Flashing, S is the boolean for Steady/On
  45.   local f = false
  46.   local s = false
  47.  
  48.   --  Clear signal if flag to forceClear isn't set to false
  49.   if forceClear ~= false then
  50.     if (type(id) == "table") then
  51.       for itr = 1, #id do
  52.         traffic.clearStates(trafficLight[id[itr]][1],trafficLight[id[itr]][2],trafficLight[id[itr]][3])
  53.       end
  54.     elseif (type(id) == "string") then
  55.       traffic.clearStates(trafficLight[id][1],trafficLight[id][2],trafficLight[id][3])
  56.     end
  57.   end
  58.  
  59.   --  Determine mode
  60.   if mode ~= nil then
  61.     --    Flashing
  62.     if string.lower(mode) == "flash" then
  63.       s = true
  64.       f = true
  65.     --   Steady
  66.     elseif string.lower(mode) == "on" then
  67.       s = true
  68.       f = false
  69.       --    Off
  70.     else
  71.       s = false
  72.       f = false
  73.     end
  74.   else
  75.     s = false
  76.     f = false
  77.   end
  78.  
  79.   --  Apply to signal
  80.   if (type(id) == "table" and state ~= nil) then
  81.     for itr = 1, #id do
  82.       traffic.setState(trafficLight[id[itr]][1],trafficLight[id[itr]][2],trafficLight[id[itr]][3],state,s,f)
  83.     end
  84.  
  85.   elseif (type(id) == "string" and state ~= nil) then
  86.     traffic.setState(trafficLight[id][1],trafficLight[id][2],trafficLight[id][3],state,s,f)
  87.   end
  88. end
  89. -- key
  90. -- S Stright
  91. -- Y stright bulb
  92. -- T Turn Bulb
  93. -- L Left
  94. -- R Right
  95. -- Middle Frame
  96.  
  97.  
  98. -- north 1 LT, 2 YS , 3 YS , 4 RT
  99. -- south 5 LT, 6 YS, 7 YS , 8 RT
  100. -- east 9 L , 10 ML , 11 MR,12 R
  101. -- west 13 L, 14 R
  102.  
  103.  
  104.  HAWK = {1,2}
  105.  Fire = {3}
  106.  Warning = {4}
  107.  
  108.  
  109. os.sleep(60)
  110. -- start script
  111.  
  112. setBundledOutput(colors.cyan, 200)
  113.  
  114. os.sleep(8)
  115.  
  116. local loop2 = thread.create(function()
  117.  
  118.     while true do
  119.      print("Emergency HAWK on PCH")
  120. -- phase 1 sl&ss
  121.   setLights(Warning, "Yellow", "flash")
  122.   setLights(HAWK, "Yellow", "flash")
  123.   os.sleep(5)
  124.   setLights(HAWK, "Yellow", "on")
  125.   os.sleep(3)
  126.   setLights(HAWK, "Red", "on")
  127.   setLights(Fire, "Green", "on")
  128.   os.sleep(10)
  129.   setLights(Fire, "Yellow", "on")
  130.   os.sleep(3)
  131.   setLights(Fire, "Yellow", "flash")
  132.   setLights(HAWK, "Red", "flash")
  133.   os.sleep(10)
  134.   setLights(Warning, "Yellow", "off"
  135.   os.sleep(60)
  136.      
  137.  
  138.     end
  139.  
  140.  
  141.   end)
  142.  
  143.  
  144.  
  145.  
  146.       thread.waitForAny({loop2})
  147.  
  148.  
  149.  
Advertisement
Add Comment
Please, Sign In to add comment