My widget prints a bracket

Twine Version: 2.3.16
Story Format: Sugarcube 2.36.1

I have most recently been playing around with widgets, specifically one for tracking XP and levelling skills as necessary. The widget I wrote works, but every time I call it, it prints a “>” in the passage where I used it. I have gone through the code in my widget four times to check for any extra triangular brackets, and found none. Is this intentional or am I doing something wrong? And more importantly, how the beep do I get rid of that extra, unwanted symbol? I have included my widget in an example below:

<<widget "experience">><<nobr>>
<<if $FocusXP gte 10 and $FocusXP lt 25>>
<<set $Focus to 1>><</if>>
<<if $FocusXP gte 25 and $FocusXP lt 50>>
<<set $Focus to 2>><</if>>
<<if $FocusXP gte 50>><<set $Focus to 3>><</if>>

<<if $SpellXP gte 10 and $SpellXP lt 25>>
<<set $SpellPower to 1>><</if>>
<<if $SpellXP gte 25 and $SpellXP lt 50>>
<<set $SpellPower to 2>><</if>>
<<if $SpellXP gte 50>><<set $SpellPower to 3>><</if>>

<<if $CounterXP gte 10 and $CounterXP lt 25>>
<<set $Counter to 1>><</if>>
<<if $CounterXP gte 25 and $CounterXP lt 50>>
<<set $Counter to 2>><</if>>>
<<if $CounterXP gte 50>><<set $Counter to 3>><</if>>

<<if $CurseXP gte 10 and $CurseXP lt 25>>
<<set $Curse to 1>><</if>>
<<if $CurseXP gte 25 and $CurseXP lt 50>>
<<set $Curse to 2>><</if>>
<<if $CurseXP gte 50>><<set $Curse to 3>><</if>>

<<if $DominationXP gte 10 and $DominationXP lt 25>>
<<set $Domination to 1>><</if>>
<<if $DominationXP gte 25 and $DominationXP lt 50>>
<<set $Domination to 2>><</if>>
<<if $DominationXP gte 50>><<set $Domination to 3>><</if>>

<<if $ElementalXP gte 10 and $ElementalXP lt 25>>
<<set $Elemental to 1>><</if>>
<<if $ElementalXP gte 25 and $ElementalXP lt 50>>
<<set $Elemental to 2>><</if>>
<<if $ElementalXP gte 50>><<set $Elemental to 3>><</if>>

<<if $FertilityXP gte 10 and $FertilityXP lt 25>>
<<set $Fertility to 1>><</if>>
<<if $FertilityXP gte 25 and $FertilityXP lt 50>>
<<set $Fertility to 2>><</if>>
<<if $FertilityXP gte 50>><<set $Fertility to 3>><</if>>

<<if $AgricultureXP gte 10 and $AgricultureXP lt 25>>
<<set $Agriculture to 1>><</if>>
<<if $AgricultureXP gte 25 and $AgricultureXP lt 50>>
<<set $Agriculture to 2>><</if>>
<<if $AgricultureXP gte 50>><<set $Agriculture to 3>><</if>>

<<if $AnimalXP gte 10 and $AnimalXP lt 25>>
<<set $AnimalHusbandry to 1>><</if>>
<<if $AnimalXP gte 25 and $AnimalXP lt 50>>
<<set $AnimalHusbandry to 2>><</if>>
<<if $AnimalXP gte 50>><<set $AnimalHusbandry to 3>><</if>>

<<if $CarpentryXP gte 10 and $CarpentryXP lt 25>>
<<set $Carpentry to 1>><</if>>
<<if $CarpentryXP gte 25 and $CarpentryXP lt 50>>
<<set $Carpentry to 2>><</if>>
<<if $CarpentryXP gte 50>><<set $Carpentry to 3>><</if>>

<<if $LatinXP gte 10 and $LatinXP lt 25>>
<<set $Latin to 1>><</if>>
<<if $LatinXP gte 25 and $LatinXP lt 50>>
<<set $Latin to 2>><</if>>
<<if $LatinXP gte 50>><<set $Latin to 3>><</if>>

<<if $LoveXP gte 10 and $LoveXP lt 25>>
<<set $Lovemaking to 1>><</if>>
<<if $LoveXP gte 25 and $LoveXP lt 50>>
<<set $Lovemaking to 2>><</if>>
<<if $LoveXP gte 50>><<set $Lovemaking to 3>><</if>>

<<if $MechanicsXP gte 10 and $MechanicsXP lt 25>>
<<set $Mechanics to 1>><</if>>
<<if $MechanicsXP gte 25 and $MechanicsXP lt 50>>
<<set $Mechanics to 2>><</if>>
<<if $MechanicsXP gte 50>><</if>>
<</nobr>><</widget>>
1 Like

You do have an extra > in your code, specifically, in this line:

<<set $Counter to 2>><</if>>>

(it’s super hard to spot things like that in longer passages of code - I pasted the code into a text editor and searched for “>>>” to locate it).

Thank you so much, it did the trick.

If your widget isn’t supposed to generate any output, then you should probably switch out the <<nobr>> with <<silently>>, which elides output rather than messing with line-breaks.

PS: You should look into <<if>>'s child macro <<elseif>>. It would make your code there more efficient.

Thanks that’s good advice. I suspected that I might be able to use “elseif” but the example I found used it like I did mine. I’ve updated my code, though. Now it looks like this, and it runs as smooth as ever:

<<widget "experience">><<silently>>
<<if $FocusXP gte 10 and $FocusXP lt 25>><<set $Focus to 1>>
<<elseif $FocusXP gte 25 and $FocusXP lt 50>><<set $Focus to 2>>
<<elseif $FocusXP gte 50>><<set $Focus to 3>><</if>>

<<if $SpellXP gte 10 and $SpellXP lt 25>><<set $SpellPower to 1>>
<<elseif $SpellXP gte 25 and $SpellXP lt 50>><<set $SpellPower to 2>>
<<elseif $SpellXP gte 50>><<set $SpellPower to 3>><</if>>

<<if $CounterXP gte 10 and $CounterXP lt 25>><<set $Counter to 1>>
<<elseif $CounterXP gte 25 and $CounterXP lt 50>><<set $Counter to 2>>
<<elseif $CounterXP gte 50>><<set $Counter to 3>><</if>>

<<if $CurseXP gte 10 and $CurseXP lt 25>><<set $Curse to 1>>
<<elseif $CurseXP gte 25 and $CurseXP lt 50>><<set $Curse to 2>>
<<elseif $CurseXP gte 50>><<set $Curse to 3>><</if>>

<<if $DominationXP gte 10 and $DominationXP lt 25>><<set $Domination to 1>>
<<elseif $DominationXP gte 25 and $DominationXP lt 50>><<set $Domination to 2>>
<<elseif $DominationXP gte 50>><<set $Domination to 3>><</if>>

<<if $ElementalXP gte 10 and $ElementalXP lt 25>><<set $Elemental to 1>>
<<elseif $ElementalXP gte 25 and $ElementalXP lt 50>><<set $Elemental to 2>>
<<elseif $ElementalXP gte 50>><<set $Elemental to 3>><</if>>

<<if $FertilityXP gte 10 and $FertilityXP lt 25>><<set $Fertility to 1>>
<<elseif $FertilityXP gte 25 and $FertilityXP lt 50>><<set $Fertility to 2>>
<<elseif $FertilityXP gte 50>><<set $Fertility to 3>><</if>>

<<if $AgricultureXP gte 10 and $AgricultureXP lt 25>><<set $Agriculture to 1>>
<<elseif $AgricultureXP gte 25 and $AgricultureXP lt 50>><<set $Agriculture to 2>>
<<elseif $AgricultureXP gte 50>><<set $Agriculture to 3>><</if>>

<<if $AnimalXP gte 10 and $AnimalXP lt 25>><<set $AnimalHusbandry to 1>>
<<elseif $AnimalXP gte 25 and $AnimalXP lt 50>><<set $AnimalHusbandry to 2>>
<<elseif $AnimalXP gte 50>><<set $AnimalHusbandry to 3>><</if>>

<<if $CarpentryXP gte 10 and $CarpentryXP lt 25>><<set $Carpentry to 1>>
<<elseif $CarpentryXP gte 25 and $CarpentryXP lt 50>><<set $Carpentry to 2>>
<<elseif $CarpentryXP gte 50>><<set $Carpentry to 3>><</if>>

<<if $LatinXP gte 10 and $LatinXP lt 25>><<set $Latin to 1>>
<<elseif $LatinXP gte 25 and $LatinXP lt 50>><<set $Latin to 2>>
<<elseif $LatinXP gte 50>><<set $Latin to 3>><</if>>

<<if $LoveXP gte 10 and $LoveXP lt 25>><<set $Lovemaking to 1>>
<<elseif $LoveXP gte 25 and $LoveXP lt 50>><<set $Lovemaking to 2>>
<<elseif $LoveXP gte 50>><<set $Lovemaking to 3>><</if>>

<<if $MechanicsXP gte 10 and $MechanicsXP lt 25>><<set $Mechanics to 1>>
<<elseif $MechanicsXP gte 25 and $MechanicsXP lt 50>><<set $Mechanics to 2>>
<<elseif $MechanicsXP gte 50>><</if>>
<</silently>><</widget>>