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
+2 -1
View File
@@ -4,8 +4,9 @@ globals = {
}
read_globals = {
-- Minetest
-- Luanti
"minetest",
"core",
-- Deps
"armor",
+4 -6
View File
@@ -1,6 +1,4 @@
minetest.register_craft({
core.register_craft({
output = "spacesuit:helmet",
recipe = {
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
@@ -9,7 +7,7 @@ minetest.register_craft({
},
})
minetest.register_craft({
core.register_craft({
output = "spacesuit:chestplate",
recipe = {
{"default:steel_ingot", "default:mese", "default:steel_ingot"},
@@ -18,7 +16,7 @@ minetest.register_craft({
},
})
minetest.register_craft({
core.register_craft({
output = "spacesuit:pants",
recipe = {
{"default:steel_ingot", "wool:white", "default:steel_ingot"},
@@ -27,7 +25,7 @@ minetest.register_craft({
},
})
minetest.register_craft({
core.register_craft({
output = "spacesuit:boots",
recipe = {
{"default:steel_ingot", "wool:white", "default:steel_ingot"},
-2
View File
@@ -1,2 +0,0 @@
default
3d_armor
+5 -7
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,10 +32,10 @@ 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()
@@ -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
+2 -9
View File
@@ -1,14 +1,11 @@
local HUD_POSITION = {x = 0.09, y = 0.4}
local OFFSET_LABEL = {x = 0, y = -16}
local OFFSET_LEVEL = {x = 0, y = 16}
local OFFSET_WARNING = {x = 0, y = -34}
local OFFSET_BAR = {x = 0, y = 0}
local HUD_ALIGNMENT = {x = 1, y = 0}
local hud = {} -- playername -> data
local setup_hud = function(player)
local playername = player:get_player_name()
local hud_data = {}
@@ -71,7 +68,6 @@ local setup_hud = function(player)
scale = {x = 100, y = 100},
number = 0xFF0000
})
end
local remove_hud = function(player)
@@ -141,15 +137,13 @@ local update_hud = function(player, has_full_suit, armor_list)
-- red
color = get_color(255,0,0)
player:hud_change(hud_data.o2_fg, "text", "spacesuit_o2_levels_fg_red.png")
end
player:hud_change(hud_data.o2_label, "number", color)
player:hud_change(hud_data.o2_level, "number", color)
end
minetest.register_on_leaveplayer(function(player)
core.register_on_leaveplayer(function(player)
-- remove stale hud data
local playername = player:get_player_name()
hud[playername] = nil
@@ -170,9 +164,8 @@ spacesuit.set_player_wearing = function(player, has_full_suit, has_helmet, armor
elseif not hud_data and has_helmet then
-- player started wearing
setup_hud(player)
minetest.after(0.1, function()
core.after(0.1, function()
update_hud(player, has_full_suit, armor_list)
end)
end
end
+2 -6
View File
@@ -1,14 +1,10 @@
spacesuit = {
armor_use = tonumber(minetest.settings:get("spacesuit.armor_use")) or 70,
armor_use = tonumber(core.settings:get("spacesuit.armor_use")) or 70,
}
local MP = minetest.get_modpath("spacesuit")
local MP = core.get_modpath("spacesuit")
dofile(MP.."/suit.lua")
dofile(MP.."/crafts.lua")
dofile(MP.."/hud.lua")
dofile(MP.."/drowning.lua")
print("[OK] Spacesuit")
+10 -7
View File
@@ -1,16 +1,19 @@
# Spacesuit
[![luacheck](https://github.com/mt-mods/spacesuit/workflows/luacheck/badge.svg)](https://github.com/mt-mods/spacesuit/actions)
[forum topic](https://forum.luanti.org/viewtopic.php?p=185473)
Spacesuit mod for minetest
Spacesuit mod for Luanti/Minetest
## Dependencies
# Dependencies
* 3d_armor
# Features
## Features
* Breathe in vacuum or water
# Attributions
* Spacesuit textures: Anonymous_moose (https://forum.minetest.net/viewtopic.php?p=185473#p185473)
* textures/spacesuit_overlay.png (https://github.com/bas080/minetest_vignette)
## Attributions
* Spacesuit textures: [Anonymous_moose](https://forum.luanti.org/memberlist.php?mode=viewprofile&u=7281)
* textures/spacesuit_overlay.png [bas080](https://github.com/bas080/minetest_vignette)
+24 -6
View File
@@ -1,9 +1,12 @@
armor:register_armor("spacesuit:helmet", {
description = "Spacesuit Helmet",
inventory_image = "spacesuit_inv_helmet.png",
groups = {armor_head=5, armor_heal=1, armor_use=spacesuit.armor_use, not_repaired_by_anvil=1},
groups = {
armor_head = 5,
armor_heal = 1,
armor_use = spacesuit.armor_use,
not_repaired_by_anvil = 1
},
wear = 0,
wear_represents = "spacesuit_wear",
})
@@ -11,7 +14,12 @@ armor:register_armor("spacesuit:helmet", {
armor:register_armor("spacesuit:chestplate", {
description = "Spacesuit Chestplate",
inventory_image = "spacesuit_inv_chestplate.png",
groups = {armor_torso=8, armor_heal=1, armor_use=spacesuit.armor_use, not_repaired_by_anvil=1},
groups = {
armor_torso = 8,
armor_heal = 1,
armor_use = spacesuit.armor_use,
not_repaired_by_anvil = 1
},
wear = 0,
wear_represents = "spacesuit_wear",
})
@@ -19,7 +27,12 @@ armor:register_armor("spacesuit:chestplate", {
armor:register_armor("spacesuit:pants", {
description = "Spacesuit Pants",
inventory_image = "spacesuit_inv_pants.png",
groups = {armor_legs=7, armor_heal=1, armor_use=spacesuit.armor_use, not_repaired_by_anvil=1},
groups = {
armor_legs = 7,
armor_heal = 1,
armor_use = spacesuit.armor_use,
not_repaired_by_anvil = 1
},
wear = 0,
wear_represents = "spacesuit_wear",
})
@@ -27,7 +40,12 @@ armor:register_armor("spacesuit:pants", {
armor:register_armor("spacesuit:boots", {
description = "Spacesuit Boots",
inventory_image = "spacesuit_inv_boots.png",
groups = {armor_feet=4, armor_heal=1, armor_use=spacesuit.armor_use, not_repaired_by_anvil=1},
groups = {
armor_feet = 4,
armor_heal = 1,
armor_use = spacesuit.armor_use,
not_repaired_by_anvil = 1
},
wear = 0,
wear_represents = "spacesuit_wear",
})