Support [set_variable]round=trunc
(cherry-picked from commit beb5dc75aa
)
This commit is contained in:
parent
6c068684d6
commit
52d3b7bb6a
1 changed files with 5 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue