Find out faction of user in UI mod

Everything about mods can be found here.

Moderator: Morax

Find out faction of user in UI mod

Postby Jip » 15 Jul 2016, 15:02

Hello everyone,

As the last part of the mod I want a certain part of the interface to be faction dependant.
As in, for seraphim it will be yellowish, aeon greenish, etc.

However, how do I find out what faction the user is using (the name of the faction, aka: aeon)?

I've been looking through the code of other UI scripts, but I find very few to no references to the faction, yet they change by faction.

Help would be much appreciated.

Lots of love,
Jip
Jip
Avatar-of-War
 
Posts: 51
Joined: 12 Jul 2015, 22:25
Has liked: 3 times
Been liked: 11 times
FAF User Name: Jip

Re: Find out faction of user in UI mod

Postby CookieNoob » 15 Jul 2016, 15:19

I cant test it right now, but it should be more or less like this:
Code: Select all
local armyTable = GetArmiesTable().armiesTable

and then
Code: Select all
armyTable[GetFocusArmy()].faction()
Check out the next level of maps: viewtopic.php?f=53&t=13014
For adaptivity, customizability and less clutter in the vault.
User avatar
CookieNoob
Priest
 
Posts: 477
Joined: 02 Aug 2014, 17:07
Has liked: 65 times
Been liked: 249 times
FAF User Name: CookieNoob

Re: Find out faction of user in UI mod

Postby nine2 » 15 Jul 2016, 16:29

the scores panel shows it, so look in somewhere like lua\game\ui\scores.lua
nine2
Councillor - Promotion
 
Posts: 2416
Joined: 16 Apr 2013, 10:10
Has liked: 285 times
Been liked: 515 times
FAF User Name: Anihilnine

Re: Find out faction of user in UI mod

Postby Jip » 15 Jul 2016, 17:56

@ SirTobi,

Thanks! This does indeed work:

Code: Select all
local armyTable = GetArmiesTable().armiesTable
local faction = armyTable[GetFocusArmy()].faction


Do not add in the () at the end, faction is just a number.

And a simple conversion function:

Code: Select all
local Factions = {'UEF', 'Aeon', 'Cybran', 'Seraphim'};

function ConvertToFaction(factionNumber)
  return Factions[factionNumber + 1];
end


And I get the actual faction name.

@ Anihilnine,

Thanks! I didn't think of it, that indeed shows how it's done.
The same way as SirTobi did it.

Lots of love,
Jip
Jip
Avatar-of-War
 
Posts: 51
Joined: 12 Jul 2015, 22:25
Has liked: 3 times
Been liked: 11 times
FAF User Name: Jip

Re: Find out faction of user in UI mod

Postby CookieNoob » 15 Jul 2016, 18:10

np, glad I could help :)

as I said, it was just a suggestion out of thin air without testing :P
Check out the next level of maps: viewtopic.php?f=53&t=13014
For adaptivity, customizability and less clutter in the vault.
User avatar
CookieNoob
Priest
 
Posts: 477
Joined: 02 Aug 2014, 17:07
Has liked: 65 times
Been liked: 249 times
FAF User Name: CookieNoob

Re: Find out faction of user in UI mod

Postby nine2 » 16 Jul 2016, 10:16

No sweat... generally when making UI mods you need to find an example of where it happens... including base game, faf upgrades and ui mods you can download. Another example I think is in chat it shows the faction logo next to the chat line
nine2
Councillor - Promotion
 
Posts: 2416
Joined: 16 Apr 2013, 10:10
Has liked: 285 times
Been liked: 515 times
FAF User Name: Anihilnine


Return to Mods & Tools

Who is online

Users browsing this forum: No registered users and 1 guest