Game Development Community

Making a function accessable from several different files.

by Josias Gibbs · in Torque Game Engine · 09/05/2008 (1:42 pm) · 3 replies

How can I create a function that can be called from several different behavior files. I'm going to be writing at least half a dozen AI's in separate behavior files, and there are a few functions that are going to be implemented in exactly the same way in all of them (identical code). I would like to implement each of these functions only once, and then call them from my behaviors.

What's the easiest way to do this?

#1
09/05/2008 (2:02 pm)
Put them in a script file that is executed in initializeProject()
#2
09/06/2008 (2:01 pm)
I'll try that out. *anticipates a question that will probably come up* I have another question, what's the syntax for calling those functions from another file?
#3
09/06/2008 (2:22 pm)
There is no special syntax. TorqueScript has no concept of things being defined in different files. Once that file is executed, the functions defined there just exist.