Thats a great smooth solution!
Another way is to use colliders as triggers, which uses far less CPUresources and causes less script lag than the constant on sensor-script.
• Make a lamp object.
• Place a prim on the floor (ON trigger), when you walk on that you turn it on.
• Place a prim outside door (or hollow around the ON trigger, OFF trigger), when walk on this you turn lamp off
>>>Script in ON trigger:
integer CHANNEL = -12345; // Use a negative channel for silent communication
default
{
collision_start(integer total_number)
{
if (llDetectedType(0) & AGENT)
{
llRegionSay(CHANNEL, "TurnOnLamp");
}
}
}
>>>Script in OFF trigger:
integer CHANNEL = -12345; // Use the same negative channel
default
{
collision_start(integer total_number)
{
if (llDetectedType(0) & AGENT)
{
llRegionSay(CHANNEL, "TurnOffLamp");
}
}
}
>>>Script in LAMP object
integer CHANNEL = -12345; // Use the same negative channel
integer isLampOn = FALSE;
default
{
state_entry()
{
// Turn the lamp off initially
llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE, , 1.0, 0.0, 0.75]);
isLampOn = FALSE;
// Listen for messages on the silent channel
llListen(CHANNEL, "", NULL_KEY, "");
}
listen(integer channel, string name, key id, string message)
{
if (message == "TurnOnLamp" && !isLampOn)
{
// Turn on the light
llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, , 1.0, 10.0, 0.75]);
isLampOn = TRUE;
}
else if (message == "TurnOffLamp" && isLampOn)
{
// Turn off the light
llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE, , 1.0, 0.0, 0.75]);
isLampOn = FALSE;
}
}
}
....Let me know if the formatting gets messed up in this box /Manda
like(1)