# HG changeset patch # User Wuzzy # Date 1532991627 -7200 # Node ID 66460d5f0d9b911bf64316e1c28b8a02ea7e648e # Parent e5761b37e99cec4d3583d7877f45dbdff729da54 Lua API: Add IsHogHidden diff -r e5761b37e99c -r 66460d5f0d9b ChangeLog.txt --- a/ChangeLog.txt Tue Jul 31 00:12:19 2018 +0200 +++ b/ChangeLog.txt Tue Jul 31 01:00:27 2018 +0200 @@ -72,6 +72,7 @@ + New call: GetAmmo(ammoType): Returns ammo configuration (corresponds to SetAmmo) + New call: GetVampiric(): Returns true if vampirism is currently active + New call: GetLaserSight(): Returns true if laser sight (as utility) is currenctly active (ignoring sniper rifle) + + New call: IsHogHidden(gear): Returns true if hog is hidden + New parameter: SetAmmoTexts: 5th param. showExtra: Set to false to hide texts like “Not yet available” + New parameter: ShowMission: 6th param. forceDisplay: Set to true to prevent this particular mission panel to be hidden manually by player + New Lua library: Achievements diff -r e5761b37e99c -r 66460d5f0d9b hedgewars/uScript.pas --- a/hedgewars/uScript.pas Tue Jul 31 00:12:19 2018 +0200 +++ b/hedgewars/uScript.pas Tue Jul 31 01:00:27 2018 +0200 @@ -2942,6 +2942,36 @@ lc_restorehog := 0; end; +function lc_ishoghidden(L: Plua_State): LongInt; Cdecl; +var i, h: LongInt; + uid: LongWord; + gear: PGear; +begin + if CheckLuaParamCount(L, 1, 'IsHogHidden', 'gearUid') then + begin + uid:= LongWord(Trunc(lua_tonumber(L, 1))); + gear:= GearByUID(uid); + if (gear <> nil) and (gear^.hedgehog <> nil) then + begin + lua_pushboolean(L, false); + lc_ishoghidden:= 1; + exit; + end + else + if TeamsCount > 0 then + for i:= 0 to Pred(TeamsCount) do + for h:= 0 to cMaxHHIndex do + if (TeamsArray[i]^.Hedgehogs[h].GearHidden <> nil) and (TeamsArray[i]^.Hedgehogs[h].GearHidden^.uid = uid) then + begin + lua_pushboolean(L, true); + lc_ishoghidden:= 1; + exit; + end + end; + lua_pushnil(L); + lc_ishoghidden:= 1; +end; + // boolean TestRectForObstacle(x1, y1, x2, y2, landOnly) function lc_testrectforobstacle(L : Plua_State) : LongInt; Cdecl; var rtn: Boolean; @@ -3955,6 +3985,7 @@ // register functions lua_register(luaState, _P'HideHog', @lc_hidehog); lua_register(luaState, _P'RestoreHog', @lc_restorehog); +lua_register(luaState, _P'IsHogHidden', @lc_ishoghidden); lua_register(luaState, _P'SaveCampaignVar', @lc_savecampaignvar); lua_register(luaState, _P'GetCampaignVar', @lc_getcampaignvar); lua_register(luaState, _P'band', @lc_band);