Script Hierarchy

Torque3D has a seldom mentioned … or at least, not mentioned enough … hierarchy, and a very important hierarchy at that. Getting it wrong stops stuff from working and won't always give you a warning about it not working (eg: audio does not play).

If you look in "art/datablocks/datablockExec.cs" (the same goes for "art/scripts/server/scriptExec.cs") you'll notice that things are exec'd in order, and there's some comments there to help out. However it really needs a "BIG WARNING SIGN" that failing to group things together in the correct section will lead to failings in-game.

This occurs because a datablock cannot call something that was not declared before itself.

Notice the hierarchy of audio -> particles/FX -> gameObjects(triggers) -> rigid -> item -> staticShape(added by me) -> weapons -> players -> vehicles.

So if you've created a new weapon/ammo it needs execing with the rest of the weapons/ammo.

This hierarchy is mirrored inside actual weapon files, which often contain all necessary data for the weapon (eg: audio, particles, items, projectiles). Failure to observe this hierarchy means failure for the weapon to work. The main issue here can be particles which have a whole host of elements.

//In order!

If you are using elements that are "pooled" or outside of the weaponObject's cs file, you'll still need to respect the hierarchy and have the seperate scripts exec'd in the correct order in "datablockExec.cs", and of course the same goes for "scriptExec.cs".

Not an exact hierarchy per se but unlike a script method a given datablock cannot call for something that wasn't already declared before itself.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License