NuiOptions( int, json, json )
From NWN Lexicon
Jump to navigationJump to search
A list of options (radio buttons). Only one can be selected
// A list of options (radio buttons). Only one can be selected
// at a time. jValue is updated every time a different element is
// selected. The special value -1 means "nothing".
json // Element
NuiOptions(
int nDirection, // NUI_DIRECTION_*
json jElements, // JsonArray of string labels
json jValue // Bind:UInt
);
Return
json Element
Parameters
- nDirection
- NUI_DIRECTION_*
- jElements
- JsonArray of string labels
- jValue
- JsonInt or NuiBind (Note: dont' get it confused with a NWN int)
Description
A list of options (radio buttons). Only one can be selected
Remarks
Version
This function was added in 1.85.8193.31 of NWN:EE.
Example
// Build a Json Array of JsonStrings to be used as options.
json jElementsOptions = JsonArray();
jElementsOptions = JsonArrayInsert(jElementsOptions, JsonString("Centered"));
jElementsOptions = JsonArrayInsert(jElementsOptions, JsonString("Random"));
// Create the Option widget with elements.
// dpane_options_location_index is the bind, you can use that to 'select' an option (via scripting) or read what the user has selected.
json jOptionsLocationType = NuiOptions(NUI_DIRECTION_HORIZONTAL, jElementsOptions, NuiBind("dpane_options_location_index"));
Later on you can read what the player has selected (typically in the OnNuiEvent )
// Read the option the user has selected, will be either 0 or 1 in this example.
// In this case 0 means they selected "Center" while 1 means "Random"
int nLocationType = JsonGetInt(NuiGetBind(oPlayer, nToken, "dpane_options_location_index"));
Or if you want to to change the option selected in scripting
// Set the option to "Random" in the example above.
NuiSetBind(oPlayer, nToken, "dpane_options_location_index", JsonInt(1));
See Also
| functions: |