1
0
Fork 0

Minor refactoring of mcl_dye, fix dye texture names.

* Reorganize dyes table.
* Rename dye item textures to conform to mcl naming standard.
* Refactor dye item registration.
* Shuffle recipes around in a more logical order.
* Remove unused dye names from lists that are probably equally unused.
water_footstep
kabou 2022-12-23 01:25:26 +01:00 committed by Gitea
parent 92ee402971
commit 44f724f677
13 changed files with 164 additions and 132 deletions

View File

@ -18,10 +18,6 @@ local S = minetest.get_translator(minetest.get_current_modname())
local math = math
local string = string
-- Other mods can use these for looping through available colors
mcl_dye.basecolors = {"white", "grey", "black", "red", "yellow", "green", "cyan", "blue", "magenta"}
mcl_dye.excolors = {"white", "lightgrey", "grey", "darkgrey", "black", "red", "orange", "yellow", "lime", "green", "aqua", "cyan", "sky_blue", "blue", "violet", "magenta", "red_violet"}
-- Base color groups:
-- - basecolor_white
-- - basecolor_grey
@ -62,43 +58,43 @@ mcl_dye.excolors = {"white", "lightgrey", "grey", "darkgrey", "black", "red", "o
-- - unicolor_medium_<excolor>_s50
-- - unicolor_dark_<excolor>_s50
-- Local stuff
local dyelocal = {}
-- This collection of colors is partly a historic thing, partly something else.
dyelocal.dyes = {
{"white", "mcl_dye_white", S("White Dye"), {dye=1, craftitem=1, basecolor_white=1, excolor_white=1, unicolor_white=1}},
{"grey", "dye_grey", S("Light Grey Dye"), {dye=1, craftitem=1, basecolor_grey=1, excolor_grey=1, unicolor_grey=1}},
{"dark_grey", "dye_dark_grey", S("Grey Dye"), {dye=1, craftitem=1, basecolor_grey=1, excolor_darkgrey=1, unicolor_darkgrey=1}},
{"black", "mcl_dye_black", S("Black Dye"), {dye=1, craftitem=1, basecolor_black=1, excolor_black=1, unicolor_black=1}},
{"violet", "dye_violet", S("Purple Dye"), {dye=1, craftitem=1, basecolor_magenta=1, excolor_violet=1, unicolor_violet=1}},
{"blue", "mcl_dye_blue", S("Blue Dye"), {dye=1, craftitem=1, basecolor_blue=1, excolor_blue=1, unicolor_blue=1}},
{"lightblue", "mcl_dye_light_blue", S("Light Blue Dye"), {dye=1, craftitem=1, basecolor_blue=1, excolor_blue=1, unicolor_light_blue=1}},
{"cyan", "dye_cyan", S("Cyan Dye"), {dye=1, craftitem=1, basecolor_cyan=1, excolor_cyan=1, unicolor_cyan=1}},
{"dark_green", "dye_dark_green", S("Cactus Green"),{dye=1, craftitem=1, basecolor_green=1, excolor_green=1, unicolor_dark_green=1}},
{"green", "mcl_dye_lime", S("Lime Dye"), {dye=1, craftitem=1, basecolor_green=1, excolor_green=1, unicolor_green=1}},
{"yellow", "dye_yellow", S("Dandelion Yellow"), {dye=1, craftitem=1, basecolor_yellow=1, excolor_yellow=1, unicolor_yellow=1}},
{"brown", "mcl_dye_brown", S("Brown Dye"), {dye=1, craftitem=1, basecolor_brown=1, excolor_orange=1, unicolor_dark_orange=1, compostability = 65}},
{"orange", "dye_orange", S("Orange Dye"), {dye=1, craftitem=1, basecolor_orange=1, excolor_orange=1, unicolor_orange=1}},
{"red", "dye_red", S("Rose Red"), {dye=1, craftitem=1, basecolor_red=1, excolor_red=1, unicolor_red=1}},
{"magenta", "dye_magenta", S("Magenta Dye"), {dye=1, craftitem=1, basecolor_magenta=1, excolor_red_violet=1,unicolor_red_violet=1}},
{"pink", "dye_pink", S("Pink Dye"), {dye=1, craftitem=1, basecolor_red=1, excolor_red=1, unicolor_light_red=1}},
local dyes = {
{"white", S("White Dye"), {basecolor_white=1, excolor_white=1, unicolor_white=1}},
{"grey", S("Light Grey Dye"), {basecolor_grey=1, excolor_grey=1, unicolor_grey=1}},
{"dark_grey", S("Grey Dye"), {basecolor_grey=1, excolor_darkgrey=1, unicolor_darkgrey=1}},
{"black", S("Black Dye"), {basecolor_black=1, excolor_black=1, unicolor_black=1}},
{"violet", S("Purple Dye"), {basecolor_magenta=1, excolor_violet=1, unicolor_violet=1}},
{"blue", S("Blue Dye"), {basecolor_blue=1, excolor_blue=1, unicolor_blue=1}},
{"lightblue", S("Light Blue Dye"), {basecolor_blue=1, excolor_blue=1, unicolor_light_blue=1}},
{"cyan", S("Cyan Dye"), {basecolor_cyan=1, excolor_cyan=1, unicolor_cyan=1}},
{"dark_green", S("Cactus Green"), {basecolor_green=1, excolor_green=1, unicolor_dark_green=1}},
{"green", S("Lime Dye"), {basecolor_green=1, excolor_green=1, unicolor_green=1}},
{"yellow", S("Dandelion Yellow"), {basecolor_yellow=1, excolor_yellow=1, unicolor_yellow=1}},
{"brown", S("Brown Dye"), {basecolor_brown=1, excolor_orange=1, unicolor_dark_orange=1}},
{"orange", S("Orange Dye"), {basecolor_orange=1, excolor_orange=1, unicolor_orange=1}},
{"red", S("Rose Red"), {basecolor_red=1, excolor_red=1, unicolor_red=1}},
{"magenta", S("Magenta Dye"), {basecolor_magenta=1, excolor_red_violet=1,unicolor_red_violet=1}},
{"pink", S("Pink Dye"), {basecolor_red=1, excolor_red=1, unicolor_light_red=1}},
}
local mg_name = minetest.get_mapgen_setting("mg_name")
-- Other mods can use these for looping through available colors
mcl_dye.basecolors = {"white", "grey", "black", "magenta", "blue", "cyan", "green", "yellow", "orange", "red", "brown"}
mcl_dye.excolors = {"white", "grey", "darkgrey", "black", "violet", "blue", "cyan", "green", "yellow", "orange", "red", "red_violet"}
dyelocal.unicolor_to_dye_id = {}
for d=1, #dyelocal.dyes do
for k, _ in pairs(dyelocal.dyes[d][4]) do
local unicolor_to_dye_id = {}
for d = 1, #dyes do
for k, _ in pairs(dyes[d][3]) do
if string.sub(k, 1, 9) == "unicolor_" then
dyelocal.unicolor_to_dye_id[k] = dyelocal.dyes[d][1]
unicolor_to_dye_id[k] = dyes[d][1]
end
end
end
-- Takes an unicolor group name (e.g. “unicolor_white”) and returns a corresponding dye name (if it exists), nil otherwise.
-- Takes an unicolor group name (e.g. “unicolor_white”) and returns a
-- corresponding dye name (if it exists), nil otherwise.
function mcl_dye.unicolor_to_dye(unicolor_group)
local color = dyelocal.unicolor_to_dye_id[unicolor_group]
local color = unicolor_to_dye_id[unicolor_group]
if color then
return "mcl_dye:" .. color
else
@ -106,25 +102,21 @@ function mcl_dye.unicolor_to_dye(unicolor_group)
end
end
-- Define items
for _, row in ipairs(dyelocal.dyes) do
local name = row[1]
local img = row[2]
local description = row[3]
local groups = row[4]
local item_name = "mcl_dye:"..name
local item_image = img..".png"
minetest.register_craftitem(item_name, {
inventory_image = item_image,
description = description,
-- Define dye items.
--
for _, row in pairs(dyes) do
local name, desc, grps = unpack(row)
minetest.register_craftitem("mcl_dye:" .. name, {
inventory_image = "mcl_dye_" .. name .. ".png",
description = desc,
_doc_items_longdesc = S("This item is a dye which is used for dyeing and crafting."),
_doc_items_usagehelp = S("Rightclick on a sheep to dye its wool. Other things are dyed by crafting."),
groups = groups,
stack_max = 64,
groups = table.update({craftitem = 1, dye = 1}, grps)
})
end
-- Bone Meal
-- Bone meal code to be moved into its own mod.
--
function mcl_dye.add_bone_meal_particle(pos, def)
if not def then
def = {}
@ -378,6 +370,10 @@ end
mcl_dye.apply_bone_meal = apply_bone_meal
-- Bone meal item registration.
--
-- To be moved into its own mod.
--
minetest.register_craftitem(":mcl_bone_meal:bone_meal", {
inventory_image = "mcl_bone_meal_bone_meal.png",
description = S("Bone Meal"),
@ -422,42 +418,155 @@ minetest.register_craft({
recipe = {{"mcl_mobitems:bone"}},
})
-- Dye mixing
-- Dye creation recipes.
--
minetest.register_craft({
output = "mcl_dye:white",
recipe = {{"mcl_bone_meal:bone_meal"}},
})
minetest.register_craft({
output = "mcl_dye:black",
recipe = {{"mcl_mobitems:ink_sac"}},
})
minetest.register_craft({
output = "mcl_dye:yellow",
recipe = {{"mcl_flowers:dandelion"}},
})
minetest.register_craft({
output = "mcl_dye:yellow 2",
recipe = {{"mcl_flowers:sunflower"}},
})
minetest.register_craft({
output = "mcl_dye:blue",
recipe = {{"mcl_core:lapis"}},
})
minetest.register_craft({
output = "mcl_dye:lightblue",
recipe = {{"mcl_flowers:blue_orchid"}},
})
minetest.register_craft({
output = "mcl_dye:grey",
recipe = {{"mcl_flowers:azure_bluet"}},
})
minetest.register_craft({
output = "mcl_dye:grey",
recipe = {{"mcl_flowers:oxeye_daisy"}},
})
minetest.register_craft({
output = "mcl_dye:grey",
recipe = {{"mcl_flowers:tulip_white"}},
})
minetest.register_craft({
output = "mcl_dye:magenta",
recipe = {{"mcl_flowers:allium"}},
})
minetest.register_craft({
output = "mcl_dye:magenta 2",
recipe = {{"mcl_flowers:lilac"}},
})
minetest.register_craft({
output = "mcl_dye:orange",
recipe = {{"mcl_flowers:tulip_orange"}},
})
minetest.register_craft({
output = "mcl_dye:brown",
recipe = {{"mcl_cocoas:cocoa_beans"}},
})
minetest.register_craft({
output = "mcl_dye:pink",
recipe = {{"mcl_flowers:tulip_pink"}},
})
minetest.register_craft({
output = "mcl_dye:pink 2",
recipe = {{"mcl_flowers:peony"}},
})
minetest.register_craft({
output = "mcl_dye:red",
recipe = {{"mcl_farming:beetroot_item"}},
})
minetest.register_craft({
output = "mcl_dye:red",
recipe = {{"mcl_flowers:poppy"}},
})
minetest.register_craft({
output = "mcl_dye:red",
recipe = {{"mcl_flowers:tulip_red"}},
})
minetest.register_craft({
output = "mcl_dye:red 2",
recipe = {{"mcl_flowers:rose_bush"}},
})
minetest.register_craft({
type = "cooking",
output = "mcl_dye:dark_green",
recipe = "mcl_core:cactus",
cooktime = 10,
})
-- Dye mixing recipes.
--
minetest.register_craft({
type = "shapeless",
output = "mcl_dye:dark_grey 2",
recipe = {"mcl_dye:black", "mcl_dye:white"},
})
minetest.register_craft({
type = "shapeless",
output = "mcl_dye:lightblue 2",
recipe = {"mcl_dye:blue", "mcl_dye:white"},
})
minetest.register_craft({
type = "shapeless",
output = "mcl_dye:grey 3",
recipe = {"mcl_dye:black", "mcl_dye:white", "mcl_dye:white"},
})
minetest.register_craft({
type = "shapeless",
output = "mcl_dye:grey 2",
recipe = {"mcl_dye:dark_grey", "mcl_dye:white"},
})
minetest.register_craft({
type = "shapeless",
output = "mcl_dye:green 2",
recipe = {"mcl_dye:dark_green", "mcl_dye:white"},
})
minetest.register_craft({
type = "shapeless",
output = "mcl_dye:magenta 4",
recipe = {"mcl_dye:blue", "mcl_dye:white", "mcl_dye:red", "mcl_dye:red"},
})
minetest.register_craft({
type = "shapeless",
output = "mcl_dye:magenta 3",
recipe = {"mcl_dye:pink", "mcl_dye:red", "mcl_dye:blue"},
})
minetest.register_craft({
type = "shapeless",
output = "mcl_dye:magenta 2",
@ -481,110 +590,33 @@ minetest.register_craft({
output = "mcl_dye:violet 2",
recipe = {"mcl_dye:blue", "mcl_dye:red"},
})
minetest.register_craft({
type = "shapeless",
output = "mcl_dye:orange 2",
recipe = {"mcl_dye:yellow", "mcl_dye:red"},
})
-- Dye creation
minetest.register_craft({
output = "mcl_dye:white",
recipe = {{"mcl_bone_meal:bone_meal"}},
})
minetest.register_craft({
output = "mcl_dye:black",
recipe = {{"mcl_mobitems:ink_sac"}},
})
minetest.register_craft({
output = "mcl_dye:yellow",
recipe = {{"mcl_flowers:dandelion"}},
})
minetest.register_craft({
output = "mcl_dye:yellow 2",
recipe = {{"mcl_flowers:sunflower"}},
})
minetest.register_craft({
output = "mcl_dye:blue",
recipe = {{"mcl_core:lapis"}},
})
minetest.register_craft({
output = "mcl_dye:lightblue",
recipe = {{"mcl_flowers:blue_orchid"}},
})
minetest.register_craft({
output = "mcl_dye:grey",
recipe = {{"mcl_flowers:azure_bluet"}},
})
minetest.register_craft({
output = "mcl_dye:grey",
recipe = {{"mcl_flowers:oxeye_daisy"}},
})
minetest.register_craft({
output = "mcl_dye:grey",
recipe = {{"mcl_flowers:tulip_white"}},
})
minetest.register_craft({
output = "mcl_dye:magenta",
recipe = {{"mcl_flowers:allium"}},
})
minetest.register_craft({
output = "mcl_dye:magenta 2",
recipe = {{"mcl_flowers:lilac"}},
})
minetest.register_craft({
output = "mcl_dye:orange",
recipe = {{"mcl_flowers:tulip_orange"}},
})
minetest.register_craft({
output = "mcl_dye:brown",
recipe = {{"mcl_cocoas:cocoa_beans"}},
})
minetest.register_craft({
output = "mcl_dye:pink",
recipe = {{"mcl_flowers:tulip_pink"}},
})
minetest.register_craft({
output = "mcl_dye:pink 2",
recipe = {{"mcl_flowers:peony"}},
})
minetest.register_craft({
output = "mcl_dye:red",
recipe = {{"mcl_farming:beetroot_item"}},
})
minetest.register_craft({
output = "mcl_dye:red",
recipe = {{"mcl_flowers:poppy"}},
})
minetest.register_craft({
output = "mcl_dye:red",
recipe = {{"mcl_flowers:tulip_red"}},
})
minetest.register_craft({
output = "mcl_dye:red 2",
recipe = {{"mcl_flowers:rose_bush"}},
})
minetest.register_craft({
type = "cooking",
output = "mcl_dye:dark_green",
recipe = "mcl_core:cactus",
cooktime = 10,
})
-- legacy item grace conversion recipes
-- Legacy items grace conversion recipes.
--
-- These allow for retrieval of precious items that were converted into
-- dye items after refactoring of the dyes. Should be removed again in
-- the near future.
minetest.register_craft({
output = "mcl_bone_meal:bone_meal",
recipe = {{"mcl_dye:white"}},
})
minetest.register_craft({
output = "mcl_mobitems:ink_sac",
recipe = {{"mcl_dye:black"}},
})
minetest.register_craft({
output = "mcl_core:lapis",
recipe = {{"mcl_dye:blue"}},
})
minetest.register_craft({
output = "mcl_cocoas:cocoa_beans",
recipe = {{"mcl_dye:brown"}},

View File

Before

Width:  |  Height:  |  Size: 205 B

After

Width:  |  Height:  |  Size: 205 B

View File

Before

Width:  |  Height:  |  Size: 213 B

After

Width:  |  Height:  |  Size: 213 B

View File

Before

Width:  |  Height:  |  Size: 213 B

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 B

View File

Before

Width:  |  Height:  |  Size: 213 B

After

Width:  |  Height:  |  Size: 213 B

View File

Before

Width:  |  Height:  |  Size: 213 B

After

Width:  |  Height:  |  Size: 213 B

View File

Before

Width:  |  Height:  |  Size: 213 B

After

Width:  |  Height:  |  Size: 213 B

View File

Before

Width:  |  Height:  |  Size: 213 B

After

Width:  |  Height:  |  Size: 213 B

View File

Before

Width:  |  Height:  |  Size: 213 B

After

Width:  |  Height:  |  Size: 213 B

View File

Before

Width:  |  Height:  |  Size: 213 B

After

Width:  |  Height:  |  Size: 213 B

View File

Before

Width:  |  Height:  |  Size: 213 B

After

Width:  |  Height:  |  Size: 213 B

View File

Before

Width:  |  Height:  |  Size: 213 B

After

Width:  |  Height:  |  Size: 213 B