Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Change object name voice command?

Nikoli Karu
Registered User
Join date: 3 Jul 2008
Posts: 7
07-04-2008 00:27
I'm trying to make a chat command that changes the name of the object that the script is in. The problem I'm having is with the llListen function. The last parameter needs to be what ever the new name is the user wants for it to work. In other words, instead of a specific message to activate the listen event I want the listen event to be activated by the very next thing that the owner types in no matter what it is.
This is what I have so far.

state changename
{
state_entry()
{
llOwnerSay("What would you like my name to be?";);
llListen(5, "Nikoli Karu", llGetOwner(), /*this is the parameter that I'm not sure about*/);
}
listen(integer channel, string name, key id, string message)
{
llSetObjectName(message);
llOwnerSay(message);
llOwnerSay("Is my new name.";);
state default;
}
}

Any help would be appreciated. : )
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
07-04-2008 00:31
llListen(5, "", llGetOwner(), "";);
_____________________

● Inworld Store: http://slurl.eclectic-randomness.com
● Website: http://www.eclectic-randomness.com
● Twitter: @WinterVentura
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
07-04-2008 04:47
To clarify Winter's anser,
The parameters to llListen are
llListen(integer channel, string name, key id, string msg)

msg is actually a filter, leave it blank to get everything said.
_____________________
I'm back......
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
07-04-2008 05:13
if you've got llGetOwner as the key, you don't ALSO need the owner's name in name. The only reason you'd want to pair them, or hardcode the name, is if you ONLY EVER wanted it to work FOR YOU, while YOU owned it. Doing it the way you did above, would break it if you tried to sell it or give a copy to a friend.

llListen(channel, name, key, filter)
...channel - integer number to listen on
... name - specific name of avatar or object to listen to. (ignores all others)
...key - specific UUID of avatar or object to listen to. (ignores all others)
...filter - specific message to listen for. (ignores everything that doesn't match)

Compare this to the event.
listen(channel, name, key, message)
...channel - channel message was heard on
...name - name of avatar or object that was heard.
...key - UUID of avatar or object that was heard.
...filter - message that was heard.

the listen event, will NEVER hear something that the script is not "listening for".. here's what different listen configurations do.

llListen(5, "", NULL_KEY, "";);
Fully open listen on channel 5. ANYTHING said on 5, by anyone or anything, will trigger the listen event.

llListen(5, "Object", NULL_KEY, "";);
Listen is open on channel 5, for anything with the name "Object". the name filter is handy if you know the name of an object that's going to be talking, but don't know it's key. Same with filtering some sort of "conversation recorder"... you don't need to know the people's keys, just their names. This doesn't support a wildcard, so a listen for "Winter" would not hear me. Note that while this is a handy filter style, it's not very secure. the script will hear ANYTHING said by ANY OBJECT with that name, on channel 5.

llListen(5, "", llGetOwner(), "";);
Thie listen is open on channel 5, for the person who owns the scripted device. it will *NOT* hear a hud.... even if the hud is owned by the same owner

llListen(5, "", llGetCreator(), "";);
Something of a backdoor... this allows you to open a persisting listen on channel 5, for the creator of the object housing the script. Of course, scripts can be moved to other prims..

llListen(5, "", llGetInventoryCreator(llGetScriptName()), "";);
This is a better backdoor... opens a listen for the creator of the script. Of course, moddable scripts can be copy-pasted into new scripts.. at this point however...

llListen(5, "", "145b5e86-fcb2-4351-877a-0dfe65e80518", "";);
That's my key there.. This is an open listen that will ONLY listen to me, on channel 5 of course. Not my HUD's.. just me. Again, not really secure as a backdoor in a moddable script (for the obvious reason that it can be modded) but it seems like it might be slightly more efficient than the previous example. Also useful if you want to open backdoors for several avatars.

llListen(5, "", NULL_KEY, "activate";);
Now here's an interesting use for the word filter. On channel 5.. it's ONLY listening for the word "activate". Now, my understanding is a little fuzzy here.. I'm not sure which of these will trigger it.

This will for sure: /5activate
Pretty sure this will too: /5 activate
I don't think this will: /5 activate me

That's the nasty bit about the filter. it's not all THAT handy.

However, you could open a listen JUST for a specific word.. maybe from a specific avatar name... I'm thinking of the SLX registration process... Where you tell them what your inworld name is, and then they tell you to got to an atm and say a magic word. That listen might look something like this:

llListen(0, "Winter Ventura", NULL_KEY, "register";);

With this listen, the ONLY thing it's listening for, is for SOMEONE, an avatar or object, with the name "Winter Ventura" to say the word "register" in open chat. Then the listen will probably store the UUID of the person who said that magic word.. and do whatever it does from there.

There's a LOT more to learn about listens, handles, listenremoves, compounding and layering listens.. but the specific fix for your problem, is in my earlier post.
_____________________

● Inworld Store: http://slurl.eclectic-randomness.com
● Website: http://www.eclectic-randomness.com
● Twitter: @WinterVentura
Nikoli Karu
Registered User
Join date: 3 Jul 2008
Posts: 7
07-04-2008 06:00
Thanks for putting the time in for that rather large post. Though I read all of it still, it was useful. ^_^

It does raise up another question though. If you just recently, say, created an IM channel or joined a group and wanted the script to listen for stuff in the IM or group channels, would that be possible?

EDIT: By the way Winter. I tried not putting my avatar's name in the llListen params, but when I run the script and type a command it doesn't do anything. So it looks like the name is required. So I'll just have to find a way to get the name from who ever is the owner.
Xhawkx Holden
Registered User
Join date: 1 Nov 2006
Posts: 86
07-04-2008 07:42
This should do it for ya....
With a touch from the owner to trigger the name change listener.. and a timeout set to 30 seconds.

state changename
{
touch(integer count)
{
llOwnerSay("What would you like my name to be?";);
llSetTimerEvent(30);
llListen(5, "", llGetOwner(),"";);
}
listen(integer channel, string name, key id, string message)
{
llSetObjectName(message);
llOwnerSay(message);
llOwnerSay("Is my new name.";);
llListenRemove(5);
}
timer()
{
llOwnerSay("Name change request timed out. Please try again";);
llListenRemove(5);
}
}
Nikoli Karu
Registered User
Join date: 3 Jul 2008
Posts: 7
07-04-2008 08:17
From: Xhawkx Holden
This should do it for ya....
With a touch from the owner to trigger the name change listener.. and a timeout set to 30 seconds.

state changename
{
touch(integer count)
{
llOwnerSay("What would you like my name to be?";);
llSetTimerEvent(30);
llListen(5, "", llGetOwner(),"";);
}
listen(integer channel, string name, key id, string message)
{
llSetObjectName(message);
llOwnerSay(message);
llOwnerSay("Is my new name.";);
llListenRemove(5);
}
timer()
{
llOwnerSay("Name change request timed out. Please try again";);
llListenRemove(5);
}
}

Well that's one way to do it, but I sort of like the way I have coded now.

On a similar note to this thread, does anyone know a way off putting a string and a string variable into the same llSay function? Or if not that, is there a function where you can combine two strings into one? I want the script to speak to someone and call them by name, only I want it all to be on the same line of speech.
FireEyes Fauna
Registered User
Join date: 26 Apr 2004
Posts: 138
07-04-2008 08:43
llOwnerSay(message);
llOwnerSay("Is my new name";);

would become llOwnerSay(message + " is my new name";);