Equivalent of #ifdef in TorqueScript ?
by David Dougher · in Torque Game Engine Advanced · 02/03/2009 (7:07 am) · 4 replies
I recently began adding a number of Add-ons to TGEA and while it was easy to bracket the code changes with a single #ifdef variable so I could try various combinations the same could not be said of TorqueScript.
While a lot of the scripted code pieces could be bracketed by something like
if ($CODEPACK)
{
the new code from the add-on here...
}
The problem is in the definition of any functions.
So while the above will work for regular code and even datablocks the following will fail.
if ($CODEPACK)
{
function(NewAddOnFunction)
{
New add-on function code
}
}
So is there any real #ifdef equivalent in TorqueScript that I missed?
If not then I have a suggestion for a really useful addition to Torque 3D...
While a lot of the scripted code pieces could be bracketed by something like
if ($CODEPACK)
{
the new code from the add-on here...
}
The problem is in the definition of any functions.
So while the above will work for regular code and even datablocks the following will fail.
if ($CODEPACK)
{
function(NewAddOnFunction)
{
New add-on function code
}
}
So is there any real #ifdef equivalent in TorqueScript that I missed?
If not then I have a suggestion for a really useful addition to Torque 3D...
About the author
Owner - Pariah Games, Adjunct Professor - Bristol Community College, Mentor - Game Design - Met School Newport, Mentor - Game Design - Met School Providence
#2
02/03/2009 (7:39 am)
Yeah, package functionality is often overlooked but it will let you do what you describe.
#3
02/03/2009 (9:10 am)
Hmmm. You're right. Never thought of trying to use a package to wrap up the functions. Thanks for the ideas guys...
#4
02/03/2009 (5:54 pm)
Packages sound like the best bet for you. Though you could also store the functions in a separate file, and doif (!$THISCODE)
exec("thiscode.cs");
Associate Orion Elenzil
Real Life Plus
activatePackage is a good keyword to look for.