Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help with Controls?

Red Steele
Registered User
Join date: 5 Dec 2004
Posts: 4
12-23-2004 22:05
I'm new to scripting with LSL, and I wanted to make a remote controlled object using llTakeControls( ).

My problem: My "control( )" event is only getting called for CONTROL_FWD and CONTROL_BACK - the av keeps doing everything else.

Here's a simple test code I tried - control() is never entered except for those two cases. (I had more "if" cases for the other CONTROL_XXX level settings - I cut them out for brevity here. But the llWhisper in control() is only called for fwd and back inputs.)

CODE
    

default
{
state_entry()
{
llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS); // get permission to take controls
}

run_time_permissions(integer perm)
{ // permissions dialog answered
if (perm & PERMISSION_TAKE_CONTROLS )
{ // we got a yes
integer conts = CONTROL_FWD | CONTROL_BACK | CONTROL_LEFT | CONTROL_RIGHT | CONTROL_LBUTTON;

llWhisper(0, "Grab controls " + (string)conts );

llTakeControls( conts, TRUE, FALSE );
}
}

control( key name, integer levels, integer edges )
{
llWhisper(0, (string)levels + (string)edges );
if( levels & CONTROL_FWD )
{
llWhisper(0, "released");
llReleaseControls( );
}
}
}



Can anyone point out what I'm doing wrong here?

Thanks - Red
SuezanneC Baskerville
Forums Rock!
Join date: 22 Dec 2003
Posts: 14,229
12-26-2004 23:13
If you include the following piece of code:

CODE
if( levels & CONTROL_LEFT )
{
llWhisper(0, "released");
llReleaseControls( );
}

in your program then the program does report released when the CONTROL_LEFT key is pressed. The CONTROL_LEFT key is shift-left-arrow, not just left arrow, assuming you are not in mouselook. To react to a plain left arrow the constant that should be used is CONTROL_ROT_LEFT.

The LSL Wiki, at http://secondlife.com/badgeo/wakka.php?wakka=HomePage, is fairly clear on this subject, just look up llTakeControls and the control event.

Questions about scripting would be better placed in the scripting forum instead of the building forum.
_____________________
-

So long to these forums, the vBulletin forums that used to be at forums.secondlife.com. I will miss them.

I can be found on the web by searching for "SuezanneC Baskerville", or go to

http://www.google.com/profiles/suezanne

-

http://lindenlab.tribe.net/ created on 11/19/03.

Members: Ben, Catherine, Colin, Cory, Dan, Doug, Jim, Philip, Phoenix, Richard,
Robin, and Ryan

-