Status Variable Definition Blocks

A status variable acts in exactly the same way as an ordinary numeric or string variable, except that its value is always displayed in a status area on the Quest window, underneath the inventory. Examples of variables you might set up as status variables are health and money - so the player can always check how healthy they are, how much money they have etc. by glancing to the right-hand side of the Quest window.

Status variable definition blocks may appear only within the game definition block.

An example of a status variable definition block is:

define variable <health>
	type numeric
	value <100>
	display <!%% health>
	onchange if (%health% <= 0) then playerlose
end define

Here is an explanation of the lines that can appear in a status variable definition block:

display [ nozero ] <display string>

Specifies how Quest is to display the status information for this variable. Use an "!" where you want the value of the variable to be printed, and use "*" characters to surround anything that should only appear in plural forms - for example, "You have ! piece*s* of toast". This will print "You have 1 piece of toast", "You have 2 pieces of toast", etc. Anything between the "*" characters is not displayed when the value of the variable is 1.

Use the nozero parameter if you don't want a numeric variable displayed when its value is zero.

The example above includes two "%" characters in the display tag because Quest uses the "%" character to denote a numeric variable - two "%" characters in the display string will print one "%" character rather than cause an error.

onchange script

Optional. If specified, the script will be executed each time the value of the variable is changed. In the above example, this checks whether the health has dropped to zero or below, and if so makes the player lose the game.

type { numeric | string }

Specifies the type of variable. The default is a numeric variable.

value <{ number | string }>

Specifies the initial value of the variable.

 

< Back