Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llGetAgentInfo question

Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
01-06-2008 09:18
im making a random little script that when a avatar is running you see a smoke trail behind them but the problem is i wont it to only go when they are moving and i cant figure out how to do that, atm i have the line like this

if(llGetAgentInfo(llGetOwner())& AGENT_ALWAYS_RUN)

i looked on wiki and there seams to only be walking and always run is there any way to make it work when a avatar runs and stops when they arent moving?
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
01-06-2008 09:49
Did you try the llGetAnimation route?



I think this is the basis of most AO scripts.
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
01-06-2008 10:02
ya it is kinda confusing to me, here is what i got

CODE

default
{
state_entry()
{
llSetTimerEvent(0.25); // poll current state (there is no event for these)
}

timer()
{
string s;

s = llGetAnimation(llGetOwner());
if(s == Running)
{
mySetParticles();
}
else if (llListFindList(l, ) == -1) l += ; // if it's not already in the list, add it
}
}
//CANT WAIT TILL CODES COME BACK :S
Debbie Trilling
Our Lady of Peenemünde
Join date: 17 Oct 2006
Posts: 434
01-06-2008 11:49
llGetAnimation() returns a string. Therefore the comparison should be

if(s == "Running";) as in the following snipit:

CODE


touch_start(integer total_number)
{
string s = llGetAnimation(llGetOwner());

if(s == "Running")
{
llSay(0,"Yep, I'm running");
}
else
{
llSay(0, "Currently I am " + s);
}
}



Unless you have a variable called 'Running', I'm surprised that the code that you posted for examination even compiled, tbh. If you do have a variable called 'Running' then ensure that it is declared as a string, and that the value is "Running"
Day Oh
Registered User
Join date: 3 Feb 2007
Posts: 1,257
01-06-2008 11:57
Also, the animation you're looking for is "Run" (:
_____________________
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-06-2008 12:03
From: Mrc Homewood
CANT WAIT TILL CODES COME BACK :S

the sticky in the top of the scripting library forum has simplified instructions on adding BBCode emulation to firefox and opera, takes just a moment to set up, and is preconfigured for the SL forums
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Debbie Trilling
Our Lady of Peenemünde
Join date: 17 Oct 2006
Posts: 434
01-06-2008 12:07
From: Day Oh
Also, the animation you're looking for is "Run" (:


I dont see "Run" listed as one of the basic animation states returned by llGetAnimation(), only "Running"

http://wiki.secondlife.com/wiki/LlGetAnimation
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
01-06-2008 12:14
it works, it is Running not Run
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
01-06-2008 13:00
Just to expand on this a little... there are four possible events you might like to trap.

1) The agent is running.
2) The agent is not running.
3) The agent starts to run.
4) The agent stops running.

What you want to avoid is triggering a lot of unnecessary code usage every 0.25 seconds. :)

Depending on your particle set up you might be interested in 1) or 3).
2) isn't really interesting.
4) is the time to stop the particles if they persist (PSYS_SRC_MAX_AGE = 0).

3) and 4) are the basis of an AO.


A bare-bones example:

string lastAnim;
string lastAnimState;

default
{
state_entry()
{
llSetTimerEvent(0.25);
}

timer()
{
string curAnimState = llGetAnimation(llGetOwner());

if (curAnimState == "Running";) // agent is running
{
// run non-persistant particles
}
else // agent is not running

if (curAnimState != lastAnimState) // something changed since we last polled
{
if (curAnimState == "Running";) // agent starts to run
{
// start persistant particles
lastAnim = curAnimState;
}
else if (lastAnim != "";) // agent stops running
{
// stop particles
lastAnim = "";
}

lastAnimState = curAnimState;
}
}
}
Day Oh
Registered User
Join date: 3 Feb 2007
Posts: 1,257
01-06-2008 13:45
Whoops! I was totally off
_____________________
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
01-06-2008 21:51
The AGENT_ALWAYS_RUN flag reported by llGetAgentInfo() is independent of whether the avatar is moving or not. It actually indicates whether the avatar will be running or not WHEN it moves, and is the same as the flag in the SL client GUI.

I believe what you want to do is test whether AGENT_ALWAYS_RUN and AGENT_WALKING are BOTH turned on.