Skip to content

main_doc

Chris Rabe edited this page Mar 2, 2018 · 3 revisions

Text Module

Function Description
toFancytext(text:string) converts text parameter input into ascii characters that look 'fancy'.
toFliptext(text: string) turns text parameter input upside-down. Returns null if a blank string or null character is passed as the parameter.
toFliptextTable(text:string) similar to toFliptext but adds a flip-table asciimoticon beside the text.
toWitchtext(text:string) converts text parameter input into ascii characters that look 'witch-like'.
toCrazytext(text:string) convert text parameter input into ascii characters that look 'crazy'.
toBubbletext(text:string) converts text parameter input into ascii characters surrounded by 'bubbles'.
toArcanetext(text:string) converts text parameter input into ascii characters that look 'arcane'.

Number Module

Function Description
dice(amount) Retrieves a die with circles specified by the amount parameter. amount must be within 1 - 6
randomDice() Retrieves a random die.
loading(percent) Creates a loading bar that contains a shaded section which symbolises the percent parameter passed.
dollarbill(amount) Creates a dollar bill that has the value of the amount parameter passed.

Faces Module

This is a map which contains the asciimoticon and the words associated to it.

const faces = core.faces;

for (var faceName in faces) {
    const face = faces[faceName];
    console.log(`|${face.ascii} | ${face.words} |`); // TOO MANY TO DEFINE
}

Each object in the map contains words and ascii properties. To retrieve a specific face, simply access it by passing the name of the asciimoticon into the map. Here's a list of all available faces.

Themes Module

This is a map which contains themes mapped to arrays of asciimoticons related to that theme.

const themes = core.themes;
for(var theme in themes){
   const faces = themes[theme]; // array object
   console.log(faces); // TOO MANY TO DEFINE
}

Parts Module

Contains ascii components for specific parts.

const parts = core.parts;
// Load different array of parts
const eyes = parts.eyes;
const cheeks = parts.cheeks;
const mouth = parts.mouth;
const face = parts.face;
const arms = parts.arms;
const wings = parts.wings;
const other = parts.other;
const weapon = parts.weapon;

Builder Module

Function Description
template() creates a new template object. Always use this if you want user define mappings.
parse(text:string, options?: object, template?: object) parses the text and converts delimited words with asciimoticons
build(sequence: string[], template: object) Builds an asciimoticon using the sequence and the custom mapping

Builder Module Usage

Templates

This functionality should be used in conjunction with core.parts module.

Defining custom keywords

const template = builder.template();
template.map('key1', 'value1');
template.map('key2', 'value2');
console.log(template.content); // {key1: 'value1', key2: 'value2'}

Deleting keywords

const template = builder.template();
template.map('key1', 'value1');
template.map('key2', 'value2');
template.delete('key1'); // deletes key1 property
console.log(template.content); // {key2: 'value2'}

Updating values inside keywords

const template = builder.template();
template.map('key1', 'value1');
template.map('key1', 'value2'); //overwrite template
console.log(template.content); // {key1: 'value2'}

Defining custom text modules

// This one is used if you want your custom text module
const template = builder.template();
template.map('customtext', (text) => { //do stuff here });
// If you pass this into the parse function, you can use it by calling (customtext,value)

Parse Function

Replacing text with faces

const input = '(bear)';
const output = builder.parse(input);
console.log(output); // ʕ·͡ᴥ·ʔ

Converting text into core.text module outputs

const input = '(fliptext,abcdefghijklmnopqrstuvwxyz)';
const output = builder.parse(input);

console.log(output); //zʎxʍʌnʇsɹbdouɯןʞɾıɥƃɟǝpɔqɐ

Defining custom prefix and suffix

const options = {
    prefix: ':',
    suffix: ':'
};
const input = ':bear:';
const output = builder.parse(input, options);
console.log(output); // ʕ·͡ᴥ·ʔ

Using custom faces with template

// define template mapping
const template = builder.template();
template.map('custom', '(o____O)');

const input = '(custom)';
const output = builder.parse(input, null, template);

console.log(output) //(o____O)

Using custom text module with template

const template = builder.template();
template.map('customtext', (text) => { //do stuff here });

const input = '(customtext,some values here)';
const output = builder.parse(input, null, template);

console.log(output); //customtext output

Build Function

Creating your own asciimoticon

const template = builder.template();
template.map('eL', 'o');
template.map('eR', 'o');
template.map('fL', '(');
template.map('fR', ')');
template.map('m', '_');

const sequence = ['fL', 'eL', 'm', 'eR', 'fR'];
const output = builder.build(sequence, template);
console.log(output); //(o_o)
Clone this wiki locally