User Tools

Site Tools


radio

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
radio [2014/09/22 21:01]
ateyourlembas Modified by AteYourLembas
radio [2017/10/09 20:39] (current)
Line 3: Line 3:
  
 The <<​radio>>​ macro lets you offer your reader with a familiar radio button input. While a [[<<​checkbox>>​]] set lets the reader make multiple choices, radio buttons are mutually exclusive--your reader can choose only one option. The <<​radio>>​ macro lets you offer your reader with a familiar radio button input. While a [[<<​checkbox>>​]] set lets the reader make multiple choices, radio buttons are mutually exclusive--your reader can choose only one option.
 +
 +Note that, in order for the value to be stored, there must be a [[<<​button>>​]] in the passage, and the user must click it.
  
 This code sample: This code sample:
Line 16: Line 18:
 Creates this set of options: Creates this set of options:
  
-{{:​twine_radio_buttons_default.png?​nolink&​200|}}+{{:​twine_radio_buttons_default.png|}}
  
  
Line 23: Line 25:
 You see each input has a value--in this example, "​yes,"​ "​no,"​ and "​maybe."​ These are what will be displayed to the reader AND stored in the variable ($choice) to be used in the next passage. You see each input has a value--in this example, "​yes,"​ "​no,"​ and "​maybe."​ These are what will be displayed to the reader AND stored in the variable ($choice) to be used in the next passage.
  
 +Thus if a reader chooses "​maybe"​ and clicks the button "Go on," it's the same as telling Twine this:
  
-=== Note that, in order for the value to be stored, there must be a [[<<button>>]] in the passage, and the user must click it. ===+    ​<<set $choice = "​maybe"​>>
  
  
Line 42: Line 45:
 This code sample creates this: This code sample creates this:
  
-{{:​twine_radio_buttons_table.png?​nolink&​200|}}+{{:​twine_radio_buttons_table.png|}}
  
  
-As of version 1.4.2, there is no option to mark a radio button as selected before your reader makes their choice.+As of Twine version 1.4.2, there is no native ​option to mark a radio button as selected before your reader makes their choice.
  
-One option to work around this is to initialize your variable to the default value and offer the reader only the other choice(s):+However if you're using the optional SugarCube story format, this option exists. You can find the [[http://​www.motoslave.net/​sugarcube/​docs/#​macros-radiobutton|SugarCube radio button documentation here]]. 
 + 
 +One option to work around this in Twine natively ​is to initialize your variable to the default value and offer the reader only the other choice(s):
  
  
Line 62: Line 67:
     <<​button [[Start the Game|start_game]]>>​     <<​button [[Start the Game|start_game]]>>​
  
-{{:​twine_radio_buttons_special.png?​nolink&​200|}} +{{:​twine_radio_buttons_special.png|}} ​
  
 A disadvantage of this approach is that, once the option is checked, it can't be unchecked back to whatever you set as the default. A disadvantage of this approach is that, once the option is checked, it can't be unchecked back to whatever you set as the default.
 +
 +Hope this helps. If you have questions, please visit the [[http://​twinery.org/​forum/​index.php/​board,​2.0.html|Twinery forum]].
radio.1411434063.txt.gz · Last modified: 2017/10/09 20:37 (external edit)