hedgewars/uScript.pas
changeset 13018 0248cf0da834
parent 12947 c8b7bc04eb4c
child 13020 d1e7f2420f00
equal deleted inserted replaced
13017:e2e40700c5cf 13018:0248cf0da834
  2104         //lua_pushnumber(L, LongInt(CurrentTeam));
  2104         //lua_pushnumber(L, LongInt(CurrentTeam));
  2105         end;
  2105         end;
  2106     //else
  2106     //else
  2107         //lua_pushnil(L)
  2107         //lua_pushnil(L)
  2108     lc_addteam:= 0;//1;
  2108     lc_addteam:= 0;//1;
       
  2109 end;
       
  2110 
       
  2111 function lc_setteamlabel(L : Plua_State) : LongInt; Cdecl;
       
  2112 var teamValue: ansistring;
       
  2113     i, n: LongInt;
       
  2114     success: boolean;
       
  2115 begin
       
  2116     if CheckAndFetchParamCount(L, 1, 2, 'SetTeamLabel', 'teamname[, label]', n) then
       
  2117         begin
       
  2118         success:= false;
       
  2119         // fetch team
       
  2120         if TeamsCount > 0 then
       
  2121             for i:= 0 to Pred(TeamsCount) do
       
  2122                 begin
       
  2123                 // skip teams that don't have matching name
       
  2124                 if TeamsArray[i]^.TeamName <> lua_tostring(L, 1) then
       
  2125                     continue;
       
  2126 
       
  2127                 // value of type nil? Then let's clear the team value
       
  2128                 if (n < 2) or lua_isnil(L, 2) then
       
  2129                     begin
       
  2130                     FreeAndNilTexture(TeamsArray[i]^.LuaTeamValueTex);
       
  2131                     TeamsArray[i]^.hasLuaTeamValue:= false;
       
  2132                     success:= true;
       
  2133                     end
       
  2134                 // value of type string? Then let's set the team value
       
  2135                 else if (lua_isstring(L, 2)) then
       
  2136                     begin
       
  2137                     teamValue:= lua_tostring(L, 2);
       
  2138                     TeamsArray[i]^.LuaTeamValue:= teamValue;
       
  2139                     FreeAndNilTexture(TeamsArray[i]^.LuaTeamValueTex);
       
  2140                     TeamsArray[i]^.LuaTeamValueTex := RenderStringTex(teamValue, TeamsArray[i]^.Clan^.Color, fnt16);
       
  2141                     TeamsArray[i]^.hasLuaTeamValue:= true;
       
  2142                     success:= true;
       
  2143                     end;
       
  2144                 // don't change more than one team
       
  2145                 break;
       
  2146                 end;
       
  2147         end;
       
  2148     // return true if operation was successful, false otherwise
       
  2149     lua_pushboolean(L, success);
       
  2150     lc_setteamlabel:= 1;
  2109 end;
  2151 end;
  2110 
  2152 
  2111 function lc_getteamname(L : Plua_State) : LongInt; Cdecl;
  2153 function lc_getteamname(L : Plua_State) : LongInt; Cdecl;
  2112 var t: LongInt;
  2154 var t: LongInt;
  2113 begin
  2155 begin
  3710 lua_register(luaState, _P'SetAmmo', @lc_setammo);
  3752 lua_register(luaState, _P'SetAmmo', @lc_setammo);
  3711 lua_register(luaState, _P'SetAmmoDelay', @lc_setammodelay);
  3753 lua_register(luaState, _P'SetAmmoDelay', @lc_setammodelay);
  3712 lua_register(luaState, _P'PlaySound', @lc_playsound);
  3754 lua_register(luaState, _P'PlaySound', @lc_playsound);
  3713 lua_register(luaState, _P'GetTeamName', @lc_getteamname);
  3755 lua_register(luaState, _P'GetTeamName', @lc_getteamname);
  3714 lua_register(luaState, _P'AddTeam', @lc_addteam);
  3756 lua_register(luaState, _P'AddTeam', @lc_addteam);
       
  3757 lua_register(luaState, _P'SetTeamLabel', @lc_setteamlabel);
  3715 lua_register(luaState, _P'AddHog', @lc_addhog);
  3758 lua_register(luaState, _P'AddHog', @lc_addhog);
  3716 lua_register(luaState, _P'AddAmmo', @lc_addammo);
  3759 lua_register(luaState, _P'AddAmmo', @lc_addammo);
  3717 lua_register(luaState, _P'GetAmmoCount', @lc_getammocount);
  3760 lua_register(luaState, _P'GetAmmoCount', @lc_getammocount);
  3718 lua_register(luaState, _P'HealHog', @lc_healhog);
  3761 lua_register(luaState, _P'HealHog', @lc_healhog);
  3719 lua_register(luaState, _P'SetHealth', @lc_sethealth);
  3762 lua_register(luaState, _P'SetHealth', @lc_sethealth);