User Tools

Site Tools


button

Button


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.

Element Properties

IconPropertyDescription
Element IDID 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 TypeDetermines 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 ActionDetermines 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.
ScriptScript 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.
ItemItem 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”.
ImageImage that will be displayed on the button. If an image is specified, it will appear to the left of the button's text.
TextText that will be displayed on the button.
Text AlignmentDetermines the horizontal alignment of the text. The available options are “Left”, “Center”, and “Right”.
FontFont 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 SizeFont size to use for the button's text.

Scripting

You can access and change certain properties of a button from within a script by simply referencing the parent widget and the button element by their unique IDs. 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"
button.txt · Last modified: 2020/12/01 10:04 by justin