Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local traffic = component.traffic_light_card
- -- === SETTINGS ===
- local x, y, z = -118, 5, -449 -- traffic light position
- local frame = 0 -- frame index to modify
- local oldBulb = "Red"
- local newBulb = "RedX"
- os.sleep(15)
- -- === STEP 1: Turn old bulb ON ===
- print("Turning on old bulb before change...")
- traffic.setState(x, y, z, oldBulb, true, false)
- -- === STEP 2: Wait then change the bulb ===
- os.sleep(5) -- wait 2 seconds to see old bulb turn on
- print("Changing bulb...")
- local success, message = traffic.changeBulb(x, y, z, oldBulb, newBulb)
- print(success and "✅ Changed bulb: " .. message or "❌ Failed: " .. message)
- -- === STEP 3: Turn new bulb ON if successful ===
- if success then
- os.sleep(5) -- wait 1 sec to allow change
- print("Turning on new bulb after change...")
- traffic.setState(x, y, z, newBulb, true, false)
- else
- print("Change failed; not activating new bulb.")
- end
- os.sleep(5)
- local success, message = traffic.changeBulb(x, y, z, newBulb, oldBulb)
- os.sleep(5)
- traffic.setState(x, y, z, oldBulb, true, false)
- os.sleep(5)
- traffic.setState(x, y, z, oldBulb, false, false)
Advertisement
Add Comment
Please, Sign In to add comment