I just came across an interesting music issue with SugarCube's load game function. If music is playing, and I decide to load game, the music will keep playing as it will reload all variables but not give any stopsound commands. But sometimes the music playing at the start of the game or where ever loaded from will not be appropriate, since I use a specific music track for the start screen.
So is there a way to tie a <<stopallsound>> command to the load game function? Cause I don't want to have to manually append <<stopsound "sound/intromusic.ogg">> to every single passge a player may load to. Or failing that, is there a way to append that command to every single passage except those tagged with a certain identifier? Pretty sure I did this at one point, but have forgotten how I did it.
E.g. Some kind of function that will automatically carry out <<stopsound "sound/intromusic.ogg">> to every passage loaded except for those passages I tag with "intro". Seems kinda excessive to just meet the load game issue, but it'd work.
Comments
1. The config object's config.saves.onLoad function:
This allows you to run javascript code when a saved game is loaded. 2. Either one of the PassageReady / PassageDone special passage or one of the predisplay / prerender / postrender postdisplay ]Task Object functions:
These allow you to run code (either <<macro>> or javascript) every time any passage is shown. You can conditionally test which passage is being shown (via title or tags) so your code only happens when you want it to.
Do you have any examples of specific javascript or conditional testing via tags for either options? Bear in mind I say this before I go to look it up myself, so I might end up figuring it out anyway.
onLoad()
callback:Or, depending on how you have everything setup, you could put a call to
<<stopallsound>>
(or<<stopsound >>
) in StoryInit special passage (though, that would also stop the audio if the player reloads the page, so maybe not the best solution).That could actually be doable, thanks. I mean, my current one works fine now, but it would be better to have something that only takes effect on load.