Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Interactive Pose ball? - HELP PLEASE!!

Sofia Weir
Registered User
Join date: 5 Feb 2007
Posts: 26
02-27-2007 03:23
Hello
I am trying to create an interactive poseball that should work like this:

A> When the avatar sits on it opens a dialog offering poses/animations
B> when the avatar selects an animation/pose from the menu this starts to play while he is seated.
(So far it is preety straight forward)
C> The user has the ability to INTERACT with the animation that is playing using the arrow keys or any other keys, WHILE he is sitting on the ball.

EXPLANATION: Each start pose /animation that is selected from the menu has 1-2 alternatives,(Different animations), that must be activated using the keys by the user WHILE sitting on the ball.

example: A Martial arts Pose, The avatar sits on the poseball and a menu opens having the selections: Select your pose :"KUNG FU POSE", "KAPUERA POSE","AIKIDO POSE"
He/She selects AIKIDO POSE, thus the avatar assumes an aikido pose/animation.
Then when he uses the arrow buttons, the avatar kicks,punches,blocks etc.
When the avatar stands up all stops.
If the user touches again the ball the same menu appears etc etc.
that when the user presses FWD key, avatar punches, when pushes the BCK key kicks. - WHILE sitting on the poseball

I have some scripts, the menu selection, the key control, but I cannot accomplish this functionality as is described yet.

could you please offer me some help /tips?
They told me this can also be achieved with HUD attachment buttons..

Thanks a lot
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-27-2007 04:07
Its not clear from your post exactly what you have working, but assuming you have the basic animation and selection working all you need to do is trap the key events and switch animations based on that. Try this thread for a few hints.
Sofia Weir
Registered User
Join date: 5 Feb 2007
Posts: 26
Thanx for the help.
02-27-2007 04:48
Thanx for the help
Well I can explain what I have so far.

I have a script for poseball, that poses the avatar when she sits on the poseball, using a specified animation.

I have a script that uses entries from a menu to change the animation, but this is done without sitting on a prim.

I have a script that take permission to control the arrow keys and controls the animations using the keys.

All these I got from blogs and tutorials.

I have combined them and finally created a script that animates the avatar using the keys, and changes the animations accordingly, but this occures WITHOUT the avatar to be seated, thus suspended from the prim/ball. The animations work fine but the avatar faces away to the direction I am turning as i use the mouse, because she is not seated! :(

A tried to use the dialog, but with the combination of the keys it throws errors!..

Basically I got a problem with the event and permission sequences.

Does anybody know if the use of HUD buttons is better?. And is there any sample code or post that has a case like this worked out?

Thanx
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-27-2007 05:10
Sounds like all you are missing is the seated part. I guess that currently when you touch the poseball it asks for animation permissions and then displays the dialog and starts animating you? Or is it driven on attach?

What you need is a changed event handler to handle when the Avatar sits or unsits.
In this you would request your permissions and then in the run_time_permissions event handler start the dialog etc. This should be very similar to what you are already doing?


Code Fragment
CODE

changed(integer change)
{
// Test for a changed inventory
if (change & CHANGED_INVENTORY)
{
llResetScript();
}

// The object's sit target has been triggered
if (change & CHANGED_LINK) // Test for a changed link
{
avatar = llAvatarOnSitTarget();
if(avatar != NULL_KEY) // Is that changed link an avatar?
{
llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION);
}
else
{
if (llGetPermissionsKey() != NULL_KEY)
{
llStopAnimation(animation_name);
animation_name = "Mountain_Pose";
}
}
}
}

run_time_permissions(integer perm)
{
if (perm & PERMISSION_TRIGGER_ANIMATION)
{
llStopAnimation("sit");
llStartAnimation(animation_name);
first = 0;
ShowMenu();
}
}
Sofia Weir
Registered User
Join date: 5 Feb 2007
Posts: 26
Well almost...
02-27-2007 07:23
Thanx again for the help
Well I have a "change" event with the code you describe.

Actually I have noticed that these steps are pretty standard, since I get to see them in all the scripts I see in this blog and elsewhere :)

I figured out how to check if the avatar is seated or not via changed and llSitTarget exactly the way you describe.
Also I do ask permission for taking controls the same way I do for animations, as you do in your script.(I cannot include my code because I am not home now :()

My problem arises when I use the arrows to change the animations.

When I press an arrow button there appears an error and debugger says that it is because there was given no permission to take controls. but that cannot be because i granted permissions just before!. I double checked it by inserting llSay() inside the IF checks.
The llSay appear in the chat, meaning that the program went inside the if loop, but the permissions are not requested from user somehow!

An other prob happens when I use an llDialog in the begining to chose the basic pose in touch_start, but if i place in anywhere elese it does not work!!...e.g If i place it in the changed(integer change) brackets the flow just...ignores it!!

I am sure it is something i overlook due to my inexperience in the states or program flow
but I am trying to figure out whats wrong!!!.....


The current version of my script works like this:
The AV touches the ball and gets the menu.
She selects the animation and the animation starts.
The user can change the animation by touching the ball again and making a different choice.
The AV can sit on the ball and the menu appear again, this time the user is suspended in sit position as she should be.
Animations change again the same way: user touches the ball menu appears etc etc.
When sitting she can end it all by standing up
when standing up she can stop the animations by selecting "Stop all animations" :)

Ah there is a bug in this way: The llDialog appears only on touch, so If I touch the ball before i seat the animations start while standing up.

What I whould like to accomplish:

The Av touches the ball -> gets a message explaining its use
The AV sits on the ball -> gets a Dialog with the basic animations/poses
The AV selects a pose/Animation -> this will be the base animation from now on.
The AV presses LEFT ARROW > AnimationA starts, when the btn is depressed the AV returns to the basic Pose/Animation
Same with the RIGHT ARROW
The AV presses UP ARROW -> menu appears so AV can change the basic pose/Animation
StandUp -> AV stand up animations end.

Well I will figure it out sometime , i think I am mixing up the sequence of permissions or something.

Any ideas?

Thanx a lot again
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-27-2007 07:41
Permissions are not additive, you would need to combine the requests
CODE

llRequestPermissions(avatar, PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);
Sofia Weir
Registered User
Join date: 5 Feb 2007
Posts: 26
It still doesnt work!
02-28-2007 15:31
Hi
Thanx again for the tip , tried it, but it doesnt work still!...
When I request both of permission together using your line with the "|", the script gets only the animation permission.
When i ask twice (One request for each permission), It seems to work but i get a script error saying that there are no animation permisssions!

AAAARG!
Anti Antonelli
Deranged Toymaker
Join date: 25 Apr 2006
Posts: 1,091
02-28-2007 22:05
Sofia, what Newgate was getting at by saying permissions are "not additive", is that you can't request a certain permission and then request another one later and still keep the old one too. That's why you're getting the results you get when you request them seperately; the second request supersedes the first request, and all you end up with is the permissions you asked for last, and your script tosses an error if you try to act on the first set of permissions (they aren't there any more).

So you need to combine them into a single request as in Newgate's example. I'm not sure why that way isn't working for you.
Sofia Weir
Registered User
Join date: 5 Feb 2007
Posts: 26
This is what I did
02-28-2007 22:57
This is what i did:



[ PHP ]changed(integer change)
{
if(change == CHANGED_LINK)
{
avatar = llAvatarOnSitTarget();
if(avatar != NULL_KEY)
{
//llRequestPermissions(avatar,PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);
//llRequestPermissions (avatar,PERMISSION_TRIGGER_ANIMATION);
//llRequestPermissions (avatar,PERMISSION_TAKE_CONTROLS);

}
else
{
if (llGetPermissionsKey() != NULL_KEY)

llStopAnimation(CURRENT_ANIMATION);

}
}


}[ /PHP ]


Of course the // do not exist in the running version, and the three permission lines are not ALL there, it either the

llRequestPermissions(avatar,PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);

or the other two.

If I use the above line which sums both permission requests, the avatar sits on the target, and I get a "stand up" button, but the buttons are not under my control.
If i use the other version requesting permissions one at a time, I get both "StandUp" and "release controls" buttons, and i have control of the buttnos, but I get script errors saying I dont have animation permissions, (As you pointed out this is fine since permissions are not accumulative)

How can I do both without the errors?

thanx!.

PS: How can i format my code blocks the way you do and make them look cool? :)
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-01-2007 05:46
To post code use PHP tags i.e. [ PHP ] code [ /PHP ] but with out the spaces.

Not sure why the permissions are not working.
Will attempt to find out if/when I can next log in.
Baron Hauptmann
Just Designs / Scripter
Join date: 29 Oct 2005
Posts: 358
03-01-2007 06:31
From: someone

llRequestPermissions(avatar,PERMISSION_TAKE_CONTRO LS | PERMISSION_TRIGGER_ANIMATION);


I assume that the space in CONTRO LS is not in the actual script (which would DEFINITELY be a problem) . . .

Baron
Sofia Weir
Registered User
Join date: 5 Feb 2007
Posts: 26
I didnt do this!
03-02-2007 06:08
Hi there

Well The gap in the code was a mistype here in the posting. The permissions still do not work. :(

I tried the
CODE
[\PHP] and it doesnt work!....:(

thanx
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-02-2007 12:35
From: Sofia Weir
Hi there

Well The gap in the code was a mistype here in the posting. The permissions still do not work. :(

I tried the
CODE
[\PHP] and it doesnt work!....:(

thanx



/PHP

Not in world so have not been able to test permissions. hopefully alter tonight.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-02-2007 15:29
Ok, been in world and played around and have had no problem getting controls and animations working. Heres the script I used, its rough and ready jsut to see what teh problem was

CODE

string animation_name = "fly";

default
{
state_entry()
{
llSay(0, "Hello, Avatar!");
llSitTarget(<0.1,0.1,0.1>,ZERO_ROTATION);
}

changed(integer change)
{
llOwnerSay("Changed event");
// The object's sit target has been triggered
if (change & CHANGED_LINK) // Test for a changed link
{
llOwnerSay("Changed links");
key avatar = llAvatarOnSitTarget();
if(avatar != NULL_KEY) // Is that changed link an avatar?
{
llOwnerSay("Changed avatar");
llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
}
else
{
if (llGetPermissionsKey() != NULL_KEY)
{
llStopAnimation(animation_name);
}
}
}
}

run_time_permissions(integer perm)
{
llOwnerSay("Permissions!");
if (perm & PERMISSION_TRIGGER_ANIMATION)
{
llStopAnimation("sit");
llStartAnimation(animation_name);
}
if (perm & PERMISSION_TAKE_CONTROLS)
{
integer KEYMASK = CONTROL_FWD | CONTROL_BACK | CONTROL_ROT_LEFT | CONTROL_ROT_RIGHT | CONTROL_UP | CONTROL_DOWN | CONTROL_LEFT | CONTROL_RIGHT | CONTROL_ML_LBUTTON;

llTakeControls(KEYMASK, TRUE, FALSE);

}
}


control(key driver, integer keys, integer edges)
{
}
}


My only thought is that you have not set a sit target which will cause a silent failure.