No TDF parser required

No TDF parser required

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

No TDF parser required

Post by trepan »

I've added the [CustomParams] section to FBI files.
To access the parameters from lua, you can use:
UnitDefs[unitDefID].customParams (a normal table).

All keys and values in the UnitDefs[].customParams
table are strings. You'll have to do your own string to
number (or bool) conversion in lua.

Note that this info is available to AIs using:
AICallback::GetUnitDef(unitID)->customParams
[const std::map<std::string, std::string>]

ex: (in unit.fbi)

Code: Select all

[UNITINFO]
{
  ...
  ...
  ...
  [CustomParams]
  {
    can_dance=1;

    // LuaRules/Gadgets/unit_morph.lua parameters
    morph_to=armdecom; 
    morph_time=20;
    morph_metal=1000;
    morph_energy=5000;

    // LuaRules/Gadgets/unit_factory.lua parameters
    fac_power=200;
    fac_build0=armmav;
    fac_build1=armack;
    fac_build2=armwar;
  }
}
P.S. I used the '_' char as a breaker because the TDF
parser converts all keys to lower case, and it's readable.
Post Reply

Return to “Lua Scripts”