need help with get avatar name (llKey2Name?) etc
|
|
Andie Convair
Registered User
Join date: 11 Mar 2008
Posts: 7
|
03-12-2008 16:46
Still Need Help, Please. See Below. I know I'm either over looking something, or just not comprehending what I've found in the wiki's and how to's. I have an object that I'm attaching to an avatar. I need to get the avatar's name when it's attached, then be able to enter it in a llSay line later on in the script. ie llSay(0,"~avatar's name~ does something or another here."  ; Any help with this would be greatly appreciated.
|
|
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
|
03-12-2008 17:47
Here's an attachment example from one of the wikis: default { attach(key attached) { if (attached != NULL_KEY) // object has been //attached// { llWhisper( 0, "I'm stuck on you, " + llKey2Name(attached) ); // etc. } else // object has been detached { llWhisper( 0, "Why hast thou forsaken me?" ); // etc. } } } llKey2Name can be used on any key, so long as the avatar/agent is in the same sim. So you can use llKey2Name to detect the name of an object... or it's owner. Check this out: default { collision(integer num_detected) { llSay(0, llKey2Name(llDetectedKey(0)) + " is currently colliding with me!"  ; if (llDetectedKey(0) != llGetOwnerKey(llDetectedKey(0)) && llGetOwnerKey(llDetectedKey(0)) != ""  llSay(0, llKey2Name(llDetectedKey(0)) + " is owned by " + llKey2Name(llGetOwnerKey(llDetectedKey(0)))); else if (llGetOwnerKey(llDetectedKey(0)) == ""  llSay(0, llKey2Name(llDetectedKey(0)) + "is an object, but I can't find their owner."  ; } } (there's also a llDetectedName() which can be used in these situations, but I wanted to illustrate how llKey2Name was used.)
_____________________
 ● Inworld Store: http://slurl.eclectic-randomness.com ● Website: http://www.eclectic-randomness.com ● Twitter: @WinterVentura
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
03-12-2008 17:48
You can only attach an object you own, so llGetOwner() will give the owner/'wearer's key. Then you can use either llKey2Name(id) or llRequestAgentData(id, DATA_NAME) to get the name. While attached, llKeyToName() should always work (since the attachment is in the same sim as the avatar. Heh. Note that llRequestAgentData() doesn't return the name; it returns a key that must be compared to the request ID passed to a 'dataserver' event along with the data (the name) to find the response you are looking for. http://www.lslwiki.net/lslwiki/wakka.php?wakka=llKey2Namehttp://www.lslwiki.net/lslwiki/wakka.php?wakka=llRequestAgentData
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
03-12-2008 21:34
object owner key to name (as in getting the name of somone elses object) can be achieved with 100% accuracy through http calls to world.secondlife.com/resident/<key> and will only fail (with a message) if it's group owned(after which you'd test world.secondlife.com/groups/<key>  , unlike request agent data, which fails with no message (you're left waiting), or key to name (which returns "" if the av isn't on the sim, or it's group owned[or in the case of objects names "" could be the name you never know])
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Andie Convair
Registered User
Join date: 11 Mar 2008
Posts: 7
|
03-12-2008 22:55
Thank you all for your help, but I'm still having problems. Syntax error tells me "name not defined within scope". Yeah, I'm relatively new to LSL so I apologize if this seems trivial. Any help here as to what I'm doing wrong would be so appreciated. //Smudging Script by Andie Convair string anim ="smoke_inhale"; string anim2 ="hold_R_handgun"; integer cntr = 0; integer checkit = 3; default { attach(key attached) { if(attached== NULL_KEY) { llStartAnimation(anim); llStartAnimation(anim2); llSay(0,llKey2Name(attached) + " lights the sage, then brings the smoke up and over their body with the feather, letting it cleanse their mind, body, and spirit."); llSetTimerEvent(10); } } timer() { llStartAnimation(anim2); llStartAnimation(anim); ++cntr; if (cntr < 2) { llSay(0,llKey2Name(attached) + " brings the smoke up over themself again, their mind and spirit being cleansed with each passing moment."); } else if (cntr < 3) { llSay(0,llKey2Name(attached) + " breathes the smoke from the sage in, letting it fill them with renewed clarity and purpose."); } else if (cntr < 4) { } else if (cntr < 5) { } else if (cntr < 6) { llSay(0,llKey2Name(attached) + " brings the smoke up over themself one last time, then passes the shell and feather on to someone else."); } else if (cntr < 8) { llDetachFromAvatar(); } } }
|
|
Kahiro Watanabe
Registered User
Join date: 28 Sep 2007
Posts: 572
|
03-13-2008 04:29
Some thins about llDetect* I saw something like: "llKey2Name(llDetectedKey(0))" I used to do that, but it's much better to do: "llDetectedName(0)" Also this: llKey2Name(llGetOwnerKey(llDetectedKey(0)))); can be replaced by llDetectedName(0). llDetect* functions work only in these events: collision_start collision collision_end sensor touch_start touch touch_end ---------- Going back to your script, I don't have time to check it all but I found a mistake at the beginning: if(attached == NULL_KEY) That means: "If attached equals a null_key" so that will be trigerred when you detach the object, instead: if (attached != NULL_KEY) or simply if (attached) Als you need to: Reques permissions to trigger animations http://rpgstats.com/wiki/index.php?title=LlRequestPermissionsAnd if you are playing an animation and want to play another one you should use something like: llStopAnimation(actualAnim); actualAnim = newAnim; llStartAnimatio(actualAnim); -- More stuff to check, i'll leave it to the next one.
|
|
revochen Mayne
...says
Join date: 14 Nov 2006
Posts: 198
|
03-13-2008 04:52
Hi Andie
Its just that you try to use 'key attached' at the timer event but its restricted to use only at the attach event. Best to do is to create a new globar string and store the name in it.
And Kahiro said right that the script will need permissions to animate and the other things he pointed at.
|
|
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
|
03-13-2008 06:49
Here's the quick fix: replace "llKey2Name(attached)" with "llKey2Name(llGetOwner)" Why? because "attached" is a key that is defined in the "scope" of the "attach" event.. but is ONLY used in that event. Look at the top of the "timer" event... at no point is "attached" defined. Since the variable ("attached"  is not defined within that event, and is not defined as a global variable... the Timer "scope" event has no idea what "attached" means. Hence the error. Here's another way to approach this... You can create a global string to store the name. Define it at the Attach event, and then reuse it. At the top of your script (above default), write: string OwnerName; Then, at the top of your Attach event, (just after the "{" ) enter this line: OwnerName = llKey2Name(attached); Then, replace every other instance of "llKey2Name(attached)" with "OwnerName"
_____________________
 ● Inworld Store: http://slurl.eclectic-randomness.com ● Website: http://www.eclectic-randomness.com ● Twitter: @WinterVentura
|
|
Darien Caldwell
Registered User
Join date: 12 Oct 2006
Posts: 3,127
|
03-13-2008 12:26
From: Winter Ventura Here's the quick fix:
replace "llKey2Name(attached)" with "llKey2Name(llGetOwner)"
Should be "llKey2Name(llGetOwner())" Waves to Winter. 
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
03-13-2008 15:16
actually if it's in the attach event and you want to differentiate between the object being worn and not, and only get the name when it's attached you could use
if (attached) name = llKey2Name( attached );
similar to kahiros's example...
the benifit is one less function call (llGetOwner) and differentiating between worn and not. the drawback if not getting the owners name if the object isn't attached.
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|