Game Development Community

Basic Scripting Questions Part 2

by Joe Nobody · in Torque Game Engine · 11/13/2003 (8:55 pm) · 9 replies

What the hell calls script functions? Do other scripts call them? Are they called in code? If they are called by other script functions, then are all script fuctions global? Also, if I was to add another player what function do I call to do this (or what class do I have to declare)?

#1
11/14/2003 (6:59 am)
Execution starts at main.cs; there are also a variety of callbacks from the engine (look for Con::exec in the source).

Most script just calls other script.

Or are you talking about ConsoleMethod/ConsoleFunctions?
#2
11/15/2003 (1:56 pm)
No not console functions just ones in .CS files

What I'm trying to determine is program flow.

It looks like there are some scripts that are nothing but to help with initialization.

But others look like their game logic.

What I'm wondering is all the functions I see in .CS files; do they get called in the engine, or by other functions, in other .CS files. IF they do get called by other .CS files, does that mean that all functions are global. Because I don't see any #includes at the top of .CS files. (obviously)
Thanks
#3
11/15/2003 (2:00 pm)
1. Script functions can be called by both C++ and Script.
2. Script functions are global
#4
11/15/2003 (3:11 pm)
.cs files execute other .cs files by calling exec("path to script file");
#5
11/15/2003 (3:48 pm)
OK thanks. What is the command in the source code to call a .CS function?
#6
11/15/2003 (4:01 pm)
function foo() {
   echo("blah");
}

foo(); // Call foo

Please read the scripting overview, it explains this in some detail.
#7
11/16/2003 (2:20 pm)
How would I call foo in source code.

//Like this
foo();

Won't this get a compiler error, cause it won't know what this function is?
#8
11/16/2003 (5:07 pm)
You mean, from C++ code?

Con::exec is a good place to start. The engine reference goes over this in some detail.
#9
11/22/2003 (8:05 pm)
Your right th engine reference does go over this...thanks.