A sugarcube widget to show the current passage's code-behind

- Posted in Coding by

Here is a widget for Sugarcube that will display the current passage's code-behind:

<<widget no-wiki>>
    <<print '<nowiki>' + Story.get(passage()).text + '</nowiki>'>>
<</widget>>

A sugarcube widget just saved me 12 Kb

- Posted in Coding by

I'm proud of a programming accomplishment I've made: I've been developing an introductory tutorial series covering Twine 2.10.0 and Sugarcube 2.37.3 — for an interested coworker.

I've been naming the tutorial passages after this convention:

TwineLesson001Passage001
TwineLesson001Passage002
etc.

Well, I had been using a block of Twinescript like the following in order to implement some cute back/forward navigation icons (shown below):

But I got to thinking to myself, "Self, there has to be a way to use a widget or function so that I'm not pasting the equivalent of a small paragraph in every single tutorial passage, just to implement this."

It took me awhile to incrementally write code, test, repeat to get the above. Just three lessons into a tutorial series (weighing in at 51 passages), my Twee3 file was 39 Kb. Using the above widget allowed me to trim that down to 27 Kb.