Skip to content

Instantly share code, notes, and snippets.

View ChapelR's full-sized avatar

Chapel ChapelR

View GitHub Profile
(() => {
"use strict";
function bindEvent (self) {
let $element = self.args[0] && typeof self.args[0] && $(self.args[0].trim());
if (!$element || !($element instanceof $) || !$element[0]) {
$element = $(self.output);
}
$element.ariaClick(self.createShadowWrapper(() => {
$.wiki(self.payload[0].contents);
}));
@ChapelR
ChapelR / gist:bcbcb08d3db2a1df60c16de73344ee20
Last active May 9, 2021 17:49
Harlowe DM Loading patch
// goes in story JS; see conversation below;
// only games played via Twine 2 (web)'s play/test modes have the bug
delete Map.prototype.toJSON; delete Set.prototype.toJSON;
@ChapelR
ChapelR / harlowe-to-sugarcube.md
Last active April 11, 2021 14:10
Harlowe to SugarCube basics

Differences From Harlowe

There are many differences between Harlowe and SugarCube, this section will document some of the most critical you will need to account for if you're coming in to SugarCube from a background in Harlowe.

Macros

Aside from general syntax, SugarCube macros don't use hooks, separate arguments differently, and don't allow other macros to be passed as arguments into macros.

Container Macros

Where Harlowe uses hook syntax (brackets) to associate a macro with its contents, SugarCube instead uses 'container' macros; macros that can have content associated with them have opening and closing tags.

@ChapelR
ChapelR / log.css
Last active February 21, 2021 10:15
expanding log
[data-tags~="show-log"] #passages {
margin-bottom: 5em;
}
#log {
position: fixed;
height: 4em;
padding: 1em 4em 0 4em;
z-index: 1;
bottom: 0;
@ChapelR
ChapelR / articles
Last active November 24, 2020 08:49
macros-demo
The articles macro set allows you to prepend words or phrases with the appropriate idenfitine article ("a" or "an").
<<A 'European man'>>.
It's been <<a 'honor'>>.
You can use this macro set for when you need to determine the correct article to use when generating, for example, random loot.
<<set _mats to either('iron', 'wooden', 'steel', 'adamantium', 'crystal')>>\
@@#output;You found <<a _mats>> sword!@@
@ChapelR
ChapelR / README.md
Last active September 14, 2020 05:38
Newbie Guide for tw-analytics

This document originally written by Somnium. Thank you for your contribution!

If you are a beginner Twine user and want a little extra help, here is a step-by-step guide for using TW-Analytics to add Google Analytics to your story.

For WINDOWS:

  1. This requires NodeJS; go to this address and install the "LTS" release: https://nodejs.org/en/
  2. Wait for Node.js to finish installing. You will probably need to reboot your PC.
  3. Open the win command prompt (either search for "cmd" in the start menu or presss WIN KEY + R and type cmd and press enter)
  4. The command prompt will open. Type npm i -g tw-analytics and press enter.
@ChapelR
ChapelR / typed.min.js
Created June 11, 2020 10:02
typed.js + speechbox
// Tweaked for the speechbox macro set by Thomas Michael Edwards
/*! typed.js integration module for SugarCube */
!function(){"use strict";function getInlineOptions(classNames){var options={},typedRe=/^typed(?:-(\w+))+\b$/,parseRe=/-(speed|delay)(\d+)\b/g,match=void 0;if("typed"!==classNames)for(var classOpts=classNames.toLowerCase().split(/\s+/),i=0;i<classOpts.length;++i)if(typedRe.test(classOpts[i])){for(;null!==(match=parseRe.exec(classOpts[i]));)switch(match[1]){case"speed":options.typeSpeed=Number(match[2]);break;case"delay":options.startDelay=Number(match[2])}break}return options}function typedCallbackFactory(el,callback){return function(){var $outer=jQuery(el),$inner=jQuery('<div class="typedjs-text-wrapper"><span class="typed"></span></div>'),$source=$outer.children('[class|="typed"]'),options=jQuery.extend({strings:["^0 "+$source.html()],typeSpeed:40,startDelay:400,onComplete:function(){$inner.children(".typed-cursor").remove(),callback()},preStringTyped:function(){jQuery.event.trigger(":typedstart"
@ChapelR
ChapelR / harlowe-transfer.js
Created December 28, 2018 09:14
Harlowe: Transfer Data Between Episodes
(function () {
// transfer Harlowe data between stories via local storage
var _state = State; // scope hack the state
var storageKey = '%%twine-game-episode-transfer'; // change this to something with your story's title in it
var hasStorage = (function () {
return !!window.localStorage;
}());
@ChapelR
ChapelR / README.md
Last active January 23, 2020 04:31
Say and Character Macro Set

<<character name imageSrc>> / setup.addCharacter(name, imageSrc)

Add character names to associate with image sources (as URLs). Must be done in StoryInit or the Story JavaScript area. Character names become macros later.

<<say name imageSrc>>...<</say>> / setup.say(outputElement, characterName, text, imageSrc)

Create a speech box with the given character name and image, which says the indicated text content.

Character Name Macros

@ChapelR
ChapelR / continue.js
Last active December 26, 2019 23:24
Continue macros.
(function () {
'use strict';
// selectors to ignore
var ignored = ['a', ':button', '*[role="button"]', '.continue-macro-ignore', '#ui-bar', '#ui-dialog'];
function ignoreMe () {
$(document).on('click.continue-macro keyup.continue-macro', ignored.join(', '), function (ev) {
ev.stopPropagation();
});