ezQuake Manual: Command set_calc

Advanced variables customization.

Syntax:
set_calc <cvar command cmdargs> | <cvar arg1 oper arg2>

cvar
Name of variable you want to save the result in.
command
Possible commands: strlen - gets length of given string, int - converts given float value to integer, substr - return substring of given string, set_substr - replaces given position in string with another string, pos - gets position of substring in given string.
cmdargs
Arguments of commands: strlen <string>; int <float>; substr <sourcestr> <position> [<length>]; set_substr - <replacestr> <position>; pos <haystack> <needle>;
arg1
First argument
oper
Possible operators: +, -, *, /, div, %%, and, or, xor.
arg2
Second argument.

Examples: set_calc a strlen "cool string" --> a=11 You can use names of cvars instead of strings of course. That's the power of this scripting possibilities. set b "cool text" set_calc a pos b ext --> a=6

Last update: 31.10.2005 13:58 PST, made by JohnNy_cz