0 votes
by (470 points)

Hello. I'm trying to get a stylized text that the player will choose. For this, I use two widgets, before and after the text.


<<widget "voice">>\
	<<if $player.voice is "gently">>\	
	<<if $player.voice is "rude">>\
	<<if $player.voice is "breathy">>\
	<<if $player.voice is "ringing">>\

<<widget "voice_end">>\



as a result, the text remains without a style. But if i use that style without widgets, style works 

1 Answer

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

Unfortunately, you cannot split markup or tags (macro or HTML) which have opening and closing sequences between widgets as you're attempting to do.

Since widgets do not currently support being containers (i.e. having an opening and closing tag), you'll probably want either a container macro or to pass the text to the widget as an argument.

EDIT: I'll provide some examples a bit later.  I'm on my phone at the moment.

by (68.6k points)

Rather than using control logic to select the appropriate class name, both of the following examples use the fact that, based on your example, the value of $player.voice seems to match the latter half of your class names.  Thus, you may simply use it to build the class name, no control logic required.


Example - Widget Arguments


<<widget "voice">>
	\<<= '@@.pcspeech_' + $player.voice + ';' + $args[0] + '@@'>>


<<voice "Hello. My name is Inigo Montoya. You killed my father. Prepare to die.">>


Example - Container Macro

Macro: (goes in Story JavaScript or the equivalent)

Macro.add('voice', {
	skipArgs : true,
	tags     : null,
	handler  : function () {
		if (this.payload[0].contents !== '') {
			var sv = State.variables;

				.addClass('pcspeech_' + sv.player.voice)


<<voice>>Hello. My name is Inigo Montoya. You killed my father. Prepare to die.<</voice>>


by (470 points)
oh my, thats really works! Thank you!