Game Development Community

Script Location Question

by Ryan Elgram · in Torque Game Engine · 02/07/2007 (3:11 pm) · 13 replies

I've been having a jab at the scripting in Torque and I really feel I am getting it. The engine ( although rather large ) is written well and pretty easy to follow. The one problem I am having right now and would like some feedback from other developers is this:

Inside the scripts there are calls to functions that do not exist in the script file. Makes sense ... you need to put your code elsewhere for better organization. However, all the functions act like static functions in C++ and I have no idea what file to even begin looking at to find the function I want to investigate.

Does anyone have some clever ( or even not clever, but useful ) ways to manage this sort of problem?

#1
02/07/2007 (7:18 pm)
If I'm reading this correctly, you are referring to ConsoleFunctions and ConsoleMethods. If you perform a search in the engine project for "ConsoleFunction" or "ConsoleMethod", you should start finding the results you are looking for.

You can narrow the search by the function call itself. Search the engine project (case sensitive and whole word parameters turned on) "commandToClient". You should see the ConsoleFunction that exposes this method in Torque Script.

ConsoleFunctions are more or less "static function calls" that can be invoked anywhere in script. ConsoleMethods are similar, but must be attached to an object. For instance, a Player object contains the ConsoleMethod damage(), hence player.damage().


Hope that helps.
#2
02/07/2007 (7:38 pm)
Not necessarily the ConsoleFunctions and ConsoleMethods, although that is definitely something to keep in mind and I thank you for your input. I am more so referring to just Script function calls. Take for example a simple main.cs file:

function initServer()
{
echo("\n--------- Initializing Server ---------");

// The common module provides the basic server functionality
initBaseServer();

// Load up game server support scripts
exec("./server/game.cs");
}


If I wanted to know where initBaseServer() was located I would have to do a search on all the .cs script files. Although this isn't a terrible method for finding it... I imagine a new scripter ( such as myself ) will be doing a whole lot of searching. There must be a cleaner and more direct way of indicating where the script function is located.
#3
02/07/2007 (8:27 pm)
Look in the script resources for the chm file. that should help. for the most part however, you are going to have alot of searching to do. you should make notes in the scripts as you go.
#4
02/07/2007 (10:05 pm)
Honestly, get an editor (Ultra Edit, or especially Torsion) that supports "find in files", and simply search through your project.

Torsion -should- have some ability to find the declaration if I remember correctly, but I could be mis-remembering.
#5
02/07/2007 (10:33 pm)
Torsion can search for text within all the files in your project: CTRL+SHIFT+F
#6
02/07/2007 (10:36 pm)
I am using UltraEdit and have been for the past many years for most of my programming needs.

Does Torsion have an 'IntelliSense' type engine with it? I think that could definitely be useful for scripting for the Torque engine. Doesn't seem like it would be that hard to integrate into a text-editor should you have an assigned path to your project or something similar.
#7
02/07/2007 (10:47 pm)
Not only does Torsion have that, but it also allows you to remotely debug Torque games, just like Visual Studio does for c++, only for TorqueScript.

You can set breakpoints, watch variables, and do several other things that are quite nice to have!
#8
02/08/2007 (5:44 am)
And to go one further, if you right click on a function you can choose to go to the definition and skip the whole "Find in files" method.

Intellisense, remote debugging, function definition and location, syntax highlighting......you NEED Torsion....I honestly couldn't live without it.
#9
02/08/2007 (9:35 am)
Does Torsion work with TSE? I don't see why it wouldn't but I would like to make sure.
#10
02/08/2007 (1:36 pm)
TGE, TGB, TGEA, Constructor, etc etc....all GG products
#11
02/09/2007 (4:32 am)
.
#12
02/09/2007 (4:52 am)
Put this:

dumpConsoleFunctions();

On top of your root main.cs file. Run Torque, then close it and open the console.log. You'll have a nice list of all C++ console functions in there.

And this:
dumpConsoleClasses();

Will dump all classes, their fields and methods to the console.log too.
#13
02/09/2007 (5:20 am)
You can find out where a function is by using an editor that supports such functionallity.

Torsion should, and I know Tribal IDE has a function list which you can iterate pretty swiftly.