Remove 'default dependency

Make the 'default' dependency optional

This commit introduces compatibility functions needed by the
3d_armor mods to adapt to the game that is being used.

Added license information to LICENSE.md in the modpack folder.

Co-authored-by: Sheriff U3 <210896603+Sheriff-Unit-3@users.noreply.github.com>
This commit is contained in:
SmallJoker
2025-12-02 15:56:38 -06:00
parent 063505f9ea
commit baa16e28cb
15 changed files with 127 additions and 99 deletions

View File

@@ -108,18 +108,16 @@ local armor_textures = setmetatable({}, {
end
})
armor = {
local armor_fields = {
timer = 0,
elements = {"head", "torso", "legs", "feet"},
physics = {"jump", "speed", "gravity"},
attributes = {"heal", "fire", "water", "feather"},
formspec = "image[2.5,0;2,4;armor_preview]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
default.get_hotbar_bg(0, 4.7)..
"list[current_player;main;0,4.7;8,1;]"..
"list[current_player;main;0,5.85;8,3;8]",
formspec = (
"image[2.5,0;2,4;armor_preview]" ..
armor.add_formspec_list("current_player", "main", 0, 4.7, 8, 1) ..
armor.add_formspec_list("current_player", "main", 0, 5.85, 8, 3, 8)
),
def = armor_def,
textures = armor_textures,
default_skin = "character",
@@ -156,10 +154,13 @@ armor = {
on_destroy = {},
},
migrate_old_inventory = true,
version = "0.4.13",
get_translator = S
}
for k, v in pairs(armor_fields) do
armor[k] = v
end
armor.config = {
init_delay = 2,
bones_delay = 1,

41
3d_armor/gamecompat.lua Normal file
View File

@@ -0,0 +1,41 @@
-- 3d_armor defaults to support unknown games
local sounds = {
wood = {
footstep = { name = "armor_wood_walk", gain = 0.5 },
dig = { name = "armor_wood_dig", gain = 0.5 },
dug = { name = "armor_wood_walk", gain = 0.5 }
},
metal = {
dig = { name = "armor_metal_dig", gain = 0.5 },
dug = { name = "armor_metal_break", gain = 0.5 },
},
glass = {
dig = { name = "armor_glass_hit", gain = 0.5 },
dug = { name = "armor_glass_break", gain = 0.5 },
},
}
local formspec_list_template = "list[%s;%s;%f,%f;%f,%f;%s]"
-- Allow custom slot styling
armor.add_formspec_list = function(location, listname, x, y, w, h, offset)
return formspec_list_template:format(location, listname, x, y, w, h, tostring(offset) or "")
end
if core.get_modpath("default") then
sounds = {
wood = default.node_sound_wood_defaults(),
metal = default.node_sound_metal_defaults(),
glass = default.node_sound_glass_defaults(),
}
-- armor.add_formspec_list : use formspec prepends for styling
end
-- Sanity checks
for name, def in pairs(sounds) do
assert(type(def) == "table", "Incorrect registration of sound " .. name)
end
armor.sounds = sounds

View File

@@ -8,6 +8,11 @@ local worldpath = minetest.get_worldpath()
local last_punch_time = {}
local timer = 0
armor = {
version = "0.4.13"
}
dofile(modpath.."/gamecompat.lua")
dofile(modpath.."/api.lua")
-- local functions
@@ -480,10 +485,12 @@ end)
if armor.config.fire_protect == true then
-- make torches hurt
minetest.override_item("default:torch", {damage_per_second = 1})
minetest.override_item("default:torch_wall", {damage_per_second = 1})
minetest.override_item("default:torch_ceiling", {damage_per_second = 1})
if core.get_modpath("default") then
-- make torches hurt
minetest.override_item("default:torch", {damage_per_second = 1})
minetest.override_item("default:torch_wall", {damage_per_second = 1})
minetest.override_item("default:torch_ceiling", {damage_per_second = 1})
end
-- check player damage for any hot nodes we may be protected against
minetest.register_on_player_hpchange(function(player, hp_change, reason)

View File

@@ -1,5 +1,5 @@
name = 3d_armor
depends = default, player_api
optional_depends = player_monoids, armor_monoid, pova, moreores
depends = player_api
optional_depends = default, player_monoids, armor_monoid, pova, moreores
description = Adds craftable armor that is visible to other players.
min_minetest_version = 5.4

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.