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.

Blessed are the Peacemakers

- Posted in SundaySchool by

Blessed are the Peacemakers

Why do you think peacemaking receives so little attention today? (Perhaps it is considered ineffective. Perhaps because it can take such a lengthy investment of time and good will. Perhaps because its goal is not just the cessation of violence but the redemption of all parties.

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()>>

Beatitude 5 - Blessed are the Merciful

- Posted in SundaySchool by

Blessed are the Merciful

Matthew 5: 7 —Blessed are the merciful, for they will be shown mercy.

The Greek word makarios (Μακάριος) means "blessed," "happy," "fortunate," or "privileged". It appears in the New Testament 50 times. Meaning Makarios is the closest Greek word to the English word "happy". It can describe someone who has a special advantage or desirable position. For example, the ancient Greeks used makarios to describe their gods, who were blessed with divine power.

Primary Twine story formats and essential tooling

- Posted in Coding by

Primary Twine story formats can be downloaded with this link, or with this one. Here is another download link.

And of course I must link to the three most important resources (ChapelR's Tweego, Chris Klimas' Twine, and Visual Studio Code. These are bundled together and can be downloaded here and here and here.

Hiev's browser storage tool is a must-have. The same author produced a nice collection of sample code, which I make downloadable here.

Here is Gwentastic's Twee File Splitter, and here is another download link. I've also backed it up to my OpenDrive and it's located here on my Onedrive account.

Finally, my go-to SugarCube template for getting new projects initiated.

Tweego compiler installer for Windows

- Posted in Coding by

Here is the download link for the Tweego compiler for Windows. It can also be downloaded here and here. Here is my template to hit the ground running with Twee3/Tweego dev. However, I recommend that, instead, you install Tweego for Windows using ChapelR's installer, and then download the much slimmer template I made here.

Remove side bar in Sugarcube 2

- Posted in Coding by

Add the following to the javascript portion of your twee file:

$('#ui-bar').remove(); 
$(document.head).find('#style-ui-bar').remove();

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

Implementing passworded content in a Twine work

- Posted in Coding by

It's not terribly difficult to implement passwording in a Twine work. First, you'd drop this into your story javascript passage:

/* hashStr - Start */
window.hashStr = function(txt) {
    var hash = 0, i, chr;
    if (txt.length === 0) return hash;
    for (i = 0; i < txt.length; i++) {
            chr   = txt.charCodeAt(i);
            hash  = ((hash << 5) - hash) + chr;
            hash |= 0; // Convert to 32bit integer
    }
    return hash;
};
/* hashStr - End */

Next, you'd need to go here (or message me and I'll help you) and use the Enter text here textbox to enter the desired password. For example, if your desired password is redrum, the hash will return -934876071 Copy that number to the clipboard, because we'll use it in the next step.

Step 3: Finally, you'll need to put the following code into a Twine passage and specify the number you got in step 2. This is a textbox where users can try to enter the correct password:

You can view the raw text here, online...

Page 5 of 67