User Tools

Site Tools


item_storage_slot

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
item_storage_slot [2020/11/30 18:43] – created justinitem_storage_slot [2024/02/18 21:45] (current) justin
Line 2: Line 2:
 ---- ----
  
-An **item storage slot** is an element for storing an [[item]] or stack of [[item|items]]. This is useful for [[inventory]] windows, [[item container]] windows, or other [[widget|widgets]] that are meant for storing [[item|items]] into for later retrieval and usage.+An **item storage slot** is a [[widget]] element for storing an [[item]] or stack of [[item|items]]. This is useful for [[inventory]] windows, [[item container]] windows, or other [[widget|widgets]] that are meant for storing [[item|items]] into for later retrieval and usage. 
 + 
 +<WRAP center round info 100%> 
 +When left-clicking to remove an [[item]] from a storage slot that is stacked, you can hold down the Control key to pick up only one of the [[item]] instead of the entire stack. 
 +</WRAP>
  
 =====Element Properties===== =====Element Properties=====
 ^Icon^Property^Description^ ^Icon^Property^Description^
 +|{{:wiki:tag_id.png?nolink|}}|Element ID|ID for the item storage slot. This ID must be unique amongst other elements within the same [[widget]]. It is currently auto-generated but will be editable in a future update.|
  
 =====Scripting===== =====Scripting=====
 +You can access certain properties of an item storage slot from a [[script]] by simply referencing the parent [[widget]] and the element by their unique IDs. See below for examples of retrieving the slot's [[item]]. In this case, we are assuming that the slot currently contains an [[item]], the [[widget]] has an ID of "test", and the item storage slot has an ID of "0001". If the slot is empty, its "item" property will be null.
 +
 +**Retrieving the item data for an item storage slot:**
 +<code bauxite>
 +$item_id = widget["test"].element["0001"].item.id;
 +$item_count = widget["test"].element["0001"].item.count
 +</code>
 +
 +**Changing the item in an item storage slot:**
 +<code bauxite>
 +widget["test"].element["0001"].item = "ITEM_0001";
 +</code>
 +
 +**Changing the count of an item in an item storage slot:**
 +<code bauxite>
 +widget["test"].element["0001"].count = 10;
 +</code>
  
-(Accessing/changing properties of the element via scripts)+**Checking if an item exists in an item storage slot:** 
 +<code bauxite> 
 +if widget["test"].element["0001"].item == null then 
 +   display_message("There isn't an item in this slot.") 
 +end 
 +</code>
  
 ~~NOTOC~~ ~~NOTOC~~
item_storage_slot.1606790602.txt.gz · Last modified: 2020/11/30 18:43 by justin