0 votes
by (440 points)
How can i put sound when ui-bar-toggle is clicked for stow and open ui-bar?

1 Answer

+1 vote
by (2.2k points)

Put this into your game's JavaScript. 

$('#ui-bar-toggle').on('click', function () {
  $.wiki(`<<audio "toggle_ui_bar" play>>`);
})

Don't forget to cache your audio file as per SugarCube docs.

by (440 points)
And if I want this only make when one Variable =1, and no make when a variable is 0? Thanks for Help Notkostas...
by (2.2k points)

If you want to provide "Mute" button for player, I think it's more easily achieved using <<masteraudio>> macro

Or something like this:

$('#ui-bar-toggle').on('click', function () {
  $.wiki('<<if $myVariable eq 1>><<audio "toggle_ui_bar" play>><</if>>');
})

 

by (440 points)
Thanks ... sorry for the noob question ... This worked perfectly.
by (2.2k points)
Glad to be of help:)
Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.
...