hedgewars/uScript.pas
changeset 9176 c21c88dca14c
parent 9174 d328fe17b195
child 9177 d5e98b81e135
equal deleted inserted replaced
9175:dc3c0e44f7f3 9176:c21c88dca14c
  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 var i : LongInt;
  1291 var i : LongInt;
       
  1292 var color : shortstring;
  1292 begin
  1293 begin
  1293 	//TODO print better error messages
  1294 	//TODO print better error messages
  1294 	statInfo := TStatInfoType(GetEnumValue(TypeInfo(TStatInfoType),lua_tostring(L, 1)));
  1295 	statInfo := TStatInfoType(GetEnumValue(TypeInfo(TStatInfoType),lua_tostring(L, 1)));
  1295 	if (lua_gettop(L) <> 2) and (statInfo <> siPlayerKills) then
  1296 	if (lua_gettop(L) <> 2) and ((statInfo <> siPlayerKills) 
       
  1297 			or (statInfo <> siClanHealth)) then
  1296         begin
  1298         begin
  1297         LuaError('Lua: Wrong number of parameters passed to SendStat!');
  1299         LuaError('Lua: Wrong number of parameters passed to SendStat!');
  1298         end
  1300         end
  1299     else if (lua_gettop(L) <> 3) and (statInfo = siPlayerKills) then
  1301     else if (lua_gettop(L) <> 3) and ((statInfo = siPlayerKills) 
       
  1302 			or (statInfo = siClanHealth)) then
  1300 		begin
  1303 		begin
  1301         LuaError('Lua: Wrong number of parameters passed to SendStat!');
  1304         LuaError('Lua: Wrong number of parameters passed to SendStat!');
  1302         end
  1305         end
  1303     else
  1306     else
  1304 		begin
  1307 		begin
  1305 		if(statInfo = siPlayerKills) then
  1308 		if ((statInfo = siPlayerKills) or (statInfo = siClanHealth)) then
  1306 			begin
  1309 			begin
  1307 			// 3: team name
  1310 			// 3: team name
  1308 			for i:= 0 to Pred(TeamsCount) do
  1311 			for i:= 0 to Pred(TeamsCount) do
  1309 				begin
  1312 				begin
  1310 				with TeamsArray[i]^ do
  1313 				with TeamsArray[i]^ do
  1311 					begin
  1314 					begin
  1312 					if TeamName = lua_tostring(L, 3) then
  1315 						if TeamName = lua_tostring(L, 3) then
  1313 						SendStat(siPlayerKills, uUtils.IntToStr(Clan^.Color) + ' ' +
  1316 							begin
  1314 							lua_tostring(L, 2) + ' ' + TeamName);
  1317 							color := uUtils.IntToStr(Clan^.Color);
  1315 					end;
  1318 							Break;
       
  1319 							end
       
  1320 					end				
  1316 				end;
  1321 				end;
       
  1322 			if (statInfo = siPlayerKills) then
       
  1323 				begin
       
  1324 					SendStat(siPlayerKills, color + ' ' +
       
  1325 						lua_tostring(L, 2) + ' ' + TeamsArray[i]^.TeamName);
       
  1326 				end
       
  1327 			else if (statInfo = siClanHealth) then
       
  1328 				begin
       
  1329 					SendStat(siClanHealth, color + ' ' +
       
  1330 						lua_tostring(L, 2));
       
  1331 				end
  1317 			end
  1332 			end
  1318 		else
  1333 		else
  1319 			begin
  1334 			begin
  1320 			SendStat(statInfo,lua_tostring(L, 2));
  1335 			SendStat(statInfo,lua_tostring(L, 2));
  1321 			end;
  1336 			end;