Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Extraneous spaces appearing after
tags?

I'm using Twine 1.4 with Sugarcube 2. One problem I'm having is that extraneous non-break spaces are showing up at the beginning of the line following <br> tags inside of <<nobr>> blocks.

I have a seashell collecting minigame that involves clicking up to 4 squares on a 3x3 grid to look for seashells. The contents of the grid are a randomly shuffled array of strings. When clicked, the bottom of the passage <<display>>s a passage with the same name as the corresponding string, which shows the results of that click (if you found anything, and if so, what). After 4 clicks, the game ends and all of the squares become non-clickable text, and the array containing the strings is emptied (to be repopulated on the next play). The game itself works perfectly, but there are all these extraneous spaces that I can't figure out how to get rid of. Here's the passage code:
<<nobr>>
<<if $seashellCount lt 4>>
Play the seashell game!<br>
<<for _j to 0; _j lt $seashellGame.length; _j++>>
<<print
	  '[ '
	+ '<<if $click' + _j + ' is false>>'
	+ '<<click "x">>'
	+ '<<print $seashellGame[' + _j + ']>>'
	+ '<<set $seashellDisplay to $seashellGame[' + _j + ']>>'
	+ '<<set $seashellCount++>>'
	+ '<<set $click' + _j + ' to true>>'
	+ '<<script>>state.display(state.active.title, null, "back")<</script>>'
	+ '<</click>>'
	+ '<<else>>'
	+ 'x'
	+ '<</if>>'
	+ ' ]'
	+ '<<if _j is 2 or _j is 5 or _j is 8>>'
	+ '<br>'
	+ '<</if>>'
>>
<</for>>
<br>
<<if $seashellDisplay is "null">>
<<else>>
	<<display $seashellDisplay>><br>
<</if>>
<<else>>
[ x ] [ x ] [ x ]
<br>
[ x ] [ x ] [ x ]
<br>
[ x ] [ x ] [ x ]
<br><br>
<<display $seashellDisplay>>
<br>
You've collected enough seashells for today. Time to head back.
<<set $seashellGame = []>>
<</if>>
<<back>>
<</nobr>>

And here are some screenshots showing the extra lines:

At the start of the game:
4TPMsFj.png

Once the game is finished:
HpVWLrZ.png

Any idea how I can get rid of these spaces? I feel like I must be overlooking something pretty simple.

Comments

  • Any idea how I can get rid of these spaces? I feel like I must be overlooking something pretty simple.
    Without the code that sets up the relevant variables and knowing what is in the passage referenced by the $seashellDisplay variable it is hard to debug your code example.

    The space characters generated by the <<nobr>> macro shouldn't cause the issue you are having.
  • Here's the code that sets up the relevant variables (encoded in a <<click>> macro from the preceding passage):
    <<click "Collect seashells">>
    	<<symUp>>
    	<<ghostCheck "seashells">>
    	<<set $click0 to false>>
    	<<set $click1 to false>>
    	<<set $click2 to false>>
    	<<set $click3 to false>>
    	<<set $click4 to false>>
    	<<set $click5 to false>>
    	<<set $click6 to false>>
    	<<set $click7 to false>>
    	<<set $click8 to false>>
    	<<set $seashellCount to 0>>
    	<<set $seashellDisplay to "null">>
    	<<set $seashellDud to Math.floor(Math.random() * (3 - 0 + 1)) + 0>>
    	<<for _d to 0; _d lt $seashellDud; _d++>>
    		<<set $seashellGame.push("shellDud")>>
    	<</for>>
    	<<if $shallowParts.length is 0>>
    		<<for _s to 0; _s lt (9 - $seashellDud); _s++>>
    			<<set $seashellGame.push($seashells.random())>>
    		<</for>>
    	<<else>>
    		<<set $seashellGame.push($shallowParts.random())>>
    		<<for _s to 0; _s lt (8 - $seashellDud); _s++>>
    			<<set $seashellGame.push($seashells.random())>>
    		<</for>>
    	<</if>>
    	<<set $seashellGame.shuffle()>>
    <</click>>
    

    There are a number of passages, but they all follow the same format:
    <<nobr>>
    <<if $seashellCollect.contains("Fighting conch")>>
    You pick up a fighting conch. It's pretty, but you already have one of these.
    <<else>>
    You pick up a fighting conch. It has a pretty sheen. You put it in your pocket.
    	<<set $seashellCollect.push("Fighting conch")>>
    <</if>>
    <</nobr>>
    
  • Try surrounding your code in { and } to remove any white spaces. That works in Harlowe, it may work in Sugarcube.
Sign In or Register to comment.