1
0
Fork 0

Cauldron leather armor washing

This commit is contained in:
the-real-herowl 2024-01-25 11:56:54 +01:00 committed by the-real-herowl
parent 3d799266c3
commit 3fa4cf6d52
3 changed files with 22 additions and 10 deletions

View File

@ -103,10 +103,10 @@ local function get_armor_texture(textures, name, modname, itemname, itemstring)
end
if overlay == "" then return core_armor_texture end -- key not present; armor not trimmed
return core_armor_texture .. overlay
end
return func
end
@ -129,6 +129,7 @@ function mcl_armor.register_set(def)
local groups = table.copy(groups)
groups["armor_" .. name] = 1
groups["combat_armor_" .. name] = 1
groups["armor_" .. def.name] = 1
groups.armor = 1
groups.combat_armor = 1
groups.mcl_armor_points = def.points[name]
@ -326,12 +327,12 @@ end
tt.register_snippet(function(itemstring, toolcaps, stack)
if not stack then return nil end
local meta = stack:get_meta()
if not mcl_armor.is_trimmed(stack) then return nil end
if not mcl_armor.is_trimmed(stack) then return nil end
-- we need to get the part of the overlay image between the overlay begin ( and the trim name end _
-- we COULD easily store this info in meta, but that would bloat the meta storage, as the same few values would be stored over and over again on every trimmed item
-- this is fine here as this code gets only executed when you put armor and a trim in a smithing table
local full_overlay = meta:get_string("mcl_armor:trim_overlay")
local trim_name = full_overlay:match("%((.-)%_")
local trim_name = full_overlay:match("%((.-)%_")
return "Upgrade:\n " .. trim_name:gsub("^%l", string.upper) .. " Armor Trim"
end)
@ -339,4 +340,4 @@ function mcl_armor.is_trimmed(itemstack)
-- this meta value will be there for every trimmed armor piece
-- remember, get_string returns "" if the key doesn't exist
return itemstack:get_meta():get_string("mcl_armor:trim_overlay") ~= ""
end
end

View File

@ -53,10 +53,10 @@ local function get_texture_function(texture)
end
if mcl_enchanting.is_enchanted(itemstack:get_name()) then
minetest.chat_send_all(out..mcl_enchanting.overlay)
-- minetest.chat_send_all(out..mcl_enchanting.overlay) -- TODO remove
return out..mcl_enchanting.overlay
else
minetest.chat_send_all(out)
-- minetest.chat_send_all(out) -- TODO remove
return out
end
end
@ -64,6 +64,9 @@ local function get_texture_function(texture)
end
function mcl_armor.colorize_leather_armor(itemstack, colorstring)
if not itemstack or minetest.get_item_group(itemstack:get_name(), "armor_leather") == 0 then
return
end
local color = color_string_to_table(colorstring)
local meta = itemstack:get_meta()
local old_color = meta:get_string("mcl_armor:color")
@ -83,7 +86,7 @@ function mcl_armor.colorize_leather_armor(itemstack, colorstring)
end
function mcl_armor.wash_leather_armor(itemstack)
if not itemstack or not itemstack:get_definition().groups.armor_leather == 1 then
if not itemstack or minetest.get_item_group(itemstack:get_name(), "armor_leather") == 0 then
return
end
local meta = itemstack:get_meta()
@ -119,7 +122,7 @@ mcl_armor.register_set({
})
tt.register_priority_snippet(function(_, _, itemstack)
if not itemstack or not itemstack:get_definition().groups.armor_leather == 1 then
if not itemstack or minetest.get_item_group(itemstack:get_name(), "armor_leather") == 0 then
return
end
local color = itemstack:get_meta():get_string("mcl_armor:color")
@ -137,7 +140,7 @@ minetest.register_chatcommand("color_leather", {
local player = minetest.get_player_by_name(name)
if player then
local item = player:get_wielded_item()
if not item or not item:get_definition().groups.armor_leather == 1 then
if not item or minetest.get_item_group(item:get_name(), "armor_leather") == 0 then
return false, "Not leather armor."
end
if param == "wash" then

View File

@ -94,6 +94,14 @@ local function register_filled_cauldron(water_level, description, liquid)
drop = "mcl_cauldrons:cauldron",
_mcl_hardness = 2,
_mcl_blast_resistance = 2,
on_rightclick = function(pos, node, player, itemstack)
local outcome = mcl_armor.wash_leather_armor(itemstack)
if outcome then
minetest.sound_play("mcl_potions_bottle_pour",
{pos=pos, gain=0.5, max_hear_range=16},true)
end
return outcome
end,
})
-- Add entry aliases for the Help