Author Topic: How to get all the Arguments for a Packaged Function  (Read 698 times)

Most people seem to have trouble finding the entire set of arguments for a packaged function. Here's a good way to get them.

Code: [Select]
package myPackage
{
// The first argument is %client.
// We know this because the function is in a namespace, so the first argument will always reflect on the namespace it is in.
// %client is the most popular variable name for a game connection, so that is what we are going to use here.
function gameConnection::onDeath(%client, %a, %b, %c, %d, %e, %f, %g, %h, %i)
{
// This echo will dump a line into your console each time someone dies.
// Since it's clearly divided by spaces and colons, you can make out easily what each variable represents.
// Then, by running a couple of dumps on any objects that appear, and guessing everything else,
// you can logically deduct the arguments of this function without needed to post a topic or ask someone else.
// Remember to take out excess arguments if they are constantly returning blanks.
// There is no point in overloading the argument if you're not using any of the extra variables.
echo(%a SPC ":" SPC %b SPC ":" SPC %c SPC ":" SPC %d SPC ":" SPC %e SPC ":" SPC %f SPC ":" SPC %g SPC ":" SPC %h SPC ":" SPC %i);

// We include the parent, or else our expirment will flat-out break the function.
//  I'm pretty sure you wouldn't want to break onDeath, too.
parent::onDeath(%client, %a, %b, %c, %d, %e, %f, %g, %h, %i);
}
};
activatePackage(myPackage);

Although simply leaving in the alphabet array that you see above would technically work, I find it much, much easier to have the argument list written down correctly. That way, if you ever need to amend your code, you can do so without going through the variable list and guessing which does what. Also, you can use it for future reference in other mods, allowing you to copy and paste the function over and then stripping it down.
« Last Edit: March 24, 2009, 12:48:17 PM by Thief »

Please add some newlines to your description as it currently stretches the page and looks bad.

Please add some newlines to your description as it currently stretches the page and looks bad.
What browser are you using? I'm in Chrome and the lines are wrapping fine. However, per your request, I will try and break up the commentary.

Firefox.

In any case, the best resource forpackaged functions I have found is a copy of either the Torque Game Engine demo or Blockland v0002. This gives you the old/basic code for the function, minus any changes Badspot may have made to it (e.g. connect functions or chat filtering), but should give you a good idea of what it's meant to do and what each argument is for.

Firefox.

In any case, the best resource forpackaged functions I have found is a copy of either the Torque Game Engine demo or Blockland v0002. This gives you the old/basic code for the function, minus any changes Badspot may have made to it (e.g. connect functions or chat filtering), but should give you a good idea of what it's meant to do and what each argument is for.
My way is more accurate and does not involve digging for archaic code. Plus, you would still need to do trial and error in order to assure you have the correct arguments.