0 votes
by (250 points)
edited by

I'm using Twine 2.2.1, Sugarcube 2.21.0, and w3.css.

I am writing a widget called <<speak>> to display a character's image with their dialog next to it.  I already have widgets predefined such as <<friend>> and <<foe>> which display the appropriate image, but am struggling to pass that character widget name into <<speak>>.

For example, I would like to use <<speak "foe" "You shall die!>> to render a picture of the Foe (using the <<foe>> widget) with the words "You shall die!" next to it.

Here is my <<foe>> widget (which works perfectly by itself):

<<widget "foe">><img data-passage=foeImage alt="Foe" class="w3-animate-zoom w3-padding-small hvr-float img-float-left"><</widget>>

Here is my <<speak>> widget (which currently does not display the image, just the dialog text):

<<widget "speak">>
  <<if $args[0]>>
	<div class="w3-row">
	  <div class="w3-col" style="width:100px">
		<<$args[0]>> /* display the image using a pre-defined widget*/
	  </div>
	  <div class="w3-rest">
		<p><<print $args[1]>></p> /* display the dialog */
	  </div>
	</div>
  <</if>>
<</widget>>

My widget, as written, displays the following on the screen:

<<foe>> You shall die!

I would kindly accept any help anyone can offer.

1 Answer

+1 vote
by (23.6k points)

You have to pass "<<foe>>" instead of "foe" then use <<print>>:

<<print $args[0]>>

You don't have to use print to display $args[1] though.

by (250 points)
Super!  Thank you for the quick response!
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.
...