Lua-based equipment

From PioneerWiki
Revision as of 15:13, 1 March 2013 by Laarmen (talk | contribs) (Short C++-side documentation for new-equipment)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

As of March 2013, there's been an ongoing effort for about a year to rewrite the equipment system to be able to define and modify random pieces of equipment through Lua. The resulting system is entirely Lua-based, and communicates with C++ only through string->integers pairs called modifiers.

From the C++ side

If you wish to know if there is an ECM installed on ship, you would just do

int ecm_mod = ship->GetModifier("ecm"); // This gets you the actual value of the modifier, ie the strength of the ECM
if (ecm_mod > 0) {
    BlastAwayThisMissileWithStrength(ecm_mod);
}

As the UI is being ported to new-ui and thus is defined in Lua, you shouldn't need to access the equipment directly. If you need more interaction with the equipment than simple modifiers, as it will probably be the case for lasers (not yet implemented at the time of writing), it might be worth it to write specific Lua interfaces that are to be called by the relevant pieces of equipment at install/uninstall time.