mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-30 15:23:18 +00:00
Support [set_variable]round=trunc
(cherry-picked from commit beb5dc75aaa60af30dcfe58074771080b5da3aeb)
This commit is contained in:
parent
6c068684d6
commit
52d3b7bb6a
@ -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…
x
Reference in New Issue
Block a user