User Tools

Site Tools


radio

Differences

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

Link to this comparison view

radio [2014/09/22 21:01]
ateyourlembas Modified by AteYourLembas
radio [2017/10/09 20:39]
Line 1: Line 1:
-====== <<​radio>>​ ====== 
  
- 
-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. 
- 
-This code sample: 
- 
-    Would you like to see some radio buttons? 
-    ​ 
-    <<​radio $choice "​yes">>​ 
-    <<​radio $choice "​no">>​ 
-    <<​radio $choice "​maybe">>​ 
-    ​ 
-    <<​button [[Go on|go_on]]>>​ 
- 
-Creates this set of options: 
- 
-{{:​twine_radio_buttons_default.png?​nolink&​200|}} 
- 
- 
-In this example, the variable $choice is the name for this set of radio buttons. You can set this to any variable name you like. 
- 
-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. 
- 
- 
-=== Note that, in order for the value to be stored, there must be a [[<<​button>>​]] in the passage, and the user must click it. === 
- 
- 
-As of version 1.4.2, Twine forces a line break between radio buttons. To work around this, you can set your radio buttons in an HTML table: 
- 
-    <​table>​ 
-        <tr> 
-            <​td>​Sound?</​td><​td><<​radio $sound "​yes">></​td><​td><<​radio $sound "​no">></​td>​ 
-        </tr> 
-        <tr> 
-            <​td>​Color effects?</​td><​td><<​radio $color_effects "​yes">></​td><​td><<​radio $color_effects "​no">></​td>​ 
-        </tr> 
-    </​table>​ 
-    <<​button [[Begin the Game|Begin]]>>​ 
- 
- 
-This code sample creates this: 
- 
-{{:​twine_radio_buttons_table.png?​nolink&​200|}} 
- 
- 
-As of version 1.4.2, there is no 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): 
- 
- 
-    <<set $sound = "​no">>​\ 
-    <<set $color_effects = "​no">>​ 
-    <​table>​ 
-        <tr> 
-            <​td>​Sound?</​td><​td></​td><​td><<​radio $sound "​yes">></​td>​ 
-        </tr> 
-        <tr> 
-            <​td>​Color effects?</​td><​td></​td><​td><<​radio $color_effects "​yes">></​td>​ 
-        </tr> 
-    </​table>​ 
-    <<​button [[Start the Game|start_game]]>>​ 
- 
-{{:​twine_radio_buttons_special.png?​nolink&​200|}} ​ 
- 
-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. 
radio.txt ยท Last modified: 2017/10/09 20:39 (external edit)