Attract-Mode Support Forum

Attract-Mode Support => Scripting => Topic started by: verion on December 13, 2015, 02:48:23 PM

Title: [solved] global video-sound-mute switch via layout options
Post by: verion on December 13, 2015, 02:48:23 PM
I would like to provide a global switch via layout options that will mute video sound (for every video in layout).
Below you will find my code.


Code: [Select]
//define layout option entry
class UserConfig {
</ label="Mute video snaps sound", help="yes = sound disabled, no = sound enabled", options="yes,no" /> mute_videoSnaps="no";
}



//when mute sound = YES in layout options - define variable "videoSound" (that will be used globally)
//that will mute sound
if ( my_config["mute_videoSnaps"] == "yes")
{
 local videoSound = Vid.NoAudio;
}


//video an cab screen
local cabScreen = fe.add_artwork ("snap", 300, 300, 400, 300);
cabScreen.video_flags = videoSound;

Unfortunately - this is not working :(

If I hard code
local videoSound = Vid.NoAudio;
it is working correctly.
But when I try to make this happend via layout options - no go.

---

I'll just add that I know that video sound can be disabled globally in AM (in SOUND options) - but I want it to be disabled for particular layout, not for all layouts.
Title: Re: [help] global video-sound-mute switch via layout options
Post by: raygun on December 13, 2015, 03:00:15 PM
Hey verion, it looks like your videoSound local is going out of scope right after you set it.  Either declare it outside of the curly brackets or declare it in the root table and that should fix things for you.

cheers
Title: Re: [help] global video-sound-mute switch via layout options
Post by: verion on December 14, 2015, 10:03:37 AM
Thanks for your help.
Your comment actually made me reading about squirrel just to understand what you are saying. Well... more karma for me :)

I'm pasting the corrected (working) code in case someone wants to copy-paste it.

Code: [Select]
if ( my_config["mute_videoSnaps"] == "yes")
{
::videoSound <- Vid.NoAudio;
}
if ( my_config["mute_videoSnaps"] == "no")
{
::videoSound <- Vid.Default;
}

Code: [Select]
//video an cab screen
local cabScreen = fe.add_artwork ("snap", 300, 300, 400, 300);
cabScreen.video_flags = videoSound;

---