Change font face and size in Twine with Sugarcue

- Posted in Coding by

Thanks to Josh Grams, I now understand how to set up players/readers of my twines with the ability to change font face and font size. Below I link to the scripts you need to drop, respectively, into the javascript and stylesheet special passages in the desktop Twine 2.10.0 app. Here is the zip containing the needed JS and CSS. I host a demo of this here and here, and mention it in my Twine Tidbits on the local copy of my blog.

Run your own website-hosted Twine dev tool

- Posted in Coding by

You can run your own copy of the Twine development tool, either by hosting it on your website or by running it in XAMPP. For example, here it is running on my own website. And here is the 4 Mb download if you want a copy. I also have a copy here on my Onedrive.

Work project as of 28th March 2025

- Posted in Coding by

Below is a compressed arrangement of the nodes that make up my current Twine project for my employer. A downloadable zip archive of these images at full size is here. The following is an Osage version:

Perhaps you'd prefer the twopi version below;

Below is the neato version:

And finally, below I show the fdp version:

Implementation of a quiz in sugarcube 2.37.3

- Posted in Coding by

Here is code I developed in Twee3 format to implement a quiz in a Twine project using Twine 2.10.0 and Sugarcube 2.37.3 — utilizing three widgets I made, combined with passages that present quiz items.

Radio buttons are used for multiple-choice ABCD responses. It's a simple 10-item quiz. The $knight* variables are setup in the :: StoryInit passage of my Twee3 source.

Here is a download of the code, and below is a listing of it.

Twine games I Want To Play

- Posted in Coding by

The IFDB

Chronicles of the Moorwakker here on itch.io or download it: generic or Win-specific — or online at the author's website

They Will Not Return by John Ayliff

Seedship by John Ayliff

Rage Quest by John Ayliff

Linking to passages by URL

- Posted in Coding by

Put the following code into the Javascript section of your Twine project:

/* Anchor Link to Passage - Start */
if ("onhashchange" in window) {  // event supported
    window.onhashchange = function () {
            hashChanged();
    };
} else {  // event not supported
    window.setInterval(function () {
            if (window.location.hash != setup.storedHash) {
                    hashChanged();
            }
    }, 100);
}
function hashChanged() {
    if (Engine.isIdle()) {
            if (window.location.hash && (setup.storedHash != window.location.hash)) {
                    setup.storedHash = window.location.hash;
                    var anchor = decodeURI(window.location.hash.substring(1));
                    if (Story.has(anchor) && (passage() !== anchor)) {
                            Engine.play(anchor);
                    }
            } else {
                    // Comment out the following line of code if you don't want the
                    // anchor link of the current passage displayed in the URL bar.
                    window.location.hash = encodeURI(passage());
            }
            // Comment out the following line of code if you don't want the
            // title of the page set to the passage name.
            document.title = passage();
    } else {
            setTimeout(hashChanged, 100);
    }
}
$(document).on(':passageend', function () { hashChanged(); });
/* Anchor Link to Passage - End */

Next, put the following into a header passage, but feel free to restrict its use with passage tags.

Iterate over passages to filter them

- Posted in Coding by
setup.getPassageNames = function() {
            const excludedNames = ['StoryInit', 'Main']; 
            const excludedTags = ['widget', 'nonono']; 
            const passageNames = [];
            
            $('tw-passagedata').each(function() {
                const name = $(this).attr('name');
                const tags = $(this).attr('tags');
                let safeTags = true;
                
                    if (excludedNames.indexOf(name) === -1) {
                      
                      for (let i = 0; i < excludedTags.length; i++) {
                        if (tags.includes(excludedTags[i])) {
                            safeTags = false;
                            break;
                        }
                      }
                      
                      if (safeTags) {
                        passageNames.push(name);
                      }  
                }
            });
        
            return passageNames; 
        };
        
        
    <<set _possiblePlaces = setup.getPassageNames()>>
    <<set _randomPassage = _possiblePlaces.random()>>

Dev notes for Twine story entitled Dorn

- Posted in Coding by
dev.tw
        passworded access to Developer Notes
dorn_head_foot.tw
        contains header and footer passage 
          for use with hbar and bbar tags\
dorn_intro.tw
        contains passages comprising the Intro to the game/story
dorn_2.tw
        contains ?# passages that form the beginning of this hyperfic
dorn_last.tw
        contains scripts and special passages
        contains code for the playtime macro
        contains code for the fade-in macro
        contains code for hashing to enable passwording
        contains code to implement [nosave] tag for passages
        contains Config data:
          maxSlotSaves = 3
          maxStates = 50
          saves.isAllowed conditions
        contains code to check for [noreturn] tag, for menuing
        contains code to add visits to passage(s) programmatically 
               during initialization (for testing)
        contains code in PassageReady to track total number of passage visits
Page 1 of 2