Twine Version: 2.3.14
Story Format: SugarCube 2.34.1
I am having a problem. Lets say passage 1 has the song “town”. Then in the next passage the player will go to a blacksmith, so passage 2 has the song “blacksmith”. When the player is in passage 2 and clicks on “back”, he returns to passage 1 where the “town” song starts to play, but the problem is that the “blacksmith” song plays too!
So, this is happening:
Passage 1
<<audio “town” play>>
this passage is playing “town” normally
[[Go to the blacksmith->Passage 2]]
← Back
then…
Passage 2
<<audio “town” stop>><<audio “blacksmith” play>>
This passage is playing only “blacksmith” normally
[[Passage 3]]
← Back
So far so good, but then, if the plays clicks on “Back”:
Passage 1 is now playing both “town” and “blacksmith”!
How do I fix this?
Try structuring your play invocations as follows:
<<audio “:all” stop>><<audio “trackName” volume 1 play>>
The :all
predefined group selects all normally registered audio audio, so you don’t have to specify a track to stop. Alternatively, :playing
would also work. (See group IDs under <<audio>>
).
You could also turn that into a widget to make it easier to type:
<<widget "play">><<audio “:all” stop>><<audio $args[0] volume 1 play>><</widget>>
Usage:
<<play "town">>
2 Likes
Thank you so much!! Just to see if I understood (I am really new to twine):
To create this widget all I have to do is create a passage with the tag “widget”, then paste all that… and then in the normal passages all I have to do is type <<play “town”>> and the game will stop all other songs and play town?
Just to be sure! I am really slow sometimes
Correct. Create a new passage—the name doesn’t matter, just no special names—tag it widget
, and paste in the widget code. From then on, you can simply use <<play "trackName">>
—e.g., <<play "town">>
, <<play "blacksmith">>
, etc.
1 Like