Debugging Script files

From Bots-United Wiki

Jump to: navigation, search

This is a on-going topic on debugging script files for FritzBot waypointers. Some information is temporarily reproduced here from Chruker's script reference. The scope of this topic is to just explain the debug specific keywords, and give a few examples of how to use them and some of the standard keywords in simple debugging of script files.

Debugging

botgebugging <ON|OFF>
Enables or disables bot debugging.
Note: That the spelling error in the command name, is also present in the source code.
UNVERIFIED  This command is not intended for use with FritzBot Bots and may create problems.

Contents

[hide]

What is the script file

The script file is the code through which some objects in the map react to the game play or state. It is also the code that defines the map objectives and determines the winner of the match. The script file is not just a simple linear program. It is rather an event driven group of routines. Each routine has its event triggers and associated code. The triggers may occur because of any one of the player's actions. Also one part of the code can trigger a different routine as if a player action occurred etc. A routine may also delay running part of itself. Consequently more than one part of the script can be considered as "running" at the same time. So in order to understand what is happening it can be very useful to be able to print out messages describing significant points in the code as well as outputting variables that affect code flow.

Debug Print Statements

There are 3 print commands available just for debugging the script in addition to the normal game message system announcements.

print [/scriptdebuglevel] <text>
Prints 'text'. Mostly for debugging purposes. If the 'scriptdebuglevel' is specified, then the text will only get printed if the g_scriptdebuglevel cvar is above of equal.

printaccum <accumNumber>
Prints the value in 'accumNumber' to the console. 1

printglobalaccum <accumNumber>
Prints the value in 'accumNumber' to the console. 2

setdebuglevel <scriptdebuglevel>
Script command to set the cvar 'g_scriptDebugLevel' to 'value'

1, 2 accums and globalaccums are discussed in the scripting reference referred to the top of this page. Note: Missing from the debug print commands is a command to print the value of a cvar. Cvars can be used (but rarely are) in the flow control statements in the script file. Lacking a way to automatically print them from inside the script file, you will have to print them from the console yourself.

Message System
wm_announce <text>
Sends 'text' to all clients in the pop-up message area.

wm_announce_icon <icon_number> <text>
Sends 'text' to all clients in the pop-up message area. The icon used is specified by 'icon_number'.

wm_voiceannounce <team> <voice_message>
Broadcast a 'voice_message' to the specified 'team'.
more later

Other commands

resetscript
Causes any currently running scripts to abort, in favour of the current script.
entityscriptname <scriptname>
Changes the cvar value of 'g_scriptname' to 'scriptname'. This value is then used instead of the map name, the next time the map is restarted.

G_scriptname

g_scriptname is the cvar that identifies the script file used by the map. It is normally set as "" or default which means that the .script filename is the same as the map's .bsp filename. To try out a different script file (rather than doing a rename-swap) open the console ' and type:

/g_scriptname <new-scriptfile>
/map_restart

NOTE: <new-scriptfile> is the filename of the script file you are testing. The scriptfile must be in the /maps sub-directory in either /etmain or /fritzbot directories. It can be in the /maps directory inside a pk3 file in the latter 2 directories or if /sv_pure is zero it can be unpacked to /etmain/maps or /fritzbot/maps.

WARNING; DO NOT add the filetype extension (.script), or mistype the filename for the field <new-scriptfile>. ET will not prevent you from using a non-existent or incorrect file and ET may crash later-on in such a case.

G_scriptdebug

g_scriptdebug is the logical cvar used to turn on a line by line echo to the console of the script file lines as they are executed. This is a fairly verbose debugging tool so use it sparingly and turn it off (/g_scriptdebug 0) if you are not using it.

You can turn this cvar on and off inside the script file with the cvar set command

cvar g_scriptdebug set <value>

where value is 1 for On, 0 for Off. The cvar set script command has a bug in the original WET source such that it has no effect! Bitset and bitreset likewise have no effect in uncorrected code. (Corrected in ETPub)

Or use the tested good increment method

cvar g_scriptdebug inc 1 //to turn on if off

The drawback being that g_scriptdebug has to be reset manually in the console or at match restart in the map.cfg file.


For the a list of functioning cvar flow control commands in a map script file go here.

Condump

Copying the console to a text file will allow for checking the map script results outside of the in-game console, and can help find errors that scroll away too quick to read. The 'condump ' command can be used from with-in the console to dump the messages that are still in the cache. For a more complete review I suggest using console logging. That way everything in the console will be saved until the next time you start FritBot ET. To read more about condump and logging to a log file read the sections in the Unattended Testing Methods article.

Permanent link to this page

Retrieved from "Debugging_Script_files"