Skip to main content

The "vngen_get_option" Function

Syntax#

vngen_get_option([id], [clear]);
ArgumentTypeDescription
[id]real/stringOptional: The ID of the option block to return result from
[clear]booleanOptional: Enables or disables clearing the result from memory after returning it (enabled by default)

Description#

Despite its name, vngen_get_option is not an action. However, it behaves like one so that it can be used both inside and outside the context of Quantum events.

When run, this script will return the result of the specified option block, or the most recent option block if no group ID is supplied. Results are stored as the ID of the selected option. If options exist but none has been selected, -1 will be returned instead, or if no options exist and have been cleared from memory, -2.

If only one argument is supplied, booleans/reals will be interpreted as [clear], and strings will be interpreted as an option block [id].

If no arguments are supplied, the most recent option block will be assumed, and clearing will be enabled by default.

This script is intended to be used in conditional statements such as if and switch to take action based on the selected option in a previous option block. In order to prevent this conditional statement from repeatedly executing code, option results will be cleared from memory after being returned. To disable this behavior, it is possible to set the [clear] argument to false, in which case option results can be cleared later with vngen_option_clear.

Example#

if (vngen_get_option() == "op1") {
//Action
}
switch (vngen_get_option("op_choice", false)) {
case "op2": /* Action */; break;
case "op3": /* Action */; break;
}
vngen_option_clear();