GetPlayerRoster() does not return AIs. Should it?

GetPlayerRoster() does not return AIs. Should it?

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

Moderator: Moderators

Post Reply
slogic
AI Developer
Posts: 626
Joined: 17 Mar 2008, 19:03

GetPlayerRoster() does not return AIs. Should it?

Post by slogic »

LolUI uses Spring.GetPlayerRoster() to get playerlist, while AdvPlayerList uses less convenient Spring.GetPlayerList(). The first one returns no AI players. Is it a bug? I miss AI players in LolUI & have to activate Advanced Player List widget.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: GetPlayerRoster() does not return AIs. Should it?

Post by zwzsg »

Would be nice if there was a way for widgets such as AdvPlayerList to get the names of the AI.
slogic
AI Developer
Posts: 626
Joined: 17 Mar 2008, 19:03

Re: GetPlayerRoster() does not return AIs. Should it?

Post by slogic »

I was thinking about it too. If Lua can't reach "ShortName" tag in [AIx] section of script.txt, then it is lobby developers who must put AI library name into "Name" key (e.g. in brackets), so there will be no need to adjust Lua widgets.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: GetPlayerRoster() does not return AIs. Should it?

Post by Argh »

Can't the contents of the script be caught and parsed at game-start?
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: GetPlayerRoster() does not return AIs. Should it?

Post by hoijui »

i had a look at the code, and it looks like the PlayerRoster class is only used for visualizing stuff, as in.. if we change what it contains, it would not break anything, just show different stuff here and there, so it should be safe to add AIs there. Don't know how big of a change it would be.

no part of the game should put the AI library/short-name into anything that is as easily visible as the player list though.
If you really need it there, then add it to Name yourself when you start the game in the lobby, or when you generate the start script.
there are enough ways already to get short-name, you could eg press B ingame, or use /debuginfo profiling, or /ailist.
slogic
AI Developer
Posts: 626
Joined: 17 Mar 2008, 19:03

Re: GetPlayerRoster() does not return AIs. Should it?

Post by slogic »

hoijui, thank you!

As we concerned getting short name of AI i have one more question to precise your answer. /ailist & other methods you specify are built-in engine methods. Does Lua has direct access to Short Name? Or Lua scripter has to grab & parse output of the executed commands provided above?
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: GetPlayerRoster() does not return AIs. Should it?

Post by hoijui »

Code: Select all

int LuaSyncedRead::GetAIInfo(lua_State* L)
in rts/Lua/LuaSyncedRead.cpp
best is if you look at the code, cause it is not documented anywhere else. The shortName, version and options of the AI can be fetched this way, but only for local AIs, as this is unsynced data, which only the spring they run on has access to.

edit: i just see, this code seems to have a bug or two :D
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: GetPlayerRoster() does not return AIs. Should it?

Post by zwzsg »

hoijui wrote:no part of the game should put the AI library/short-name into anything that is as easily visible as the player list though.
Why?

I just would like to be able to write a modified AdvPlayerList widget that tells which AI it is running instead of calling every AI by the same "AI-Bot" name.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: GetPlayerRoster() does not return AIs. Should it?

Post by hoijui »

because not all players woudl see the same thing there then, and you just said that you want a polished game. that is not something i'd call polished, if i see some internal naming on a GUI thats always visible.
it would be ok in my eyes, if it was in a tooltip, but for things like missions and stuff, you want a custom name there, like "the barbarian hordes of the east", and not "KAIK".
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: GetPlayerRoster() does not return AIs. Should it?

Post by zwzsg »

Ok, I can understand how letting any code redefine the language and libraries is bad. I don't see how this is related to the topic at hand however.

hoijui wrote:because not all players woudl see the same thing there then
Since I assume AI are mostly used in single player, showing their name in single player but not in multiplayer would already be interesting.
hoijui wrote:and you just said that you want a polished game. that is not something i'd call polished
Yes, I want a polished game, but going toward it incrementally. Which is just my excuse to request polish from others when it suits me and write dirty code myself when it suits me.
hoijui wrote:if i see some internal naming on a GUI thats always visible.
I don't mean the hard coded player list. I mean widgets player list.
hoijui wrote:but for things like missions and stuff, you want a custom name there, like "the barbarian hordes of the east", and not "KAIK".
Yeah. But it'd be nice if I could have a widget showing the AI names no matter who created the startscript. That doesn't preclude using a better name when the widget can find a better name through custom tags.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: GetPlayerRoster() does not return AIs. Should it?

Post by hoijui »

i can understand you, also i for one, would alwyas like to se the AI shortName of course, casue i ma usually testing, and i know them a lot, and i would like to see which color is which AI lib right away.
but for users it is much better if name is the primary thing thats shown, as they set it themselfs in the lobby. thye might set it to KAIK 1, or to MyAllyKAIK, or to MyAlly, and when the game starts, they will see only "KAIK" there, or "KAIK 1 (KAIK)". I and others got lots of requests to make the name show up in player lists, and not the shortName.
not to say you can not use that, but that users want the name as the primary thing.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: GetPlayerRoster() does not return AIs. Should it?

Post by zwzsg »

Well, your upcoming Lua command will return both, widget makers will then be free to use one or another or both, and player be free to choose one widget or another, or to bug widget makers into showing one or another or both.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: GetPlayerRoster() does not return AIs. Should it?

Post by AF »

Actually I was just making people aware of the concept/notion of monkey patching
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: GetPlayerRoster() does not return AIs. Should it?

Post by zwzsg »

AF: :roll: Still totally irrelevant to this thread.



Anyway, Hoijui coded some nice thing:

Code: Select all

Spring.GetAIInfo
 ( number teamID ) -> 
   nil | number  teamID,
         number  skirmishAIID,
         string  name,
         number  hostingPlayerID,
         string  shortName, (synced => "SYNCED_NOSHORTNAME"; non-local => "UNKNOWN")
         string  version,   (synced => "SYNCED_NOVERSION";   non-local => "UNKNOWN")
         table   options    (synced & non-local => empty-table)
And it actually works: startscript, widget, result.

(as long as you don't assign to a C++ AI any other version than the ones it has.
(Omitting the version field in startscript works and is safer)).
Post Reply

Return to “Lua Scripts”