Difference between revisions of "LlListFindList/ja"
Jump to navigation
Jump to search
(Initial translation) |
|||
(One intermediate revision by one other user not shown) | |||
Line 5: | Line 5: | ||
|return_type=integer|p1_type=list|p1_name=src|p2_type=list|p2_name=test | |return_type=integer|p1_type=list|p1_name=src|p2_type=list|p2_name=test | ||
|func_footnote='''src''' において '''test''' が見つからなかった場合は {{HoverText|-1|マイナス1, 0x{{LSL_Hex/Write|-1}}}} が返されます。<br/> | |func_footnote='''src''' において '''test''' が見つからなかった場合は {{HoverText|-1|マイナス1, 0x{{LSL_Hex/Write|-1}}}} が返されます。<br/> | ||
リストの先頭要素のインデックスは {{HoverText|0|ゼロ}} です。 | リストの先頭要素のインデックスは {{HoverText|0|ゼロ}} です。<br> | ||
'''test''' が '''src''' の最後のインデックスで見つかると、正のインデックスが返ります (5 つの要素の 5 番目の場合、 4) 。 | |||
|func_desc | |func_desc | ||
|return_text='''src''' において最初に '''test''' が出現するインデックス | |return_text='''src''' において最初に '''test''' が出現するインデックス | ||
Line 11: | Line 12: | ||
|caveats=*マッチングの際、データ型の一致、大文字/小文字の一致が必須です。 | |caveats=*マッチングの際、データ型の一致、大文字/小文字の一致が必須です。 | ||
|constants | |constants | ||
|examples=< | |examples=<source lang="lsl2">list numbers = [1, 2, 3, 4, 5]; | ||
default | default | ||
{ | { | ||
Line 21: | Line 22: | ||
list three_four = llList2List(numbers, index, index + 1); | list three_four = llList2List(numbers, index, index + 1); | ||
llOwnerSay(llDumpList2String(three_four, ",")); | llOwnerSay(llDumpList2String(three_four, ",")); | ||
// | // オブジェクト: 3,4 | ||
} | } | ||
} | } | ||
}</ | }</source><source lang="lsl2">//2 つの要素をいっぺんに調べ、リストの中のパターンを見つけることもできます。 | ||
list avatarsWhoFoundMagicLeaves = ["Fire Centaur","Red Leaf"]; | |||
default | |||
{ | |||
state_entry() | |||
{ | |||
integer index = llListFindList(avatarsWhoFoundMagicLeaves, ["Fire Centaur","Red Leaf"]); | |||
if (index != -1) | |||
{ | |||
list output = llList2List(avatarsWhoFoundMagicLeaves, index, index + 1); | |||
llOwnerSay(llDumpList2String(output, ",")); | |||
// オブジェクト: Fire Centaur, Red Leaf | |||
} | |||
} | |||
}</source> | |||
|helpers= | |helpers= | ||
ある要素がリストに含まれているかを簡単に調べるには... | ある要素がリストに含まれているかを簡単に調べるには... | ||
< | <source lang="lsl2">if(~llListFindList(myList, (list)item)) | ||
{//存在する場合の処理をここに記述。 | {//存在する場合の処理をここに記述。 | ||
// ~(-1) == 0 なので、上の条件式で問題ありません。 | // ~(-1) == 0 なので、上の条件式で問題ありません。 | ||
// != -1 | // != -1 よりもバイトコードの節約となり、動作も速いです。 | ||
}</ | }</source> | ||
|also_functions= | |also_functions= | ||
{{LSL DefineRow||{{LSLG/ja|llSubStringIndex}}| | {{LSL DefineRow||{{LSLG/ja|llSubStringIndex}}|他の文字列の中で文字列を検索する}} | ||
{{LSL DefineRow||[[User:Void_Singer/Functions#List:_Find_Last_Index|List: Find Last Index]]|入力文字列でヒットした '''最後の''' インスタンスのインデックスを表す整数値を返す}} | |||
{{LSL DefineRow||[[User:Void_Singer/Functions#List:_Multi-Find_Index_.28First_or_Last.29|List: Multi-Find Index (First_or_Last)]]|入力文字列でマッチした要素の '''全部の''' 最初 (または最後) のインデックスを取得する}} | |||
|also_events | |also_events | ||
|also_tests | |also_tests |
Latest revision as of 07:12, 25 February 2016
LSL ポータル | 関数 | イベント | 型 | 演算子 | 定数 | 実行制御 | スクリプトライブラリ | カテゴリ別スクリプトライブラリ | チュートリアル |
要約
関数: integer llListFindList( list src, list test );警告
- マッチングの際、データ型の一致、大文字/小文字の一致が必須です。
サンプル
list numbers = [1, 2, 3, 4, 5];
default
{
state_entry()
{
integer index = llListFindList(numbers, [3]);
if (index != -1)
{
list three_four = llList2List(numbers, index, index + 1);
llOwnerSay(llDumpList2String(three_four, ","));
// オブジェクト: 3,4
}
}
}
//2 つの要素をいっぺんに調べ、リストの中のパターンを見つけることもできます。
list avatarsWhoFoundMagicLeaves = ["Fire Centaur","Red Leaf"];
default
{
state_entry()
{
integer index = llListFindList(avatarsWhoFoundMagicLeaves, ["Fire Centaur","Red Leaf"]);
if (index != -1)
{
list output = llList2List(avatarsWhoFoundMagicLeaves, index, index + 1);
llOwnerSay(llDumpList2String(output, ","));
// オブジェクト: Fire Centaur, Red Leaf
}
}
}
便利なスニペット
ある要素がリストに含まれているかを簡単に調べるには...
if(~llListFindList(myList, (list)item))
{//存在する場合の処理をここに記述。
// ~(-1) == 0 なので、上の条件式で問題ありません。
// != -1 よりもバイトコードの節約となり、動作も速いです。
}
関連項目
関数
• | llSubStringIndex | – | 他の文字列の中で文字列を検索する | |
• | List: Find Last Index | – | 入力文字列でヒットした 最後の インスタンスのインデックスを表す整数値を返す | |
• | List: Multi-Find Index (First_or_Last) | – | 入力文字列でマッチした要素の 全部の 最初 (または最後) のインデックスを取得する |
特記事項
この項目はあなたにとって参考にならない項目ですか?もしかしたらLSL Wikiの関連した項目が参考になるかもしれません。