"Fairmath System": Snowman (v1.3.0)


"Fairmath System" demonstrates how to re-create the Fairmath system found in ChoiceScript. Based on a percentage operation, increase and decrease changes the value by a percentage as the difference between the original and adjusted value.

This example uses functions increase() and decrease() as part of a created global window.fairmath. These can be called through using the Underscore template functionality to define, use, and show the values of the functions in any one passage.

Live Example

Download: Live Example

Twee Code

:: StoryTitle
Fairmath in Snowman

:: UserScript[script]
window.fairmath = {};

window.fairmath.increase = function(x,y) {
    return Math.round(x+((100-x)*(y/100)));

window.fairmath.decrease = function(x,y) {
    return Math.round(x-(x*(y/100)));

:: Start
Decrease 100 by 50% using Fairmath:
<%= window.fairmath.decrease(100, 50) %>

Increase 50 by 50% using Fairmath:
<%= window.fairmath.increase(50, 50) %>

Download: Twee Code

results matching ""

    No results matching ""