Difference between revisions of "LlGetInventoryNumber/ja"

From Second Life Wiki
Jump to navigation Jump to search
m
 
(2 intermediate revisions by the same user not shown)
Line 5: Line 5:
|func_footnote
|func_footnote
|func_desc
|func_desc
|return_text=プリムのインベントリ内の取得する'''タイプ'''のアイテムの数
|return_text=プリムのインベントリの中の、指定された '''type''' のアイテム数
|spec
|spec
|caveats
|caveats
|constants={{LSL Constants Inventory/ja}}
|constants={{LSL Constants Inventory/ja}}
|examples=<lsl>//                            Item Counter
|examples=<lsl>//                            アイテムカウンター
//
//                      By Apollia Pirandello
//                      By Apollia Pirandello
//
//                              9/19/2007
//                              9/19/2007
//
//
// Public domain.  Free to use and/or modify for any purpose,
// パブリックドメインです。商用利用を含め、使用・改変自由です。
// including commercial purposes.
//
//
// Once you drop this script in any prim, it will immediately
// プリムの中にこのスクリプトを入れるとすぐに、
// tell you in an OwnerSay how many items are in that prim,
// llOwnerSay でプリムの中にあるアイテムの数を通知します。
// minus 1, so the script itself isn't counted.
// スクリプト自身がカウントされないように、マイナス 1 します。
//
//
// It will also do that whenever the prim is touched.
// プリムがタッチされた場合はいつでも同様の処理を行います。
//**********SCRIPT BEGINS BELOW**********
//**********SCRIPT BEGINS BELOW**********


Line 35: Line 32:
{
{
   items_contained = llGetInventoryNumber( INVENTORY_ALL );
   items_contained = llGetInventoryNumber( INVENTORY_ALL );
   --items_contained;
   --items_contained; //INVENTORY_ALL フラグを使っているので、スクリプト自身がカウントされないようにマイナス 1 します。
}
}


Line 61: Line 58:
}</lsl>
}</lsl>
<lsl>objects = llGetInventoryNumber(INVENTORY_OBJECT);</lsl>
<lsl>objects = llGetInventoryNumber(INVENTORY_OBJECT);</lsl>
<lsl>// インベントリ統計 By Zep Palen.
// これは llGetInventoryNumber の別の使い方で、フローティングテキストで統計を表示します。
// このスクリプトが動作するためには、showlist と excludelist をスクリプトの入っているアイテムの「説明」に追加しないといけません。
// この説明フィールドには次のように入れます: [showlist];[Excludelist]
// 例: 0,1,3,5,6,7,10,13,20,21;3,7,10
// この例では、全てのタイプが表示されますが、3, 7, 10 は合計に入りません。どの番号がどのタイプに該当するかは、このページのリストをご覧ください。
// -----------------
// このスクリプトの利用と改変は自由です - Zep Palen
// --------------------------
list inv_types = [0, 1, 3, 5, 6, 7, 10, 13, 20, 21];
list inv_names = ["Textures", "Sounds", "Landmarks", "Clothings", "Objects", "Notecards", "Scripts", "Bodyparts", "Animations", "Gestures"];
processCountInventory()
{
    list objDesc = llParseString2List(llGetObjectDesc(), [";"], []);
    list showList = llParseString2List(llList2String(objDesc, 0), [","], []);
    list excludeFromCount = llParseString2List(llList2String(objDesc, 1), [","], []);
           
    string counted = "ITEM COUNTER";
    integer i = ~llGetListLength(showList);
    while (++i)
    {
        integer showItem = (integer)llList2String(showList, i);
        integer sIndex = llListFindList(inv_types, [showItem]);
        if (~sIndex)
            counted += "\n" + llList2String(inv_names, sIndex) + ": " + (string)llGetInventoryNumber(showItem);
    }
    integer totalCount = llGetInventoryNumber(INVENTORY_ALL);
    for (i = ~llGetListLength(excludeFromCount); ++i;)
    {
        integer exclItem = (integer)llList2String(excludeFromCount, i);
        integer cIndex = llListFindList(inv_types, [(string)exclItem]);
        if (~cIndex)
            totalCount = totalCount - llGetInventoryNumber(exclItem);
    }
   
    counted += "\n \n" + "Total: " + (string)totalCount;
    llSetText(counted, <1,1,0>, 1);
}
default
{
    state_entry()
    {
        processCountInventory();
    }
   
    changed(integer change)
    {
        if (change & CHANGED_INVENTORY)
        {
            processCountInventory();
        }
    }
}</lsl>
|helpers
|helpers
|also_functions=
|also_functions=
{{LSL DefineRow||[[llGetInventoryName/ja|llGetInventoryName]]|}}
{{LSL DefineRow||{{LSLG/ja|llGetInventoryName}}|インベントリアイテムの名前を返します}}
{{LSL DefineRow||[[llGetInventoryCreator/ja|llGetInventoryCreator]]|}}
{{LSL DefineRow||{{LSLG/ja|llGetInventoryType}}|インベントリアイテムが存在するか検査し、あればそのタイプを返します}}
{{LSL DefineRow||[[llGetInventoryKey/ja|llGetInventoryKey]]|}}
{{LSL DefineRow||{{LSLG/ja|llGetInventoryCreator}}|インベントリアイテムのクリエーターを返します}}
{{LSL DefineRow||[[llGetInventoryType/ja|llGetInventoryType]]|}}
{{LSL DefineRow||{{LSLG/ja|llGetInventoryPermMask}}|インベントリアイテムの権限を返します}}
{{LSL DefineRow||{{LSLG/ja|llGetInventoryKey}}|インベントリアイテムの {{LSLG/ja|UUID}} を返します (フルパーミッションの場合)}}
|also_events
|also_events
|also_tests
|also_tests=
{{LSL DefineRow||[[llGiveInventory_All_Test]]|}}
|also_articles
|also_articles
|notes
|notes
|permission
|permission
|negative_index
|sort=GetInventoryNumber
|sort=GetInventoryNumber
|cat1=Inventory
|cat1=Inventory

Latest revision as of 18:23, 3 May 2010

要約

関数: integer llGetInventoryNumber( integer type );

プリムのインベントリの中の、指定された type のアイテム数を integer で返します。

• integer type INVENTORY_*フラグ

フラグ インベントリタイプ
INVENTORY_NONE -1 アイテムは存在しません。
INVENTORY_ALL 全てのインベントリタイプ
INVENTORY_TEXTURE 0 テクスチャ
INVENTORY_SOUND 1 サウンド
INVENTORY_LANDMARK 3 ランドマーク
INVENTORY_CLOTHING 5
フラグ インベントリタイプ
INVENTORY_OBJECT 6 オブジェクト
INVENTORY_NOTECARD 7 ノートカード
INVENTORY_SCRIPT 10 スクリプト
INVENTORY_BODYPART 13 体のパーツ
INVENTORY_ANIMATION 20 アニメーション
INVENTORY_GESTURE 21 ジェスチャー

サンプル

<lsl>// アイテムカウンター // By Apollia Pirandello // 9/19/2007 // // パブリックドメインです。商用利用を含め、使用・改変自由です。 // // プリムの中にこのスクリプトを入れるとすぐに、 // llOwnerSay でプリムの中にあるアイテムの数を通知します。 // スクリプト自身がカウントされないように、マイナス 1 します。 // // プリムがタッチされた場合はいつでも同様の処理を行います。 //**********SCRIPT BEGINS BELOW**********

//****VARIABLE

integer items_contained;

//****END OF VARIABLE SECTION //****FUNCTIONS****

CountItems() {

 items_contained = llGetInventoryNumber( INVENTORY_ALL );
 --items_contained; //INVENTORY_ALL フラグを使っているので、スクリプト自身がカウントされないようにマイナス 1 します。

}

SayCount() {

 llOwnerSay( "This prim contains " + (string)items_contained + " items." );

}

//****END OF FUNCTIONS**** //****DEFAULT STATE****

default {

 state_entry()
 {
   CountItems();
   SayCount();
 }
 touch_start(integer total_number)
 {
   CountItems();
   SayCount();
 }  

}</lsl> <lsl>objects = llGetInventoryNumber(INVENTORY_OBJECT);</lsl> <lsl>// インベントリ統計 By Zep Palen. // これは llGetInventoryNumber の別の使い方で、フローティングテキストで統計を表示します。 // このスクリプトが動作するためには、showlist と excludelist をスクリプトの入っているアイテムの「説明」に追加しないといけません。 // この説明フィールドには次のように入れます: [showlist];[Excludelist] // 例: 0,1,3,5,6,7,10,13,20,21;3,7,10 // この例では、全てのタイプが表示されますが、3, 7, 10 は合計に入りません。どの番号がどのタイプに該当するかは、このページのリストをご覧ください。 // ----------------- // このスクリプトの利用と改変は自由です - Zep Palen // --------------------------

list inv_types = [0, 1, 3, 5, 6, 7, 10, 13, 20, 21]; list inv_names = ["Textures", "Sounds", "Landmarks", "Clothings", "Objects", "Notecards", "Scripts", "Bodyparts", "Animations", "Gestures"];

processCountInventory() {

   list objDesc = llParseString2List(llGetObjectDesc(), [";"], []);
   list showList = llParseString2List(llList2String(objDesc, 0), [","], []);
   list excludeFromCount = llParseString2List(llList2String(objDesc, 1), [","], []);
           
   string counted = "ITEM COUNTER";
   integer i = ~llGetListLength(showList);
   while (++i)
   {
       integer showItem = (integer)llList2String(showList, i);
       integer sIndex = llListFindList(inv_types, [showItem]);
       if (~sIndex)
           counted += "\n" + llList2String(inv_names, sIndex) + ": " + (string)llGetInventoryNumber(showItem);
   }
   integer totalCount = llGetInventoryNumber(INVENTORY_ALL);
   for (i = ~llGetListLength(excludeFromCount); ++i;)
   {
       integer exclItem = (integer)llList2String(excludeFromCount, i);
       integer cIndex = llListFindList(inv_types, [(string)exclItem]);
       if (~cIndex)
           totalCount = totalCount - llGetInventoryNumber(exclItem);
   }
   
   counted += "\n \n" + "Total: " + (string)totalCount;
   llSetText(counted, <1,1,0>, 1);

}

default {

   state_entry()
   {
       processCountInventory();
   }
   
   changed(integer change)
   {
       if (change & CHANGED_INVENTORY)
       {
           processCountInventory();
       }
   }
}</lsl>

関連項目

関数

•  llGetInventoryName インベントリアイテムの名前を返します
•  llGetInventoryType インベントリアイテムが存在するか検査し、あればそのタイプを返します
•  llGetInventoryCreator インベントリアイテムのクリエーターを返します
•  llGetInventoryPermMask インベントリアイテムの権限を返します
•  llGetInventoryKey インベントリアイテムの UUID を返します (フルパーミッションの場合)

特記事項

Search JIRA for related Issues

テスト

•  llGiveInventory_All_Test

Signature

function integer llGetInventoryNumber( integer type );
この翻訳は 原文 と比べて古いですか?間違いがありますか?読みにくいですか?みんなで 修正 していきましょう! (手順はこちら)
この項目はあなたにとって参考にならない項目ですか?もしかしたらLSL Wikiの関連した項目が参考になるかもしれません。