Can mod Lua read tags?

Can mod Lua read tags?

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

Moderator: Moderators

Post Reply
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Can mod Lua read tags?

Post 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?
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post 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).
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Post 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.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post 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?
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Post by imbaczek »

Lua unit control bindings would need more love, but basically yes, you could turn this game into supcom. :P :wink:
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

Or CE, for that matter.
Post Reply

Return to “Lua Scripts”