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.
A couple of notes about what you’re attempting to do here:
That is not how you call a widget, which is called exactly like a macro—because that’s what it is in the end.
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:
Translate your widget into a function so you can call it from the link markup’s setter component.
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 */