# HG changeset patch # User Wuzzy # Date 1525437481 -7200 # Node ID c5353014244290be4f652050fa39dc0e13cfda83 # Parent 03e4d9b5b09cbcf3f8726c16f8fb787824b6eac1 Lua API: Add EnableSwitchHog to manually enable hog switching diff -r 03e4d9b5b09c -r c53530142442 ChangeLog.txt --- a/ChangeLog.txt Fri May 04 01:39:22 2018 +0200 +++ b/ChangeLog.txt Fri May 04 14:38:01 2018 +0200 @@ -25,6 +25,7 @@ Lua API: + New call: Retreat(time [, respectGetAwayTimeFactor): Force current turn into retreating mode + New call: GetAmmoTimer(gearUid, ammoType): Returns current set timer for given ammoType and hog gear in ms. Returns nil for non-timerable ammo + + New call: EnableSwitchHog(): Enable hog switching + New parameter: SetAmmoTexts: 5th param. showExtra: Set to false to hide texts like “Not yet available” ====================== 0.9.24.1 ==================== diff -r 03e4d9b5b09c -r c53530142442 hedgewars/uScript.pas --- a/hedgewars/uScript.pas Fri May 04 01:39:22 2018 +0200 +++ b/hedgewars/uScript.pas Fri May 04 14:38:01 2018 +0200 @@ -1677,6 +1677,19 @@ lc_switchhog:= 0 end; +function lc_enableswitchhog(L : Plua_State) : LongInt; Cdecl; +var gear: PGear; +begin + if CheckLuaParamCount(L, 0, 'EnableSwitchHog', '') then + begin + gear:= AddGear(hwRound(CurrentHedgehog^.Gear^.X), hwRound(CurrentHedgehog^.Gear^.Y), gtSwitcher, 0, _0, _0, 0); + CurAmmoGear:= gear; + lastGearByUID:= gear; + bShowFinger:= false; + end; + lc_enableswitchhog:= 0; +end; + function lc_addammo(L : Plua_State) : LongInt; Cdecl; var gear : PGear; at, n, c: LongInt; @@ -3966,6 +3979,7 @@ lua_register(luaState, _P'GetZoom', @lc_getzoom); lua_register(luaState, _P'HogSay', @lc_hogsay); lua_register(luaState, _P'SwitchHog', @lc_switchhog); +lua_register(luaState, _P'EnableSwitchHog', @lc_enableswitchhog); lua_register(luaState, _P'HogTurnLeft', @lc_hogturnleft); lua_register(luaState, _P'GetGearElasticity', @lc_getgearelasticity); lua_register(luaState, _P'SetGearElasticity', @lc_setgearelasticity);