Game Development Community

Using scripts?

by Mike Lentini · in Torque Game Engine · 03/10/2006 (6:17 pm) · 5 replies

I've had the book 3D Game Programming All In One for a while now, and I finally got together the money to buy Torque Game Engine today. In the book it explains how to run scripts after making them in Ultra-Edit 32, but it only explains how to do it straight off of their CD with the Torque Demo. So, my question is, how do I run scripts with Torque?

#1
03/10/2006 (6:54 pm)
Here is the short answer:

You can run additionnal scripts by including the following command in an existing script:

exec("./myscript.cs");

Torque will compile them into a DSO and use them.

By default, the function "runEntryScript" in main.cc will load the "main.cs" script at launch. Other scripts are launched in chain from this one...

The other alternative is to load the scripts in memory and execute them using the function "Con::evaluate(...)"

If what you want to know is how to use call already loaded scripts from your C++ code, then you can do that using the Con::executef(...) function.

Have fun!
#2
03/10/2006 (7:07 pm)
Thanks, I guess that kind of helped. But in the book when they run a script, let's say... the Hello World program. When they ran it, it just came up in a window that said Hello World. Is that just a book thing, or is that what I'm actually supposed to be doing. I guess it would help to get an answer from someone who read the book.
#3
03/11/2006 (1:06 am)
That was just a classic hello world example, common to all first lessons for all programming langues, and it shows that it works that's all...

move on with the book and it will take you farther along with using scripts etc...
#4
03/11/2006 (2:43 pm)
Oh ok, thanks. So the book will eventually start explaining how to run scripts like Mathieu said?
#5
03/11/2006 (3:02 pm)
Here is the forum for the book. There is also and Advanced 3D Game Programming All in One book, which is a continuation of the one you have.