# HG changeset patch # User Wuzzy # Date 1540519655 -7200 # Node ID 2828ec67c47c8ff00ba110bc2afa30df5f1edf16 # Parent 350adfa0e89642cc5f61d9ad1a18354cac0051c8 Add PlayMusicSound/StopMusicSound to Lua API diff -r 350adfa0e896 -r 2828ec67c47c ChangeLog.txt --- a/ChangeLog.txt Fri Oct 26 03:59:20 2018 +0200 +++ b/ChangeLog.txt Fri Oct 26 04:07:35 2018 +0200 @@ -157,6 +157,8 @@ + 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 call: PlayMusicSound(soundId): Play a sound as replacement for the main background music + + New call: StopMusicSound(soundId): Stop a “music sound” and resume the regular music + Changed call: AddTeam: 2nd param. color: Accepts negative value to use a default clan color from player settings + Changed call: HedgewarsScriptLoad: 2nd param. mustExist. If false, it's allowed for the script to not exist + Changed call: HedgewarsScriptLoad: Return true on success and false on failure diff -r 350adfa0e896 -r 2828ec67c47c hedgewars/uScript.pas --- a/hedgewars/uScript.pas Fri Oct 26 03:59:20 2018 +0200 +++ b/hedgewars/uScript.pas Fri Oct 26 04:07:35 2018 +0200 @@ -2195,6 +2195,37 @@ lc_playsound:= 0; end; +function lc_playmusicsound(L : Plua_State) : LongInt; Cdecl; +var s: LongInt; +const + call = 'PlayMusicSound'; + params = 'soundId'; +begin + if CheckLuaParamCount(L, 1, call, params) then + begin + s:= LuaToSoundOrd(L, 1, call, params); + if s >= 0 then + PlayMusicSound(TSound(s)) + end; + lc_playmusicsound:= 0; +end; + +function lc_stopmusicsound(L : Plua_State) : LongInt; Cdecl; +var s: LongInt; +const + call = 'StopMusicSound'; + params = 'soundId'; +begin + if CheckLuaParamCount(L, 1, call, params) then + begin + s:= LuaToSoundOrd(L, 1, call, params); + if s >= 0 then + StopMusicSound(TSound(s)) + end; + lc_stopmusicsound:= 0; +end; + + function lc_setsoundmask(L : Plua_State) : LongInt; Cdecl; var s: LongInt; soundState: boolean; @@ -4189,6 +4220,8 @@ lua_register(luaState, _P'GetAmmo', @lc_getammo); lua_register(luaState, _P'SetAmmoDelay', @lc_setammodelay); lua_register(luaState, _P'PlaySound', @lc_playsound); +lua_register(luaState, _P'PlayMusicSound', @lc_playmusicsound); +lua_register(luaState, _P'StopMusicSound', @lc_stopmusicsound); lua_register(luaState, _P'SetSoundMask', @lc_setsoundmask); lua_register(luaState, _P'GetTeamName', @lc_getteamname); lua_register(luaState, _P'GetTeamIndex', @lc_getteamindex);