From 9b72e1aea2c554c338839fd5357f7ae5da1ed09a Mon Sep 17 00:00:00 2001 From: Robert Perce Date: Tue, 3 May 2016 14:44:40 -0500 Subject: [PATCH] Added 'if' function for math.js to use whenever eval-ing input --- rpg-docs/lib/functions/evaluate.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rpg-docs/lib/functions/evaluate.js b/rpg-docs/lib/functions/evaluate.js index 552f6944..9fce8c79 100644 --- a/rpg-docs/lib/functions/evaluate.js +++ b/rpg-docs/lib/functions/evaluate.js @@ -1,3 +1,12 @@ +// if we want to add more functions, consider pulling out into its own file +(function() { + math.import({ + "if": function(pred, a, b) { + return (!!(pred)) ? a : b; + } + }); +})(); + //evaluates a calculation string evaluate = function(charId, string){ if (!string) return string;