Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

help for sword script

Shai Galli
Registered User
Join date: 16 Nov 2007
Posts: 6
03-11-2008 11:57
hey all...sorry for my little english..xD..
i have rezzed a nice katana, and done custom animations to put on it, so i try to start a script..and when i hold the left mouse button or left mouselook button the animation "ready" run, and when i hold the forward arrow (or W key) too, the animation "slash" run, but also the av moving forward!!..and i dont want this..:)

i would that when i hold the LBUTTON+FWD the avatar stay firm, and commands must control only the animations not the movements of the avi.

this is the trunk of my script:
//------------------------------------------------------------------------
run_time_permissions(integer perm)
{
if (perm)
{
llTakeControls(CONTROL_ML_LBUTTON | CONTROL_LBUTTON | CONTROL_UP | CONTROL_DOWN | CONTROL_FWD | CONTROL_BACK | CONTROL_ROT_LEFT | CONTROL_LEFT | CONTROL_RIGHT | CONTROL_ROT_RIGHT, TRUE, TRUE);
}
}

control(key owner, integer level, integer edge)
{
if (level & (CONTROL_ML_LBUTTON | CONTROL_LBUTTON))
{
llStartAnimation("ready";);
if(edge & level & CONTROL_FWD)
{

llStopAnimation("ready";);
llStartAnimation("slash";);
llSetTimerEvent(0.25);
}
}
else
{
llStopAnimation("ready";);
}
}//--control()
//-------------------------------------------------------------

thx^^ Shai
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
03-11-2008 12:22
Two choices that I can think of here:

1.) While the mouse button is down, hold your avatar in place using something like llMoveToTarget().

2.) When the mouse button is pressed, re-take the controls until the mouse button is let up. When the mouse button is up, you want to either not take the movement controls at all, or you want them to be passed through to the system so normal behavior occurs (pass_on, the last parameter of TRUE). When the mouse button is down, you want to keep normal behavior from happening (except maybe for rotation controls; see "Taking Complete Control" section under URL below), so you re-take the controls with the pass_on (last) parameter equal to FALSE.

http://www.lslwiki.net/lslwiki/wakka.php?wakka=llTakeControls
Shai Galli
Registered User
Join date: 16 Nov 2007
Posts: 6
03-11-2008 20:22
thx Hewee...the 2nd choice look exactly as i would want was:)...but is not simple for a script noob like me..lol..

a little step..i try to change the script into this one:
//------------------------------------------
run_time_permissions(integer perm)
{
if (perm & PERMISSION_TAKE_CONTROLS)
{
llTakeControls(CONTROL_ML_LBUTTON | CONTROL_LBUTTON | CONTROL_UP | CONTROL_DOWN | CONTROL_FWD | CONTROL_BACK | CONTROL_ROT_LEFT | CONTROL_LEFT | CONTROL_RIGHT | CONTROL_ROT_RIGHT, TRUE, FALSE);
}
}

control(key owner, integer level, integer edge)
{
if (level & (CONTROL_ML_LBUTTON | CONTROL_LBUTTON))
{
llStartAnimation("ready";);
if(edge & level & CONTROL_FWD)
{

llStopAnimation("ready";);
llStartAnimation("slash";);
llSetTimerEvent(0.25);
}
}
else
{
llStopAnimation("ready";);
llReleaseControls();
}
}//--control()
//-------------------------------------------------------------
this one works as i would want...but only the 1st time i hold down the mouse button, when i release it...nothing more happen..

where i need to recall llTakeControls?..after mouse button "if"?
Shai Galli
Registered User
Join date: 16 Nov 2007
Posts: 6
03-13-2008 07:42
it seems that this one works as i wanted..xD..(plz correct me if there is something wrong..)
//-------------------------------------------------------------
run_time_permissions(integer perm)
{
if (perm & PERMISSION_TAKE_CONTROLS)
{
llTakeControls(CONTROL_ML_LBUTTON | CONTROL_LBUTTON | CONTROL_UP | CONTROL_DOWN | CONTROL_FWD | CONTROL_BACK | CONTROL_ROT_LEFT | CONTROL_LEFT | CONTROL_RIGHT | CONTROL_ROT_RIGHT, TRUE, FALSE);
}
}

control(key owner, integer level, integer edge)
{
if (level & (CONTROL_ML_LBUTTON | CONTROL_LBUTTON))
{
llGetPermissions();
llTakeControls(CONTROL_ML_LBUTTON|CONTROL_LBUTTON | CONTROL_FWD,TRUE,FALSE);
llStartAnimation("ready";);
if(edge & level & CONTROL_FWD)
{

llStopAnimation("ready";);
llStartAnimation("slash";);
llSetTimerEvent(0.25);
}
}
else if (~level & (CONTROL_ML_LBUTTON | CONTROL_LBUTTON))
{
llGetPermissions();
llTakeControls(CONTROL_ML_LBUTTON|CONTROL_LBUTTON,TRUE,TRUE);
llStopAnimation("ready";);
}
}//--control()
//-------------------------------------------------------------