Page 1 of 1
Can mod Lua read tags?
Posted: 12 Apr 2007, 17:02
by KDR_11k
For most uses of Lua in a mod it would be beneficial to say the least if variables used by the script could be adjusted easily, e.g. if someone implements a mana system to have the mana easily changeable for each unit or for a prerequisite system easily change the prerequisite. Thus I wonder if it's possible to make Lua read tags in the unit fbis? That would be synced Lua, of course. Can it do that kind of stuff?
Posted: 12 Apr 2007, 17:09
by trepan
Yes, it can.
I've previously mentionned that all need be done is to write a lua
TDF parser (not a hard thing to do, lua is pretty good at parsing).
Posted: 12 Apr 2007, 17:22
by imbaczek
Also, see Lua/LuaUnitDefs.cpp in game source. You can access all what's defined there if you do something like this:
Code: Select all
unitDefByName = {}
for k,ud in pairs(UnitDefs) do
unitDefByName[ud.name] = ud
end
-- access here
unitDefByName[unitname goes here].param
-- eg. unitDefByName['Lord'].isBuilder returns true in nanoblobz
Of course there's no need to define that mapping, I do it for convenience.
Posted: 12 Apr 2007, 20:06
by KDR_11k
So it would be possible to make generic modules that implement often demanded features you can just plop into your mod's folders, add the necessary tags to your units and use?
Posted: 12 Apr 2007, 21:02
by imbaczek
Lua unit control bindings would need more love, but basically yes, you could turn this game into supcom.

Posted: 13 Apr 2007, 16:19
by KDR_11k
Or CE, for that matter.