This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
crafting_input_slot [2020/11/30 20:30] justin |
crafting_input_slot [2020/12/02 18:33] (current) justin |
||
---|---|---|---|
Line 6: | Line 6: | ||
=====Element Properties===== | =====Element Properties===== | ||
^Icon^Property^Description^ | ^Icon^Property^Description^ | ||
- | (WIP) | + | |{{:wiki:tag_id.png?nolink|}}|Element ID|ID for the crafting input 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 a crafting input 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 crafting input slot has an ID of "0001". If the slot is empty, its "item" property will be null. | ||
- | (WIP - Accessing/changing properties of the element via scripts) | + | **Retrieving the item data for a crafting input slot:** |
+ | <code bauxite> | ||
+ | $item_id = widget["test"].element["0001"].item.id; | ||
+ | $item_count = widget["test"].element["0001"].item.count | ||
+ | </code> | ||
+ | |||
+ | **Checking if an item exists in a crafting input 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~~ |