# HG changeset patch # User Wuzzy # Date 1525377925 -7200 # Node ID da913fc1d3508fd5de2a7157f884588ec2231070 # Parent e202d58236b1bf6b076a5c2e92b9f094a2f8eab2 Lua API: GetAmmoTimer, to get the player-set timer for an ammo diff -r e202d58236b1 -r da913fc1d350 ChangeLog.txt --- a/ChangeLog.txt Thu May 03 21:40:13 2018 +0200 +++ b/ChangeLog.txt Thu May 03 22:05:25 2018 +0200 @@ -23,6 +23,7 @@ Lua API: + New call: Retreat(time [, respectGetAwayTimeFactor): Force current turn into retreating mode + + New call: GetAmmoTimer(ammoType, gearUid): Returns current set timer for given ammoType and hog gear in ms. Returns nil for non-timerable ammo + New parameter: SetAmmoTexts: 5th param. showExtra: Set to false to hide texts like “Not yet available” * Fix hog being unable to walk after using sniper rifle without firing both shots diff -r e202d58236b1 -r da913fc1d350 hedgewars/uScript.pas --- a/hedgewars/uScript.pas Thu May 03 21:40:13 2018 +0200 +++ b/hedgewars/uScript.pas Thu May 03 22:05:25 2018 +0200 @@ -2976,6 +2976,26 @@ lc_getammoname:= 1; end; +function lc_getammotimer(L : Plua_state) : LongInt; Cdecl; +var at: LongInt; + weapon: PAmmo; +const call = 'GetAmmoTimer'; + params = 'ammoType, gearUid'; +begin + if CheckLuaParamCount(L, 2, call, params) then + begin + at:= LuaToAmmoTypeOrd(L, 1, call, params); + weapon:= GetAmmoEntry(CurrentHedgehog^, TAmmoType(at)); + if (Ammoz[TAmmoType(at)].Ammo.Propz and ammoprop_Timerable) <> 0 then + lua_pushnumber(L, weapon^.Timer) + else + lua_pushnil(L); + end + else + lua_pushnil(L); + lc_getammotimer:= 1; +end; + function lc_setvampiric(L : Plua_state) : LongInt; Cdecl; begin if CheckLuaParamCount(L, 1, 'SetVampiric', 'bool') then @@ -3971,6 +3991,7 @@ lua_register(luaState, _P'SetCinematicMode', @lc_setcinematicmode); lua_register(luaState, _P'SetMaxBuildDistance', @lc_setmaxbuilddistance); lua_register(luaState, _P'GetAmmoName', @lc_getammoname); +lua_register(luaState, _P'GetAmmoTimer', @lc_getammotimer); lua_register(luaState, _P'SetVampiric', @lc_setvampiric); lua_register(luaState, _P'SetLaserSight', @lc_setlasersight); lua_register(luaState, _P'Explode', @lc_explode);