# HG changeset patch # User Wuzzy # Date 1548035529 -3600 # Node ID e6363b84b3fe2fffb0074639fe43624af4558c4e # Parent 3e15412536c8a1723ea28ac92736a3a638fb6d85 SetAmmoDelay: Unselect weapon if neccessary diff -r 3e15412536c8 -r e6363b84b3fe hedgewars/uScript.pas --- a/hedgewars/uScript.pas Mon Jan 21 02:09:30 2019 +0100 +++ b/hedgewars/uScript.pas Mon Jan 21 02:52:09 2019 +0100 @@ -2859,7 +2859,7 @@ function lc_setammodelay(L : Plua_State) : LongInt; Cdecl; -var at: LongInt; +var at, delay: LongInt; const call = 'SetAmmoDelay'; params = 'ammoType, delay'; @@ -2867,8 +2867,14 @@ if CheckLuaParamCount(L, 2, call, params) then begin at:= LuaToAmmoTypeOrd(L, 1, call, params); - if at >= 0 then - ScriptSetAmmoDelay(TAmmoType(at), Trunc(lua_tonumber(L, 2))); + delay:= Trunc(lua_tonumber(L, 2)); + if (at >= 0) and (TAmmoType(at) <> amNothing) then + begin + ScriptSetAmmoDelay(TAmmoType(at), delay); + // Unselect weapon if neccessary + if (delay > 0) and (CurrentHedgehog <> nil) and (CurrentHedgehog^.CurAmmoType = TAmmoType(at)) then + ParseCommand('setweap ' + char(0), true, true); + end; end; lc_setammodelay:= 0 end;