Game Development Community

Torquescript seems ambiguous

by James Dunlap · in Torque Game Engine · 01/25/2006 (10:54 am) · 8 replies

I'm used to C++ programming and, to be honest, the fact that Torquescript is typeless is starting to frustrate me. It makes the script files alot harder to wrap my mind around, especially when I'm looking at method/function definitions. I'm used being able to look at the declaration, find the object type, and looking up its members in documentation. For example,

function doClientAttackAnimation(%attacker, %target)
{
...
}

If I want to look up the members of either %attacker or %target I'm stumped. Am I missing a concept here?

#1
01/25/2006 (11:03 am)
I agree, it can make starting out quite diffucult. Your best bet is to build your engine in debug and do dumps on the objects you want to see the methods for. Example:

%attacker.dump();
#2
01/25/2006 (11:20 am)
Also find a good find-in-files utility.
My favorite is Visual Studio's, but there's other, free ones.

I search the entire source tree for things like "doClientAttackAnimation" very regularly,
it's a big help in finding out what sort of objects %attacker and %target should be.
#3
01/25/2006 (11:53 am)
Thanks,

%attacker.dump();

is most helpfull. How do you prefer to execute it? In this instance, I'm transfering %attacker to a global variable and calling dump() from the console.
#4
01/25/2006 (11:56 am)
That seems like a reasonably good way.
or you could dump it in doClientAttack(),
or echo its value to the console (eg echo("attacker=" SPC %attacker);)
and then dump via the results of that,
but really your way seems better than either of those.
#5
01/25/2006 (12:31 pm)
[snarle]Okay, speaking of Torquescript being typeless...[/snarle] I've got a few more seemingly simple questions,

1) How can I access individual characters withing a string? For example,

$myarray = "testing";

How can I access the letter 's' ?

Note: Sorry for the C++ syntax. I do realize that 's' is a tagged string in Torque.

2) How can I round floating point values? For example,

$f = 8.5;

How can I round this up to 9.0?

Please tell me I don't have to jump out to C++...
#6
01/25/2006 (1:15 pm)
This site might help you, James. www.egotron.com/torque/old_script.html

It's rather old, but most of it should still be relevant.

So, to answer you questions:

1). Using a combo of getSubStr() and strchr() will allow you to find individual characters in a string.

2). Use mCeil() to round up or mFloor() to round down.
#7
01/25/2006 (1:20 pm)
1. i think you have to use getSubStr().
2. mCeil().

you can find these functions documented in the windows .chm file listed here.

if you're planning on doing 1. a lot, you might want to write a C++ function to help out.
#8
01/25/2006 (2:38 pm)
Thanks.