# HG changeset patch # User Periklis Ntanasis # Date 1370478959 -10800 # Node ID 575dd8fe4a55557609d439ab724e147072a36535 # Parent 72bfa6a3e8e200531d5e3debe0274da748fd97d7 LuaAPI sendstat finds correct clan colors by team names on siPlayerKills diff -r 72bfa6a3e8e2 -r 575dd8fe4a55 hedgewars/uScript.pas --- a/hedgewars/uScript.pas Tue Jun 04 00:10:48 2013 +0300 +++ b/hedgewars/uScript.pas Thu Jun 06 03:35:59 2013 +0300 @@ -1288,15 +1288,37 @@ function lc_sendstat(L : Plua_State) : LongInt; Cdecl; var statInfo : TStatInfoType; +var i : LongInt; begin + //TODO print better error messages statInfo := TStatInfoType(GetEnumValue(TypeInfo(TStatInfoType),lua_tostring(L, 1))); - if lua_gettop(L) <> 2 then + if (lua_gettop(L) <> 2) and (statInfo <> siPlayerKills) then begin LuaError('Lua: Wrong number of parameters passed to SendStat!'); end + else if (lua_gettop(L) <> 3) and (statInfo = siPlayerKills) then + begin + LuaError('Lua: Wrong number of parameters passed to SendStat!'); + end else begin - SendStat(statInfo,lua_tostring(L, 2)); + if(statInfo = siPlayerKills) then + begin + // 3: team name + for i:= 0 to Pred(TeamsCount) do + begin + with TeamsArray[i]^ do + begin + if TeamName = lua_tostring(L, 3) then + SendStat(siPlayerKills, uUtils.IntToStr(Clan^.Color) + ' ' + + lua_tostring(L, 2) + ' ' + TeamName); + end; + end; + end + else + begin + SendStat(statInfo,lua_tostring(L, 2)); + end; end; lc_sendstat:= 0 end;