mirror of
https://github.com/mt-mods/spacesuit.git
synced 2026-05-04 13:56:51 -06:00
working hud
This commit is contained in:
+17
-2
@@ -4,18 +4,27 @@
|
||||
local timer = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
timer = timer + dtime;
|
||||
if timer >= 2 then
|
||||
if timer >= 1 then
|
||||
local t0 = minetest.get_us_time()
|
||||
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
local name = player:get_player_name()
|
||||
|
||||
local name, armor_inv = armor.get_valid_player(armor, player, "[spacesuit]")
|
||||
|
||||
local has_helmet = armor_inv:contains_item("armor", "spacesuit:helmet")
|
||||
local has_chestplate = armor_inv:contains_item("armor", "spacesuit:chestplate")
|
||||
local has_pants = armor_inv:contains_item("armor", "spacesuit:pants")
|
||||
local has_boots = armor_inv:contains_item("armor", "spacesuit:boots")
|
||||
|
||||
if has_helmet and has_chestplate and has_pants and has_boots and player:get_breath() < 10 then
|
||||
local has_full_suit = has_helmet and has_chestplate and has_pants and has_boots
|
||||
|
||||
local armor_list = armor_inv:get_list("armor")
|
||||
|
||||
-- does the player wear a suit?
|
||||
spacesuit.set_player_wearing(player, has_full_suit, has_helmet, armor_list)
|
||||
|
||||
if has_full_suit and player:get_breath() < 10 then
|
||||
|
||||
for i, stack in pairs(armor_inv:get_list("armor")) do
|
||||
if not stack:is_empty() then
|
||||
@@ -29,5 +38,11 @@ minetest.register_globalstep(function(dtime)
|
||||
end
|
||||
end
|
||||
timer = 0
|
||||
|
||||
local t1 = minetest.get_us_time()
|
||||
local diff = t1 - t0
|
||||
if diff > 10000 then
|
||||
minetest.log("warning", "[spacesuit] update took " .. diff .. " us")
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user