Hud: Modify Y-positioning of health/breath starbars to prevent overlapping with Hotbar
[oweals/minetest.git] / builtin / game / misc.lua
index 4afcdb99e59c91a1d563a7cce326a2795e11425a..c31df541d026977bff31ce3fee636ee3385ef4ba 100644 (file)
@@ -11,11 +11,15 @@ core.register_globalstep(function(dtime)
                table.insert(core.timers, timer)
        end
        core.timers_to_add = {}
-       for index, timer in ipairs(core.timers) do
+       local index = 1
+       while index <= #core.timers do
+               local timer = core.timers[index]
                timer.time = timer.time - dtime
                if timer.time <= 0 then
                        timer.func(unpack(timer.args or {}))
                        table.remove(core.timers,index)
+               else
+                       index = index + 1
                end
        end
 end)
@@ -89,30 +93,6 @@ function core.get_node_group(name, group)
        return core.get_item_group(name, group)
 end
 
-function core.string_to_pos(value)
-       local p = {}
-       p.x, p.y, p.z = string.match(value, "^([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+)$")
-       if p.x and p.y and p.z then
-               p.x = tonumber(p.x)
-               p.y = tonumber(p.y)
-               p.z = tonumber(p.z)
-               return p
-       end
-       local p = {}
-       p.x, p.y, p.z = string.match(value, "^%( *([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+) *%)$")
-       if p.x and p.y and p.z then
-               p.x = tonumber(p.x)
-               p.y = tonumber(p.y)
-               p.z = tonumber(p.z)
-               return p
-       end
-       return nil
-end
-
-assert(core.string_to_pos("10.0, 5, -2").x == 10)
-assert(core.string_to_pos("( 10.0, 5, -2)").z == -2)
-assert(core.string_to_pos("asd, 5, -2)") == nil)
-
 function core.setting_get_pos(name)
        local value = core.setting_get(name)
        if not value then