Search code examples
linden-scripting-language

How can I hide an object's name in chat in LSL?


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

Solution

  • 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);