hedgewars/uScript.pas
changeset 13020 d1e7f2420f00
parent 13018 0248cf0da834
child 13036 434bcdd9562c
equal deleted inserted replaced
13019:880662cf41ee 13020:d1e7f2420f00
  2162             lua_pushstring(L, str2pchar(TeamsArray[t]^.TeamName));
  2162             lua_pushstring(L, str2pchar(TeamsArray[t]^.TeamName));
  2163         end
  2163         end
  2164     else
  2164     else
  2165         lua_pushnil(L);
  2165         lua_pushnil(L);
  2166     lc_getteamname:= 1;
  2166     lc_getteamname:= 1;
       
  2167 end;
       
  2168 
       
  2169 function lc_getteamindex(L : Plua_state) : LongInt; Cdecl;
       
  2170 var i: LongInt;
       
  2171     found: boolean;
       
  2172 begin
       
  2173     found:= false;
       
  2174     if CheckLuaParamCount(L, 1, 'GetTeamIndex', 'teamname') then
       
  2175         if TeamsCount > 0 then
       
  2176             for i:= 0 to Pred(TeamsCount) do
       
  2177                 begin
       
  2178                 // skip teams that don't have matching name
       
  2179                 if TeamsArray[i]^.TeamName <> lua_tostring(L, 1) then
       
  2180                     continue;
       
  2181                 lua_pushnumber(L, i);
       
  2182                 found:= true;
       
  2183                 break;
       
  2184                 end;
       
  2185     if (not found) then
       
  2186         lua_pushnil(L);
       
  2187     lc_getteamindex:= 1;
       
  2188 end;
       
  2189 
       
  2190 function lc_getteamclan(L : Plua_state) : LongInt; Cdecl;
       
  2191 var i: LongInt;
       
  2192     found: boolean;
       
  2193 begin
       
  2194     found:= false;
       
  2195     if CheckLuaParamCount(L, 1, 'GetTeamClan', 'teamname') then
       
  2196         if TeamsCount > 0 then
       
  2197             for i:= 0 to Pred(TeamsCount) do
       
  2198                 begin
       
  2199                 // skip teams that don't have matching name
       
  2200                 if TeamsArray[i]^.TeamName <> lua_tostring(L, 1) then
       
  2201                     continue;
       
  2202                 lua_pushnumber(L, TeamsArray[i]^.Clan^.ClanIndex);
       
  2203                 found:= true;
       
  2204                 break;
       
  2205                 end;
       
  2206     if (not found) then
       
  2207         lua_pushnil(L);
       
  2208     lc_getteamclan:= 1;
  2167 end;
  2209 end;
  2168 
  2210 
  2169 function lc_dismissteam(L : Plua_State) : LongInt; Cdecl;
  2211 function lc_dismissteam(L : Plua_State) : LongInt; Cdecl;
  2170 var HHGear: PGear;
  2212 var HHGear: PGear;
  2171     i, h  : LongInt;
  2213     i, h  : LongInt;
  3751 lua_register(luaState, _P'AddCaption', @lc_addcaption);
  3793 lua_register(luaState, _P'AddCaption', @lc_addcaption);
  3752 lua_register(luaState, _P'SetAmmo', @lc_setammo);
  3794 lua_register(luaState, _P'SetAmmo', @lc_setammo);
  3753 lua_register(luaState, _P'SetAmmoDelay', @lc_setammodelay);
  3795 lua_register(luaState, _P'SetAmmoDelay', @lc_setammodelay);
  3754 lua_register(luaState, _P'PlaySound', @lc_playsound);
  3796 lua_register(luaState, _P'PlaySound', @lc_playsound);
  3755 lua_register(luaState, _P'GetTeamName', @lc_getteamname);
  3797 lua_register(luaState, _P'GetTeamName', @lc_getteamname);
       
  3798 lua_register(luaState, _P'GetTeamIndex', @lc_getteamindex);
       
  3799 lua_register(luaState, _P'GetTeamClan', @lc_getteamclan);
  3756 lua_register(luaState, _P'AddTeam', @lc_addteam);
  3800 lua_register(luaState, _P'AddTeam', @lc_addteam);
  3757 lua_register(luaState, _P'SetTeamLabel', @lc_setteamlabel);
  3801 lua_register(luaState, _P'SetTeamLabel', @lc_setteamlabel);
  3758 lua_register(luaState, _P'AddHog', @lc_addhog);
  3802 lua_register(luaState, _P'AddHog', @lc_addhog);
  3759 lua_register(luaState, _P'AddAmmo', @lc_addammo);
  3803 lua_register(luaState, _P'AddAmmo', @lc_addammo);
  3760 lua_register(luaState, _P'GetAmmoCount', @lc_getammocount);
  3804 lua_register(luaState, _P'GetAmmoCount', @lc_getammocount);