User Tools

Site Tools


widget

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
widget [2020/12/01 11:09]
justin
widget [2021/04/21 20:24] (current)
justin
Line 9: Line 9:
  
 =====Scripting===== =====Scripting=====
 +You can access and change certain element properties from within a [[script]] by simply referencing the parent [[widget]] and the child element by their unique IDs. The following example code assumes there is a [[widget]] with an ID of "test", and it contains a [[text field]] with an ID of "0001" and a [[button]] with an ID of "0002"
  
-<code+This script will close the [[widget]], store the text that was entered into the [[text field]] into a variable, then display a message to the player using their name. 
 +<code bauxite> 
 +hide_widget("test"); 
 +$name = widget["test"].element["0001"].text; 
 +display_message("Hello, " + $name + "!"); 
 +</code>
  
-(WIP - Accessing elements within a widget to change them or get a value from them)+This script will change the text of the [[button]] to "New Text"
 +<code bauxite> 
 +widget["test"].element["0002"].text = "New Text"; 
 +</code>
  
 ~~NOTOC~~ ~~NOTOC~~
widget.1606849799.txt.gz · Last modified: 2020/12/01 11:09 by justin