Author Topic: Easy way to know what variables are used in Parents?  (Read 1568 times)

Is there any way to easily find out what variables are used in a parent? Such as ::onFire(variables)?

Unfortunately, no, unless someone already knows or it gives an error when you use it wrongly.

For example, the code "getSubStr();" gives you an error telling you the three variables it uses.


However, you CAN package the unknown function and then cause it to be called.

package getInfo
{
   function Armor::onTrigger(%a, %b, %c, %d, %e, %f, %g, %h, %i, %j)
   {
      %ret = Parent::onTrigger(%a, %b, %c, %d, %e, %f, %g, %h, %i, %j);
      echo("Armor::onTrigger(\""@%a@"\", \""@%b@"\", \""@%c@"\", \""@%d@"\", \""@%e@"\", \""@%f@"\", \""@%g@"\", \""@%h@"\", \""@%i@"\", \""@%j@") returns \""@%ret@"\"");
      if(%ret !$= "")
         return %ret;
   }
};
activatePackage(getInfo);

Or you can type trace(1);, call the function naturally (not through console or script, such as jumping to call onTrigger)

It'll show you a list of what it did, in this case it would show

Armor::onTrigger(some number less than 4100, some number over 4100, 2, 1)
This will always return the second arg
then
Armor::onTrigger(some number less than 4100, some number over 4100, 2, 0)
This will always return 0

From this we can see that:
The first one is a datablock.
The second one is an object.
The third one is probably the slot of the trigger.
The forth one is press or release.

To find out what kinds of objects these are, for example, if the first number was 44 and the second one was 157083.
echo(44.getClassName());
This tells you PlayerData. This means that it's a player datablock. Because this is a player datablock function, the next argument will most likely be the player object, but let's check to make sure.
echo(157083.getClassName());
It tells you Player. This means that it is indeed a player object.

This means:
Armor::onTrigger(datablock, object, slot, value)

So then we try to figure out which slot is which.
So we trace again, and press in this order: shoot, jet, and crouch. We already know jump is 2.
Shoot gave us 0, jet gave us 4, and crouch gave us 3.
This means that:
0 = Shoot
2 = Jump
3 = Crouch
4 = Jet

There is a trigger for 1, called AltTrigger, but this is unused in Blockland, and is not in your controls by default. The function still exists, but is only able to be used for weapons like akimbo guns, which allows you to shoot just the left gun.

Also as a side note, any object ID less than 4100 is a datablock, except for rootGroup (-1), false (0), true (1), and whatever the hell is using the ID 2.

Or you can type trace(1);, call the function naturally (not through console or script, such as jumping to call onTrigger)

It'll show you a list of what it did, in this case it would show

Armor::onTrigger(some number less than 4100, some number over 4100, 2, 1)
This will always return the second arg
then
Armor::onTrigger(some number less than 4100, some number over 4100, 2, 0)
This will always return 0

From this we can see that:
The first one is a datablock.
The second one is an object.
The third one is probably the slot of the trigger.
The forth one is press or release.

To find out what kinds of objects these are, for example, if the first number was 44 and the second one was 157083.
echo(44.getClassName());
This tells you PlayerData. This means that it's a player datablock. Because this is a player datablock function, the next argument will most likely be the player object, but let's check to make sure.
echo(157083.getClassName());
It tells you Player. This means that it is indeed a player object.

This means:
Armor::onTrigger(datablock, object, slot, value)

So then we try to figure out which slot is which.
So we trace again, and press in this order: shoot, jet, and crouch. We already know jump is 2.
Shoot gave us 0, jet gave us 4, and crouch gave us 3.
This means that:
0 = Shoot
2 = Jump
3 = Crouch
4 = Jet

There is a trigger for 1, called AltTrigger, but this is unused in Blockland, and is not in your controls by default. The function still exists, but is only able to be used for weapons like akimbo guns, which allows you to shoot just the left gun.

Also as a side note, any object ID less than 4100 is a datablock, except for rootGroup (-1), false (0), true (1), and whatever the hell is using the ID 2.
Ah, I see.

Unfortunately, no, unless someone already knows or it gives an error when you use it wrongly.

For example, the code "getSubStr();" gives you an error telling you the three variables it uses.


However, you CAN package the unknown function and then cause it to be called.

package getInfo
{
   function Armor::onTrigger(%a, %b, %c, %d, %e, %f, %g, %h, %i, %j)
   {
      %ret = Parent::onTrigger(%a, %b, %c, %d, %e, %f, %g, %h, %i, %j);
      echo("Armor::onTrigger(\""@%a@"\", \""@%b@"\", \""@%c@"\", \""@%d@"\", \""@%e@"\", \""@%f@"\", \""@%g@"\", \""@%h@"\", \""@%i@"\", \""@%j@") returns \""@%ret@"\"");
      if(%ret !$= "")
         return %ret;
   }
};
activatePackage(getInfo);
Alright, I'll try using that.

Has anyone made a list of all of these? If not, is it possible to do that?

Has anyone made a list of all of these? If not, is it possible to do that?
There's no list that I know of right now, but you can just look at other mods for a lot of it if you're not feeling like doing what Chrono just said.

There's a massive list of functions. Figuring them all out would take some time...

But it would be a nice resource.

There's a massive list of functions. Figuring them all out would take some time...

But it would be a nice resource.
There's already a project. I forked it on Github: https://github.com/Zack0Wack0/bldocs
And the latest updated docs are here: http://readthedocs.org/docs/bldocs/en/latest/
I can't be bothered to find the link to the Modification Discussion topic.
The problem is I was one of the only people working on it.

you'll want to do something like this:

 function Armor::onTrigger(%a, %b, %c, %d, %e, %f, %g, %h, %i, %j)
   {
    echo("%a: " @ %a SPC %a.getClassName() );
    echo("%b: " @ %b SPC %b.getClassName() );
    echo("%c: " @ %c SPC %c.getClassName() );
   .... and so on for every argument

    return parent::onTrigger(%a, %b, %c, %d, %e, %f, %g, %h, %i, %j);
   }

some  of them may generate errors, but it will give you a number and a class name for each argument.
then you can use <number>.dump();   at the console to see what the object is.
again - some of these may not always work if the object id has been deleted by the time you start typing.

and then like Chrono said, the first argument %a, will always be an instance of armor:
%a: <number>  Armor