2

Given an object named MyObject, an llSay(0, "Hello World"); from a script inside the object will look like this in chat:

MyObject: Hello World

How can I get it to just look like this?

Hello World
Ry-
  • 218,210
  • 55
  • 464
  • 476
btubbs
  • 1,845
  • 1
  • 16
  • 19

3 Answers3

2
string message = "Hello World!";
// save the old name of the object for later use
string oldname = llGetObjectName();
// get the words (split by spaces) in the message
list messageParts = llParseString2List(message, [" "], []);
// make the objects name the first word of the message.
llSetObjectName(llList2String(messageParts,0));
// delete the first word.
messageParts = llDeleteSubList(messageParts,0,0);
// use an emote to remove the : from the said text
llSay(0, "/me "+llDumpList2String(messageParts, " ");
// set our objects name back to its old text.
llSetObjectName(oldname);
gnarf
  • 105,192
  • 25
  • 127
  • 161
2

Using the first word of the string as the object's name may result in some oddnessess with colouring of the chat. A cleaner (and leaner on the limited RAM in LSL) way is to name the object "" instead, like this:

// Your message in a string
string message = "Waves crash on the beach";

// Store the current object name to restore it afterwards
string oldName = llGetObjectName();

// Rename the object with a blank string
llSetObjectName("");

// Say the message
llSay(0, "/me " + message);

// Restore the object name
llSetObjectName(oldName);
Hippyjim
  • 2,520
  • 6
  • 38
  • 54
0

integer ListenHandle;

default {

state_entry()
    {
    ListenHandle = llListen(1234,"",llGetOwner(),"");       
    }

listen(integer channel, string name, key id, string message)
    {
    list mess = llParseString2List(message,[" "],[]);
    llSetObjectName(llList2String(mess,0));
    mess = llDeleteSubList(mess,0,0);
    message = llDumpList2String(mess," ");
    llSay(0,"/me " + message);
    }
}

The chat on channel 1234 (for this example) will be displayed in chat (channel 0) without the prefix of name of the object containing the script.

usage:

/1234 message to be displayed

text displayed in chat channel 0:

message to be displayed