Skip to content

Instantly share code, notes, and snippets.

@jmfergeau
Last active December 7, 2023 22:28
Show Gist options
  • Save jmfergeau/3e5ce0daaa76fb8af55ca42bd430071c to your computer and use it in GitHub Desktop.
Save jmfergeau/3e5ce0daaa76fb8af55ca42bd430071c to your computer and use it in GitHub Desktop.
Lightswitch system
// LIGHTSWITCH SYSTEM
// A very simple set of scripts for lighting your house
// This script is meant to be in the lightbulbs.
integer channel = 916847; // To change depending of the channel of the button.
string buttonName = "Lightswitch"; // This must be the name of the prim used for the light switch.
vector lightColor = <1.0,0.717647,0.486275>; // The color of the lights, in case you want to change them
integer switch;
default
{
state_entry()
{
switch = TRUE;
llSetPrimitiveParams([PRIM_POINT_LIGHT, switch, lightColor, 1.0, 4.0, 0, PRIM_FULLBRIGHT, ALL_SIDES, switch]);
llListen(channel, buttonName, "", "");
}
listen(integer channel, string name, key id, string message)
{
if (switch) switch = FALSE;
else switch = TRUE;
llSetPrimitiveParams([PRIM_POINT_LIGHT, switch, lightColor, 1.0, 4.0, 0, PRIM_FULLBRIGHT, ALL_SIDES, switch]);
}
}
// LIGHTSWITCH SYSTEM
// A very simple set of scripts for lighting your house
// This script is meant to be in the lightswitch button.
// The prim MUST be named "Lightswitch".
// Or then change the name of the variable buttonName in the other script
integer channel = 916847; // To change depending of the channel the lights you want to control.
default
{
touch_start(integer total_number)
{
llPlaySound("8eae9c2b-3caa-477c-964d-c3752c23eddb", 0.3);
llSay(channel, "switch");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment