Skip to content

Instantly share code, notes, and snippets.

View tmedwards's full-sized avatar

Thomas M. Edwards tmedwards

View GitHub Profile
@tmedwards
tmedwards / preload-images.js
Created January 8, 2023 12:59
Image preload function & macro
/*
Image preload function & macro.
*/
/*
preload(imageURLs)
*/
var preload = (function () {
var loadImage = (function () {
// Image loading attributes.
@tmedwards
tmedwards / saves_dialog_w_overwrite.js
Last active August 31, 2022 02:38
Saves dialog w/ overwrite buttons
(function () {
// Create a new localization string for overwrite buttons.
l10nStrings.savesLabelOverwrite = 'Overwrite';
// Attempt to alter the Saves dialog.
$(document).on(':dialogopened', function (ev) {
// Cache the jQuery-wrapped dialog body element.
var $dialogBody = $(ev.target);
// Bail out if this is not the Saves dialog.
@tmedwards
tmedwards / README_DATE_TIME_WIDGETS.md
Last active October 2, 2021 00:05
Date & Time Widgets for the Gregorian Calendar

Date & Time Widgets for the Gregorian Calendar

The widgets use the JavaScript Date object to provide the inner workings of a Gregorian Calendar (a.k.a. Christian/Western calendar).

Set the initial date to the date/time you want and all players should see the same game world dates and times.

Installation

The widgets within the date_time_widgets.txt file (see below) should be pasted into a widget tagged passage. After doing so, the initial game date/time must be set within the setup section. Each of the printing widgets may be customized.

@tmedwards
tmedwards / binary-to-unicode.js
Last active October 21, 2019 23:21
Binary text to Unicode functions.
/*
Functions to covert binary text to Unicode.
setup.latin1FromBinary(inputString)
Param: `inputString` - Binary string to convert (1-byte per char).
Returns: The converted Unicode string.
setup.unicodeFromBinary(inputString) → Unicode string.
Param: `inputString` - Binary string to convert (2-bytes per char).
Returns: The converted Unicode string.
@tmedwards
tmedwards / basic_context_example.js
Last active February 16, 2021 02:50
Very basic example showing how to share state via the context chain
Macro.add('scene', {
tags : null,
handler : function () {
/* Argument sanity checking. */
// Extend our execution context with the `_scene` object so our
// descendants may share state, by looking up our context.
Object.defineProperty(this, '_scene', {
value : /* Whatever you need to share, probably an object. */
});
@tmedwards
tmedwards / textboxplus-macro.min.js
Created June 28, 2019 08:27
<<textboxplus>> macro for SugarCube v2
/*! <<textboxplus>> macro for SugarCube v2 */
!function(){"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj};if("undefined"==typeof version||void 0===version.title||"SugarCube"!==version.title||void 0===version.major||version.major<2||void 0===version.minor||version.minor<22)throw new Error("<<textboxplus>> macro requires SugarCube 2.22.0 or greater, aborting load");Macro.add("textboxplus",{isAsync:!0,tags:null,handler:function(){var _this=this;if(this.args.length<2){var errors=[];return this.args.length<1&&errors.push("variable name"),this.args.length<2&&errors.push("default value"),this.error("no "+errors.join(" or ")+" specified")}if("string"!=typeof this.args[0])return this.error("variable name argument is not a string");var varName=this.args[0].trim();if("$"!==varName[0]&&"_"!==varName[0])return this.error('variable n
@tmedwards
tmedwards / snippet-phoenix-with-qn-qp.gcs
Created May 1, 2019 17:11
Code snippet to add QN/QP to the core attribute section of the Phoenix character sheet for GCA4.
''''''''''''''''''
'basic attributes'
''''''''''''''''''
'setup for the basic attributes & (optionally) Tech Level
CurrentY = CurrentTop
StatLeft = CurrentLeft
StatRight = StatLeft + SubColWidth
'print the basic attributes
PrimaryStats_RenderItem "ST", StatLeft, StatRight, StatHeight, True, True
@tmedwards
tmedwards / t8n-typewriter-module-for-sugarcube-v2.js
Created August 9, 2018 04:48
t8n-typewriter module for SugarCube v2
/*! t8n-typewriter module for SugarCube v2 */
!function(){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),Furl=function(){function Furl(current,append){if(_classCallCheck(this,Furl),Object.defineProperties(this,{node:{value:current},childNodes:{value:[]},value:{writable:!0,value:""},append:{writable:!0,value:!!append},abortTyping:{writable:!0,value:!1}}),this.node.nodeValue&&(this.value=this.node.nodeValue,this.node.n
@tmedwards
tmedwards / sc-i18n-example-2.twee
Last active November 28, 2023 01:08
SugarCube v2 basic internationalization (i18n) example using a switching method (in Twee notation)
:: StoryTitle
SugarCube i18n example
:: Language Switching [script]
;(function () {
/***********************************************************
Set up a `i18n` object on SugarCube's `setup` object.
***********************************************************/
setup.i18n = {
@tmedwards
tmedwards / move-ui-bar-right.css
Last active January 24, 2018 21:08
Move the SugarCube v2 UI bar to the right side.
/*
Move the UI bar to the right side.
*/
#story {
margin-left: 2.5em;
margin-right: 20em;
transition: none;
transition: margin-right 200ms ease-in;
}
#ui-bar.stowed ~ #story {