Author Topic: Fixing F2 (ToggleSound) issue with Companion  (Read 4111 times)

0 Members and 1 Guest are viewing this topic.

Offline Cloudee1

Fixing F2 (ToggleSound) issue with Companion
« on: October 16, 2010, 01:47:13 PM »
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: [Select]
(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: [Select]
(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")
        )
)

And that should take care of it. 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.

* Bug Fixed as of template version 1.1 found on the tools page.
« Last Edit: December 22, 2012, 01:36:09 PM by Cloudee1 »


Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline MusicallyInspired

Re: Fixing F2 (ToggleSound) issue with Companion
« Reply #1 on: October 16, 2010, 08:49:55 PM »
Nice! You should throw this into Companion's template game so nobody has to do this manually ever again. It's funny that this error wasn't caught and fixed like the other ones from Studio's template game.
Brass Lantern Prop Competition


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.088 seconds with 22 queries.