Console Syntax

From HoNWiki
Jump to: navigation, search

Clipped from Savage2 Mod Wiki

The Syntax used in the Console covers the essentials but is not particularly user-friendly.


Comments use the typical C++ syntax of putting "//" (without quotes) in front of a line you want to act as a comment. This will make sure the line is not parsed. This is typically used to document your script or disable certain lines of code.

Command Grouping[edit]

As well as being on separate lines within scripts, multiple commands can also be used on the same line when separated with a ";" symbol (without the quotes). Like in this example:

Echo Message 1; Echo Message 2

This will print both messages. The spaces in-between the ";" symbols are optional.

Console Evaluator[edit]

The Console Evaluator is a special syntax that indicates that the Console parser needs to pre-evaluate parameters that it has been given before parsing them. Otherwise for example functions and variables are treated as strings as opposed to what value they return.

To tell the console to evaluate certain strings into functions or variables we need to use the # brackets.

It should also be noticed that you can't use more # symbols in-between the bracketing to evaluate a second value, to do this you need to use "|#" symbols (without quotes) to tell the console parser to evaluate this value before evaluating the first. A third step cannot be made however and you may have to use multiple variables to achieve your eventual goal.

Here is an example of the Console Evaluator:

Set _number 5.5
Echo #Ceil(|#_number|#)#

The Console parser will treat this example as follows:
It will evaluate the text within the |# brackets to the value within the variable _number which is: 5.5
It will then evaluate the the text within the # brackets parsing the Ceil function and returning the value 6.
It will finally print "6" (Without Quotes) to the Console.

Mathematical Calculations[edit]

To do number calculations you need to put [ and ] brackets around the numbers that are to be calculated.


Echo [1 + 1]

Will return: 2.

Variables can also be calculated here too. The console evaluator cannot be used inside calculation brackets but it is not needed in this case.


Set _i 5
Echo [_i + 10]

Will return: 15.

Some operators that can be used:

  •  % - Modulus.
echo [4 % 3]
will print 1.
  • rand - Random.
echo [rand]
will print a number between 0 and 1.