hedgewars/uScript.pas
changeset 11945 1e58845fa3c1
parent 11944 87edf67f2107
child 11963 0c1420aaa59e
equal deleted inserted replaced
11944:87edf67f2107 11945:1e58845fa3c1
  2602         declareAchievement(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), lua_tointeger(L, 4));
  2602         declareAchievement(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), lua_tointeger(L, 4));
  2603     lc_declareachievement:= 0
  2603     lc_declareachievement:= 0
  2604 end;
  2604 end;
  2605 
  2605 
  2606 function lc_getammoname(L : Plua_state) : LongInt; Cdecl;
  2606 function lc_getammoname(L : Plua_state) : LongInt; Cdecl;
  2607 var at: LongInt;
  2607 var np, at: LongInt;
       
  2608     ignoreOverwrite: Boolean;
  2608 const call = 'GetAmmoName';
  2609 const call = 'GetAmmoName';
  2609       params = 'ammoType';
  2610       params = 'ammoType [, ignoreOverwrite ]';
  2610 begin
  2611 begin
  2611     if CheckLuaParamCount(L, 1, call, params) then
  2612     if CheckAndFetchParamCountRange(L, 1, 2, call, params, np) then
  2612         begin
  2613         begin
  2613         at:= LuaToAmmoTypeOrd(L, 1, call, params);                                                                                                   
  2614         at:= LuaToAmmoTypeOrd(L, 1, call, params);                                                                                                   
       
  2615         ignoreOverwrite := false;
       
  2616         if np > 1 then
       
  2617             ignoreOverwrite := lua_toboolean(L, 2);
  2614         if at >= 0 then   
  2618         if at >= 0 then   
  2615             if length(trluaammo[Ammoz[TAmmoType(at)].NameId]) > 0 then
  2619             if (not ignoreOverwrite) and (length(trluaammo[Ammoz[TAmmoType(at)].NameId]) > 0) then
  2616                 lua_pushstring(L, PChar(trluaammo[Ammoz[TAmmoType(at)].NameId]))
  2620                 lua_pushstring(L, PChar(trluaammo[Ammoz[TAmmoType(at)].NameId]))
  2617             else
  2621             else
  2618                 lua_pushstring(L, PChar(trammo[Ammoz[TAmmoType(at)].NameId]));
  2622                 lua_pushstring(L, PChar(trammo[Ammoz[TAmmoType(at)].NameId]));
  2619         end
  2623         end
  2620     else
  2624     else