hedgewars/uScript.pas
changeset 9173 575dd8fe4a55
parent 9171 e72f4f37a444
child 9174 d328fe17b195
equal deleted inserted replaced
9172:72bfa6a3e8e2 9173:575dd8fe4a55
  1286     lc_endgame:= 0
  1286     lc_endgame:= 0
  1287 end;
  1287 end;
  1288 
  1288 
  1289 function lc_sendstat(L : Plua_State) : LongInt; Cdecl;
  1289 function lc_sendstat(L : Plua_State) : LongInt; Cdecl;
  1290 var statInfo : TStatInfoType;
  1290 var statInfo : TStatInfoType;
  1291 begin
  1291 var i : LongInt;
       
  1292 begin
       
  1293 	//TODO print better error messages
  1292 	statInfo := TStatInfoType(GetEnumValue(TypeInfo(TStatInfoType),lua_tostring(L, 1)));
  1294 	statInfo := TStatInfoType(GetEnumValue(TypeInfo(TStatInfoType),lua_tostring(L, 1)));
  1293 	if lua_gettop(L) <> 2 then
  1295 	if (lua_gettop(L) <> 2) and (statInfo <> siPlayerKills) then
  1294         begin
  1296         begin
  1295         LuaError('Lua: Wrong number of parameters passed to SendStat!');
  1297         LuaError('Lua: Wrong number of parameters passed to SendStat!');
  1296         end
  1298         end
  1297     else
  1299     else if (lua_gettop(L) <> 3) and (statInfo = siPlayerKills) then
  1298 		begin
  1300 		begin
  1299 		SendStat(statInfo,lua_tostring(L, 2));
  1301         LuaError('Lua: Wrong number of parameters passed to SendStat!');
       
  1302         end
       
  1303     else
       
  1304 		begin
       
  1305 		if(statInfo = siPlayerKills) then
       
  1306 			begin
       
  1307 			// 3: team name
       
  1308 			for i:= 0 to Pred(TeamsCount) do
       
  1309 				begin
       
  1310 				with TeamsArray[i]^ do
       
  1311 					begin
       
  1312 					if TeamName = lua_tostring(L, 3) then
       
  1313 						SendStat(siPlayerKills, uUtils.IntToStr(Clan^.Color) + ' ' +
       
  1314 							lua_tostring(L, 2) + ' ' + TeamName);
       
  1315 					end;
       
  1316 				end;
       
  1317 			end
       
  1318 		else
       
  1319 			begin
       
  1320 			SendStat(statInfo,lua_tostring(L, 2));
       
  1321 			end;
  1300 		end;
  1322 		end;
  1301     lc_sendstat:= 0
  1323     lc_sendstat:= 0
  1302 end;
  1324 end;
  1303 
  1325 
  1304 function lc_sendstats(L : Plua_State) : LongInt; Cdecl;
  1326 function lc_sendstats(L : Plua_State) : LongInt; Cdecl;