Lua: added helper.round function

This commit is contained in:
Elvish_Hunter 2012-04-12 10:12:05 +00:00
parent 8418f05e8c
commit 6bfaa5ef88
2 changed files with 13 additions and 0 deletions

View file

@ -82,6 +82,7 @@ Version 1.11.0-svn:
* Changed: Extended support for toggle_button.
* Fixed: wesnoth.find_reach does no longer replace a passed private lua
proxy unit with the on-map unit at the same location
* new: helper.round function
* Multiplayer:
* Fix an accidental terrain type change in Isar's Cross
* Fix attacker side being human in 6p_Team_Survival (bug #19400)

View file

@ -368,4 +368,16 @@ function helper.deprecate(msg, f)
end
end
function helper.round( number )
-- code converted from util.hpp, round_portable function
-- round half away from zero method
if number >= 0 then
number = math.floor( number + 0.5 )
else
number = math.ceil ( number - 0.5 )
end
return number
end
return helper