Fixing F2 (ToggleSound) issue with Companion

From SCI Wiki
Jump to navigationJump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

By Cloudee1

As Brandon has noted, sometimes it appears as though F2, or toggle sound, works and sometimes it does not. The problem arises out of sci companion's compiler. While there are no errors thrown, the compiled script fails to mute or unmute the sounds.

Code:
(procedure public (ToggleSound)
    (var SOUND_OFF)
    = SOUND_OFF DoSound(sndSET_SOUND)
    = SOUND_OFF DoSound( sndSET_SOUND not(SOUND_OFF) )
    (if(SOUND_OFF)
        SetMenu(MENU_TOGGLESOUND smMENU_TEXT "Turn On")
    )(else
        SetMenu(MENU_TOGGLESOUND smMENU_TEXT "Turn Off")
    )
)

Luckily, fixing the procedure isn't too difficult. The logic of the procedure, if you can play the sound then mute, otherwise unmute. Simple enough right? So here it is.

Code:
(procedure public (ToggleSound) // mute, unmute
    (if(DoSound(sndSET_SOUND)) // if true, mute
            DoSound(sndSET_SOUND FALSE)
            SetMenu(MENU_TOGGLESOUND smMENU_TEXT "Turn On")
        )
    (else  // must be false, unmute
            DoSound(sndSET_SOUND TRUE)
            SetMenu(MENU_TOGGLESOUND smMENU_TEXT "Turn Off")
        )
)

Simply replace the whole procedure with this new one and the game will respond correctly regardless of which editor you use to compile the script.