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 revisionPrevious revision
Next revision
Previous revision
widget [2020/11/28 17:36] justinwidget [2021/04/21 20:24] (current) justin
Line 5: Line 5:
  
 <WRAP center round info 100%> <WRAP center round info 100%>
-Custom [[widget|widgets]] can be displayed in-game using the [[Show Widget]] scripting function. You can also add them to the [[management screen]] by adding their IDs to the comma-separated list of [[widget|widgets]] in the "Experimental" section of your [[Game Configuration]].+Custom widgets can be displayed in-game using the [[Show Widget]] scripting function. You can also add them to the [[management screen]] by adding their IDs to the comma-separated list of widgets in the "Experimental" section of your [[Game Configuration]].
 </WRAP> </WRAP>
- 
-{{:wiki:inventory.png?nolink|}} 
  
 =====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"
  
-(Showing/hiding widgets)+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>
  
-(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.txt · Last modified: 2021/04/21 20:24 by justin