mirror of
https://github.com/minetest-mods/3d_armor.git
synced 2025-12-18 17:25:25 +01:00
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:
@@ -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
41
3d_armor/gamecompat.lua
Normal 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
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
BIN
3d_armor/sounds/armor_glass_break.ogg
Normal file
BIN
3d_armor/sounds/armor_glass_break.ogg
Normal file
Binary file not shown.
BIN
3d_armor/sounds/armor_glass_hit.ogg
Normal file
BIN
3d_armor/sounds/armor_glass_hit.ogg
Normal file
Binary file not shown.
BIN
3d_armor/sounds/armor_metal_break.ogg
Normal file
BIN
3d_armor/sounds/armor_metal_break.ogg
Normal file
Binary file not shown.
BIN
3d_armor/sounds/armor_metal_dig.ogg
Normal file
BIN
3d_armor/sounds/armor_metal_dig.ogg
Normal file
Binary file not shown.
BIN
3d_armor/sounds/armor_wood_walk.ogg
Normal file
BIN
3d_armor/sounds/armor_wood_walk.ogg
Normal file
Binary file not shown.
@@ -2,12 +2,8 @@
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
local armor_stand_formspec = "size[8,7]" ..
|
||||
default.gui_bg ..
|
||||
default.gui_bg_img ..
|
||||
default.gui_slots ..
|
||||
default.get_hotbar_bg(0,3) ..
|
||||
"list[current_name;main;3,0.5;2,1;]" ..
|
||||
"list[current_name;main;3,1.5;2,1;2]" ..
|
||||
armor.add_formspec_list("current_name", "main", 3, 0.5, 2, 1) ..
|
||||
armor.add_formspec_list("current_name", "main", 3, 1.5, 2, 1, 2) ..
|
||||
"image[3,0.5;1,1;3d_armor_stand_head.png]" ..
|
||||
"image[4,0.5;1,1;3d_armor_stand_torso.png]" ..
|
||||
"image[3,1.5;1,1;3d_armor_stand_legs.png]" ..
|
||||
@@ -179,7 +175,7 @@ local function register_armor_stand(def)
|
||||
},
|
||||
groups = {choppy=2, oddly_breakable_by_hand=2},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
sounds = armor.sounds.wood,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec", armor_stand_formspec)
|
||||
|
||||
BIN
3d_armor_stand/sounds/armor_wood_dig.ogg
Normal file
BIN
3d_armor_stand/sounds/armor_wood_dig.ogg
Normal file
Binary file not shown.
BIN
3d_armor_stand/sounds/armor_wood_walk.ogg
Normal file
BIN
3d_armor_stand/sounds/armor_wood_walk.ogg
Normal file
Binary file not shown.
@@ -8,3 +8,9 @@ Armor Textures: Copyright (C) 2017-2023 davidthecreator - CC-BY-SA 3.0
|
||||
Special credit to Jordach and MirceaKitsune for providing the default 3d character model.
|
||||
|
||||
New armor/shield textures CC-BY-SA 3.0 / davidthecreator / https://forum.minetest.net/viewtopic.php?f=11&t=4654&start=800#p356448
|
||||
|
||||
Wood armor sounds / CC0 / TinyWorlds / https://opengameart.org/content/different-steps-on-wood-stone-leaves-gravel-and-mud
|
||||
|
||||
Metal armor sounds / CC0 / Ogrebane / https://opengameart.org/content/wood-and-metal-sound-effects-volume-2
|
||||
|
||||
Glass armor sounds / CC0 / rubberduck / https://opengameart.org/content/75-cc0-breaking-falling-hit-sfx
|
||||
128
shields/init.lua
128
shields/init.lua
@@ -8,16 +8,36 @@
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
local disable_sounds = minetest.settings:get_bool("shields_disable_sounds")
|
||||
local function play_sound_effect(player, name)
|
||||
if not disable_sounds and player then
|
||||
local pos = player:get_pos()
|
||||
if pos then
|
||||
minetest.sound_play(name, {
|
||||
pos = pos,
|
||||
max_hear_distance = 10,
|
||||
gain = 0.5,
|
||||
})
|
||||
end
|
||||
local function play_sound_effect(player, sounds, field_main, field_fallback)
|
||||
if disable_sounds or not player then
|
||||
return
|
||||
end
|
||||
|
||||
local soundspec = sounds[field_main] or (field_fallback and sounds[field_fallback])
|
||||
if not soundspec then
|
||||
core.log("warning", "3d_armor: no shield sound available in " .. dump(sounds))
|
||||
return
|
||||
end
|
||||
|
||||
local pos = player:get_pos()
|
||||
if pos then
|
||||
minetest.sound_play(soundspec, {
|
||||
pos = pos,
|
||||
max_hear_distance = 10,
|
||||
gain = 1.0,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
-- Helper functions to play a sound in "on_damage" and "on_destroy" callbacks
|
||||
local function on_damage_play_sound(sounds)
|
||||
return function(player, index, stack)
|
||||
play_sound_effect(player, sounds, "dig", "footstep")
|
||||
end
|
||||
end
|
||||
local function on_destroy_play_sound(sounds)
|
||||
return function(player, index, stack)
|
||||
play_sound_effect(player, sounds, "dug")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -66,12 +86,8 @@ if armor.materials.wood then
|
||||
armor_groups = {fleshy=5},
|
||||
damage_groups = {cracky=3, snappy=2, choppy=3, crumbly=2, level=1},
|
||||
reciprocate_damage = true,
|
||||
on_damage = function(player, index, stack)
|
||||
play_sound_effect(player, "default_wood_footstep")
|
||||
end,
|
||||
on_destroy = function(player, index, stack)
|
||||
play_sound_effect(player, "default_wood_footstep")
|
||||
end,
|
||||
on_damage = on_damage_play_sound(armor.sounds.wood),
|
||||
on_destroy = on_destroy_play_sound(armor.sounds.wood),
|
||||
})
|
||||
--- Enhanced Wood Shield
|
||||
--
|
||||
@@ -93,12 +109,8 @@ if armor.materials.wood then
|
||||
armor_groups = {fleshy=8},
|
||||
damage_groups = {cracky=3, snappy=2, choppy=3, crumbly=2, level=2},
|
||||
reciprocate_damage = true,
|
||||
on_damage = function(player, index, stack)
|
||||
play_sound_effect(player, "default_dig_metal")
|
||||
end,
|
||||
on_destroy = function(player, index, stack)
|
||||
play_sound_effect(player, "default_dug_metal")
|
||||
end,
|
||||
on_damage = on_damage_play_sound(armor.sounds.metal),
|
||||
on_destroy = on_destroy_play_sound(armor.sounds.metal),
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "shields:shield_enhanced_wood",
|
||||
@@ -136,12 +148,8 @@ if armor.materials.cactus then
|
||||
armor_groups = {fleshy=5},
|
||||
damage_groups = {cracky=3, snappy=3, choppy=2, crumbly=2, level=1},
|
||||
reciprocate_damage = true,
|
||||
on_damage = function(player, index, stack)
|
||||
play_sound_effect(player, "default_wood_footstep")
|
||||
end,
|
||||
on_destroy = function(player, index, stack)
|
||||
play_sound_effect(player, "default_wood_footstep")
|
||||
end,
|
||||
on_damage = on_damage_play_sound(armor.sounds.wood),
|
||||
on_destroy = on_destroy_play_sound(armor.sounds.wood),
|
||||
})
|
||||
--- Enhanced Cactus Shield
|
||||
--
|
||||
@@ -163,12 +171,8 @@ if armor.materials.cactus then
|
||||
armor_groups = {fleshy=8},
|
||||
damage_groups = {cracky=3, snappy=3, choppy=2, crumbly=2, level=2},
|
||||
reciprocate_damage = true,
|
||||
on_damage = function(player, index, stack)
|
||||
play_sound_effect(player, "default_dig_metal")
|
||||
end,
|
||||
on_destroy = function(player, index, stack)
|
||||
play_sound_effect(player, "default_dug_metal")
|
||||
end,
|
||||
on_damage = on_damage_play_sound(armor.sounds.metal),
|
||||
on_destroy = on_destroy_play_sound(armor.sounds.metal),
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "shields:shield_enhanced_cactus",
|
||||
@@ -209,12 +213,8 @@ if armor.materials.steel then
|
||||
armor_groups = {fleshy=10},
|
||||
damage_groups = {cracky=2, snappy=3, choppy=2, crumbly=1, level=2},
|
||||
reciprocate_damage = true,
|
||||
on_damage = function(player, index, stack)
|
||||
play_sound_effect(player, "default_dig_metal")
|
||||
end,
|
||||
on_destroy = function(player, index, stack)
|
||||
play_sound_effect(player, "default_dug_metal")
|
||||
end,
|
||||
on_damage = on_damage_play_sound(armor.sounds.metal),
|
||||
on_destroy = on_destroy_play_sound(armor.sounds.metal),
|
||||
})
|
||||
end
|
||||
|
||||
@@ -242,12 +242,8 @@ if armor.materials.bronze then
|
||||
armor_groups = {fleshy=10},
|
||||
damage_groups = {cracky=2, snappy=3, choppy=2, crumbly=1, level=2},
|
||||
reciprocate_damage = true,
|
||||
on_damage = function(player, index, stack)
|
||||
play_sound_effect(player, "default_dig_metal")
|
||||
end,
|
||||
on_destroy = function(player, index, stack)
|
||||
play_sound_effect(player, "default_dug_metal")
|
||||
end,
|
||||
on_damage = on_damage_play_sound(armor.sounds.metal),
|
||||
on_destroy = on_destroy_play_sound(armor.sounds.metal),
|
||||
})
|
||||
end
|
||||
|
||||
@@ -271,12 +267,8 @@ if armor.materials.diamond then
|
||||
armor_groups = {fleshy=15},
|
||||
damage_groups = {cracky=2, snappy=1, choppy=1, level=3},
|
||||
reciprocate_damage = true,
|
||||
on_damage = function(player, index, stack)
|
||||
play_sound_effect(player, "default_glass_footstep")
|
||||
end,
|
||||
on_destroy = function(player, index, stack)
|
||||
play_sound_effect(player, "default_break_glass")
|
||||
end,
|
||||
on_damage = on_damage_play_sound(armor.sounds.glass),
|
||||
on_destroy = on_destroy_play_sound(armor.sounds.glass),
|
||||
})
|
||||
end
|
||||
|
||||
@@ -304,12 +296,8 @@ if armor.materials.gold then
|
||||
armor_groups = {fleshy=10},
|
||||
damage_groups = {cracky=1, snappy=2, choppy=2, crumbly=3, level=2},
|
||||
reciprocate_damage = true,
|
||||
on_damage = function(player, index, stack)
|
||||
play_sound_effect(player, "default_dig_metal")
|
||||
end,
|
||||
on_destroy = function(player, index, stack)
|
||||
play_sound_effect(player, "default_dug_metal")
|
||||
end,
|
||||
on_damage = on_damage_play_sound(armor.sounds.metal),
|
||||
on_destroy = on_destroy_play_sound(armor.sounds.metal),
|
||||
})
|
||||
end
|
||||
|
||||
@@ -332,12 +320,8 @@ if armor.materials.mithril then
|
||||
armor_groups = {fleshy=16},
|
||||
damage_groups = {cracky=2, snappy=1, level=3},
|
||||
reciprocate_damage = true,
|
||||
on_damage = function(player, index, stack)
|
||||
play_sound_effect(player, "default_glass_footstep")
|
||||
end,
|
||||
on_destroy = function(player, index, stack)
|
||||
play_sound_effect(player, "default_break_glass")
|
||||
end,
|
||||
on_damage = on_damage_play_sound(armor.sounds.glass),
|
||||
on_destroy = on_destroy_play_sound(armor.sounds.glass),
|
||||
})
|
||||
end
|
||||
|
||||
@@ -361,12 +345,8 @@ if armor.materials.crystal then
|
||||
armor_groups = {fleshy=15},
|
||||
damage_groups = {cracky=2, snappy=1, level=3},
|
||||
reciprocate_damage = true,
|
||||
on_damage = function(player, index, stack)
|
||||
play_sound_effect(player, "default_glass_footstep")
|
||||
end,
|
||||
on_destroy = function(player, index, stack)
|
||||
play_sound_effect(player, "default_break_glass")
|
||||
end,
|
||||
on_damage = on_damage_play_sound(armor.sounds.glass),
|
||||
on_destroy = on_destroy_play_sound(armor.sounds.glass),
|
||||
})
|
||||
end
|
||||
|
||||
@@ -390,12 +370,8 @@ if armor.materials.nether then
|
||||
armor_groups = {fleshy=20},
|
||||
damage_groups = {cracky=3, snappy=2, level=3},
|
||||
reciprocate_damage = true,
|
||||
on_damage = function(player, index, stack)
|
||||
play_sound_effect(player, "default_glass_footstep")
|
||||
end,
|
||||
on_destroy = function(player, index, stack)
|
||||
play_sound_effect(player, "default_break_glass")
|
||||
end,
|
||||
on_damage = on_damage_play_sound(armor.sounds.glass),
|
||||
on_destroy = on_destroy_play_sound(armor.sounds.glass),
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
name = shields
|
||||
depends = default, 3d_armor
|
||||
depends = 3d_armor
|
||||
optional_depends = default
|
||||
description = Adds visible shields to 3d armor.
|
||||
|
||||
Reference in New Issue
Block a user