Page 1 of 1

Accessing category unitdef

Posted: 19 Jan 2014, 13:14
by code_man
Hello

I need to know how to access the "category" field of unitdefs from lua.
The wiki specifies nothing and having tried just "category" brings up an error.

Specifically what i need is to check whetever a certain unit belongs to a category, i dont really know how to do that either once i have the category field as a string.

Re: Accessing category unitdef

Posted: 19 Jan 2014, 13:25
by Silentwings
The wiki tells you on this page http://springrts.com/wiki/Lua_UnitDefs, where the format of the modCategories table is specified. For example:

Code: Select all

UnitDefs[unitDefID].modCategories['ship']
returns true if and only if the unitDefID has category ship.

Re: Accessing category unitdef

Posted: 19 Jan 2014, 13:35
by code_man
Works like a charm, thanks.