jump

Module(s): vncanvas-base, vncanvas-cmds
Description: Script jumps to specified label.

jump, "label_name"
Unconditional jump.
Label name can take the following forms:
"label" - a label in the current chapter.
"chapter#label" - a label in the given chapter.
"return" - a special label that allows return to previous jump call. Use for returning from calling in-game option forms (see demo sample).
hyperlink - if parameter is a URL, opens the link on a new window. Use, for example, on image-based ads. To use this however, popups must not be blocked.
"$label" - if the label is prepended with a $ sign, the jump will be executed but will not be pushed into the frame stack. Useful if you don't want to remember a jump.
jump, {param}
Conditional jump.
Execution jumps to given label if condition is true.
Parameters are given as {param:value, param:value, ...}
Parameter Attributes and Description
name:comparison_value
Compares variable given by 'name' to 'value' given.
User and Config variables are supported.
Multiple conditions are supported. This is an AND condition, meaning all comparison must result to true.

If type of variable is a number, checks if variable is greater than or equal to the value given.
If type of variable is a string, performs a case-sensitive comparison if the string is the same as value.
If type of variable is boolean, compares if same as value.
Note: The actual value of variable is not changed.
label:"label_name"
Label to jump to if condition is true.
Label takes the forms described above.
The first unconditional jump call moves the game to "label1". The second jump call moves to the next chapter at label "start".
  
chapter = [

	...
	jump, "label1",
	...
	label, "label1",
	...
	jump, "next_chapter#start",
	...
];
						
This conditional jump compares "uservar1" with value given and since 5 is greater than 2, jumps to label2.
  
chapter = [

	...
	set, {uservar1:5},
	...
	jump, {uservar1:2, label:"label2},
	...
	// script lines here are skipped
	...
	label, "label2",
	...
];
						
This conditional jump checks "uservar1", "uservar2" and "uservar3" against the given condition, jumps to label2 if all are true.
  
chapter = [

	...
	set, {uservar1:5, uservar2:true, uservar3:"hello"},
	...
	jump, {label:"label2", uservar1:2, uservar2:true, uservar3:"hello"},
	/* the following are checked:
		uservar1 >= 2 (value is 5)
		uservar2 == true (value is true)
		uservar3 == "hello" (value is "hello")
	*/
	...
	// script lines here are skipped since all conditions are true
	...
	label, "label2",
	...
];
						
This conditional jump compares configuration variable "gameMatureFilter" to skip mature contents.
  
chapter = [

	...
	jump, {gameMatureFilter:true, label:"skip},
	...
	// mature content here are skipped if
	// MatureFilter is on
	...
	label, "skip",
	...
];
						
Though these may not be particularly useful for visual novels, loops can be constructed using special constructs with label, user variables and conditional jumps. Note: the user variables can either be boolean to check for true/false, or number that can be incremented/decremented.
  
chapter = [

	...
	/* This loop checks user variable first before executing the loop. */
	set, {user_var:0},
	label, "loop_start1",
	jump, {user_var:10, label:"loop_end1"},

	// Do some things here

	set, {user_var:"+1"),
	jump, "loop_start1",
	label, "loop_end1",
	...
	/* This loop executes at least once before user variable is checked */
	set, {user_var:10},
	label, "loop_start2",
	
	// Do some things here
	
	set, {user_var:"-1"),
	jump, {user_var:0, label:"loop_start2"},
	label, "loop_end2",
	...
];