0 votes
by (250 points)
closed by

Hello, I'm making a dungeon crawler style game in Sugarcube, and things have mostly been going great. In order to potentially have more control over UI, and possibly open up better options for in-line menus rather than passage-based menus with copious control logic, I was advised to update to the latest version of sugarcube.

Unfortunately, this seems to have broken my functionality, in at least one of my widget-containing passages.
https://imgur.com/a/XJl2ZCX
 

Furthermore, as you can see, the error is being cut off. This is not new behavior - all of my error messages have been cut off since install, but usually the first line has been enough to get me started on a fix.

The full passage is quite long, but I do have it tagged with 'widget' (it was working before the update.)
Here is a small example widget:
 

<<widget "FightMenu">><span id = "FightMenu"><<if $charmedTurnsLeft > 0>><<Resist>><<else>><<if $tethered>><<RemoveTether>><br><</if>><<Attack!>><br><<DodgeAndWait>><br><<Flee!>><br><<Spellbook>><</if>></span><</widget>>


I'm really at a loss as to how to proceed, other than to revert to the old version of Sugarcube. Any help is appreciated, thanks.

closed with the note: Answered

1 Answer

0 votes
by (159k points)
selected by
 
Best answer

There are differences between how things work in the 1.x series and the 2.x series of SugarCube, I strongly suggests you read the Instructions for upgrading from prior SugarCube releases part of the the SugarCube 2.x documentations (if you haven't done so already. I would start at the bottom Upgrading to any release ≥2.0.0 section and work your way upwards.

I am going to assume that you have correctly tagged the Combat Widgets passage with the widget tag.

It is difficult to debug a widget that references other widgets/macros without access to the source code of those other widgets/macros, but looking at the example you did supply I did noticed a couple of things.

1. You are including punctuation characters (in this case an exclamation mark ! ) in your widget/macro names and that makes them invalid. Simply removing them will solve that issue. It is also not a good idea to include punctuation characters in passage names either.

2. You have a space character between the span element's id attribute and it's equals sign, and it's equals sign and the attribute's value. This isn't correct and can lead to issues.

<span id="FightMenu">


After I changed your example to include the above (and created dummy widgets for those you didn't supply) and ran it I didn't get an error.

by (68.6k points)

As noted by greyelf, the cause of the widget issue is the punctuation within the widget names (e.g. since you couldn't see the error: <<widget>>: cannot create widget macro "Attack!": invalid macro name "Attack!").

As to the truncated error messages.  IIRC, that's an issue with the earlier Twine 2 releases, so updating to the latest release (v2.2.1, as I write this) should fix that.  Beyond that, the latest release of SugarCube 2 (v2.24.0, as I write this) will, in addition to the error dialogs, also log most error messages to the developer console, so you may check that for the error.

...