Syntax Error: Unexpected string at call.output.output

I recently just started to use twine, like a week before, so I’m very new to to this. This is a sample code, so I’m sure tehre’s nothing wrong with this, but it’s just in case.

/* <<SetGender>> widget - Start */
<<widget "SetGender">><<nobr>>
/* Usage... (defaults to male) */
/* for "he":   <<SetGender>> or <<SetGender "m">> */
/* for "she":  <<SetGender "f">> */
/* for "they": <<SetGender "b">> */
/* for "it":   <<SetGender "n">> */
/* $pgen: 0 = male, 1 = female, 2 = gender neutral, 3 = no gender */
	<<switch $args[0]>>
		<<case "f">>
			<<set $pgen = 1>>
		<<case "b">>
			<<set $pgen = 2>>
		<<case "n">>
			<<set $pgen = 3>>
		<<default>>
			<<set $pgen = 0>>
	<</switch>>
<</nobr>><</widget>>
/* <<SetGender>> widget - End */

I put my option as but I don’t think there’s something wrong with that either? I honestly think it’s something wrong with my app data or something.

[[Master|Link1][SetGender "m"]]

A couple of notes about what you’re attempting to do here:

  1. That is not how you call a widget, which is called exactly like a macro—because that’s what it is in the end.
  2. The link markup’s setter component, as noted in its documentation, works like the <<set>> macro. Meaning it needs TwineScript, or JavaScript, not markup, which includes macros.

You have two basic options:

  1. Translate your widget into a function so you can call it from the link markup’s setter component.
  2. Use the <<link>> macro so you can use your existing widget.

The latter, option 2, would be the easiest, but I’ll cover both.

Option 1 Example

JavaScript:
Place the following into your Story JavaScript:

/*
	SetGender() function - Start

	Usage: (defaults to male)
		- "he":   SetGender() or SetGender("m")
		- "she":  SetGender("f")
		- "they": SetGender("b")
		- "it":   SetGender("n")

	$pgen: 0 = male, 1 = female, 2 = neutral, 3 = none
*/
setup.SetGender = function (gid) {
	var sv = State.variables;

	switch (gid) {
		case "f":
			sv.pgen = 1;
			break;
		case "b":
			sv.pgen = 2;
			break;
		case "n":
			sv.pgen = 3;
			break;
		default:
			sv.pgen = 0;
			break;
	}
};
/* SetGender() function - End */

Usage:

[[Master|Link1][setup.SetGender("m")]]
Option 2 Example

Usage:

<<link [[Master|Link1]]>>
	<<SetGender "m">>
<</link>>
1 Like

I see, thank you! I decided to use the second option. By the way, I decided to cycle through the pronouns like such.

<<nobr>>
<span id="cycle">
<<cycle "$SetGender" autoselect>>
<<option Mistress <<SetGender "f">>
<<option Master <<SetGender "m">>
<<option Liege <<SetGender "b">>
<</cycle>></span>
<</nobr>>

But it doesn’t work? Do I have to create a new $SetGender for this to work as it says

Error: <<cycle>>: variable name "SetGender" is missing its sigil ($ or _)

If you’re letting the player directly set the value, then you probably don’t need the widget at all.

Anyway. Your <<cycle>> code should probably look something like:

<span id="cycle"><<cycle "$SetGender" autoselect>>
<<option Mistress "f">>
<<option Master "m">>
<<option Liege "b">>
<</cycle>></span>

Of course, you’d have to run the widget on the player selected value later.

Alternatively. Just set $pcgen directly:

<span id="cycle"><<cycle "$pcgen" autoselect>>
<<option Mistress 1>>
<<option Master 0>>
<<option Liege 2>>
<</cycle>></span>
1 Like

I see, thank you very much for the help!