Late Night On lsl Leash Script Check
|
|
Jenn Yoshikawa
Registered User
Join date: 14 Nov 2007
Posts: 91
|
07-29-2008 02:07
here is a leash script I cooked up I have yet to add particle chain to it. But can you all look this over and tell me if it would work. If not where did I go wrong lol. 2nd thing would this work for the leash holder to get the object key so its not going to my leg? float distance = 1.5; float time = 2; integer onleash = FALSE; integer yank = FALSE; default { state_entry() { } attach(key attached) { llResetScript(); } link_message(integer send, integer num, string msg, key id) { if ( num == -200 ) { onleash = TRUE; llSensorRepeat(llKey2Name(id), id, AGENT, 50, TWO_PI, time); } else if ( num == -201 ) { onleash = FALSE; llSensorRemove(); } else if ( num == -203 ) { time = 1; yank = TRUE; } } no_sensor() { llSensorRemove(); } sensor(integer total_number) { if (onleash == TRUE) { if (yank == TRUE) { vector holder = llDetectedPos(0); llMoveToTarget(holder,0.1); yank = FALSE; } vector holder = llDetectedPos(0); if(llVecMag(llGetPos() - holder) > distance) { llMoveToTarget(holder + (distance * llVecNorm(llGetPos() - holder)),0.3); llSleep(time / 4.0); llStopMoveToTarget(); } } } } ---------------------------------------------------------------------------------------------------- this would be in the script above at some point if it will work listen(integer channel, string name, key id, string mesg) { list tmp = llParseString2List(mesg, ["|"], []); key holder = llList2Key(tmp, 0); string mesg = llList2String(tmp, 1); if(holder == llGetOwner()) { key to the object for the particle chain } ---------------------------------------------------------------------------------------------------- this would be in the av hand for the particle chain key to I know some things are not there I'm just asking if it would work. llSay(1, owner + "|" + "objectkey"  ;
|
|
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
|
07-29-2008 08:14
There's no need to specify both a name _and_ a key in the llSensorRepeat call, as either is enough to uniquely identify the avatar.
Also, the script you've given pulls the wearer towards the midpoint of the line between the leash holder and the wearer - there's actually no need to do that, since you can just use the distance option of llMoveToTarget to stop them in range of the wearer. The reason why it's a bad idea is because, if there's lag, the leash may still wind up pulling them towards an outdated location which can be problematic if they have circled the leash holder in the meantime.
|
|
Destiny Niles
Registered User
Join date: 23 Aug 2006
Posts: 949
|
07-29-2008 08:28
You might also want to no use sensors at all and instend use llGetObjectDetails.
You change the sensor event to a timer event and replaced the llDetectedPos(0) vector holder = llList2Vector(llGetObjectDetails(id, [OBJECT_POS]),0);
|
|
Jenn Yoshikawa
Registered User
Join date: 14 Nov 2007
Posts: 91
|
ummmm
07-29-2008 08:54
so I would want to change it to this lol sorry sensors are not my idea of fun.
llSensorRepeat("", id, AGENT, 50, TWO_PI, time);
on llGetObjectDetails and SetObjectDetails I think it would work but the collar would be mod and I think so one chould use a timer or change command to SetObjectDetails to stop the leash from working. Now unless theres a way to set up pass words on scripts IE if I make a plug in where the main script would check to see if there is a pass word and if its right if not trun off the script and or remove it lol.
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
07-29-2008 10:54
There is no such function as llSetObjectDetails(). The llGetObjectDetails() function can be used to get some of the same things you can obtain from a sensor or certain function calls from within a script in the prim. In particular, it is very useful (and quite efficient compared to sensors) for getting the position and rotation of an avatar or object if you know their key ahead of time. See http://www.lslwiki.net/lslwiki/wakka.php?wakka=llGetObjectDetails
|
|
Jenn Yoshikawa
Registered User
Join date: 14 Nov 2007
Posts: 91
|
llGetObjectDetails()
07-29-2008 13:09
is a little lost on llGetObjectDetails() not sure what you mean or even how to work in it lol
|
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
07-29-2008 16:38
From: someone is a little lost on llGetObjectDetails() not sure what you mean or even how to work in it lol Well, key avi; llGetObjectDetails(avi, [OBJECT_POS,]); should return a vector telling you where he is without your having to use sensors, assuming he's on the same sim and you know what his key is, both of which will be true in this context.
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
07-29-2008 20:22
Right. key avatar = "abcd1234-abcd-1234-abcd-1234abcd1234";
list details = llGetObjectDetails(avatar, [ OBJECT_POS ]); if (llGetListLength(details) < 1) { llSay(0, "Avatar not in range"); } else { llSay(0, "Avatar is at "+llList2Vector(details, 0)); }
Note that the function MIGHT detect the avatar if the avatar is in a neighboring region.
|
|
Jenn Yoshikawa
Registered User
Join date: 14 Nov 2007
Posts: 91
|
Now I fill dumb
07-30-2008 13:50
From: Hewee Zetkin Right. key avatar = "abcd1234-abcd-1234-abcd-1234abcd1234";
list details = llGetObjectDetails(avatar, [ OBJECT_POS ]); if (llGetListLength(details) < 1) { llSay(0, "Avatar not in range"); } else { llSay(0, "Avatar is at "+llList2Vector(details, 0)); }
Note that the function MIGHT detect the avatar if the avatar is in a neighboring region. how dose this help move to target sorry never used llGetObjectDetails. And can you give me a tiny lay out how I would script it lol.What you posted lost me ten times over lol.
|
|
Jenn Yoshikawa
Registered User
Join date: 14 Nov 2007
Posts: 91
|
omg blond lol
07-30-2008 16:44
ok tried to use what you all said. gahhh its not working for me lol. so can you point out the areas to me where I did worng and show me like a 2 year old lol default { state_entry() { llParticleSystem([]); } changed(integer change) { if (change & CHANGED_OWNER) { llResetScript(); } } attach(key attached) { llResetScript(); } listen(integer channel, string name, key id, string msg) { if (0 == llSubStringIndex(msg, "holder "  ) { target = (llGetSubString(msg, 7, -1)); } } link_message(integer send, integer num, string msg, key id) { if ( num == -200 ) { onleash = TRUE; lsiten(); llSay(-7734, (string)id + "|" + "leash"  ; llSay(0, (string)id + "|" + "leash"  ; } else if ( num == -201 ) { onleash = FALSE; llParticleSystem([]); } else if ( num == -203 ) { time = 1; yank = TRUE; } } timer () { if (onleash == TRUE) { if (yank == TRUE) { vector holder = llList2Vector(llGetObjectDetails(target, [OBJECT_POS]),0); llMoveToTarget(holder,0.1); yank = FALSE; } vector holder = llList2Vector(llGetObjectDetails(target, [OBJECT_POS]),0); if(llVecMag(llGetPos() - holder) > distance) { setParticles(); remove(); llMoveToTarget(holder + (distance * llVecNorm(llGetPos() - holder)),0.3); llSleep(time / 4.0); llStopMoveToTarget(); } } } }
|
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
07-30-2008 20:05
|
|
Jenn Yoshikawa
Registered User
Join date: 14 Nov 2007
Posts: 91
|
lol
07-30-2008 21:16
I after reading over the post 100 times I got what you all said hehe. Listen thats to get the leash holder object uuid so I can use a particle chain.
|
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
07-31-2008 03:11
From: Jenn Yoshikawa I after reading over the post 100 times I got what you all said hehe. Listen thats to get the leash holder object uuid so I can use a particle chain. Sorry I didn't make myself clearer... but while listen() may well find the leash holder object's uuid, lsiten() isn't going to do much other than stop it compiling. I was assuming the code you quoted is something you've copied and pasted from your script -- in which case that typo will be one thing that's causing you problems -- or have you actually typed it out again? What problem are you having with the leash and holder exactly? Is the code not compiling or can you get it to compile and it's not doing what you want it to?
|