It's good you have something working, Darius6.
If you knew when the setting was changed in the Options dialog, you could call the function to turn off any sound that might be playing.
I was thinking specifically of
ui_amk_options.script. In the
amk_options:on_okay() function, the variable is saved via
amk.save_variable("option_hud", radio_hud:GetActiveIndex() ). If the active index at this point is
NOT 2, then you could call
mask_sounds.start_stop_sound(nil) if
mask_sounds is valid (not nil).
Better still, perform the test in the
on_quit() function of that script. If the level is present and the actor is valid and alive, then turn off the menu and call the function to adjust the sound based on the option setting and the current suit. Something like this:
- Code: Select all
function amk_options:on_quit()
local console = get_console()
self:GetHolder():start_stop_menu (self.owner, true)
self:GetHolder():start_stop_menu (self,true)
--self.owner:Show (true)
if level.present() and (db.actor ~= nil) and db.actor:alive() then
console:execute("main_menu off")
if mask_sounds then
if amk.load_variable("option_hud",2)==2 then
local hud_outfit = db.actor:get_current_outfit()
local hud_outfit_id = nil
if hud_outfit then
hud_outfit_id = hud_outfit:section()
end
mask_sounds.start_stop_sound(hud_outfit_id)
else
mask_sounds.start_stop_sound(nil)
end
end
end
end
That way, you would turn off any sound currently playing if they disable the option, otherwise automatically turn it on if they are already wearing a suit with a mask.
I think you can remove the test for the option variable in the
set_hud_tex() function in
amk_mod.script if you do this.