Armor textures support

This commit is contained in:
Elias Fleckenstein 2020-11-02 17:22:03 +01:00
parent afa11c0723
commit 22083a0ff5
4 changed files with 9 additions and 7 deletions

View file

@ -460,7 +460,7 @@ mcl_enchanting.enchantments.thorns = {
requires_tool = false, requires_tool = false,
} }
-- for tools & weapons implemented via on_enchant; for bows implemented in mcl_bows, unimplemented Armor and Fishing Rods -- for tools & weapons implemented via on_enchant; for bows implemented in mcl_bows; for armor implemented in mcl_armor and mcl_tt; unimplemented for Fishing Rods
mcl_enchanting.enchantments.unbreaking = { mcl_enchanting.enchantments.unbreaking = {
name = "Unbreaking", name = "Unbreaking",
max_level = 3, max_level = 3,

View file

@ -215,9 +215,9 @@ function mcl_enchanting.initialize()
local new_name = itemname .. "_enchanted" local new_name = itemname .. "_enchanted"
minetest.override_item(itemname, {_mcl_enchanting_enchanted_tool = new_name}) minetest.override_item(itemname, {_mcl_enchanting_enchanted_tool = new_name})
local new_def = table.copy(itemdef) local new_def = table.copy(itemdef)
new_def.inventory_image = itemdef.inventory_image .. "^[colorize:purple:50" new_def.inventory_image = itemdef.inventory_image .. "^[brighten^[colorize:purple:50"
if new_def.wield_image then if new_def.wield_image then
new_def.wield_image = new_def.wield_image .. "^[colorize:purple:50" new_def.wield_image = new_def.wield_image .. "^[brighten^[colorize:purple:50"
end end
new_def.groups.not_in_creative_inventory = 1 new_def.groups.not_in_creative_inventory = 1
new_def.groups.enchanted = 1 new_def.groups.enchanted = 1

View file

@ -5,7 +5,7 @@ mcl_enchanting = {
book_offset = vector.new(0, 0.75, 0), book_offset = vector.new(0, 0.75, 0),
roman_numerals = dofile(modpath .. "/roman_numerals.lua"), -- https://exercism.io/tracks/lua/exercises/roman-numerals/solutions/73c2fb7521e347209312d115f872fa49 roman_numerals = dofile(modpath .. "/roman_numerals.lua"), -- https://exercism.io/tracks/lua/exercises/roman-numerals/solutions/73c2fb7521e347209312d115f872fa49
enchantments = {}, enchantments = {},
debug = true, debug = false,
} }
dofile(modpath .. "/engine.lua") dofile(modpath .. "/engine.lua")

View file

@ -119,7 +119,7 @@ armor.set_player_armor = function(self, player)
local textures = {} local textures = {}
local physics_o = {speed=1,gravity=1,jump=1} local physics_o = {speed=1,gravity=1,jump=1}
local material = {type=nil, count=1} local material = {type=nil, count=1}
local preview = armor:get_preview(name) or "character_preview.png" local preview
for _,v in ipairs(self.elements) do for _,v in ipairs(self.elements) do
elements[v] = false elements[v] = false
end end
@ -136,8 +136,9 @@ armor.set_player_armor = function(self, player)
local level = def.groups["armor_"..k] local level = def.groups["armor_"..k]
if level then if level then
local texture = def.texture or item:gsub("%:", "_") local texture = def.texture or item:gsub("%:", "_")
table.insert(textures, texture..".png") local enchanted = mcl_enchanting.is_enchanted_def(item)
preview = preview.."^"..texture.."_preview.png" table.insert(textures, "("..texture..".png"..(enchanted and "^[brighten^[colorize:purple:50" or "")..")")
preview = "(player.png^[opacity:0^"..texture.."_preview.png"..(enchanted and "^[brighten^[colorize:purple:50" or "")..")"..(preview and "^"..preview or "")
armor_level = armor_level + level armor_level = armor_level + level
items = items + 1 items = items + 1
mcl_armor_points = mcl_armor_points + (def.groups["mcl_armor_points"] or 0) mcl_armor_points = mcl_armor_points + (def.groups["mcl_armor_points"] or 0)
@ -161,6 +162,7 @@ armor.set_player_armor = function(self, player)
end end
end end
end end
preview = (armor:get_preview(name) or "character_preview.png")..(preview and "^"..preview or "")
if minetest.get_modpath("shields") then if minetest.get_modpath("shields") then
armor_level = armor_level * 0.9 armor_level = armor_level * 0.9
end end