Difference between revisions of "Fixing F2 (ToggleSound) issue with Companion"

From SCI Wiki
Jump to navigationJump to search
m (1 revision)
Line 4: Line 4:
  
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockHeader">Code:</div>
<syntaxhighlight lang="sci">(procedure public (ToggleSound)
+
<syntaxhighlight lang="sci" class="cs">(procedure public (ToggleSound)
 
     (var SOUND_OFF)
 
     (var SOUND_OFF)
 
     = SOUND_OFF DoSound(sndSET_SOUND)
 
     = SOUND_OFF DoSound(sndSET_SOUND)
Line 18: Line 18:
  
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockHeader">Code:</div>
<syntaxhighlight lang="sci">(procedure public (ToggleSound) // mute, unmute
+
<syntaxhighlight lang="sci" class="cs">(procedure public (ToggleSound) // mute, unmute
 
     (if(DoSound(sndSET_SOUND)) // if true, mute
 
     (if(DoSound(sndSET_SOUND)) // if true, mute
 
             DoSound(sndSET_SOUND FALSE)
 
             DoSound(sndSET_SOUND FALSE)

Revision as of 15:59, 5 August 2013

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.