InuYasha Meiji
Half Demon
Join date: 14 Mar 2005
Posts: 127
|
04-25-2005 08:01
I have an interesting problem I hope someone could cure. I'm attempting to make a couch. It has room for 4 people. I put this script into each of the four cushions. Note: I'm not selling the script, but I may sell the couch. //script for sitting cross legged on an object //by Ananda Sandgrain - free to distribute but please don't sell! key avatar; vector pos = <0.68,0.0,-0.40>; //adjust the position to fit object -must be //nonzero in at least one direction or script will not work! rotation rot = <1,1,1,1>; //adjust rotation (1 in any vector gives 90 deg) default { state_entry() { llSitTarget(pos, rot); } changed(integer change) { avatar = llAvatarOnSitTarget(); if(change & CHANGED_LINK) { if(avatar == NULL_KEY) { // You have gotten off llStopAnimation("sit crossed"  ; llReleaseControls(); llResetScript(); } else if(avatar == llAvatarOnSitTarget()) { // You have gotten on llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION); } } } run_time_permissions(integer perms) { if(perms) { llStopAnimation("sit"  ; llStartAnimation("sit crossed"  ; } else { llUnSit(avatar); } } } The problem I am having is that if I leave the couch and cushions unlinked, avs can sit on each cushion with no error at all. But, If I link the couch into one big object, I get the avs to sit correctly using my chosen sit animation, but I get the dreaded (Permission_Trigger_Animation) blue block appearing all the time. What am I doing wrong, and how may I fix this. I am very new at messing with scripts. I need detailed descriptions, I'm trying to learn. Please help me. Inuyasha Meiji
|
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
|
04-25-2005 08:32
Try putting the script in each cushion. That'll handle each avatar's permissions separately, easing your problem considerably.
_____________________
---
|
InuYasha Meiji
Half Demon
Join date: 14 Mar 2005
Posts: 127
|
I re-inerate
04-25-2005 15:46
From: Jeffrey Gomez Try putting the script in each cushion. That'll handle each avatar's permissions separately, easing your problem considerably. I did that, but I also linked the cushions with the couch and each other, and the problem appears. Before linking, it all worked fine. But I wanted to link so that I don't need to select each piece of the couch to move the couch. I want to be in edit mode, click on the couch to highlight the couch and all of its parts to move it. Is there a way to do that?
|
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
|
04-25-2005 19:10
There is. Unfortunately, it's a bit more involved, as it would require you either 1) handle every sit target and permission in the couch primitive and/or 2) handle the whole thing with link messages to each "cushion" for triggering the animation. Essentially, something like this for each cushion: key agent = "";
link_message(integer sender, integer num, string str, key id) { if(str == "sit") { llRequestPermissions(id,PERMISSION_TRIGGER_ANIMATION); } else if(str == "nuke this agent") { if(agent == id) { llStopAnimation("animation name here"); agent = ""; llMessageLinked(1,llGetLinkNumber(),"off",""); } } }
run_time_permissions(integer perm) { if(perm) { llStopAnimation("sit"); llStartAnimation("animation name here"); llMessageLinked(1,llGetLinkNumber(),"on",""); } } And this in the couch: list sit_targets = [<0,0,0>,<1,0,0>,<2,0,0>,<3,0,0>]; // Add sit target vectors here - this assumes same rotation list cushions = [1,2,3,4]; // Add cushion link numbers here. You can do this by using // llGetLinkNumber() rotation rot = <0,0,0,1>; // Sit rotation; static. list agents = ["","","",""]; // Keep agents here. list used = []; // For used cushion scripts
AddThatAgent(key agent) { list temp = cushions; integer count = llGetListLength(used); integer i = 0; while(i < count) { llDeleteSubList(temp,llListFindList(temp,llList2List(used,i,i)),llListFindList(temp,llList2List(used,i,i))) } integer use_int = llList2Integer(temp,0); if(use_int > 0) { llMessageLinked(use_int,0,"sit",agent); } }
RemoveThatAgent(key agent) { llMessageLinked(LINK_ALL_OTHERS,0,"nuke this agent",agent); }
state_entry() { llSitTarget(llList2Vector(sit_targets,0),rot); }
collision_start(integer total_number) { integer i; for(i = 0; i < total_number; i++) if(llListFindList(agents,(list)llDetectedKey(i)) != -1) RemoveThatAgent(llDetectedKey(i)) }
changed(integer change) { if(change & CHANGED_LINK) { key person = llGetAvatarOnSitTarget(); if(person) AddThatAgent(person); } }
link_message(integer sender, integer num, string str, key id) { if(str == "on") { list temp = cushions; integer count = llGetListLength(used); integer i = 0; while(i < count) { llDeleteSubList(temp,llListFindList(temp,llList2List(used,i,i)),llListFindList(temp,llList2List(used,i,i))) } integer use_int = llList2Integer(temp,0); if(use_int > 0) { used += num; }
// Queue up the next target temp = cushions; i = 0; while(i < count) { llDeleteSubList(temp,llListFindList(temp,llList2List(used,i,i)),llListFindList(temp,llList2List(used,i,i))) } integer use_int = llList2Integer(temp,0); if(use_int > 0) { use_int = llListFindList(cushions,(list)use_int); if(use_int > 0) llSetSitTarget(llList2Vector(sit_targets,use_int), rot); } } else if(str == "off") { integer use_int = llListFindList(used,(list)num); if(use_int > 0) { llDeleteSubList(used,use_int,use_int); }
list temp = cushions; integer i = 0; while(i < count) { llDeleteSubList(temp,llListFindList(temp,llList2List(used,i,i)),llListFindList(temp,llList2List(used,i,i))) } integer use_int = llList2Integer(temp,0); if(use_int > 0) { use_int = llListFindList(cushions,(list)use_int); if(use_int > 0) llSetSitTarget(llList2Vector(sit_targets,use_int), rot); } } } Of course, you'll find that's probably extreme overkill, and since I wrote it all in the script window, will be a bit buggy I bet. I would say... just sit the cushions. 
_____________________
---
|
Damanios Thetan
looking in
Join date: 6 Mar 2004
Posts: 992
|
04-25-2005 21:13
You could just add an llGetPermissionsKey() check... This could be done a lot more tidy, with the right checks... but this should solve the problem quickly. Just replace the block in the original code with this block. --- code omited ---
if(avatar == NULL_KEY) { // You have gotten off or sat down on another prim if (llGetPermissionsKey() != NULL_KEY) { llStopAnimation("sit crossed"); // llReleaseControls(); - useless } llResetScript(); }
---- code omited
Basically the 'changed' event is triggered for all the prims when the avatar sits or unsits on the couch. But only the one prim he actually sits on will have the llAvatarOnSittarget() return the agent. If there's no agent, either the avatar stood up, or sat down on another cushion.
|
InuYasha Meiji
Half Demon
Join date: 14 Mar 2005
Posts: 127
|
Thanks.
04-26-2005 20:33
I just wanted to thank you, I now have a working couch.
I'm going to attempt something, I wouldn't mind help with, but I wanted to see what you thought of. I would like to weear an item that would make my avatar preform an action when ever a specific person said a certain phrase.
In my case a cursed necklace would make it so that when my wife said. "sit boy I would crash to the ground. This same thing could be used between couples and the blow kiss animation. They could put the script in wedding bands and when thier spouse says, "I Love you" they could automatically blow kisses to each other.
It has many uses.
What do you think of that for an idea?
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
04-27-2005 00:53
It's easy to do, I can help you if you want and grab me in world.
As anyone who plays with D/s can tell you there's a variety of these things out there. Prio's pet collars, KDC does one too, Leonard's Wondertoy, the Supervibe that I made etc.
|
Kurt Zidane
Just Human
Join date: 1 Apr 2004
Posts: 636
|
04-27-2005 12:38
Not to mention free dance braaclets
|
InuYasha Meiji
Half Demon
Join date: 14 Mar 2005
Posts: 127
|
Thanks, I got it.
05-26-2005 03:44
From: Eloise Pasteur It's easy to do, I can help you if you want and grab me in world.
As anyone who plays with D/s can tell you there's a variety of these things out there. Prio's pet collars, KDC does one too, Leonard's Wondertoy, the Supervibe that I made etc. I did it. I'm not sure if I made a scripting error or not, but it seems to work. I just don't want to cause lag. I thank you for the offer. If I ever see you online at the same time I'm on, I'll show it to you.. -Inu
|