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

From SCI Wiki
Jump to navigationJump to search
m (Andrew Branscom moved page Fixing F2 (ToggleSound) issue with Companion to Fixing F2 (ToggleSound) Issue with Companion without leaving a redirect)
 
Line 4: Line 4:
 
[[SCI Tutorials]]
 
[[SCI Tutorials]]
 
[[SCI Tutorials and Guides]]
 
[[SCI Tutorials and Guides]]
'''By Cloudee1'''
+
 
 +
 
 +
<div align="center"><span style="font-size: 22pt">Fixing F2 (ToggleSound) Issue with Companion</span><br />
 +
'''By Cloudee1'''</div>
 +
 
 +
<br />
 +
==<br /> Introduction ==
  
 
As [[User:MusicallyInspired|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.
 
As [[User:MusicallyInspired|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.

Latest revision as of 16:29, 2 April 2025

SCI Tutorials SCI Tutorials and Guides


Fixing F2 (ToggleSound) Issue with Companion
By Cloudee1



Introduction

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.