mirror of
https://github.com/mt-mods/hangglider.git
synced 2024-11-13 05:50:38 +01:00
Preserve colour on repair by crafting (#15)
This commit is contained in:
parent
2c708abd88
commit
8fc1f596d2
14
crafts.lua
14
crafts.lua
|
@ -40,6 +40,14 @@ local function get_color_name(name)
|
|||
return name
|
||||
end
|
||||
|
||||
local function get_color_name_from_color(color)
|
||||
for name, color_hex in pairs(dye_colors) do
|
||||
if color == color_hex then
|
||||
return name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- This recipe is just a placeholder
|
||||
do
|
||||
local item = ItemStack("hangglider:hangglider")
|
||||
|
@ -61,9 +69,15 @@ minetest.register_on_craft(function(crafted_item, _, old_craft_grid)
|
|||
local name = stack:get_name()
|
||||
if name == "hangglider:hangglider" then
|
||||
wear = stack:get_wear()
|
||||
color = stack:get_meta():get("hangglider_color")
|
||||
color_name = get_color_name_from_color(color)
|
||||
elseif minetest.get_item_group(name, "dye") ~= 0 then
|
||||
color = get_dye_color(name)
|
||||
color_name = get_color_name(name)
|
||||
elseif "wool:white" == stack:get_name()
|
||||
or "default:paper" == stack:get_name()
|
||||
then
|
||||
wear = 0
|
||||
end
|
||||
end
|
||||
if wear and color and color_name then
|
||||
|
|
Loading…
Reference in New Issue
Block a user