Skip to content

Instantly share code, notes, and snippets.

View cyrusfirheir's full-sized avatar
👾
npm i -g common-sense

Cyrus Firheir cyrusfirheir

👾
npm i -g common-sense
  • India
  • 20:42 (UTC +05:30)
View GitHub Profile
@cyrusfirheir
cyrusfirheir / Live-updates of variables displays on change - overview.md
Last active July 12, 2020 05:57
Pseudo one-way data-binding SugarCube 2 and JS variables with DOM elements.
@cyrusfirheir
cyrusfirheir / headsplit.js
Last active August 20, 2020 05:00
Splits text into parts based on a regexp of headers and returns an array of objects with the header and the content. (description is WIP)
//split text by headers (headerRegex, noOfCaptureGroupsInHeaderToReturn)
if(!String.prototype.headsplit) {
Object.defineProperty(String.prototype, 'headsplit', {
configurable: true,
writable: true,
value: function headsplit(regexp, caps = 1) {
const text = this.trim().split(/\r?\n/);
let retArr = [],
_header = "",
_content = "",
@cyrusfirheir
cyrusfirheir / VN-style-dialogue-system(SugarCube-v2)-part1.md
Last active February 25, 2022 08:40
Storing dialogue in plain text and converting it to html elements on the fly using JavaScript.

Storing dialogue in plain text and converting it to html elements on the fly using JavaScript. (Part 1)

Note!
This system is not a replacement for standard usage, and has been developed only to facilitate faster/easier markup of story/dialogue data. In no way is this advanced enough to handle choices and a bajillion conditionals. At least not yet.

This sort of an approach is best suited when one needs to display text sequentially (like in a Visual Novel) without focusing much on writing html or macros. I decided to do something like this because typing:

<<speech "Speaker Name">>
	Speech text