logging playerlist including bots (half done but bugged)

logging playerlist including bots (half done but bugged)

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

Moderator: Moderators

Post Reply
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

logging playerlist including bots (half done but bugged)

Post by knorke »

I want to log all players in a game with their Allyteam, colors etc. to a textfile.
For human players that works already. For bots it does not.
code so far:
http://pastebin.org/448406

It logs some bots, but not all. Cant see a system to it though.
Compare the "Result:" with the real setup: http://www.abload.de/img/clipboard02md2f.jpg
Ais called "ca_Drei" and "Vier" are missing.

Does not matter if CA's Lua AI "CAI" or Nullai its never quite correct.

I want the real name of the AIs not the ones of their hosters.
If someone can have a look at this that would be cool :)
I do not even know if .dll or Lua AI makes a difference?

Reason I need this is so that Bots can show up in game stats image thingies just like human players:
http://img13.abload.de/img/2v2icyrunkomplettp4ty.jpg
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: logging playerlist including bots (half done but bugged)

Post by zwzsg »

GetPlayerInfo takes a playerID
GetAIInfo takes a teamID
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: logging playerlist including bots (half done but bugged)

Post by AF »

Try looking at the shard stats widget
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: logging playerlist including bots (half done but bugged)

Post by knorke »

zwzsg wrote:GetPlayerInfo takes a playerID
GetAIInfo takes a teamID
Oh. They can both take it up their .. for all I care!
Thanks, will be helpful.
But then this would be incorrect as well?

Code: Select all

for p = 0,31 do
	local name,active,spec,teamID,allyTeamID,pingTime,cpuUsage = Spring_GetPlayerInfo(p)
	if name == nil then
	teamID, skirmishAIID, name, hostingPlayerID, shortName, version = Spring.GetAIInfo(p)
	pingTime,cpuUsage = 100 end
end
Smoth copy&pasted that in lobby from one of his widgets.

It is done like this AdvPlayerlist as well:
http://sl.pastebin.com/JSsqUDxg
line 1813 and 1816
2000 lines for a playerlist Oo
AF wrote:Try looking at the shard stats widget
What file would I find this in, I downloaded Shard.0.29Spikey
game:SendToConsole("OHAI DER")

---
wtf.
Here is the latest version:
http://pastebin.org/449217
It tries to write to whateverfolderspringuses\replaylogs\[somename].txt

function get_playerlist_s () is the problem.
Its called at gamestart but you can retrigger it by typing
openlogfile
getplayerlist
into chat.

I want it to output something like:
[PlayerInfo]name=<[RoX]knorke> playerID=<1> allyTeamID=<0> teamID=<0> spectator=<true> playercolor_r=<248> playercolor_g=<6> playercolor_b=<223>
[PlayerInfo]name=<[Sin]Thogram> playerID=<2> allyTeamID=<0> teamID=<0> spectator=<false> playercolor_r=<248> playercolor_g=<6> playercolor_b=<223>
[PlayerInfo]name=<[SNTT]lfing> playerID=<3> allyTeamID=<0> teamID=<0> spectator=<true> playercolor_r=<248> playercolor_g=<6> playercolor_b=<223>
[PlayerInfo]name=<[CoX]jimjoe> playerID=<4> allyTeamID=<1> teamID=<1> spectator=<false> playercolor_r=<25> playercolor_g=<255> playercolor_b=<0>
But including AIplayers.
Maybe with botplayer=<yes> but I dont care for that.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: logging playerlist including bots (half done but bugged)

Post by AF »

The shard stats widget has its own thread in this forum
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: logging playerlist including bots (half done but bugged)

Post by knorke »

AF: Was that the thing used for the AI kp tourney?
Did not find that thread again but still thanks.

Also many thanks to smoth and zwsg for their efforts.
Seperate loops for
Spring.GetAIInfo(i) and Spring.GetPlayerInfo (i)
solved it. I hope.
slogic
AI Developer
Posts: 626
Joined: 17 Mar 2008, 19:03

Re: logging playerlist including bots (half done but bugged)

Post by slogic »

For me shortName is empty since Spring 0.82RC in the following line:

Code: Select all

teamID, skirmishAIID, name, hostingPlayerID, shortName, version = Spring.GetAIInfo(p)
script.txt does contain ShortName keys. Strange.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: logging playerlist including bots (half done but bugged)

Post by hoijui »

slogic, version is not empty?
they will have default values/be empty if the AI is not local, cause shortName and version are not synced info.
slogic
AI Developer
Posts: 626
Joined: 17 Mar 2008, 19:03

Re: logging playerlist including bots (half done but bugged)

Post by slogic »

Ouch, my wrong. I fixed it. Number of items in return list of GetAIInfo() is reduced by one. Long ago i was surprised that practical result does not correspond what i've read in source code. May be that time source code was from upcoming 0.82.x.

Anyway, i can't tell what exactly was removed currently.
Post Reply

Return to “Lua Scripts”