hedgewars/uScript.pas
branchwebgl
changeset 9244 bb95e351270c
parent 9240 3a6608ae0a5e
child 9264 21df1a0ec9ed
equal deleted inserted replaced
9242:c07f341adad9 9244:bb95e351270c
    82     uTextures,
    82     uTextures,
    83     uLandGraphics,
    83     uLandGraphics,
    84     SDLh,
    84     SDLh,
    85     SysUtils,
    85     SysUtils,
    86     uIO,
    86     uIO,
    87     uPhysFSLayer,
    87     uPhysFSLayer
    88     typinfo
       
    89     ;
    88     ;
    90 
    89 
    91 var luaState : Plua_State;
    90 var luaState : Plua_State;
    92     ScriptAmmoLoadout : shortstring;
    91     ScriptAmmoLoadout : shortstring;
    93     ScriptAmmoProbability : shortstring;
    92     ScriptAmmoProbability : shortstring;
  1290 function lc_sendstat(L : Plua_State) : LongInt; Cdecl;
  1289 function lc_sendstat(L : Plua_State) : LongInt; Cdecl;
  1291 var statInfo : TStatInfoType;
  1290 var statInfo : TStatInfoType;
  1292 var i : LongInt;
  1291 var i : LongInt;
  1293 var color : shortstring;
  1292 var color : shortstring;
  1294 begin
  1293 begin
  1295 	statInfo := TStatInfoType(lua_tostring(L, 1));
  1294     statInfo := TStatInfoType(lua_tointeger(L, 1));
  1296 	if (lua_gettop(L) <> 2) and ((statInfo <> siPlayerKills) 
  1295     if (lua_gettop(L) <> 2) and ((statInfo <> siPlayerKills)
  1297 			and (statInfo <> siClanHealth)) then
  1296             and (statInfo <> siClanHealth)) then
  1298         begin
  1297         begin
  1299         LuaError('Lua: Wrong number of parameters passed to SendStat! Expected 2 parameters.');
  1298         LuaError('Lua: Wrong number of parameters passed to SendStat! Expected 2 parameters.');
  1300         end
  1299         end
  1301     else if (lua_gettop(L) <> 3) and ((statInfo = siPlayerKills) 
  1300     else if (lua_gettop(L) <> 3) and ((statInfo = siPlayerKills)
  1302 			or (statInfo = siClanHealth)) then
  1301             or (statInfo = siClanHealth)) then
  1303 		begin
  1302         begin
  1304         LuaError('Lua: Wrong number of parameters passed to SendStat! Expected 3 parameters.');
  1303         LuaError('Lua: Wrong number of parameters passed to SendStat! Expected 3 parameters.');
  1305         end
  1304         end
  1306     else
  1305     else
  1307 		begin
  1306         begin
  1308 		if ((statInfo = siPlayerKills) or (statInfo = siClanHealth)) then
  1307         if ((statInfo = siPlayerKills) or (statInfo = siClanHealth)) then
  1309 			begin
  1308             begin
  1310 			// 3: team name
  1309             // 3: team name
  1311 			for i:= 0 to Pred(TeamsCount) do
  1310             for i:= 0 to Pred(TeamsCount) do
  1312 				begin
  1311                 begin
  1313 				with TeamsArray[i]^ do
  1312                 with TeamsArray[i]^ do
  1314 					begin
  1313                     begin
  1315 						if TeamName = lua_tostring(L, 3) then
  1314                         if TeamName = lua_tostring(L, 3) then
  1316 							begin
  1315                             begin
  1317 							color := uUtils.IntToStr(Clan^.Color);
  1316                             color := uUtils.IntToStr(Clan^.Color);
  1318 							Break;
  1317                             Break;
  1319 							end
  1318                             end
  1320 					end				
  1319                     end
  1321 				end;
  1320                 end;
  1322 			if (statInfo = siPlayerKills) then
  1321             if (statInfo = siPlayerKills) then
  1323 				begin
  1322                 begin
  1324 					SendStat(siPlayerKills, color + ' ' +
  1323                     SendStat(siPlayerKills, color + ' ' +
  1325 						lua_tostring(L, 2) + ' ' + TeamsArray[i]^.TeamName);
  1324                         lua_tostring(L, 2) + ' ' + TeamsArray[i]^.TeamName);
  1326 				end
  1325                 end
  1327 			else if (statInfo = siClanHealth) then
  1326             else if (statInfo = siClanHealth) then
  1328 				begin
  1327                 begin
  1329 					SendStat(siClanHealth, color + ' ' +
  1328                     SendStat(siClanHealth, color + ' ' +
  1330 						lua_tostring(L, 2));
  1329                         lua_tostring(L, 2));
  1331 				end
  1330                 end
  1332 			end
  1331             end
  1333 		else
  1332         else
  1334 			begin
  1333             begin
  1335 			SendStat(statInfo,lua_tostring(L, 2));
  1334             SendStat(statInfo,lua_tostring(L, 2));
  1336 			end;
  1335             end;
  1337 		end;
  1336         end;
  1338     lc_sendstat:= 0
  1337     lc_sendstat:= 0
  1339 end;
  1338 end;
  1340 
  1339 
  1341 function lc_sendhealthstatsoff(L : Plua_State) : LongInt; Cdecl;
  1340 function lc_sendhealthstatsoff(L : Plua_State) : LongInt; Cdecl;
  1342 begin
  1341 begin