diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b529d52 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +# + +*.xcf +*.swp diff --git a/init.lua b/init.lua index bfe6715..c9c31d9 100644 --- a/init.lua +++ b/init.lua @@ -37,6 +37,7 @@ minetest.register_tool(mod_name..':leather_armor', { description = 'Leather Armor', _dinv_armor = 0.9, _dinv_location = 'body', + _dinv_texture = 'dinv_char_leather_armor.png', }) minetest.register_tool(mod_name..':boots', { @@ -44,6 +45,7 @@ minetest.register_tool(mod_name..':boots', { description = 'Sturdy Boots', _dinv_armor = 0.9, _dinv_location = 'feet', + _dinv_texture = 'dinv_char_boots.png', }) minetest.register_tool(mod_name..':leather_cap', { @@ -51,6 +53,7 @@ minetest.register_tool(mod_name..':leather_cap', { description = 'Leather Cap', _dinv_armor = 0.9, _dinv_location = 'head', + _dinv_texture = 'dinv_char_leather_helm.png', }) minetest.register_tool(mod_name..':steel_helmet', { @@ -58,6 +61,7 @@ minetest.register_tool(mod_name..':steel_helmet', { description = 'Steel Helmet', _dinv_armor = 0.8, _dinv_location = 'head', + --_dinv_texture = '', }) minetest.register_tool(mod_name..':wood_shield', { @@ -65,6 +69,7 @@ minetest.register_tool(mod_name..':wood_shield', { description = 'Wooden Shield', _dinv_armor = 0.8, _dinv_location = 'arm', + _dinv_texture = 'dinv_char_wood_shield.png', }) minetest.register_tool(mod_name..':steel_shield', { @@ -72,6 +77,7 @@ minetest.register_tool(mod_name..':steel_shield', { description = 'Steel Shield', _dinv_armor = 0.7, _dinv_location = 'arm', + --_dinv_texture = '', }) minetest.register_tool(mod_name..':chain_armor', { @@ -79,6 +85,7 @@ minetest.register_tool(mod_name..':chain_armor', { description = 'Chain Mail', _dinv_armor = 0.75, _dinv_location = 'body', + _dinv_texture = 'dinv_char_chain_armor.png', }) minetest.register_tool(mod_name..':plate_armor', { @@ -86,6 +93,7 @@ minetest.register_tool(mod_name..':plate_armor', { description = 'Plate Mail', _dinv_armor = 0.6, _dinv_location = 'body', + --_dinv_texture = '', }) minetest.register_tool(mod_name..':diamond_plate_armor', { @@ -93,6 +101,7 @@ minetest.register_tool(mod_name..':diamond_plate_armor', { description = 'Diamond Plate Mail', _dinv_armor = 0.45, _dinv_location = 'body', + --_dinv_texture = '', }) minetest.register_tool(mod_name..':fur_cloak', { @@ -101,6 +110,7 @@ minetest.register_tool(mod_name..':fur_cloak', { _dinv_armor = 0.98, _dinv_warmth = 2, _dinv_location = 'back', + --_dinv_texture = '', }) --print(dump(minetest.registered_tools[mod_name..':plate_armor'])) @@ -640,6 +650,7 @@ minetest.register_on_joinplayer(function(player) pinv:set_size(worn_inv, 8) mod.set_main_size_by_bags(player) mod.set_armor(player) + mod.set_armor_textures(player) player:set_inventory_formspec(mod.make_inventory_spec(player)) end) @@ -829,6 +840,29 @@ function mod.get_warmth(player) end +function mod.set_armor_textures(player) + local prop = player:get_properties() + local textures = prop.textures + --local tex = (textures and textures[1] or 'character.png') + local tex = 'character.png' + local pile = {} + for k, v in worn_items(player) do + local vs = v:get_name() + local it = minetest.registered_items[vs] + if it._dinv_location and it._dinv_texture then + pile[it._dinv_location] = it._dinv_texture + end + end + for _, loc in pairs({ 'body', 'feet', 'head', 'arm', 'back' }) do + if pile[loc] then + tex = tex .. '^' .. pile[loc] + end + end + textures = { tex } + player_api.set_textures(player, textures) +end + + function mod.set_armor(player) if not player then return @@ -870,6 +904,7 @@ function mod.damage_armor(player, damage) player:get_inventory():set_stack(worn_inv, k, v) if ow + wear > 65535 then mod.set_armor(player) + mod.set_armor_textures(player) end end end @@ -912,6 +947,7 @@ minetest.register_on_player_inventory_action(function(player, action, inventory, mod.set_main_size_by_bags(player) mod.set_armor(player) + mod.set_armor_textures(player) end) diff --git a/textures/dinv_char_boots.png b/textures/dinv_char_boots.png new file mode 100644 index 0000000..eba0f66 Binary files /dev/null and b/textures/dinv_char_boots.png differ diff --git a/textures/dinv_char_chain_armor.png b/textures/dinv_char_chain_armor.png new file mode 100644 index 0000000..7737257 Binary files /dev/null and b/textures/dinv_char_chain_armor.png differ diff --git a/textures/dinv_char_leather_armor.png b/textures/dinv_char_leather_armor.png new file mode 100644 index 0000000..00eb942 Binary files /dev/null and b/textures/dinv_char_leather_armor.png differ diff --git a/textures/dinv_char_leather_helm.png b/textures/dinv_char_leather_helm.png new file mode 100644 index 0000000..da3ecfb Binary files /dev/null and b/textures/dinv_char_leather_helm.png differ diff --git a/textures/dinv_char_wood_shield.png b/textures/dinv_char_wood_shield.png new file mode 100644 index 0000000..ee1b6a2 Binary files /dev/null and b/textures/dinv_char_wood_shield.png differ