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

QuestNet Server: Status Variables have a "scope" that is either global or local. A variable with global scope has the same value for every player, and is accessed in exactly the same way as a status variable for a single-player game. An example of a variable with global scope might be a string variable representing the date, or a numeric variable representing the temperature - these are values which are the same throughout the game world. In contrast, a variable with local scope has a value for each player. An example might be the amount of money they player has, or the player's age. The variables are access as arrays, with the array index being the user ID. For example, %age[userid]%.

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.

scope { global | local }

QuestNet Server Only Specifies whether the variable has a global or local scope. The default is a global scope. See above for an explanation of the difference between global and local scopes.

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