Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How do emoters work?

Catherine Dollinger
Registered User
Join date: 11 May 2007
Posts: 26
08-09-2007 03:42
Another maybe simple question:

I think everybody knows emoters, usually attachments (but have seen similar messages from objects as well) that can be used to state arbitrary text in chat (usually presented in green colour) after that's said on a specific channel.
The text is displayed _without_ the speaker's or object's name in front.
The general layout is clear: listen on the specific channel and echo it on channel 0.
BUT: how is the sayer's prefix removed?

Example:
If you say "/0 This is a sentence" this usually results to:
Catherine Dollinger: This is a sentence
If you say "/5 This is a sentence" when wearing an emoter listening on channel 5 it gives:
This is a sentence

The reason why I'm asking is that I would like to have a configurable emoter with a channel I can choose as the available free emoters are always fixed to a channel and therefore sometimes come in way with other objects listening on that channel, eg. poseballs listening for hide/show commands.

Does anybody have got a clue or better: an example?

Thanks in advance
Cathy
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
08-09-2007 04:36
In your script take the message heard by the listen on channel 5. Grab the first word from the string and change the object name to that word, then say the rest of the string but with "/me " in front.

In concept it's pretty simple but string manipulation can be a pain for some.
_____________________
www.nandnerd.info
http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum
Ilmira Yesheyev
Registered User
Join date: 8 Dec 2006
Posts: 40
08-09-2007 08:51
I wrote one that sets the object name to a null string when it is rezzed and uses /me in the llsay() to channel 0. It's probably not the most efficient way of doing it, but it works.

CODE

default
{

on_rez(integer param)
{//Triggered when the object is rezed, like after the object had been sold from a vendor
llResetScript();//By resetting the script on rez it forces the listen to re-register.
}
changed(integer mask)
{//Triggered when the object has been sold as "original" from in world.
if(mask & CHANGED_OWNER)
{
llResetScript();
}
}
state_entry()
{
// Set the prim to be transparent
llSetAlpha(0,ALL_SIDES);
//Set the object name to be a null string
llSetObjectName("");
//Listen on channel for text from the owner only
llListen(12,"",llGetOwner(),"");

}
listen(integer channel,string name,key id,string message)
{
//Repeat what the owner said, using /me to remove the : that would show otherwise
llSay(0,"/me " + message);
}
}
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
08-09-2007 08:56
Here's a quick little snippet I just wrote up. can't garauntee it will compile, but it should give you a general idea of what you need to do


CODE

default{

state_entry()
{
llSetName(llKey2Name(llGetOwner()));//this will give the object the same name as the owner, therefore allowing it to appear as if the owner were speaking when the object speaks.
llListen(5,"",NULL_KEY,"");
}

listen(integer channel, string name, key id, string message)
{
if(channel == 5)
{
llSay(0,"/me " + message);// Emotes what was said on channel 5. This will still show up as green chat that an object generates, not as white text like an avatar.
}
}
}
_____________________
My SLExchange shop

Typos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not.


The function is working perfectly fine. It's just not working the way you wanted it to work.
Catherine Dollinger
Registered User
Join date: 11 May 2007
Posts: 26
Thanks a bundle to all - here's my solution:
08-09-2007 12:00
Thank you all, different approaches - and I finally got the grip on it.

Senuka, your code was almost the right thing, only I wanted the owner not included, but your's also an interesting possibility for items that want to express themselves in the name of the owner.

Here's my code snippet that I just tested in-world that does what I thought of - it's a combination of your thoughts and I wouldn't claim it to be mine :) :

CODE

string myName;

default{

state_entry()
{
myName = llGetObjectName();

llListen(5,"",NULL_KEY,"");
}

listen(integer channel, string name, key id, string message)
{
if(channel == 5)
{
llSetObjectName("");
llSay(0,"/me " + message);
llSetObjectName(myName);
}
}
}


Basically I set the object name to "" before output and reset it afterwards to the original.


Again - thanks for your tremendous help!