Merge pull request #7 from coil0/timer

Wear spacesuit accounting for server lag
This commit is contained in:
Thomas Rudin
2019-06-25 07:05:20 +02:00
committed by GitHub
2 changed files with 7 additions and 7 deletions
+6 -6
View File
@@ -30,7 +30,7 @@ minetest.register_globalstep(function(dtime)
if not stack:is_empty() then if not stack:is_empty() then
local name = stack:get_name() local name = stack:get_name()
if name:sub(1, 10) == "spacesuit:" then if name:sub(1, 10) == "spacesuit:" then
local use = minetest.get_item_group(name, "armor_use") or 0 local use = minetest.get_item_group(name, "armor_use") * timer or 0
armor:damage(player, i, stack, use) armor:damage(player, i, stack, use)
end end
end end
@@ -41,10 +41,10 @@ minetest.register_globalstep(function(dtime)
end end
timer = 0 timer = 0
local t1 = minetest.get_us_time() local t1 = minetest.get_us_time()
local diff = t1 - t0 local diff = t1 - t0
if diff > 10000 then if diff > 10000 then
minetest.log("warning", "[spacesuit] update took " .. diff .. " us") minetest.log("warning", "[spacesuit] update took " .. diff .. " us")
end end
end end
end) end)
+1 -1
View File
@@ -1,6 +1,6 @@
spacesuit = { spacesuit = {
armor_use = tonumber(minetest.settings:get("spacesuit.armor_use")) or 75, armor_use = tonumber(minetest.settings:get("spacesuit.armor_use")) or 70,
} }