Getting the army of a unit in lua

Interesting mapping tools and mapping help.

Moderator: Morax

Getting the army of a unit in lua

Postby EntropyWins » 09 Feb 2018, 20:21

When I create a unit with CreateUnitHPR, how can I get the army it belongs to? I'm fine with the army name string such as ARMY_1 or the army index integer.

Been looking for over half an hour now and getting quite frustrated with how obscure the API is :)
EntropyWins
Avatar-of-War
 
Posts: 113
Joined: 02 Oct 2016, 20:26
Has liked: 18 times
Been liked: 4 times
FAF User Name: EntropyWins

Re: Getting the army of a unit in lua

Postby Exotic_Retard » 09 Feb 2018, 20:31

http://supcom.wikia.com/wiki/LUADOC_1.5.3599

Unit:GetArmy() is what i usually end up using, doesnt work on all things, projectiles dont have an army for example. But for units its just fine.

also something something slack something
User avatar
Exotic_Retard
Contributor
 
Posts: 1470
Joined: 21 Mar 2013, 22:51
Has liked: 557 times
Been liked: 626 times
FAF User Name: Exotic_Retard

Re: Getting the army of a unit in lua

Postby EntropyWins » 14 Feb 2018, 20:26

For reference, after not realizing I had made dumb capitalization mistake and writing getArmy instead of GetArmy and spending an hour searching for an alternative, I found that unit:GetAIBrain().Name will give me the army name (ie ARMY_1).
EntropyWins
Avatar-of-War
 
Posts: 113
Joined: 02 Oct 2016, 20:26
Has liked: 18 times
Been liked: 4 times
FAF User Name: EntropyWins


Return to Mapping

Who is online

Users browsing this forum: No registered users and 1 guest