General Info About Prims
- Prim size 10m or smaller than 0.010m.
- Linking Distance within 3.5m of attach point.
- Linked Object Limit 254m
- Physical object limit 31
Google Code
http://code.google.com/p/secondlifelivelyscripts/
Code in Three Parts
Light Switch Code – 3 Parts
Part 1: Rotor – put this code on the rotor
myon_state()
{
rotation rot = llGetRot();
vector vrot = llRot2Euler(rot);
vrot+=<-30*DEG_TO_RAD,0,0>;
rot=llEuler2Rot(vrot);
llSetRot(rot);
}
myoff_state()
{
rotation rot = llGetRot();
vector vrot = llRot2Euler(rot);
vrot+=<30*DEG_TO_RAD,0,0>;
rot=llEuler2Rot(vrot);
llSetRot(rot);
}
default
{
state_entry()
{
myoff_state();
}
link_message(integer sender_num, integer num, string str, key id)
{
if(str=="stop")
{
myoff_state();
}
if(str=="start")
{
myon_state();
}
}
}
Part 2: Switch Panel (Root Prim) -
Put on the switch Panel
integer myswitch;
default
{
state_entry()
{
myswitch=FALSE;
llSetText("Light Switch", <1.0, 1.0, 1.0>, 1.0);
}
touch_start(integer total_number)
{
if(myswitch==FALSE)
{
//Turn Light Bulb ON
llMessageLinked(LINK_ALL_CHILDREN, 0, "start", NULL_KEY);
myswitch=TRUE;
}
else
{
//Turn Light Bulb Off
llMessageLinked(LINK_ALL_CHILDREN, 0, "stop", NULL_KEY);
myswitch=FALSE;
}
}
}
Part 3: Light Bulb Script
Put on the light source
default
{
state_entry()
{
llSetPrimitiveParams([PRIM_FULLBRIGHT,ALL_SIDES,FALSE]);
}
link_message(integer sender_num, integer num, string str, key id)
{
if(str=="stop")
{
llSetPrimitiveParams([PRIM_FULLBRIGHT,ALL_SIDES,FALSE]);
}
if(str=="start")
{
llSetPrimitiveParams([PRIM_FULLBRIGHT,ALL_SIDES,TRUE]);
}
}
}
No comments:
Post a Comment