Section Index


1. OpenAL || 2. Debugging || 3. String Manipulation || 4. Networking || 5. Console || 6. Device I/O || 7. File I/O
8. Packages || 9. Objects || 10. Event Scheduling || 11. Datablocks || 12. Video / Texturing || 13. Special || 14. Resource Management
15. Scene || 16. Containers and Raycasts || 17. Editors || 18. Build || 19. Time || 20. GUIs || 21. Math


This quick reference guide was taken directly out of The Game Programmer's Guide to Torque by Edward Maurina. It's an outstanding resource - a must for anyone wanting to get serious about programming in Torque.


Contents

Networking

addTaggedString( string )

Purpose
Use the addTaggedString function to tag a new string and add it to the NetStringTable.

Syntax
string
– The string to tagged and placed in the NetStringTable. Tagging ignores case, so tagging the same string (excluding case differences) will be ignored as a duplicated tag.

Returns
Returns a string (containing a numeric value) equivalent to the string ID for the newly tagged string.



buildTaggedString( format , <arg1, ...arg9> )

Purpose
Use the buildTaggedString function to build a tagged string using the specified format.

Syntax
enable
– A boolean value. If set to true, network packet logging is enabled, otherwise it is disabled.

Returns
No return value.



detag( tagID )

Purpose
Use the detag function to convert a tag to a string. This can only be used in the proper context, i.e. to parse values passed to a client command or to a server command. See 'Remote Procedure Call Samples' below.

Syntax
tagID
– A numeric tag ID corresponding to a previously tagged string.


Returns
Returns the string associated witht the tag ID.

See Also
commandToClient(), commandToServer().



dumpNetStringTable()

Purpose
Use the dumpNetStringTable function to dump a list of all the currently registered NetStringTable entries, including the times each has been referenced, the total entry count, and the current 'highest' reference string.

Returns
No return value.

Notes
For this to work, the engine must have been compiled with TORQUE_DEBUG defined.



getTag( taggedString )

Purpose
Use the getTag function to retrieve the tag ID associated with a previously tagged string.

Syntax
taggedString
– A previously tagged string.

Returns
Returns the tag ID of the string. If the string was not previously tagged, it gets tagged and the new tag ID is returned.



getTaggedString( tag )

Purpose
Use the getTaggedString function to convert a tag to a string. This is not the same a detag() which can only be used within the context of a function that receives a tag. This function can be used any time and anywhere to convert a tag to a string.

Syntax
tag
– A numeric tag ID.

Returns
Returns the string corresponding to the tag ID.



removeTaggedString( tag )

Purpose
Use the removeTaggedSTring function to remove a previously tagged string from the NetStringTable.

Syntax
tag
– A number tag ID.

Returns
No return value.



gotoWebPage( address )

Purpose
Use the gotoWebPage function to open a browser and go to the specified URL address.

Syntax
address
– A complete and valid URL.

Returns
No return value.



setNetPort( port )

Purpose
Use the setNetPort function to set the netport that the server will listen on.

Syntax
port
– A numeric port ID.

Returns
Returns true if the set worked, false otherwise.



telnetSetParameters( port, consolePass, listenPass [ , remoteEcho ] )

Purpose
Use the telnetSetParameters function to setup and accept telnet requests on a specific port.

Syntax
port
– A numeric port ID.
consolePass – Password for read/write access to the console.
listenPass – Password for read access to the console.
remoteEcho – A boolean value to enable echoing to the client, false by default.

Returns
No return value.



commandToClient( client, func [ , arg1, ... , argn ] )

Purpose
Use the commandToClient function to issue a remote procedure call on a client.

Syntax
client
– The numeric ID of a client gameConnection.
func – The suffix of the remote procedure name to be executed on the client.
arg1 .. argn – Optional arguments to be passed to the remote procedure.

Returns
No return value.

Notes
All arguments (excluding client) may be in tagged or non-tagged format. See 'Remote Procedure Call Samples' below.



commandToServer( func [ , arg1, ... , argn ] )

Purpose
Use the commandToServer function to issue a remote procedure call the server.

Syntax
func
– The suffix of the remote procedure name to be executed on the client.
arg1 .. argn – Optional arguments to be passed to the remote procedure.

Returns
No return value.

Notes
All arguments may be in tagged or non-tagged format. See 'Remote Procedure Call Samples' below.



allowConnections( enable )

Purpose
Use the allowConnections to enable (or disable) remote connections to the local game server.

Syntax
enable
– A boolean value enabling, or disabling connections to the local server.

Returns
No return value.



cancelServerQuery()

Purpose
Use the cancelServerQuery function to cancel a previous query*() call.

Returns
No return value.

See Also
queryLANServers(), queryMasterServer(), querySingleServer()



getServerCount()

Purpose
Use the getServerCount function to determine the number of game servers found on the last queryLANServers() or queryMasterServer() call.

Returns
Returns a numeric value equal to the number of game servers found on the last queryLANServers() or queryMasterServer() call. Returns 0 if the function was not called, or none were found.

Notes
This value is important because it allows us to properly index when calling setServerInfo().

See Also
queryLANServers, queryMasterServer, setServerInfo()



queryLANServers( port , flags , gametype , missiontype , minplayers , maxplayers , maxbots , regionmask , maxping , mincpu , filterflags )

Purpose
Use the queryLANServers function to establish whether any game servers of the required specification(s) are available on the local area network (LAN).

Syntax
port
– Look for any game servers advertising at this port. Set to 0 if you don't care what port the game server is using.
flags - Look for any game servers with these special flags set. Set to 0 for no flags.
gametype - Look for any game servers playing a game type that matches this string. Set to the NULL string to look for any game type.
missiontype - Look for any game servers playing a mission type that matches this string. Set to the NULL string to look for any mission type.
minplayers - Look for any game servers with this number of players or more. Set to 0 for no lower limit.
maxplayers - Look for any game servers with this number of players or fewere. Set to 0 for no upper limit.
maxbots - Look for any game servers with this number of AI controlled players or fewer. Set to 0 for no limit.
regionmask - Look for any master servers, on our master server list, in this region. Set to 0 to examine all regions.
maxping - Look for any game servers with a PING rate equal to or lower than this. Set to 0 for no upper PING limit.
mincpu - Look for any game servers with a CPU (clock speed) equal or greater than this. Set to 0 for no CPU (clock speed) limit.
filterflags - Look for any game servers with this game version number or higher. Set to 0 to find all versions.

Returns
No return value.

See Also
getServerCount, queryMasterServer, setServerInfo, stopServerQuery



queryMasterServer( flags , gametype , missiontype , minplayers , maxplayers , maxbots , regionmask , maxping , mincpu , filterflags )

Purpose
Use the queryMasterServer function to query all master servers in the master server list and to establish if they are aware of any game servers that meet the specified requirements, as established by the arguments passed to this function.

Syntax
flags
- Look for any game servers with these special flags set. Set to 0 for no flags.
gametype - Look for any game servers playing a game type that matches this string. Set to the NULL string to look for any game type.
missiontype - Look for any game servers playing a mission type that matches this string. Set to the NULL string to look for any mission type.
minplayers - Look for any game servers with this number of players or more. Set to 0 for no lower limit.
maxplayers - Look for any game servers with this number of players or fewere. Set to 0 for no upper limit.
maxbots - Look for any game servers with this number of AI controlled players or fewer. Set to 0 for no limit.
regionmask - Look for any master servers, on our master server list, in this region. Set to 0 to examine all regions.
maxping - Look for any game servers with a PING rate equal to or lower than this. Set to 0 for no upper PING limit.
mincpu - Look for any game servers with a CPU (clock speed) equal or greater than this. Set to 0 for no CPU (clock speed) limit.
filterflags - Look for any game servers with this game version number or higher. Set to 0 to find all versions.

Returns
No return value.

Notes
In order for this function to do anything, a list of master servers must have been previously specified. This list may contain one or more server addresses. A call to this function will search all servers in the list. To specify a list, simply create a set of array entries like this:

$pref::Master[0] = "2:192.168.123.15:28002";
$pref::Master[1] = "2:192.168.123.2:28002";
...


The format of these values is --> Region Number:IP Address:Port Number

These values should be specified in either the client's or the server's preferences file (prefs.cs). You may specifiy it elsewhere, however be sure that it is specified prior to this function being called and before any other functions that rely on it.

See Also
getServerCount, queryLANServers, setServerInfo, startHeartbeat, stopServerQuery



querySingleServer( address [ , flags ] )

Purpose
Use the querySingleServer function to re-query a previously queried lan server, OR a game server found with queryLANServers or with queryMasterServer and selected with setServerInfo. This will refresh the information stored by TGE about this server. It will not however modify the values of the $ServerInfo::* global variables.

Syntax
address
– The IP address and Port to re-query, i.e. "192.168.123.2:28000".
flagsNo longer used.

Returns

No return value.

See Also
getServerCount, queryLANServers, queryMasterServer, setServerInfo, stopServerQuery



setServerInfo( index )

Purpose
Use the setServerInfo function to set the values of the $ServerInfo::* global variables with information for a server found with queryLANServers or with queryMasterServer.

Syntax
index
– The index of the server to get information about.

Returns
Will return true if the information was successfully set, false otherwise.

See Also
getServerCount, queryLANServers, queryMasterServer, querySingleServer



startHeartbeat()

Purpose
Use the startHeartbeat function to start advertising this game server to any master servers on the master server list.

Returns
No return value.

Notes
In order for this function to do anything, a list of master servers must have been previously specified. This list may contain one or more server addresses. Once this function is called, the game server will re-advertise itself to all the master servers on its master server list every two minutes. To specify a list, simply create a set of array entries like this:

$pref::Master[0] = "2:192.168.123.15:28002";
$pref::Master[1] = "2:192.168.123.2:28002";
...


The format of these values is --> Region Number:IP Address:Port Number

These values should be specified in either the client's or the server's preferences file (prefs.cs). You may specifiy it elsewhere, however be sure that it is specified prior to this function being called and before any other functions that rely on it.

See Also
queryMasterServer, stopHeartbeat



stopHeartbeat()

Purpose
Use the stopHeartbeat function to stop advertising this game server to any master servers on the master server list.

Returns
No return value.

See Also
queryMasterServer, startHeartbeat



stopServerQuery()

Purpose
Use the stopServerQuery function to cancel any outstanding server queries.

Returns
No return value.

See Also
queryLANServers, queryMasterServer, querySingleServer



getMaxFrameAllocation()

Purpose
Use the getMaxFrameAllocation function to determine the largest amount of memory that has ever been allocated in the process of rendering a single frame.

Returns
Returns a non-negative integer representing the largest number of bytes temporarily allocated during the rendering of a single frame.

Notes
For this to work, the engine must have been compiled with TORQUE_DEBUG defined. During frame rendering, the engine will dynamically allocate and deallocate memory for various tasks. This function allows us to get a peek at the largest ammount of allocation that has occured to date. If this number is very large, we may have a bug or be facing a serious performance issue of one form or another. We want this number to be small.


Section Index


1. OpenAL || 2. Debugging || 3. String Manipulation || 4. Networking || 5. Console || 6. Device I/O || 7. File I/O
8. Packages || 9. Objects || 10. Event Scheduling || 11. Datablocks || 12. Video / Texturing || 13. Special || 14. Resource Management
15. Scene || 16. Containers and Raycasts || 17. Editors || 18. Build || 19. Time || 20. GUIs || 21. Math