Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llSetObjectName

Katryna Jie
Registered User
Join date: 24 Jun 2007
Posts: 187
04-09-2008 18:18
Hi all.. I've been trying to make an object speak as the owner name instead of as the object name, but can't figure out how to do this except for renaming the object.

I came across llSetObjectName(), and it says this::

Calling llSetObjectName in an object worn as a HUD will change its name, but only while it is worn. In inventory, the name change will not be reflected. Taking it off and re-wearing the HUD is like renaming it back to what it was before your script renamed it.

Does this apply to normal attachments too? *kicks the internet because she's unable to log in atm to test it*
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
04-09-2008 19:26
What about this?
CODE
string objectName;

default
{
attach(key id)
{
if(id != NULL_KEY) //When you wear this
{
objectName = llGetObjectName(); //Remember the original name
llSetObjectName(llKey2Name(id)); //Set your name to the object
llListen(1, "", id, "");
}
else //When you take off this
{
llSetObjectName(objectName); //Get it back to the original name
}
}
listen(integer channel, string name, key id, string message)
{
llSay(0, message);
}
}

You can say, "/1 Something" to let it to say, "Something". Nothing is diffent between normal attachments and HUDs.
_____________________
:) Seagel Neville :)
Katryna Jie
Registered User
Join date: 24 Jun 2007
Posts: 187
04-09-2008 22:17
ok, thanks, I'll have a play around with that then and see if it works... ^^
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
04-10-2008 07:42
From: Katryna Jie
Does this apply to normal attachments too?
I believe so. I ran into this quirk sometime ago when writing a script for a "self-destructing" object which, after a timeout or moving outside a certain range from another object, would no longer function. I tried to have it re-name itself to include "Delete Me" when it entered it's "dead" state, but this change was never reflected in the inventory.
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
04-10-2008 07:56
Changes to attached objects have historically been very unreliable.. If you need to do something permanent, your best bet is to do it while the object is on the ground, take it back into inventory, and wear it again.
_____________________
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
04-10-2008 10:52
Yes, it applies to normal attachments and not just HUDs. The Wiki should be corrected.

Just change the object name to the owner's name each time it's attached (in the 'attach' handler). Its name won't change in inventory.

Seagel's code is superflouous. Why save the name and set it back to the original, if SL does that for you anyway? Well, it would protect you from a change in semantics.

This is all you need:

CODE

attach(key id) {
if (id != NULL_KEY) {
llSetObjectName(llKey2Name(id));
}
}


You probably don't even need the test for NULL_KEY.
Virrginia Tombola
Equestrienne
Join date: 10 Nov 2006
Posts: 938
04-10-2008 11:46
From: Deanna Trollop
I believe so. I ran into this quirk sometime ago when writing a script for a "self-destructing" object which, after a timeout or moving outside a certain range from another object, would no longer function. I tried to have it re-name itself to include "Delete Me" when it entered it's "dead" state, but this change was never reflected in the inventory.



I just encountered this the other day, trying to do just that with a demo attachment. I also had an llOwnerSay telling the owner to delete it. When the object spoke, it used the new name (i.e. "Used Demo: Find 'used demo' in inventory and delete me";), but it never changed its name in inventory.

I suppose I'm glad to know it's not my scripting, but an LSL thing.
_____________________


Horses, Carriages, Modern and Historical Riding apparel. Ride a demo horse, play whist, or just loiter. I'm fair used to loiterers.

http://slurl.com/secondlife/Caledon%20Eyre/48%20/183/23/
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
04-11-2008 01:04
From: Lear Cale
Seagel's code is superflouous. Why save the name and set it back to the original, if SL does that for you anyway? Well, it would protect you from a change in semantics.
Ouch, but I thought it was the most desirous feature of her demand. :p
_____________________
:) Seagel Neville :)
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
04-11-2008 09:03
/me winks to Seagel, and reminds himself to take a chill pill or 3. ;)
Katryna Jie
Registered User
Join date: 24 Jun 2007
Posts: 187
04-13-2008 20:04
Thanks guys... help much appreciated **opens a new thread for her next question**
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
04-13-2008 23:37
sadly, both the name and descriptions of an attachment, don't save when unworn. So scripts that "store" data in the descriptiong (like a size setting for example) will lose their setting on rewear.
_____________________

● Inworld Store: http://slurl.eclectic-randomness.com
● Website: http://www.eclectic-randomness.com
● Twitter: @WinterVentura
Katryna Jie
Registered User
Join date: 24 Jun 2007
Posts: 187
04-14-2008 00:41
well I got it working without it getting all messy.. once I got home to experiment with it, it was pretty straight forward after the advice given.