Twine 2 Sugarcube 2 - Are templates with multiple outputs possible?

Twine Version: 2.3.13
Story Format: Sugarcube 2.34.1

As the title suggests, I’m trying to figure out if having a template provide multiple outputs is actually possible.

I’ve been trying to get a single template to print out one item each from three separate arrays.
Array one: [‘fluffy’,‘warm’,‘comfy’] Array two: [‘red’,‘blue’,‘green’] Array three: [‘jacket’,‘sweater’,‘hoodie’]

So the end result would be something like “comfy red jacket”.

My attempts haven’t worked so far. Now I know I could do this by using three separate templates, but I’m really curious if this can actually be achieved with a single template.

Anyone have any luck doing something similar?

So you don’t want to do this?

<<run Template.add('quality', ['fluffy', 'warm', 'comfy'])>>\
<<run Template.add('color', ['red', 'blue', 'green'])>>\
<<run Template.add('item', ['jacket', 'sweater', 'hoodie'])>>\
?quality ?color ?item

You could use a function, but I can’t see how that’s different in any useful way…

<<run Template.add('jacket', function() {
	return ['fluffy', 'warm', 'comfy'].random()
		+ ' ' + ['red', 'blue', 'green'].random()
		+ ' ' + ['jacket', 'sweater', 'hoodie'].random()
})>>\
?jacket

Honestly the reason was just to keep things contained in one template. That way I could have one template provide simple outputs like" You have a jacket." And then using another template when examining it to print out a semi random description for it.

Thanks for the help.

I know I’m a little late, but I have something similar to this in my game. I’m not the best coder so I’m sure it could be improved, but this could work for you:

You have a <<cycle "$adjective">><<option "fluffy">> <<option "warm">> <<option "comfy">><</cycle>> <<cycle "$colour">><<option "red">> <<option "blue">> <<option "green">><</cycle>> <<cycle "$noun">><<option "jacket">> <<option "sweater">> <<option "hoodie">><</cycle>>. 

Which players could then cycle through. If you want to know how to style it, it’s “a.macro-cycle” :slight_smile: