Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component");
- local redlight = component.traffic_light_card;
- local os = require("os")
- local term = require("term")
- local sides = require("sides")
- local colors = require("colors")
- local thread = require("thread")
- local rs = component.redstone
- function sleep(n)
- os.sleep(n)
- end
- term.clear()
- print("Traffic lights are starting! Lights are in flash mode")
- rs.setBundledOutput(sides.back, {[colors.cyan] = 200});
- sleep(80)
- term.clear()
- print("Traffic lights are starting all lights are red!")
- rs.setBundledOutput(sides.back, {[3] = 200})
- sleep(1)
- rs.setBundledOutput(sides.back, {[3] = 0})
- sleep(8)
- mode = "normal"
- running = "yes"
- console = "East Left"
- time = os.date("*t")
- cycledtime = time.hour .. ":" .. time.min
- local loop1 = thread.create(function()
- while true do
- time2 = os.date("*t")
- if(time2.hour == 21) or (time2.hour == 22) or (time2.hour == 23) or (time2.hour == 0) or (time2.hour == 1) or (time2.hour == 2) or (time2.hour == 3) or (time2.hour == 4) or (time2.hour == 5) and (mode == "normal") then
- mode = "flash"
- if(running == "no") then
- rs.setBundledOutput(sides.back, {[colors.yellow] = 0, [colors.pink] = 200})
- end
- else
- if(mode == "flash") and (running == "no") then
- if(time2.hour == 6) or (time2.hour == 7) or (time2.hour == 8) or (time2.hour == 9) or (time2.hour == 10) or (time2.hour == 11) or (time2.hour == 12) or (time2.hour == 13) or (time2.hour == 14) or (time2.hour == 15) or (time2.hour == 16) or (time2.hour == 17) or (time2.hour == 18) or (time2.hour == 19) or (time2.hour == 20) then
- rs.setBundledOutput(sides.back, {[3] = 200, [colors.pink] = 0})
- sleep(1)
- rs.setBundledOutput(sides.back, {[3] = 0})
- sleep(8)
- running = "yes"
- mode = "normal"
- end
- end
- end
- term.clear()
- print("Time Cycled: " .. cycledtime)
- print("Current Time: " .. time2.hour .. ":" .. time2.min)
- print("Current Cycle " .. console);
- sleep(1)
- end
- end)
- local loop2 = thread.create(function()
- while true do
- if(mode == "normal") then
- time3 = os.date("*t")
- cycledtime = time3.hour .. ":" .. time3.min
- console = "Stright"
- rs.setBundledOutput(sides.back, {[colors.yellow] = 0, [colors.black] = 0, [colors.brown] = 200})
- sleep(33)
- rs.setBundledOutput(sides.back, {[colors.yellow] = 255})
- sleep(5)
- rs.setBundledOutput(sides.back, {[colors.brown] = 0})
- sleep(3)
- rs.setBundledOutput(sides.back, {[colors.green] = 200})
- sleep(1)
- console = "U-Turn"
- rs.setBundledOutput(sides.back, {[colors.green] = 0, [colors.red] = 200})
- sleep(12)
- rs.setBundledOutput(sides.back, {[colors.red] = 0})
- sleep(3)
- rs.setBundledOutput(sides.back, {[colors.black] = 200})
- sleep(1)
- else
- if(running == "yes") then
- print("oof")
- running = "no"
- sleep(1)
- else
- sleep(1)
- end
- end
- end
- end)
- thread.waitForAny({loop1, loop2})
Advertisement
Add Comment
Please, Sign In to add comment