summaryrefslogtreecommitdiff
path: root/npc/functions
diff options
context:
space:
mode:
Diffstat (limited to 'npc/functions')
-rw-r--r--npc/functions/math.txt8
1 files changed, 8 insertions, 0 deletions
diff --git a/npc/functions/math.txt b/npc/functions/math.txt
index b213cfd79..068d46cba 100644
--- a/npc/functions/math.txt
+++ b/npc/functions/math.txt
@@ -77,6 +77,14 @@ function script is_between {
}
+// forces the equation: lower <= target <= higher.
+// Note it still works if higher and target values are swapped.
+// limit ( lower, target, higher)
+function script limit {
+ return max(getarg(0), min(getarg(1), getarg(2)));
+}
+
+
// result is the ponderate average.
// ponderate_avg ( arg1, sub1, arg2, sub2)
function script ponderate_avg {