From 4bb45b8a90776808265f47967f501680be3dd83f Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Fri, 30 Mar 2018 12:51:18 -0400 Subject: [PATCH] Support [set_variable]round=trunc --- data/lua/wml/set_variable.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/data/lua/wml/set_variable.lua b/data/lua/wml/set_variable.lua index ac62c49b5ba9f..2e52992739ad2 100644 --- a/data/lua/wml/set_variable.lua +++ b/data/lua/wml/set_variable.lua @@ -70,6 +70,11 @@ function wesnoth.wml_actions.set_variable(cfg) wesnoth.set_variable(name, math.ceil(var)) elseif round_val == "floor" then wesnoth.set_variable(name, math.floor(var)) + elseif round_val == "trunc" then + -- Storing to a variable first because modf returns two values, + -- and I'm not sure if set_variable will complain about the extra parameter + local new_val = math.modf(var) + wesnoth.set_variable(name, new_val) else local decimals = math.modf(tonumber(round_val) or 0) local value = var * (10 ^ decimals)