Game Development Community

When to be concerned w/ passing parameters in torquescript?

by Joe Bestor · in Torque Game Builder · 03/11/2005 (7:58 am) · 1 replies

I suppose the two biggest factors would be whats being passed by copy and if the function call is inside a loop with many iterations. In the following situation I should be alright.

In the root main.cs file there are the following functions with the similar definitions:

function pushFront(%list, %token, %delim)
{
   if(%list !$= "")
      return(%token@ %delim@ %list);

   return(%token);
}

function pushBack(%list, %token, %delim)
{
   if(%list !$= "")
      return(%list@ %delim@ %token);

   return(%token);
}

I could write one function to replace both of these. The function push would handle both return statements based on an additional parameter.

#1
03/11/2005 (10:36 am)
No reason you can't do it the way you discuss--some people like to have functions that accomplish a single task for organization and re-usability, and some like to have comprehensive dispatcher functions that can be highly configured based on parameters. Nothing in TGEScript drives either decision, it's simply how you like your code organized.