0 votes
by (8.7k points)

I really struggle with <<nobr>>s and \s to remove whitespaces from my widgets.

So I have this widget:

<<widget "genericTaunt">><<nobr>>\
<<set _genericTaunt to [
'You scruffy looking nerf herder',
'Bantha poodoo',
'E chu ta']>>
<<= _genericTaunt.random()>>\
<</nobr>><</widget>>

The passage calls it like so:

"<<genericTaunt>>!" he snaps.

It outputs thusly (note the space after the first " ):

" E chu ta!" he snaps.

I tried putting \s in the array, but that returned an "invalid or unexpected token" error.  I also tried putting all the elements within the array onto one line, separated by commas, but that didn't remove the space.

Can anybody see what I'm doing wrong?

1 Answer

+1 vote
by (63.7k points)
selected by
 
Best answer

Look after the <<set>> macro.  For example:

'E chu ta']>>  ← Line break, which <<nobr>> turns into a space
<<= _genericTaunt.random()>>\

This widget is short enough, I'd suggest dropping the <<nobr>> completely and simply using line continuations.  For example:

<<widget "genericTaunt">>
\<<set _genericTaunt to [
	'You scruffy looking nerf herder',
	'Bantha poodoo',
	'E chu ta'
]>>
\<<= _genericTaunt.random()>>
\<</widget>>

I used leading line continuations there because they're generally more noticeable—meaning you're more likely to notice when you've missed placing one.

FURTHER SUGGESTION: You might want to place the taunt array on the setup object, so you're not recreating it every time you call the widget.  For example, in the StoryInit special passage:

<<set setup.genericTaunt to [
	'You scruffy looking nerf herder',
	'Bantha poodoo',
	'E chu ta'
]>>

Which allows your widget to become:

<<widget "genericTaunt">>
\<<= setup.genericTaunt.random()>>
\<</widget>>

 

by (8.7k points)
Thanks for helping me understand that.  :-)
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.
...