Attachment Passing Info to Rezzed Object
|
|
Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
|
05-19-2008 10:28
I am attempting to have an attachment rezz an object, then pass an avatar key to the rezzed object to use in a sensor. Here is what I have tried: This portion is in the attachment; integer object_num = 3; string messageReparo = "Reparo"; integer rezzchannel = -1234; key TargetKey; string object = "Reparo obj test";//Object in inventory string TargetSend = ""; string TargetName(key id) { // Get a name from a key string name = llKey2Name( id ); return name; }
default { state_entry() { }
link_message(integer sender_num, integer num, string str, key id) { if ( num == object_num ) { if ( str == messageReparo ) { TargetKey = id; TargetSend = TargetName(TargetKey); llRezObject(object, llGetPos() + <0, 0, 2>, ZERO_VECTOR, ZERO_ROTATION, 42); llSay(rezzchannel, TargetSend); } } } // end of link_message }
In the rezzed object I have: integer rezzchannel = -1234; string target = "";
startup() { llSensorRemove(); llSensorRepeat( target,"",AGENT,200,2*PI,.5); }
default { state_entry() { llListen( rezzchannel, "", llGetOwner() , ""); startup(); }
on_rez(integer start_param) { startup(); } listen(integer rezzchannel, string name, key id, string message) { if ( llGetOwner() == llGetOwnerKey( id )) { llOwnerSay( message ); target = message; llSay(0, target); // just testing } } sensor(integer total_number) { vector pos = llDetectedPos(0); // Various sensor stuff } }
The Attachment script does say the avatar's name. The communication in receiving the key (or rather the avatar name) fails. I'm not sure if I have handled the information properly for the sensor to use after that, as well. Can I use the name as a string - llSensorRepeat( target,"",AGENT,200,2*PI,.5); - or do i need to do something else.
|
|
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
|
05-19-2008 10:51
I think you need to redo the llSensorRepeat in the listen event, after you've set the target.
You might also want to change Startup() to _not_ do the llSensorRepeat if target=="".
edit: also, sensors are only good for 96 meters - passing a 200 is fine but you won't get anything that's more than 96m away.
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!! - Go here: http://jira.secondlife.com/browse/SVC-1224- If you see "if you were logged in.." on the left, click it and log in - Click the "Vote for it" link on the left
|
|
Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
|
05-19-2008 11:06
Well I can't work much on the sensor functions until i get the communication issue solved, unfortunately, but yes I'll need to change the sensor distance, thanks 
|
|
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
|
05-19-2008 11:30
The point sorta was that when the object rezzes, 'target' is not yet set but you do the llSensorRepeat anyway. That and the listen event doesn't reset the sensor to look for the new target. Also, looking at this again, you rez the object and then immediately chat the target - this is likely to have problems, especially on a busy region, because the rezzing the object can take time and it probably won't see the chat because it hasn't rezzed yet. Check out the object_rez event, which is a callback telling you that an llRezObject has actually done it's thing. This would be a far better place to put the llSay. edit: something like this: link_message(integer sender_num, integer num, string str, key id) { if ( num == object_num ) { if ( str == messageReparo ) { TargetKey = id; TargetSend = TargetName(TargetKey); llRezObject(object, llGetPos() + <0, 0, 2>, ZERO_VECTOR, ZERO_ROTATION, 42); } } }
object_rez (key id) { llSay(rezzchannel, TargetSend); }
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!! - Go here: http://jira.secondlife.com/browse/SVC-1224- If you see "if you were logged in.." on the left, click it and log in - Click the "Vote for it" link on the left
|
|
Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
|
05-19-2008 12:13
I tested your suggestion on the use of object_rez like this: link_message(integer sender_num, integer num, string str, key id) { if ( num == object_num ) { if ( str == messageReparo ) { TargetKey = id; TargetSend = TargetName(TargetKey); llRezObject(object, llGetPos() + <0, 0, 2>, ZERO_VECTOR, ZERO_ROTATION, 42); } } }
object_rez (key id) { llSay(rezzchannel, TargetSend); llSay(0, TargetSend); //just for testing }
It does make sense thanks, and the test say does work, however, the: llSay(0, target); // just testing in the rezzed object listen still does nothing. Driving me bonkers. Your comment - "The point sorta was that when the object rezzes, 'target' is not yet set but you do the llSensorRepeat anyway. That and the listen event doesn't reset the sensor to look for the new target." - I think I understand and will work on that issue soon as I can test it after the script is getting the information passed.
|
|
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
|
05-19-2008 12:24
Ooooo... Don't give the llListen a llGetOwner() - that will only listen to you, not to an object. Maybe something like this untested piece of code will work... integer rezzchannel = -1234; string target = "";
ResetSensor() { llSensorRemove(); if (target != "") { llSensorRepeat(target, "", AGENT, 100.0, TWO_PI, .5); } }
default { state_entry() { llListen (rezzchannel, "", "", "");
ResetSensor(); }
on_rez(integer start_param) { ResetSensor(); }
listen(integer rezzchannel, string name, key id, string message) { if (llGetOwner() == llGetOwnerKey( id )) { target = message; ResetSensor(); llSay(0, target); // just testing } }
sensor(integer total_number) { vector pos = llDetectedPos(0); // Various sensor stuff } }
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!! - Go here: http://jira.secondlife.com/browse/SVC-1224- If you see "if you were logged in.." on the left, click it and log in - Click the "Vote for it" link on the left
|
|
Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
|
05-19-2008 13:28
Wow! Bows to the most excellent Meade! At last, yes the listen fix worked and also the resetting sensor fix  Finally it's working, thanks so much for the help, I was hopelessly mired and stuck.
|
|
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
|
05-19-2008 13:31
Yay! Glad it works!
edit: d'oh!
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!! - Go here: http://jira.secondlife.com/browse/SVC-1224- If you see "if you were logged in.." on the left, click it and log in - Click the "Vote for it" link on the left
|
|
Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
|
05-19-2008 13:35
Oh boy I spoke too soon. I tested it with two avatars in range, the script recives the correct avatar name , but the sensor moves it to the 1st avatar I tried, rather than the new avatar that was selected!
|
|
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
|
05-19-2008 13:43
So the object moves over or follows the target avatar around? And it worked right on the first avatar but then you tried to redirect it to a second avatar and it didn't work?
Are you sure that the object is within 20m of the object that's doing the llSay - llSay is limited to 20m.. Also, are you trying to move the object more than 10m? If so, that will silently fail - can't move more than 10m at once with llSetPos().
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!! - Go here: http://jira.secondlife.com/browse/SVC-1224- If you see "if you were logged in.." on the left, click it and log in - Click the "Vote for it" link on the left
|
|
Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
|
05-19-2008 14:06
Well i wanted a script i could change a few things on to have either follow or move over depending on the use, here's the full script that adapted the follow behavior from and the new things added to let it be a rezzed from an attachment and targets a chosen avatar: // Open Shifting Float and Follow Script, by Foolish Frost. // // From Open Basic Follower/Facing Script, by Logan Bauer. // /////////////////////////////////////////////////////////////////////// // OFFSET is the position of your pet in relation to it's owner's position. // For example, in the default setting below, "vector offset =<-1,0,1>;" // I.E. (x,y,z), the -1 puts it 1m back behind owner, the 0 means don't have // it stay left or right, and 1 means have it stay 1m above it's owner. // So, if you wanted the script to make it follow directly in front of you, // and to the left, then you would change it to "vector offset =<1,1,0>;" integer rezzchannel = -12345; string target = ""; // llFrand(float max)
vector offset =<0.0,0,0>; vector currentoffset =<0,0,0>; float xshift =.0; //How far it roams forward and back. float yshift =0.0; //How wide it roams left to right. float bob =0; //multiplyer of the BobCycle listed below. float shifttime =5; //average time it takes to shift to another XY position. integer timeset=0; //Is the timer running? float currentxshift =0; //current X shift position float currentyshift =0; //current Y shift position float currentyfacing =0; //currentyfacing storage integer currentbob; //current state of the BobCycle float bobbing =0; //bob storage list BobCycle = [0.0, 0.08, 0.12, 0.14, 0.15, 0.14, 0.12, 0.08, 0.0, -0.08, -0.12, -0.14, -0.15, -0.14, -0.12, -0.08];
startup() { llSensorRemove(); if (target != "") { llSensorRepeat(target, "", AGENT, 100.0, TWO_PI, .5); } vector pos = llGetPos(); llSetStatus(STATUS_ROTATE_Z,TRUE); llSetStatus(STATUS_PHYSICS, TRUE); }
default { state_entry() { startup(); llListen (rezzchannel, "", "", ""); }
on_rez(integer start_param) { startup(); } listen(integer rezzchannel, string name, key id, string message) { if (llGetOwner() == llGetOwnerKey( id )) { target = message; startup(); llSay(0, target); // just testing } } sensor(integer total_number) { vector pos = llDetectedPos(0); bobbing = llList2Float(BobCycle, currentbob)*bob; llSetTimerEvent(llFrand(shifttime)); currentoffset = <currentxshift, currentyshift, bobbing>; llMoveToTarget(pos+(offset+currentoffset)*llDetectedRot(0),.3); if (currentyshift>=0) { currentyfacing = currentyshift; } else { currentyfacing = currentyshift*-1; }
llLookAt(pos+<0,0+(currentyfacing*.33),1+bobbing>, 1 , 2);
currentbob = currentbob +1; if (currentbob == 16) { currentbob = 0; } if(timeset==0) { timeset = 1; llSetTimerEvent(((llFrand(shifttime)+llFrand(shifttime)+llFrand(shifttime))/3)*2); } }
timer() { timeset = 0; currentyshift = llFrand(yshift*2)-yshift; currentxshift = llFrand(xshift*2)-xshift; } }
The avatars tested on were 9 and 12 meters away. It worked when dirst tested, or so i thought, with only one avatar in range, but with the two avatars, and selecting the "new" avatar, it persisted in moving to the first avatar, even though the script did receive the new name.
|
|
Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
|
05-19-2008 14:11
hmm, tried it again and is now working for some sl only knows reason!
|
|
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
|
05-19-2008 14:13
Er.. Dunno.
Maybe put an llOwnerSay in the sensor event to make sure that that's only getting one hit (total_number == 1) and that llDetectedName(0) is the same as your target..
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!! - Go here: http://jira.secondlife.com/browse/SVC-1224- If you see "if you were logged in.." on the left, click it and log in - Click the "Vote for it" link on the left
|
|
Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
|
05-19-2008 14:25
Well i notice the behavior is that it moves to one avatar at first, then when the message is received it moves to the correct one take (several seconds). I also have to figure out the best way to add a timed die in. Update: I finally reorganized it to use states to do flow control and that did the trick 
|