It looks like you're new here. If you want to get involved, click one of these buttons!
<<widget "hangar">>
<<set $hangaropen to random(4)>>
<<if $hangaropen is 0>><audio src="hangar1.wav" autoplay></audio><</if>>
<<if $hangaropen is 1>><audio src="hangar2.wav" autoplay></audio><</if>>
<<if $hangaropen is 2>><audio src="hangar3.wav" autoplay></audio><</if>>
<<if $hangaropen is 3>><audio src="hangar4.wav" autoplay></audio><</if>>
<<if $hangaropen is 4>><audio src="hangar5.wav" autoplay></audio><</if>>
<</widget>>
When I put in <<silently>><<hanger>></silently>> Produced the message Error: <<silently>>: error within contents (Error: macro <<hangar>> does not exist)
<<widget hangar>>
<<set $hangaropen to random(4)>>
<<if $hangaropen is 0>><audio src="hangar1.wav" autoplay></audio><</if>>
<<if $hangaropen is 1>><audio src="hangar2.wav" autoplay></audio><</if>>
<<if $hangaropen is 2>><audio src="hangar3.wav" autoplay></audio><</if>>
<<if $hangaropen is 3>><audio src="hangar4.wav" autoplay></audio><</if>>
<<if $hangaropen is 4>><audio src="hangar5.wav" autoplay></audio><</if>>
<</widget>>
Comments
widget
. Correct?Anyway, without a live example of the issue, the only thing I can do is guess. If all you did was remove the quotes (and it started working) and added them back (and it continued working), then one of your original quotes may have been a typographic quote (i.e. curly quote) or you had a non-printable mixed in, which was deleted with the original quotes. /shrug
PS: You're processing
$hangaropen
more often than you need to for what you're doing there. As a suggestion, look into using<<elseif>>
. For example: n.b. Since you're throwing the output of the widget away, and the extraneous whitespace won't be an issue, I went for maximum readability there.I concluded that the widget is haunted and have just put the whole thing in the relevant passages.
The only possible thing I can think of is I didn't make that widget from scratch. It was formerly named "click", then I changed the sound effect, so renamed it hanger. Then the weirdness started. So maybe something with browser memory is going on and Twine for some reason wants to keep reading it as "click".
Thanks for the tip about elseif. As I learn more stuff I'll keep optimizing my code.
Hmm. It shouldn't have worked with the name
click
at allthe built-in<<click>>
macro should have seen to that as<<widget>>
should absolutely refuse to clobber existing macros. Do you have some scripting that is modifying SugarCube or something? Not that I'm saying you shouldn't, it's just that I can't think of another reason why trying to useclick
as the name of a widget didn't make<<widget>>
throw an error.Actually, that makes me think of something else. Did your ever add SugarCube to Twine 2 manually (via the Formats menu in its sidebar) or was your first time using it after it was made one of the built-in story format choices? Also, your version does identify itself as v1.0.16, yes?
Yeah, using 1.016, it was included in 2.0 at the time I downloaded Twine.
Oh, BTW. While I do encourage quoting the names of your widgets in the call to
<<widget>>
, as long as you limit yourself to a simple word, basically, you don't actually have to. For example, the following two invocations are equivalent: So, if you run into a similar issue in the future, where dropping the quotes fixes your widget, feel free to just leave them off. Just don't start dropping quotes everywhere.I've set it up so that it plays a certain sound unless I have the tag "notyping" in the passage, with: and This works for every passage except one, that seems to completely ignore the tags feature, which will keep playing a sound even with that tag.
And the ultra weird thing is even if I tell that passage to play another sound by referencing another widget, it refuses to and will just play the typing sound, while not throwing up an error message for the widget it's not recognising. It's like it's not remembering the correct information in the passage and is defaulting to an older version that's stuck in memory somewhere.
Then when I changed the passage to include the raw html reference to the new sound I wanted playing, suddenly the notyping tag started working again.
At this stage the best idea I have is to wipe my browser's memory after saving backups and reinstall twine and my story.
If you start playing an audio clip, navigating to a new passage will not automatically terminate/stop the clip. Your shown code only ensures that a new clip isn't started (and yes, you can have multiple instances of the same clip all playing at once), it does not stop playing clips.
That's probably caused by how you're playing the audio clips. At least with the code you've shown, your rendering the
<audio>
element outside of the DOM and then throwing away all references you have to the element, so it's sitting in limbo just playing away.Well, it's working 99.99% of the time (I have heaps of passages), so I don't know why the exception is occurring. If I was doing something seriously wrong I'd see the problem occurring more than that?
I might just switch to putting the raw html audio call in every passage without any widgets, just to be safe.