MyObject
、という名前のオブジェクトが与えられた場合、オブジェクトllSay(0, "Hello World");
内のスクリプトからはチャットで次のようになります。
MyObject: Hello World
どうすればこのように見せることができますか?
Hello World
MyObject
、という名前のオブジェクトが与えられた場合、オブジェクトllSay(0, "Hello World");
内のスクリプトからはチャットで次のようになります。
MyObject: Hello World
どうすればこのように見せることができますか?
Hello World
文字列の最初の単語をオブジェクトの名前として使用すると、チャットの色がおかしくなる可能性があります。よりクリーンな(そして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);
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);
整数ListenHandle;
デフォルト {
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に表示されるテキスト:
表示するメッセージ