Light Drain And Restore Script | Sansar Store
Light Drain And Restore Script

Light Drain And Restore Script

 49

You need to own this item to leave a rating.

0 ratings

Thanks to Nicci for her excellent suggestions and help.

------------------------------

### LIGHTDRAINANDRESTORE (v1.7)

Add smooth theatrical lighting effects to your interactive props.

------------------------------

### WHAT IT DOES (PURPOSE)

Controls an item’s LightComponent and material emissive/tint for a soft, theatrical look:

• While held:
→ Light intensity gradually drains
→ Optional: color cycles smoothly through a rainbow
→ Emissive can follow light intensity

• On release:
→ Light restores to a target intensity
→ Color either latches to last rainbow hue or fades back to white

Includes robust anti-flicker system with throttled material writes and engine-side lerp for smooth color and emissive transitions.

------------------------------

### HOW IT WORKS (BASICS)

1. INITIALIZATION

* Start After First Grab keeps idle lamps unchanged until used
* Force White At Init sets light and tint to pure white at start

2. WHILE HELD

* Intensity decreases via Drain Per Second until reaching Min Intensity While Held
* If Rainbow is enabled, hue rotates at Rainbow Hue Speed and smooths over Rainbow Smoothing Seconds
* If Sync Emissive With Light is enabled, emissive tracks light intensity with shaping via Emissive Gamma

3. ON RELEASE

* Intensity recovers via Restore Per Second up to Target Intensity On Release
* Color either:
→ Latches to last rainbow color (if Latch Color On Release), or
→ Fades to white (if Return To White On Release), over Color Return Seconds

------------------------------

### MOST IMPORTANT PARAMETERS

• TARGET INTENSITY ON RELEASE / DRAIN PER SECOND / RESTORE PER SECOND
→ Controls core brightness behavior

• ENABLE RAINBOW ON GRAB / RAINBOW HUE SPEED / RAINBOW SMOOTHING SECONDS
→ Controls rainbow effect behavior

• LATCH COLOR ON RELEASE vs RETURN TO WHITE ON RELEASE
→ Choose persistent rainbow hue or fade-back to white

• SYNC EMISSIVE WITH LIGHT / EMISSIVE GAMMA / EMISSIVE TARGET / MIN EMISSIVE
→ Cohesive glow matching light behavior

• MATERIAL LERP SECONDS / MATERIAL WRITE INTERVAL SECONDS
→ Fine-tunes anti-flicker and transition smoothness

------------------------------

### OPTIONS OVERVIEW

• LIGHT NAME FILTER / MATERIAL NAME FILTER
→ Target specific components by name

• START FROM CURRENT INTENSITY
→ Use scene light’s current value on init

• START AFTER FIRST GRAB
→ Prevents brightening before interaction

• DEBUG LOG
→ Prints useful traces in scene log for troubleshooting

------------------------------

Enjoy and Keep Good Vibes.
Hugs from Morgane.

------------------------------

Item name
MPP - LightDrainAndRestore v1.7
Min. resale price
50