Files
stationeers/Lights/OccupancyOld.ic10
2025-10-13 11:25:05 -05:00

53 lines
1.4 KiB
Plaintext

# ===== Config =====
# 1 = require darkness too, 0 = ignore day/night
define EnableDayCheck 0
# any avg > this turns lights on
define MotionOnThresh 0.5
# ===== Hashes (sensors) =====
define HashOcc HASH("StructureOccupancySensor")
define HashDay HASH("StructureDaylightSensor")
# ===== Hashes (lights) from Kit (Lights) page =====
define HashLightWallRegular -1860064656
define HashLightWallLong 797794350
define HashLightWallLongWide 555215790
define HashLightWallLongAngled 1847265835
define HashLightWallBattery -1306415132
define HashLightRound 1514476632
define HashLightRoundAngled 1592905386
define HashLightRoundSmall 1436121888
# r0 = occAvg,r1 = dayAvg,r2 = wantLights,r3 = tmp
Start:
# Average all Occupancy sensors' Activate
lb r0 HashOcc Activate Average
move r1 0
beq EnableDayCheck 0 SkipDay
# Average all Daylight sensors' Activate
lb r1 HashDay Activate Average
SkipDay:
# wantLights = (occAvg > threshold)
sgt r2 r0 MotionOnThresh
# If day-check is enabled: require darkness too
beq EnableDayCheck 0 Decide
seqz r3 r1
and r2 r2 r3
Decide:
# Batch write On to each light type
sb HashLightWallRegular On r2
sb HashLightWallLong On r2
sb HashLightWallLongWide On r2
sb HashLightWallLongAngled On r2
sb HashLightWallBattery On r2
sb HashLightRound On r2
sb HashLightRoundAngled On r2
sb HashLightRoundSmall On r2
yield
j Start