Skip to content

Instantly share code, notes, and snippets.

View ChapelR's full-sized avatar

Chapel ChapelR

View GitHub Profile
function match (id, target, contents, macroName) {
return $(document.createElement('span'))
.attr({'id' : id, 'data-term' : target })
.addClass('macro-' + macroName)
.wiki(contents);
}
function change (id, replacement) {
var $el = $(id),
text = $el.text(),
/*! howler.js v2.0.5 | (c) 2013-2017, James Simpson of GoldFire Studios | MIT License | howlerjs.com */
// modified for Harlowe by Chapel
!function(){"use strict";var e=function(){this.init()};e.prototype={init:function(){var e=this||n;return e._counter=1e3,e._codecs={},e._howls=[],e._muted=!1,e._volume=1,e._canPlayEvent="canplaythrough",e._navigator="undefined"!=typeof window&&window.navigator?window.navigator:null,e.masterGain=null,e.noAudio=!1,e.usingWebAudio=!0,e.autoSuspend=!0,e.ctx=null,e.mobileAutoEnable=!0,e._setup(),e},volume:function(e){var o=this||n;if(e=parseFloat(e),o.ctx||_(),void 0!==e&&e>=0&&e<=1){if(o._volume=e,o._muted)return o;o.usingWebAudio&&(o.masterGain.gain.value=e);for(var t=0;t<o._howls.length;t++)if(!o._howls[t]._webAudio)for(var r=o._howls[t]._getSoundIds(),a=0;a<r.length;a++){var u=o._howls[t]._soundById(r[a]);u&&u._node&&(u._node.volume=u._volume*e)}return o}return o._volume},mute:function(e){var o=this||n;o.ctx||_(),o._muted=e,o.usingWebAudio&&(o.masterGain.gain.value=e?0:o._vol
(function () {
var options = {
setting : true,
settingName : 'Transparency: ',
defTrans : 30,
skipTags : ['mainmenu']
};
function toPerc (val) {
window.Chapel = window.Chapel || {};
(function () {
var storage = window.localStorage || false;
var achievementKey = 'tw-achievement';
var achievements = [];
function setItem (key, val) {
try {
if (storage) {
storage.setItem(key, JSON.stringify(val));
\<<widget 'tenth'>>
\ <span id="typewriter"></span>
\ <<set _textArrayLength to 0, _i to 0, _output to ''>>
\ <<repeat .1s>>
\ <<if _textArrayLength gte $args[_i].length>>
\ <<set _i++, _textArrayLength to 0>>
\ <<if _i gte $args.length>>
\ <<stop>>
\ <</if>>
\ <<set _output to _output + '<br />'>>
@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 / swap.js
Last active January 11, 2019 21:51
swap macro set
/*
the following `(function () {...}());` statement creates a local scope for our JavaScript code.
this is called an IIFE, or "immediately invoked function expression". most langauges have block scoping,
JS has function scoping. think of this as a way to get block scoping to prevent any of our stuff from
polluting the global scope.
*/
(function () {
/*