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
- term.clear()
- print("Traffic lights are starting! Lights are in flash mode")
- rs.setBundledOutput(sides.back, {[colors.cyan] = 200})
- os.sleep(60);
- term.clear()
- print("Traffic lights are starting all lights are red!")
- rs.setBundledOutput(sides.back, {[3] = 200})
- os.sleep(1)
- rs.setBundledOutput(sides.back, {[3] = 0})
- os.sleep(8)
- redlight.setState(-1423, 74, -578, "StraightGreen", true, false)
- redlight.setState(-1419, 74, -578, "StraightGreen", true, false)
- redlight.setState(-1423, 74, -578, "StraightRed", false, false)
- redlight.setState(-1419, 74, -578, "StraightRed", false, false)
- function sleep(n)
- os.sleep(n)
- end
- console = "East Left"
- time = os.date("*t")
- cycledtime = time.hour .. ":" .. time.min
- local loop1 = thread.create(function()
- while true do
- time2 = os.date("*t")
- 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
- time3 = os.date("*t")
- cycledtime = time3.hour .. ":" .. time3.min
- console = "Left Turn"
- rs.setBundledOutput(sides.back, {[colors.blue] = 0, [colors.black] = 200})
- redlight.setState(-1404, 74, -589, "NoRightTurn", true, false)
- sleep(12)
- rs.setBundledOutput(sides.back, {[colors.black] = 0})
- sleep(3)
- rs.setBundledOutput(sides.back, {[colors.red] = 200})
- sleep(1)
- redlight.setState(-1404, 74, -589, "NoRightTurn", false, false)
- console = "Striaght"
- rs.setBundledOutput(sides.back, {[colors.red] = 0, [colors.green] = 200})
- sleep(30)
- rs.setBundledOutput(sides.back, {[colors.green] = 0})
- sleep(3)
- rs.setBundledOutput(sides.back, {[colors.blue] = 200})
- sleep(1)
- end
- end)
- thread.waitForAny({loop1, loop2})
Advertisement
Add Comment
Please, Sign In to add comment