LUA get name function?
Moderator: Moderators
-
razac920
- 2nd Lieutenant

- Posts: 365
- Joined: Sun Jan 16, 2011 12:42 am
LUA get name function?
Is there a way to get the name of an AI character (i.e. Rayce Branigan, Unit 048, Theta 273, TK 421) through a LUA function? Basically whatever replaces "%s" in the "%s killed %s" message? I'd like to have localized messages for all the Imperial troop names, but I don't know which one to show, given the character unit. So is there any LUA functions which input characters and output the name of the character (not the unit class name)? Thanks.
-
fasty
- 1st Lieutenant

- Posts: 438
- Joined: Thu Apr 15, 2010 4:17 am
- Projects :: Server modding
- Contact:
Re: LUA get name function?
The only way is by localizing. Impossible with lua as far as I know.
- Locutus
- 1st Lieutenant

- Posts: 420
- Joined: Fri Jun 04, 2010 10:08 am
- Projects :: Stargate Battlefront Pegasus
- Location: Germany
- Contact:
Re: LUA get name function?
The teamstats.lua seems to use ScriptCB_GetTeamstats(team).
Not sure of that can be of any use, though.
I never looked into it but maybe psych0freds most recent lua release contains a function that fills %s with a string so you can display a chat message saying "XXX was infected!".
Not sure of that can be of any use, though.
I never looked into it but maybe psych0freds most recent lua release contains a function that fills %s with a string so you can display a chat message saying "XXX was infected!".
-
razac920
- 2nd Lieutenant

- Posts: 365
- Joined: Sun Jan 16, 2011 12:42 am
Re: LUA get name function?
Well actually there IS a built-in lua function designed for just that: string.format()
http://lua-users.org/wiki/StringLibraryTutorial
The problem is that for use in, say, ShowMessageText(), you give it a localization key, such as "game.infomsg.killed", and what shows up on the screen is the value "%s killed %s". In LUA you can't actually get the string "%s killed %s" (at least I haven't found any LUA functions that look up the value of a localization key), so you can't edit it directly.
http://lua-users.org/wiki/StringLibraryTutorial
The problem is that for use in, say, ShowMessageText(), you give it a localization key, such as "game.infomsg.killed", and what shows up on the screen is the value "%s killed %s". In LUA you can't actually get the string "%s killed %s" (at least I haven't found any LUA functions that look up the value of a localization key), so you can't edit it directly.
