From 8c27b1488a93ef3c3fdcaf019931d0e6c4c64e70 Mon Sep 17 00:00:00 2001 From: Reid Date: Mon, 11 Apr 2016 04:00:13 +0200 Subject: Add compareandsetq function, it compares a given quest variable's value with the current one, if both vals are equals, it sets the variable with a new value. --- npc/functions/main.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'npc/functions/main.txt') diff --git a/npc/functions/main.txt b/npc/functions/main.txt index f2dad770..420f2b79 100644 --- a/npc/functions/main.txt +++ b/npc/functions/main.txt @@ -172,3 +172,16 @@ function script askyesno { return select (menuaction(l("Yes")), menuaction(l("No"))); } + +// Argument: +// 0 Quest variable +// 1 Current value +// 2 Next value +function script compareandsetq { + if (getq (getarg(0)) == getarg(1)) + { + setq getarg(0), getarg(2); + return true; + } + return false; +} -- cgit v1.2.3-60-g2f50