Skip to main content

The "vngen_option_create" Function

Syntax#

vngen_option_create(id, text, sprite, spr_hover, spr_select, x, y, z, font, color, transition, duration, [ease]);
ArgumentTypeDescription
idreal/stringThe unique identifier to use for the new option
textstringThe option text to display over the background (or "" for none)
spritespriteThe sprite to display as a button background
spr_hoverspriteThe sprite to display as a background when hovered (or keyword none for default)
spr_selectspriteThe sprite to display as a background when selected (or keyword none for default)
xrealThe horizontal position to display the option, relative to the option block offset
yrealThe vertical position to display the option, relative to the option block offset
zrealThe drawing depth and list order of the option, relative to other options only
fontfontThe font to draw text in, where fnt_default is default
colorcolorThe color to draw text in, where c_white is default
transitionscript Sets the transition animation to perform when created and destroyed
durationreal Sets the duration of the transition animations, in seconds
[ease]integer/macroOptional: Sets the ease override for the transition script

Description#

Creates a new option which will be displayed until any option in the current option block has been selected. The chosen option ID will be recorded as the selected choice. Options can selected by mouse/touch, or by other input devices with vngen_option_nav and vngen_option_select.

Unlike other entities, option z-index determines not just drawing depth, but also navigation order. Options with lower z-index will be considered lower in the list of options. If z-index is equal between two or more options, navigation order will automatically be set by reverse creation order, but this may or may not be visually correct. Therefore, it is recommended to always set z-index explicitly. The actual values used are inconsequential so long as they are ordered from highest to lowest.

Note that although this script is an action, it cannot be executed outside of a vngen_option block. In this way, an entire option block can be thought of as a single action.

See Included Animations and Macros & Keywords for a list of available transition animations and ease modes.

Example#

if vngen_event() {
if vngen_option("op_choice", 0, 0, 0.5, 0.5) {
vngen_option_create("op1", "Option 1", spr_option, spr_option_hover, spr_option_select, 0, 0, -1, fnt_Arial, c_white, trans_slide_right, 1);
vngen_option_create("op2", "Option 2", spr_option, spr_option_hover, spr_option_select, 0, 50, -2, fnt_Arial, c_white, trans_slide_right, 1.5);
}
}