Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Creating custom weapons - VScript: Difference between revisions

From TF2 Classified Wiki
Rei1556 (talk | contribs)
→Table and collector method: Added info about stacking tables, though this could be technical and may need to be cleaned up
 
Line 18: Line 18:
Hooking can be done in two ways, a table and collector (making a table of functions and collecting them) and a direct hook to the game's events. As of writing, the writer here has no idea what the difference is.
Hooking can be done in two ways, a table and collector (making a table of functions and collecting them) and a direct hook to the game's events. As of writing, the writer here has no idea what the difference is.
== Table and collector method ==
== Table and collector method ==
Here's an example table that disables Medic's health regen when he's holding a weapon that has a custom, schema defined attribute.
This is the recommended method to allow other VScript mods to coexist with each other so long as they have uniquely named tables.<br>
Here's an example table that disables Medic's health regen when he's holding a weapon that has a custom, schema defined attribute.<br>
<pre>
<pre>
::AttributeTable <- {
::AttributeTable <- {
Line 64: Line 65:
}
}
</pre>
</pre>
It also doesn't need an attribute class either, since the VScript only uses the attribute's name, so ideally you shouldn't have an attribute class on vscript attributes.
It also doesn't need an attribute class either, since the VScript only uses the attribute's name, so ideally you shouldn't have an attribute class on vscript attributes.<br>
 
In the instance that two scripts do come with their own uniquely named tables that happen to hook on the same GameEvent, assuming multiple scripts are imported that each have their own tables, these tables will be executed in reverse order to the way they were imported, assuming you're using an importer. For example say I have table1 and table2 which both use the same <code>OnGameEvent_</code> and later we run <code>__CollectGameEventCallbacks(Table1)</code> and then <code>__CollectGameEventCallbacks(Table2)</code> after that. Table2 runs first even though the collector function was last. It's unknown ''why'' this happens, but it is something to keep in mind if you need to control the order in which each table is handled (for example you need variables to be changed before a different table starts using them)


== Direct hook method ==
== Direct hook method ==