hedgewars/uScript.pas
changeset 13373 0a93948e8ec7
parent 13371 da913fc1d350
child 13378 c53530142442
equal deleted inserted replaced
13372:57e15407804d 13373:0a93948e8ec7
  2977 end;
  2977 end;
  2978 
  2978 
  2979 function lc_getammotimer(L : Plua_state) : LongInt; Cdecl;
  2979 function lc_getammotimer(L : Plua_state) : LongInt; Cdecl;
  2980 var at: LongInt;
  2980 var at: LongInt;
  2981     weapon: PAmmo;
  2981     weapon: PAmmo;
       
  2982     gear: PGear;
  2982 const call = 'GetAmmoTimer';
  2983 const call = 'GetAmmoTimer';
  2983       params = 'ammoType, gearUid';
  2984       params = 'gearUid, ammoType';
  2984 begin
  2985 begin
  2985     if CheckLuaParamCount(L, 2, call, params) then
  2986     if CheckLuaParamCount(L, 2, call, params) then
  2986         begin
  2987         begin
  2987         at:= LuaToAmmoTypeOrd(L, 1, call, params);
  2988         gear:= GearByUID(Trunc(lua_tonumber(L, 1)));
  2988         weapon:= GetAmmoEntry(CurrentHedgehog^, TAmmoType(at));
  2989         if (gear <> nil) and (gear^.Hedgehog <> nil) then
  2989         if (Ammoz[TAmmoType(at)].Ammo.Propz and ammoprop_Timerable) <> 0 then
  2990             begin
  2990             lua_pushnumber(L, weapon^.Timer)
  2991             at:= LuaToAmmoTypeOrd(L, 2, call, params);
       
  2992             weapon:= GetAmmoEntry(gear^.Hedgehog^, TAmmoType(at));
       
  2993             if (Ammoz[TAmmoType(at)].Ammo.Propz and ammoprop_Timerable) <> 0 then
       
  2994                 lua_pushnumber(L, weapon^.Timer)
       
  2995             else
       
  2996                 lua_pushnil(L);
       
  2997             end
  2991         else
  2998         else
  2992             lua_pushnil(L);
  2999             lua_pushnil(L);
  2993         end
  3000         end
  2994     else
  3001     else
  2995         lua_pushnil(L);
  3002         lua_pushnil(L);