Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Turning key on avatar back

Casandra Kumsung
Registered User
Join date: 6 Sep 2006
Posts: 93
08-22-2008 15:25
I need the script for turning a key on the back of an avatar. If that is possible. I figure it is since you can have flapping wings.

I would like to be able to turn if off and one with a touch.

Thanks
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
08-22-2008 15:39
Luckily, this is one of the things that can be done in LSL with a tiny script!
CODE

integer Turning = FALSE;

default
{
touch_start(integer total_number)
{
if (Turning) {
llTargetOmega(ZERO_VECTOR, 0., 0.); // stop turning
}
else {
llTargetOmega(<0., 0., 1.>, PI / 3., 1.); // start turning
}

Turning = !Turning;
}
}


Also dropped you a simple built example in world.
_____________________
Casandra Kumsung
Registered User
Join date: 6 Sep 2006
Posts: 93
Thanks Viktoria Dovgal
08-22-2008 16:51
Next question. I am going to make a button for my belly. It starts out red when touched it turns green. You know on and off. I wounder if it is possible for when it is turned on it will start the key and turned off stop the key.

I seem to remember seeing a command that will communicate with another object but I gather they have to be linked . I suppose the button and key could be linked,with a cylinder thru the avatar that does not show but I do not see how since then the button will turn too.

A bit kinky but that is why we are in SL!
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
08-22-2008 18:11
this should work, i'll log in and try it out the first one goes into the key, and the second one goes into the button

From: someone
default
{
link_message(integer sender_num, integer num, string str, key id){
if (str == "Turning";) {
llTargetOmega(<0., 0., 1.>*llGetLocalRot(), PI / 3., 1.); // start turning
}
else {
llTargetOmega(ZERO_VECTOR, 0., 0.); // stop turning
}
}
}



From: someone
integer Turning = FALSE;

default
{
touch_start(integer total_number)
{
if (Turning) {
llMessageLinked(LINK_SET, 0, "Turning", NULL_KEY);
llSetColor(<0.0, 1.0, 0.0>, ALL_SIDES);//Turns the button green when on
}
else {
llMessageLinked(LINK_SET, 0, "", NULL_KEY);
llSetColor(<1.0, 1.0, 1.0>, ALL_SIDES );//Turns the button white when off
}

Turning = !Turning;
}
}



EDIT: added a small function to the target omega so it rotates on it's local axis no matter which way you're turned
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
08-22-2008 18:18
From: Casandra Kumsung
but I gather they have to be linked . I suppose the button and key could be linked,with a cylinder thru the avatar that does not show but I do not see how since then the button will turn too.


there doesn't really need to be a cylinder linked in between, prims don't have to touch to be linked.

also, make sure the touch script is in the root prim, that way the whole object can receive the touch event. if the rotate script is in the root prim, the whole object would rotate