# HG changeset patch # User Wuzzy # Date 1479590228 -3600 # Node ID 1e58845fa3c1b5d7dde313aad9129ba7bd5f0601 # Parent 87edf67f21070a7d393be7614ea54356bb63e241 Allow to ignore overwritten ammo name in GetAmmoName diff -r 87edf67f2107 -r 1e58845fa3c1 ChangeLog.txt --- a/ChangeLog.txt Sat Nov 19 22:00:23 2016 +0100 +++ b/ChangeLog.txt Sat Nov 19 22:17:08 2016 +0100 @@ -77,7 +77,7 @@ Lua-API: + New call: SetCinematicMode(enable) -- e.g. for cutscenes etc. - + New call: GetAmmoName(ammoType) -- returns the localized name for the specified ammoType + + New call: GetAmmoName(ammoType [, ignoreOverwrite]) -- returns the localized name for the specified ammoType + New call: GetVisualGearType(vgUid) -- returns the visual gear type + New call: SetAmmoTexts(ammoType, name, caption, description) -- Overwrite displayed name and description of an ammo type + New call: SetAmmoDescriptionAppendix(ammoType, descAppend) -- Append a custom text to the description of an ammo type without overwriting it diff -r 87edf67f2107 -r 1e58845fa3c1 hedgewars/uScript.pas --- a/hedgewars/uScript.pas Sat Nov 19 22:00:23 2016 +0100 +++ b/hedgewars/uScript.pas Sat Nov 19 22:17:08 2016 +0100 @@ -2604,15 +2604,19 @@ end; function lc_getammoname(L : Plua_state) : LongInt; Cdecl; -var at: LongInt; +var np, at: LongInt; + ignoreOverwrite: Boolean; const call = 'GetAmmoName'; - params = 'ammoType'; + params = 'ammoType [, ignoreOverwrite ]'; begin - if CheckLuaParamCount(L, 1, call, params) then + if CheckAndFetchParamCountRange(L, 1, 2, call, params, np) then begin at:= LuaToAmmoTypeOrd(L, 1, call, params); + ignoreOverwrite := false; + if np > 1 then + ignoreOverwrite := lua_toboolean(L, 2); if at >= 0 then - if length(trluaammo[Ammoz[TAmmoType(at)].NameId]) > 0 then + if (not ignoreOverwrite) and (length(trluaammo[Ammoz[TAmmoType(at)].NameId]) > 0) then lua_pushstring(L, PChar(trluaammo[Ammoz[TAmmoType(at)].NameId])) else lua_pushstring(L, PChar(trammo[Ammoz[TAmmoType(at)].NameId]));