FairfaxGamingYT

HAWK Ped Beacon

Jul 9th, 2024 (edited)
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.06 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.  local hawk - {1,2,3,4,5}
  105.  local ped - {6,7}
  106.  
  107. os.sleep(60)
  108. -- start script
  109.  
  110. setBundledOutput(colors.cyan, 200)
  111.  
  112. os.sleep(20)
  113.  
  114. local loop2 = thread.create(function()
  115.  
  116.     while true do
  117.      print("Lakewood Elem. School Ped HAWK")
  118. -- phase 1 sl&ss
  119.  setLights(hawk, "Yellow", "flash")    
  120.  os.sleep(4)
  121.  setLights(hawk, "Yellow", "on")
  122.  os.sleep(3)
  123.  setLights(hawk, "Red", "on")
  124.  os.sleep(1)
  125.  setLights(ped, "Cross", "on")
  126.  os.sleep(5)
  127.  setLights(hawk, "Red", "flash")
  128.  setLights(ped, "Dontcross", "flash")
  129.  os.sleep(5)
  130.  setLights(ped, "DontCross", "on")
  131.  setLights(hawk, "red", "off")
  132.  os.sleep(1)
  133.      
  134.  
  135.     end
  136.  
  137.  
  138.   end)
  139.  
  140.  
  141.  
  142.  
  143.       thread.waitForAny({loop2})
  144.  
  145.  
Advertisement
Add Comment
Please, Sign In to add comment