— — — — —
— — — — —
— — — — —
— — — — —
— — — — —
— — — — —
— — — — —
— — — — —
This is an old revision of the document!
A button is a clickable widget element that can be configured to run a script, close the parent widget, craft a new item into a storage slot using any populated input slots, or craft a specific item using the player's inventory.
Icon | Property | Description |
---|---|---|
![]() | Element ID | ID for the button. 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. |
![]() | Button Type | Determines whether the button will have standard behavior or if it will behave as a toggle button (i.e. the button toggles between an “on” and “off” state each time it's pressed). |
![]() | Button Action | Determines what action will be taken when the button is pressed (only applicable to the “Standard” button type). The available options are to run a script, close the parent widget, craft a new item into a storage slot using any populated input slots, or craft a specific item using the player's inventory. |
![]() | Script | Script that will be triggered when the button is clicked. This option is only available when the button type is “Toggle” or the button type is “Standard” with an action of “Run Script”. For toggle buttons, a local variable named $pressed will be available to your script. It will have a value of either true or false according to the new state of the button. |
![]() | Item | Item that the game will attempt to craft using the player's inventory when the button is clicked. This option is only available when the button type is “Standard” with an action of “Craft Item by ID”. |
![]() | Image | Image that will be displayed on the button. If an image is specified, it will appear to the left of the button's text. |
![]() | Text | Text that will be displayed on the button. |
![]() | Text Alignment | Determines the horizontal alignment of the text. The available options are “Left”, “Center”, and “Right”. |
![]() | Font | Font that will be used for the button's text. If the “Default” option is selected, your game's default dialogue font will be used. |
![]() | Font Size | Font size to use for the button's text. |
You can access and change certain properties of a button from within a script by simply referencing the parent widget by its ID followed by a reference to the button element by its ID. See below for examples of changing the text, image, and script of a button. In these cases, the widget has an ID of “test” and the button has an ID of “0001”.
Changing a button's text:
widget["test"].element["0001"].text = "New Text"
Changing a button's image:
widget["test"].element["0001"].image = "new_image.png"
Changing a button's script:
widget["test"].element["0001"].script = "new_script_name"