1

私は文字列を持っています:

string cover = "withaname"

に変更したいのですwithanamewithnoname

withnoname次に、に変更したいと思いwithanamegooseます。

LSLでこれを達成するための最良の方法は何ですか?

4

2 に答える 2

2

データを区切る特殊文字がある場合は、llList2Stringなどの関数を使用できます。

llGetSubStringはおそらくあなたが実際に探しているものです。私はあなたの正確な質問を本当に理解していません。

string The_String = "withaname";
integer i = llSubStringIndex(The_String, "a");
The_String = llInsertString(llDeleteSubString(The_String, i, i), i, "no");
llSay(0, The_String);
// says "withnoname"
于 2009-07-23T06:33:17.097 に答える
0

繰り返しますが、何が欲しいかわかりません。 http://wiki.secondlife.com/wiki/Category:LSL_String#Useful_Functions

いくつかのサンプルコード(申し訳ありませんが、Google PrettifyはLSLを強調表示していません):


default
{
    touch_start(integer num_detected)
    {
        string myString = "this is some text";

        //  if you simply want to change the value
        myString = "now diff"+"erent "+"text";
        llSay(PUBLIC_CHANNEL, myString);

        //  if you want to change the value only if substring in string
        if (llSubStringIndex(myString, "text") != -1)
        {
            myString = "string contained text as substring";
            llSay(PUBLIC_CHANNEL, myString);
        }

        //  if you want to replace a word in a sentence
        //  and you know the spelling and it's surrounded by spaces
        list words = llParseString2List(myString, [" "], []);
        integer found = llListFindList(words, ["text"]);
        if (found != -1)// or use: if (~found)
        {
            words = llListReplaceList(words, ["textReplacedWithAnotherWord"], found, found);
            myString = llDumpList2String(words, " ");
            llSay(PUBLIC_CHANNEL, myString);
        }
    }
}
于 2013-05-02T17:47:26.890 に答える