2

给定一个名为 的对象MyObjectllSay(0, "Hello World");对象内部的脚本在聊天中将如下所示:

MyObject: Hello World

我怎样才能让它看起来像这样?

Hello World
4

3 回答 3

2

使用字符串的第一个单词作为对象的名称可能会导致聊天着色有些奇怪。一种更简洁(并且更精简 LSL 中有限 RAM)的方法是将对象命名为“”,如下所示:

// 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);
于 2009-08-14T15:18:47.897 回答
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);
于 2009-08-04T22:56:45.903 回答
0

整数监听句柄;

默认 {

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

频道 1234 上的聊天(对于此示例)将显示在聊天(频道 0)中,没有包含脚本的对象名称的前缀。

用法:

/1234要显示的消息

聊天频道 0 中显示的文字:

要显示的消息

于 2009-06-23T08:30:54.053 回答