GamearooCodes

Untitled

Aug 4th, 2025
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. local component = require("component")
  2. local traffic = component.traffic_light_card
  3.  
  4. -- === SETTINGS ===
  5. local x, y, z = -118, 5, -449 -- traffic light position
  6. local frame = 0 -- frame index to modify
  7. local oldBulb = "Red"
  8. local newBulb = "RedX"
  9. os.sleep(15)
  10. -- === STEP 1: Turn old bulb ON ===
  11. print("Turning on old bulb before change...")
  12. traffic.setState(x, y, z, oldBulb, true, false)
  13.  
  14. -- === STEP 2: Wait then change the bulb ===
  15. os.sleep(5) -- wait 2 seconds to see old bulb turn on
  16.  
  17. print("Changing bulb...")
  18. local success, message = traffic.changeBulb(x, y, z, oldBulb, newBulb)
  19. print(success and "✅ Changed bulb: " .. message or "❌ Failed: " .. message)
  20.  
  21. -- === STEP 3: Turn new bulb ON if successful ===
  22. if success then
  23. os.sleep(5) -- wait 1 sec to allow change
  24. print("Turning on new bulb after change...")
  25. traffic.setState(x, y, z, newBulb, true, false)
  26. else
  27. print("Change failed; not activating new bulb.")
  28. end
  29.  
  30.  
  31. os.sleep(5)
  32.  
  33. local success, message = traffic.changeBulb(x, y, z, newBulb, oldBulb)
  34.  
  35. os.sleep(5)
  36.  
  37. traffic.setState(x, y, z, oldBulb, true, false)
  38.  
  39. os.sleep(5)
  40.  
  41. traffic.setState(x, y, z, oldBulb, false, false)
  42.  
Advertisement
Add Comment
Please, Sign In to add comment