← MPP-Mainstore › Scripts MPP - Light Switch Download the documentation (.md)

Version 1.5.3 · updated September 23, 2026

MPP - Light Switch Script V1.5.3 - Documentation

Turns lights and glowing materials on and off on any object: by click, by Nearby Chat command, in sync with other lamps in the same group, or from another script (a scheduler, a button, your own trigger). Smooth fades, access by permission mode (owner only, owner + whitelist, everyone except a blacklist), works alone or as the receiving end of MPP - Day and Night Sky Cycle and MPP - Action Button.

This script is standalone - it does not require any other MPP script to function. It becomes useful together with a trigger: your own click, a chat command, an Action Button, or the Day Night scheduler.

New in V1.5: one anti-spam cooldown for every way of switching a lamp (the last command is never lost), a private "please wait" message for a click during the cooldown, access by avatar handle or UUID, a private message for denied visitors, the option to hide the switch from them, smoother long fades, and settings grouped by category in the Build panel.

New in V1.5.3: the transition mode is chosen by a number (Transition/Transition Mode (1-5), no name to type), the access control uses the scheme shared by every MPP script (Access/Permission Mode (1-3) with a Whitelist and a Blacklist), and the labels follow the MPP conventions (Hover Text, Enable Chat Commands, Enable Script Events). Two settings are not carried over from V1.5.1: the transition mode and the access. Read "Updating from V1.5.1" before you update lamps already placed in a scene.


Overview

Drag the script onto any object - a street lamp, a window, a neon sign, a whole building. On that object it can:

The object has two states, ON and OFF, each with its own light color/intensity and material tint/emissive. Switching between them fades smoothly over Transition/Transition Seconds (0 = instant).

In the Build panel the settings are grouped by category: Activation/, Light/, Material/, Transition/, Access/, Chat/, Events/ and Debug/.


How It Works

Four independent ways to trigger a switch, all ending at the same ON/OFF state:

TriggerWho can use itTypical use
ClickAny avatar, or only the ones allowed by the Access/ settingsA physical switch, a lamp visitors can turn on themselves
Chat commandAny avatar (same access rules as the click)/lamp on, /lamp street toggle...
Group syncInternal - triggered by a click on another lamp of the same GroupA row of street lamps that all react to one click
External Script EventAny other script in the sceneThe Day Night scheduler, an Action Button, your own script

Group sync vs. External Events - not the same thing. These are two separate mechanisms that happen to both use the Group setting:

A lamp can use one, both, or neither. They never conflict: a click can drive both the local group and be silent to the outside world, or vice versa.


Click


Cooldown (anti-spam)

Activation/Cooldown Seconds (default 0.25, 60 at most) is the minimum delay between two changes of a lamp, whatever the source: click, chat, group sync or another script.

Cooldown Notice. With Activation/Cooldown Notice On (default), an avatar whose click is ignored receives a private chat message, only visible to them, that tells how long to wait: by default "Please wait 2 seconds before using this switch again." At most one message every 3 seconds per avatar, and none when the wait is under half a second (the next click already works). Write your own text in Activation/Cooldown Notice Text: {time} becomes the remaining time with its unit ("2 seconds", "1 minute 5 seconds"), {seconds} the whole number of seconds. Leave the text empty, or turn the notice Off, for silent clicks. Chat commands and script events never get this message: they are kept and applied at the end of the cooldown.

Why it matters with Day Night: when the scene starts, and each time someone changes the season or the city, the Day Night scheduler replays the last 24 hours at once, so the lamps catch up with the time of day. It sends both commands together, for example sunrise | ..._off then sunset | ..._on at night. The lamp goes straight to the right state, without blinking, whatever Activation/Start On says.

0 turns the cooldown off: every command applies at once, with no delay and no anti-spam.


Chat Commands

Enabled by Chat/Enable Chat Commands (default On), with Chat/Chat Prefix (default /lamp). Channel: Nearby Chat (0).

/lamp <action>
/lamp <group> <action>
/lamp <group>
/lamp *  <action>
You typeEffect
/lamp on /lamp off /lamp toggleApplies to this lamp's own group (see No-Group Targets All below)
/lamp street onApplies only to lamps whose Group is street (case-insensitive)
/lamp streetSame as above with no action given: defaults to toggle
/lamp * toggleApplies to every lamp, whatever its Group
/lamp street blahAn unrecognized action word falls back to toggle

Chat/No-Group Targets All (default Off) decides what a groupless command (/lamp on, no group word) does: Off = it only reaches lamps whose own Group is empty; On = it reaches every lamp regardless of group. Either way, /lamp * always reaches everyone. The same setting applies to the groupless external events <prefix>_on / _off / _toggle (see "External Script Events").

Chat commands follow the same access rules as the click. An avatar who is not allowed gets no answer in chat (every lamp reads the chat, and each one would otherwise reply).


Group Sync

Give several lamps the same Activation/Group (for example street, case does not matter) and, with Activation/Click Syncs Group and Events/Internal Group Events both On (both default On), clicking any one of them toggles all of them together - a row of street lamps that light up as one.

Lamps with an empty Group form one click-sync group of their own: clicking one of them toggles all the other lamps that have no Group. To keep a lamp independent, turn Activation/Click Syncs Group Off, or give it a Group of its own. (A lamp with an empty Group still answers /lamp * in chat and the _all_ external events, see below.)


External Script Events

This is the integration point with Day Night Cycle, Action Button, and any script of your own. Enabled by Events/Enable Script Events (default On), with Events/Script Event Prefix (default mpp_lamp).

The script listens for these Script Event names (<prefix> = your Script Event Prefix):

Event nameReaches
<prefix>_on / _off / _toggleThe lamps whose Group is empty; every lamp when Chat/No-Group Targets All is On
<prefix>_all_on / _all_off / _all_toggleEvery lamp with this prefix, whatever its Group
<prefix>_<group>_on / _off / _toggleEvery lamp whose Group matches <group> (lowercase, spaces become underscores)

With the defaults (mpp_lamp), a lamp in Group = Street answers mpp_lamp_street_on, mpp_lamp_all_on, and mpp_lamp_on only if Chat/No-Group Targets All is On (a lamp with an empty Group always answers it). Write the group part in lowercase: event names are matched exactly.

Any script can trigger these with PostScriptEvent("mpp_lamp_street_on", null). In practice you will mostly use:

Script events are not subject to the access rules (setting up a scheduler or a button is itself a Build-mode action), but they do follow the cooldown.


What Gets Switched - Lights

Light/Affect Lights (default On). Applies to every LightComponent on the object (or only the ones named in Light/Light Names, comma-separated - empty means all). A light that is not scriptable is skipped.

SettingDefaultWhat it does
Light/On Intensity, Off Intensity1.0 / 0.0Target intensity for each state
Light/On Color, Off Colorwhite / whiteTarget color for each state

What Gets Switched - Materials

Material/Affect Materials (default On). Applies to every scriptable material found on the object's meshes (or only the ones named in Material/Material Slots, comma-separated - empty means all). Only the properties a given material actually supports are touched (a material without a tint or an emissive channel is simply left alone on that property - nothing to fix if it does not visibly react).

SettingDefaultWhat it does
Material/On Emissive, Off Emissive1.0 / 0.0Target emissive intensity for each state
Material/Tint On, Tint Offwhite / whiteTarget tint color for each state

A common combination: a lamp post with a real light for illumination and an emissive material on its bulb mesh so the bulb itself glows - both switch together on the same click.

If one light or material of the object cannot be updated for a moment (a busy scene), the others still switch.


Transition (Fade)

Shared by lights and materials - one setting controls both:

SettingDefaultWhat it does
Transition/Transition Mode (1-5)2The shape of the fade: 1 Linear (even), 2 Smoothstep (soft at both ends), 3 EaseIn (slow start), 4 EaseOut (slow end), 5 Step (one jump halfway)
Transition/Transition Seconds0.20Fade duration in seconds. 0 = instant jump for both lights and materials

Materials fade through Sansar's own built-in interpolation. Lights have no built-in fade in Sansar, so the script animates them itself at about 15 updates per second: a short fade stays light on the scene, a long fade (several seconds) stays smooth.


Access Control

Who can use the click and the chat commands is set by one number and two lists, in the Access/ group. This is the scheme shared by every MPP script (Action Button V1.7.1 and later, Random Object Spawner, Avatar Speed...):

Access/Permission ModeWho can click and use chat
1 - Owner onlyThe scene owner only
2 - Owner + WhitelistThe scene owner and the avatars of Access/Whitelist (empty list = owner only)
3 - Everyone except Blacklist (default)Everyone, minus the avatars of Access/Blacklist (empty list = everyone)

Editor Properties Reference (36 total)

Activation

PropertyTypeDefaultDescription
Activation/Start OnboolOffInitial state when the scene starts
Activation/Enable ClickboolOnClick toggles the switch; Off = no click and no hover text
Activation/Click Syncs GroupboolOnClick sends the group event instead of toggling only this object
Activation/Hover Text When ONstring"Turn Off"Hover text while ON
Activation/Hover Text When OFFstring"Turn On"Hover text while OFF
Activation/Cooldown Secondsfloat0.25Minimum delay between two changes of this lamp, whatever the source (see Cooldown)
Activation/Cooldown NoticeboolOnPrivate "please wait" message for a click during the cooldown
Activation/Cooldown Notice Textstring"Please wait {time} before using this switch again."Text of that message; {time} and {seconds} are replaced, empty = no message
Activation/Groupstring""Lamps sharing a Group react together. Empty = the lamps without a Group, which react together too

Light

PropertyTypeDefaultDescription
Light/Affect LightsboolOnDrives the lights of this object
Light/Light Namesstring""Comma-separated light names. Empty = all
Light/On Intensity, Off Intensityfloat1.0 / 0.0Target intensity per state
Light/On Color, Off ColorColorwhite / whiteTarget color per state

Material

PropertyTypeDefaultDescription
Material/Affect MaterialsboolOnDrives the materials of this object
Material/Material Slotsstring""Comma-separated material names. Empty = all
Material/On Emissive, Off Emissivefloat1.0 / 0.0Target emissive intensity per state
Material/Tint On, Tint OffColorwhite / whiteTarget tint per state

Transition

PropertyTypeDefaultDescription
Transition/Transition Mode (1-5)int (1-5)21 Linear, 2 Smoothstep, 3 EaseIn, 4 EaseOut, 5 Step
Transition/Transition Secondsfloat0.20Fade duration for lights and materials. 0 = instant

Access

PropertyTypeDefaultDescription
Access/Permission Mode (1-3)int (1-3)31 = Owner only, 2 = Owner + Whitelist, 3 = Everyone except Blacklist. The owner is always allowed
Access/Whiteliststring""Handles or UUIDs allowed in mode 2, comma or semicolon separated
Access/Blackliststring""Handles or UUIDs blocked in mode 3, comma or semicolon separated
Access/Denied Textstring"You are not allowed to use this switch."Private message for a denied click (empty = no message)
Access/Hide From DeniedboolOffDenied avatars do not see the object as clickable

Chat

PropertyTypeDefaultDescription
Chat/Enable Chat CommandsboolOnEnables /lamp ... in Nearby Chat
Chat/Chat Prefixstring"/lamp"Command prefix
Chat/No-Group Targets AllboolOffA groupless chat command or <prefix>_on/_off/_toggle event reaches every lamp (On) or only groupless lamps (Off)

Events

PropertyTypeDefaultDescription
Events/Internal Group EventsboolOnEnables click-sync between lamps of the same Group
Events/Internal Event Prefixstring"MPPLightSwitch"Change only to avoid a name clash
Events/Enable Script EventsboolOnListens to Script Events from other scripts (Day Night, Action Button, your own)
Events/Script Event Prefixstring"mpp_lamp"Base name of the external events, see that section

Debug

PropertyTypeDefaultDescription
Debug/Debug LoggingboolOffWrites state changes, commands, skipped components and the handle and UUID of each avatar who clicks or is denied to the script console

Version Notes

All versions share the same on / off / toggle vocabulary.

VersionWhat changed
V1.3External events <prefix>:<group>:<action> (colon-separated), or <prefix>:<action> with an empty Group
V1.4.0Switched to <prefix>_on / _off / _toggle and <prefix>_all_on / _all_off / _all_toggle (the enable switch was then named Enable External Script Events)
V1.4.1Same external event names as V1.4.0
V1.4.2Adds <prefix>_<group>_on / _off / _toggle to target one group directly
V1.5.0One cooldown for every source (the last command is never lost); access by handle or UUID with Owner Only, Denied Text and Hide From Denied; guarded updates; smoother long light fades; settings grouped by category. Event names unchanged
V1.5.1Adds Activation/Cooldown Notice and Cooldown Notice Text: a private "please wait" message for a click during the cooldown
V1.5.2Transition/Transition Mode (1-5) is a number instead of a name to type (never sold, merged into V1.5.3)
V1.5.3 (this version)Access by Permission Mode (1-3) with a Whitelist and a Blacklist, the scheme shared by every MPP script, instead of Owner Only + Access List; MPP labels (Hover Text When ON / OFF, Enable Chat Commands, Enable Script Events, Script Event Prefix); groups in the order Activation, Light, Material, Transition, Access, Chat, Events, Debug. Event names, chat commands and group sync unchanged

Updating from V1.5.1

Before you update, take a screenshot of the Build panel of one lamp of each kind (each Group, each transition mode, each access setting). Two settings are replaced by new ones and their values are not carried over; the screenshot lets you enter them again in a minute.

V1.5.1 settingsV1.5.3 settings
Owner Only Off, list empty (default)Permission Mode 3, lists empty: nothing to do
Owner Only Off, Access List filled (blacklist)Permission Mode 3, paste the list into Blacklist
Owner Only On, list emptyPermission Mode 1
Owner Only On, Access List filled (whitelist)Permission Mode 2, paste the list into Whitelist

Updating from V1.4.2


Recipes

A - A single lamp, click only. Defaults are enough: drop the script on the object, leave Group empty. Click to toggle. With several such lamps in the scene, turn Click Syncs Group Off, or give each lamp its own Group, otherwise one click toggles them all.

B - A row of street lamps, one click lights them all. Same Activation/Group (for example Street) on every lamp, keep Click Syncs Group and Internal Group Events On (defaults).

C - Lamps switched by Day Night Cycle at sunset/sunrise. Events/Enable Script Events On, Script Event Prefix = mpp_lamp (default). In the Day Night Control's Events/Actions A: sunset | mpp_lamp_all_on and sunrise | mpp_lamp_all_off (or mpp_lamp_street_on / _off to target one group only). See the Day Night documentation, section 9.

D - Lamps switched by an Action Button. On the button: Send as Command On, Command 1 = mpp_lamp_all_toggle (or a group/on/off variant).

E - A silent backstage lamp. Activation/Enable Click Off, Chat/Enable Chat Commands Off - the lamp only reacts to External Script Events, invisible to visitors.

F - Lamps only you can switch. Access/Permission Mode 1 on each lamp, or 2 with your friends' handles in Access/Whitelist. Turn Hide From Denied On so visitors do not even see the lamps as clickable. Day Night and your buttons keep working (script events are not restricted).

G - A lamp that lights up when someone arrives. With Commands Help On Chat V1.5 or later in the scene: Arrival/Send Arrival Event On with Arrival Event Name = mpp_lamp_all_on, and if you like Send Departure Event On with Departure Event Name = mpp_lamp_all_off.


Troubleshooting

SymptomCheck
Nothing happens on clickActivation/Enable Click On? Access/Permission Mode: with 1 only the owner can click, with 2 the avatar must be in the Whitelist, with 3 it must not be in the Blacklist. A denied avatar receives the Denied Text
An avatar in my Whitelist is still refusedPermission Mode must be 2 (a Whitelist is ignored in the other modes, with a warning in the script console). The list needs the avatar handle (or UUID), not the display name. Turn Debug/Debug Logging On and let the avatar click: the console shows its handle
A material does not visibly reactIt may support neither Tint nor Emissive - only compatible properties are touched. Check Material Slots matches its actual name, or leave it empty
A light does not reactLight/Affect Lights On? Light Names matches the actual light name, or is empty? Is it scriptable?
Clicking one lamp toggles others unexpectedlyThey share a Group (an empty Group counts as one: all the lamps without a Group toggle together) and Click Syncs Group is On - expected behavior. Turn Click Syncs Group Off, or give this lamp its own Group
/lamp street on does nothingThe lamp's Group must match street exactly (case-insensitive, no extra spaces). Chat/Enable Chat Commands On? Denied avatars get no answer in chat
Day Night or Action Button events do not reach the lampEvents/Enable Script Events On? Script Event Prefix matches on both sides (default mpp_lamp)? Group part in lowercase? Turn Debug/Debug Logging On to see what is received in the script console
A lamp reacts a fraction of a second lateNormal with a cooldown: the lamp waits a tenth of a second to group the commands sent together, and a command that arrives during the cooldown is applied at its end. Lower Activation/Cooldown Seconds, or set it to 0 for instant switching without anti-spam
A click does nothing right after a chat command or a Day Night changeThe lamp is in its cooldown: clicks are ignored until it ends (0.25 s by default). Click again. With Activation/Cooldown Notice On, a wait of half a second or more is announced by a private message
The fade looks different after updating the scriptTransition/Transition Mode (1-5) is back to 2 (Smoothstep): enter the number of your old mode (see "Updating from V1.5.1")
Visitors can click a lamp that was owner onlyThe access starts again at Permission Mode 3 after the update: set 1 or 2 again (see "Updating from V1.5.1")
Settings lost after updating the scriptCompare with your screenshot, or with a lamp not yet updated, then enter the values again

Limits


ItemWhat it adds
MPP - Day and Night Sky CycleA scheduler that can switch these lamps on at sunset and off at sunrise, and more - see its documentation, section 9
Action Button Script (V1.7.1)Turn any object into a button that can drive these lamps via Send as Command. Store: https://www.sansar.com/store/listings/3e1a3546-6c79-4527-bc1e-78d02648d19e/action-button-script
Commands Help On Chat Script (V1.5.2)Its arrival and departure events can switch these lamps when a visitor enters or leaves; list your /lamp commands in its help. Store: https://www.sansar.com/store/listings/fea2df6b-21ce-48eb-94fc-4b7a7aad2777/commands-help-on-chat-script

MPP - My Pretty Pixels. Light Switch Script V1.5.3 (script MPP - Light Switch). Store: https://www.sansar.com/store/listings/7379d48c-2b6f-45f6-b6f1-205ce95aec1c/light-switch-script

↑