Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Taking Controls

Stephen Yumako
Registered User
Join date: 6 Oct 2007
Posts: 4
10-08-2007 12:57
Hi Everyone!
I'm writing a script for an attachment, placed on the spine, that needs to detect when the movement keys is pressed, in order to play one animation while the avatar stands still, and another (move) animation, while the avatar moves...

I couldn't get anything to work, while having it is an attachment, so is trying with it as a hud, but if anyone can tell me, how to make this work, while still attached to the spine, please let me know...

anyway, my problem is, that while it is a hud, the animations work, but I can only move in one direction... so, please have a look at the code, as I'm about to give up on this.

CODE

default
{
state_entry()
{
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
}
run_time_permissions(integer perms)
{
if (perms == 20)
{
state animated;
}
else
{
llResetScript();
}
}
}

state animated
{

state_entry()
{
llStartAnimation("stand");
llTakeControls(CONTROL_FWD,TRUE,FALSE);
}

control(key id, integer held, integer change)
{
if (held & CONTROL_FWD)
{
llStopAnimation("stand");
llStartAnimation("move");

vector pos = llGetPos(); // I was told that theese 2 lines would
llMoveToTarget(pos+<0.0, 5.0, 0.0>, 0.5); // work, but can't get the avatar to
// change direction.
}
else if (~held & change & CONTROL_FWD)
{
// Have placed this one, for when the
llStopMoveToTarget(); // avatar is standing.

llStopAnimation("move");
llStartAnimation("stand");
}
else if (held & CONTROL_BACK)
{
llStopAnimation("stand");
llStartAnimation("move");
}
else if (~held & change & CONTROL_BACK)
{
llStopAnimation("move");
llStartAnimation("stand");
}
}

}
[/end code]

hope anyone can help me with this!
- Stephen
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
10-08-2007 15:02
I guess to start, probably the call to llTakeControls should use TRUE as the third, "pass_on" argument, so the agent will just move as normal... unless there is a special reason to use llMoveToTarget to push the agent around. (If there is, then the offset to the target needs to be rotated to be in front of the agent, as in .)

But, if the intent is just to override the stand and walk animations, tracking the control inputs might not be necessary. One might start with the ZHAO script (GPL'd open-source, available in-world) to see how that works. (It may still be useful to llTakeControls, but do nothing with their inputs, just so the attachment script will continue to execute on no-script parcels.)

There are probably other ways to do this specific kind of animation override. I don't think I've tried this, but using moving_start and moving_end as triggers for testing llGetAgentInfo might be sufficient.

But I'm not totally sure that the AO functionality is all that's actually desired here.
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-08-2007 15:14
Two questions:

What exactly do you need the move to with the animation for?

Are you trying this in Beta/Aditi? If you are then, movement is seriously broken and it is not a good place for testing a script right now.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
10-08-2007 15:17
llMoveToTarget will not change an avatar's facing. It will simply move them to a particular point. Unfortunately I am not aware of a function which _will_ reliably change their facing.
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!

http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal

http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-08-2007 15:56
From: Jesse Barnett
Two questions:

What exactly do you need the move to with the animation for?

Are you trying this in Beta/Aditi? If you are then, movement is seriously broken and it is not a good place for testing a script right now.

The reason I am asking is instead of using movement controls, why not just use llGetAgentInfo in a timer to see if the av is walking, moving etc?
Think AO.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Stephen Yumako
Registered User
Join date: 6 Oct 2007
Posts: 4
10-08-2007 21:18
Thanks for the help :)
I tried moving_start and moving_end, but that didn't work for me, so instead I tried setting the Pass_On argument in llTakeControls to TRUE, and that seems to work perfectly!
Thanks a lot everyone! :)