How do I get an action into an object?
|
Cocoanut Koala
Coco's Cottages
Join date: 7 Feb 2005
Posts: 7,903
|
04-12-2005 18:34
I have a bed that needs to be able to slept in, and a pillow that needs to be able to be sat cross-legged on. I also have a hamper with a round lid that needs to be able to be opened, like doors open.
How do you get actions into the furniture? Is there more than one method? Thank you for your help.
coco
|
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
|
04-12-2005 19:09
Here's an example using on of the built-in animations. It does the cross-legged sit. The sleep one is pretty much the same. // Escort's sit cross-legged seat script string DEFAULT_ANIM = "sit"; string ANIMATION = "sit_ground"; // default { // state_entry() { // You must set the sit target position or this won't work! // Getting the right sit position is a matter of trial and error // with the vector you pass for the sit target... llSitTarget(<-0.15, 0, 0.8>, ZERO_ROTATION); }
// When an avatar sits on the prim, the changed event fires... changed(integer change) { if(change & CHANGED_LINK) { llSleep(0.25); // the short sleep helps with this next call key agent = llAvatarOnSitTarget(); if (agent != NULL_KEY) { // if the agent/avatar chose to sit, then the trigger anim perm // will automatically be granted, so I don't bother to check it llRequestPermissions(agent, PERMISSION_TRIGGER_ANIMATION); llStopAnimation(DEFAULT_ANIM); llStartAnimation(ANIMATION); } else { llStopAnimation(ANIMATION); } } }
// This helps most scripts... on_rez(integer start_param) { llResetScript(); } } The hamper is a bit more complex, as you probably can't get the animation you want without using llBreakLink(), then llSetPos()/llSetRot, then llCreateLink() to relink the lid. That is the only way I have managed to make a satisfactory "integrated door" which, it sounds, is essentially what the hamper lid is... /esc
_____________________
http://slurl.com/secondlife/Together
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
04-13-2005 08:56
Don't use his script. It takes shortcuts you shouldn't take. In the long run it will cause you more trouble then it is worth. string anim = "sit_ground"; vector sit_pos = <0,0,0.00001>; vector sit_rot = <0,0,0>; integer perms = PERMISSION_TRIGGER_ANIMATION;
key user;
default { state_entry() { llSitTarget(sit_pos, llEuler2Rot(sit_rot * DEG_TO_RAD)); } changed(integer change) { if (change & CHANGED_LINK) { llSleep(0.01);//i'm not sure if a sleep is actualy needed. but i'll leave it key sit = llAvatarOnSitTarget(); integer u = ((llGetAgentSize(user) != ZERO_VECTOR) && (llGetPermissions() & perms) == perms) ); if(sit == NULL_KEY) { user = NULL_KEY; if(u) llStopAnimation(anim); } else if(!u) llRequestPermissions(sit, perms); } } run_time_permissions(integer perm) { key sit = llAvatarOnSitTarget(); if((perm&perms) != perms || llGetAgentSize(sit) == ZERO_VECTOR || sit!=llGetPermissionsKey()) { user = NULL_KEY; return; } user = sit; llStopAnimation("sit"); llStartAnimation(anim); } }
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
|
04-13-2005 10:23
From: Strife Onizuka Don't use his script. *shrugs* It's a free country. Seems to work OK for me (I guess you didn't try it). Still, you pays ya money... you get what you get. /esc
_____________________
http://slurl.com/secondlife/Together
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
04-13-2005 11:08
From: Strife Onizuka Don't use his script. It takes shortcuts you shouldn't take. In the long run it will cause you more trouble then it is worth. I'm not in-world right now, but it looks like the script you're saying "Eek, no" about is the one that I've used since I picked it up as a freebie somewhere. Can I ask what's so bad about it, it's worked for me over the months...
|
gene Poole
"Foolish humans!"
Join date: 16 Jun 2004
Posts: 324
|
04-13-2005 11:13
I think the "bad" bit has to do with order of operations: when requesting permissions, one should handle the resulting 'run_time_permissions' event, and do the anim-changes there. But I'm not sure that's what Strife was getting at.
|
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
|
04-13-2005 15:12
From: gene Poole I think the "bad" bit has to do with order of operations: when requesting permissions, one should handle the resulting 'run_time_permissions' event, and do the anim-changes there. But I'm not sure that's what Strife was getting at. Well, given that the agent sat on the target the perms are implicit. And so no, I'm not sure what strife is getting at either. It's quite possible I'm missing something, even though the script I use appears to work every time -- so any further contribs would be most welcome. /esc
_____________________
http://slurl.com/secondlife/Together
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
04-13-2005 15:34
There are two reasons. The first you have nailed on the head. You shouldn't depend on permissions always being implicit. If this behavoir was changed you script would fail (and LL is known for changing things and not telling anyone).
The other issue is less obvious. It's what happens when you put your script in two box's and link them. The script does not check if the agent is in the sim or if permissions have been granted before stopping the animation. It does not even check if it needs to stop the animation. It just fires a stop animation anytime there is a changed link and there is nobody on the sit target. This is bad for a number of reasons.
1. If the agent is no longer in the sim an error box will be generated. 2. If the agent got up and sat on another object near by which then used the same animation. Then someone else sat on the object or got up from the object they were perviously sitting on, but were on a different sit target on the object it would cause the animation of the original agent (now sitting on another object but with the same key) to stop. 3. On *every* change link the animations are started and stopped, regardless if this is needed.
So I stand behind what I said.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
|
04-13-2005 15:47
You know, despite what you said, and which I read carefully, I stand behind mine too.
A third party comment would be interesting.
/esc
_____________________
http://slurl.com/secondlife/Together
|
Cocoanut Koala
Coco's Cottages
Join date: 7 Feb 2005
Posts: 7,903
|
04-13-2005 16:36
Thanks, guys, for the scripts!
Now, how do I get the script into the pillow? Do I copy it and paste it onto a notecard and then put the notecard into the pillow's contents tab?
Or do I have to make a pose ball - whatever that is? And do what with it?
I got the script, I got the pillow. I just don't know how to connect the two.
Thanking you in advance,
coco
|
Frans Charming
You only need one Frans
Join date: 28 Jan 2005
Posts: 1,847
|
04-13-2005 18:32
copy this script, open the contents of your pillow. Click on new script, And paste this script over it.
|
Cocoanut Koala
Coco's Cottages
Join date: 7 Feb 2005
Posts: 7,903
|
04-13-2005 20:41
Thank you so very much! I'll let you all know how the pillow turns out.  coco
|
Cocoanut Koala
Coco's Cottages
Join date: 7 Feb 2005
Posts: 7,903
|
04-13-2005 21:08
It doesn't work. Neither of those scripts work. I must be doing something wrong. I copied the script, pasted it into the thing under "new script" - which already had something on it. I tried putting it in a note card and dragging the card to the pillow.
Doesn't work. I don't sit cross-legged on the pillow.
Can any of you tell by this what I am doing wrong? *sobs*
coco
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
04-14-2005 02:42
It will only work if it's a script, not a notecard.
Would it let you save the script (button in the bottom right)? The save light will go out as soon as you click it, but that doesn't actually mean it's saved, there is a pane beneath the one with the script in it that will detail the first error it found. Some of these errors are useful, but often it just says syntax error and I know I've spent hours staring at bits of code trying to work out where I've missed or added a semi-colon or a bracket on occasion.
The likeliest error is that you aren't replacing the existing default script which you will need to do to make it work. You can most easily do this by creating a new script in the object (contents > new script) then clicking into the script and using Cntl-A so it highlights the existing default script, then pasting the actual script you want to use in.
After that, you might find various syntax errors, although on a quick read through both scripts you probably won't if you copied them right.
|
Cocoanut Koala
Coco's Cottages
Join date: 7 Feb 2005
Posts: 7,903
|
04-14-2005 17:02
Thank you. I copied them exactly as they were shown above.
I will now copy your message, and go in the game and see if I can't get one of those scripts to work right. Thanks!
coco
|
Cocoanut Koala
Coco's Cottages
Join date: 7 Feb 2005
Posts: 7,903
|
04-15-2005 07:32
Nothing works. Nothing nothing nothing nothing nothing.
I have a suspicion that I am doing something very simple and obvious wrong. Either that, or putting scripts in things is such a hit-and-miss proposition that scripts can't possibly be shared without huge and random difficulty, and surely that can't be.
It always says "syntax error." I have done everything exactly as I was told - to the extent of copying the posts above on notecards and consulting them carefully as I go along, over and over. I've also tried a bunch of variations I thought might help.
This just CAN'T be that hard to do. It's not like I'm trying to write a script. I'm just trying to put a simple "sit with knees crossed like on the ground" script into a pillow.
I think I'm going to have to beg someone on the game to help me. But I don't want them to just do it FOR me, I want to be shown how to do it for myself.
I want to know how to take scripts of all kinds (not scripts I've written, but those which others or Lindens have written) and put them into objects I've created. I won't sell my objects until they can do the things I want them to. Beds you can't actually sleep in (on) and pillows that when you sit down on them your legs are halfway disappeared into the ground are useless, in my opinion. I can't go on with my work until I get this conquered.
If any of you would be willing to come into the game with me and teach me how to do this, I would be greatly appreciative. I know it is very difficult to get these things across on the game, but I sure would appreciate it.
yours in dumbieness,
coco
|
Foolish Frost
Grand Technomancer
Join date: 7 Mar 2005
Posts: 1,433
|
04-16-2005 02:44
Did you get a crosslegged pose to put in the pillow too?
You need to have the pose as well...
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
04-16-2005 04:38
Oops, that's not right Foolish!
sit-ground is one of the default anims that you can call WITHOUT putting it into the object. It plays exactly the one your AV plays if you choose "sit" on the ground from the pie menu (hence the imaginative name I guess) and so (very non-technically speaking) you already "know how to do it." The same is true of various stand, sit, shooting, pointing, flying, walking etc. poses.
And although Cocoanut was having problems (rotations and position ones) I took a copy of Strife's script into world for him, compiled it and sent it over with full perms after I checked it worked. It was going to be just a case of hacking the vectors
|
Cocoanut Koala
Coco's Cottages
Join date: 7 Feb 2005
Posts: 7,903
|
04-16-2005 11:21
Yes, Eloise has helped me with getting that script in, and for that I'm very greatful! Then I started a thread about the vectors, and she's helping me with that, too.
The pose and pose ball thing - I get the feeling that that is some whole other way of having actions, maybe for the cases of where you have two people on a couch each needing to do a different action, or a bed where you want a choice of actions - in other words, most useful for where you need one object to offer more than one action.
Where you need the object to offer only one action, then skipping the whole pose ball thing saves a prim.
Am I right on that, Eloise? Or maybe it's something else entirely. Like, do you have to have a poseball if its not a default animation?
coco
|
Foolish Frost
Grand Technomancer
Join date: 7 Mar 2005
Posts: 1,433
|
04-16-2005 11:57
From: Eloise Pasteur Oops, that's not right Foolish!
sit-ground is one of the default anims that you can call WITHOUT putting it into the object. It plays exactly the one your AV plays if you choose "sit" on the ground from the pie menu (hence the imaginative name I guess) and so (very non-technically speaking) you already "know how to do it." The same is true of various stand, sit, shooting, pointing, flying, walking etc. poses.
And although Cocoanut was having problems (rotations and position ones) I took a copy of Strife's script into world for him, compiled it and sent it over with full perms after I checked it worked. It was going to be just a case of hacking the vectors Whoops! Was assuming it was not a standard pose. Sorry about that.
|
Cocoanut Koala
Coco's Cottages
Join date: 7 Feb 2005
Posts: 7,903
|
04-16-2005 20:35
Yep yep yep, I'm just at the baby steps.
coco
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
04-18-2005 06:36
From: Cocoanut Koala Yes, Eloise has helped me with getting that script in, and for that I'm very greatful! Then I started a thread about the vectors, and she's helping me with that, too.
The pose and pose ball thing - I get the feeling that that is some whole other way of having actions, maybe for the cases of where you have two people on a couch each needing to do a different action, or a bed where you want a choice of actions - in other words, most useful for where you need one object to offer more than one action.
Where you need the object to offer only one action, then skipping the whole pose ball thing saves a prim.
Am I right on that, Eloise? Or maybe it's something else entirely. Like, do you have to have a poseball if its not a default animation?
coco Poseballs are a trickier thing, there are several reasons to use them, and one excellent one not to! Poseballs give you a ball, that you can rotate and position independent of the item of furniture, which means you can make your furniture at any tortured angle you want, slap a poseball on and rotate and position the ball independently of that - thus saving hacking the sit_pos and sit_rot vectors! (No cheering now) Poseballs also let you add "seating" (or lying, standing etc.) for multiple people to one item. So you have a sofa with three spaces on it, three pose balls, one per seating space. There are other ways, but that is one of the easiest. As you've said, though, it does mean you 'waste' a prim - but you don't pull your hair out, your call. To play a non-default animation you have to make sure that the animation is in the inventory with the script. If you're using a pose ball it has to be in the poseball's inventory. That is actually another advantage of poseballs - if you're making several using the same pose you can make the pose ball and copy it, script, anim and all several times...
|