mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-25 20:11:06 +01:00
Crafting colorized leather armor
This commit is contained in:
parent
3fa4cf6d52
commit
fc6fe3f1ed
1 changed files with 53 additions and 3 deletions
|
@ -53,10 +53,8 @@ local function get_texture_function(texture)
|
||||||
end
|
end
|
||||||
|
|
||||||
if mcl_enchanting.is_enchanted(itemstack:get_name()) then
|
if mcl_enchanting.is_enchanted(itemstack:get_name()) then
|
||||||
-- minetest.chat_send_all(out..mcl_enchanting.overlay) -- TODO remove
|
|
||||||
return out..mcl_enchanting.overlay
|
return out..mcl_enchanting.overlay
|
||||||
else
|
else
|
||||||
-- minetest.chat_send_all(out) -- TODO remove
|
|
||||||
return out
|
return out
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -68,9 +66,11 @@ function mcl_armor.colorize_leather_armor(itemstack, colorstring)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local color = color_string_to_table(colorstring)
|
local color = color_string_to_table(colorstring)
|
||||||
|
colorstring = minetest.colorspec_to_colorstring(color)
|
||||||
local meta = itemstack:get_meta()
|
local meta = itemstack:get_meta()
|
||||||
local old_color = meta:get_string("mcl_armor:color")
|
local old_color = meta:get_string("mcl_armor:color")
|
||||||
if old_color ~= "" then
|
if old_color == colorstring then return
|
||||||
|
elseif old_color ~= "" then
|
||||||
color = calculate_color(
|
color = calculate_color(
|
||||||
color_string_to_table(minetest.colorspec_to_colorstring(old_color)),
|
color_string_to_table(minetest.colorspec_to_colorstring(old_color)),
|
||||||
color
|
color
|
||||||
|
@ -132,6 +132,56 @@ tt.register_priority_snippet(function(_, _, itemstack)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
for name, element in pairs(mcl_armor.elements) do
|
||||||
|
local modname = minetest.get_current_modname()
|
||||||
|
local itemname = modname .. ":" .. element.name .. "_leather"
|
||||||
|
minetest.register_craft({
|
||||||
|
type = "shapeless",
|
||||||
|
output = itemname,
|
||||||
|
recipe = {
|
||||||
|
itemname,
|
||||||
|
"group:dye",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
local ench_itemname = itemname .. "_enchanted"
|
||||||
|
minetest.register_craft({
|
||||||
|
type = "shapeless",
|
||||||
|
output = ench_itemname,
|
||||||
|
recipe = {
|
||||||
|
ench_itemname,
|
||||||
|
"group:dye",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
local function colorizing_crafting(itemstack, player, old_craft_grid, craft_inv)
|
||||||
|
if minetest.get_item_group(itemstack:get_name(), "armor_leather") == 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local found_la = nil
|
||||||
|
local dye_color = nil
|
||||||
|
for _, item in pairs(old_craft_grid) do
|
||||||
|
local name = item:get_name()
|
||||||
|
if name == "" then
|
||||||
|
-- continue
|
||||||
|
elseif minetest.get_item_group(name, "armor_leather") > 0 then
|
||||||
|
if found_la then return end
|
||||||
|
found_la = item
|
||||||
|
elseif minetest.get_item_group(name, "dye") > 0 then
|
||||||
|
if dye_color then return end
|
||||||
|
for _, row in pairs(colors) do
|
||||||
|
if row[3] == name then dye_color = row[4] end
|
||||||
|
end
|
||||||
|
else return end
|
||||||
|
end
|
||||||
|
|
||||||
|
return mcl_armor.colorize_leather_armor(found_la, dye_color) or ItemStack()
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_craft_predict(colorizing_crafting)
|
||||||
|
minetest.register_on_craft(colorizing_crafting)
|
||||||
|
|
||||||
|
|
||||||
minetest.register_chatcommand("color_leather", {
|
minetest.register_chatcommand("color_leather", {
|
||||||
params = "<color>",
|
params = "<color>",
|
||||||
|
|
Loading…
Reference in a new issue