core -> minetest and fix some formating/style (#16)

Co-authored-by: Sheriff_U3 <sheriff_u3@noreply.codeberg.org>
This commit is contained in:
Sheriff_U3
2026-06-28 19:12:30 -05:00
committed by GitHub
parent 6d3e303c9a
commit 33f7331eb9
8 changed files with 69 additions and 64 deletions
+6 -8
View File
@@ -10,9 +10,7 @@ local function check_player(player, timer)
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")
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?
@@ -24,7 +22,7 @@ local function check_player(player, timer)
if not stack:is_empty() then
local name = stack:get_name()
if name:sub(1, 10) == "spacesuit:" then
local use = minetest.get_item_group(name, "armor_use") * timer or 0
local use = (core.get_item_group(name, "armor_use") * timer) or 0
armor:damage(player, i, stack, use)
end
end
@@ -34,17 +32,17 @@ local function check_player(player, timer)
elseif not has_full_suit then
-- check if player is in vacuum without spacesuit
local is_admin = minetest.check_player_privs(player:get_player_name(), "privs")
local is_admin = core.check_player_privs(player:get_player_name(), "privs")
if not is_admin then
local ppos = player:get_pos()
local node = minetest.get_node(ppos)
local node = core.get_node(ppos)
if node.name == "vacuum:vacuum" then
-- player does not wear a suit, let him/her suffer!
local breath = player:get_breath()
if breath > 0 then
player:set_breath(math.max(0, player:get_breath() - 4))
end
if breath < 4 then
if breath < 4 then
player:set_hp( player:get_hp() - 2, "drown" )
end
end
@@ -53,10 +51,10 @@ local function check_player(player, timer)
end
local timer = 0
minetest.register_globalstep(function(dtime)
core.register_globalstep(function(dtime)
timer = timer + dtime;
if timer >= 2 then
for _,player in ipairs(minetest.get_connected_players()) do
for _,player in ipairs(core.get_connected_players()) do
check_player(player, timer)
end
timer = 0