Game Development Community

Using a external LIB

by Diego Perez · in Torque 3D Beginner · 02/10/2010 (7:08 am) · 6 replies

Hello,

I would like to use an external lib (C++ lib with some tools I have created). Is there any way to use this library using Torque Script? Can I use torque script to load a lib that is not integrated in Torque source engine?

Many thanks,

Diego.

#1
02/10/2010 (10:06 am)
You could probably make a library loader if you wanted to. To more easily add your library, you just link it, include its headers in one of the files where console functions are defined and start adding ConsoleMethod wrappers for your functions. There are some posts here on the forum about making such methods (but you might be able to figure it out from the source).
#2
02/10/2010 (10:42 am)
You'll have to load the library on the C++ side and then create ConsoleFunctions that call your lib's function for use in the scripts.
#3
02/10/2010 (11:20 am)
Thanks guys for your replies.

@Ronny: About the library loader... do you mean a library loader programmed in TorqueScript? Is there any domumentation about how to do such a thing out there?

@Both: About the other option, for doing that I would have to modify the project/source that Torque creates for me, wouldn't I? If so, this can't be an option for me, I have to keep the Torque source intact (as if I were a user with no access to the code) :S

I only can modify Torque scripts for doing this things (and my own lib, obviously).

Thanks again.

Diego.
#4
02/10/2010 (6:24 pm)
The library loader would be necessity be C++ with some TorqueScript glue functions. Dunno how I'd do it, since when you have the source, just plug it in normally :)

Why would you have to keep the source intact? It's there for you to have fun with.
#5
02/10/2010 (7:04 pm)
The fact that the source must be kept without modifications is a requirement of the project. The idea is that whoever needs my library can use it without the need to modify the source code (not willing to do it, or just that he has no access to it).

If there is no chance to do it, maybe that requirement changes... but first I have to see if there is a way ;)

Thanks!
#6
02/10/2010 (7:37 pm)
You need to make some C++ changes to get the loader in. Then you probably need some custom code to extract function calls, present them as TorqueScript functions and also know how many arguments they take (and what types). You'll have to look into how people normally make plugins on your platform, and inspect the console method macros closely.