2015-06-29 19:55:56 +02:00
-- To make recipes that will work with any dye ever made by anybody, define
-- them based on groups.
-- You can select any group of groups, based on your need for amount of colors.
-- basecolor: 9, excolor: 17, unicolor: 89
--
-- Example of one shapeless recipe using a color group:
-- Note: As this uses basecolor_*, you'd need 9 of these.
-- minetest.register_craft({
-- type = "shapeless",
2021-05-29 16:12:33 +02:00
-- output = "<mod>:item_yellow",
-- recipe = {"<mod>:item_no_color", "group:basecolor_yellow"},
2015-06-29 19:55:56 +02:00
-- })
2017-02-14 18:20:54 +01:00
mcl_dye = { }
2018-05-31 05:45:57 +02:00
2021-05-29 16:12:33 +02:00
local S = minetest.get_translator ( minetest.get_current_modname ( ) )
local string = string
2019-03-08 00:00:09 +01:00
2015-06-29 19:55:56 +02:00
-- Base color groups:
-- - basecolor_white
-- - basecolor_grey
-- - basecolor_black
-- - basecolor_red
-- - basecolor_yellow
-- - basecolor_green
-- - basecolor_cyan
-- - basecolor_blue
-- - basecolor_magenta
-- Extended color groups (* = equal to a base color):
-- * excolor_white
-- - excolor_lightgrey
-- * excolor_grey
-- - excolor_darkgrey
-- * excolor_black
-- * excolor_red
-- - excolor_orange
-- * excolor_yellow
-- - excolor_lime
-- * excolor_green
-- - excolor_aqua
-- * excolor_cyan
-- - excolor_sky_blue
-- * excolor_blue
-- - excolor_violet
-- * excolor_magenta
-- - excolor_red_violet
-- The whole unifieddyes palette as groups:
-- - unicolor_<excolor>
-- For the following, no white/grey/black is allowed:
-- - unicolor_medium_<excolor>
-- - unicolor_dark_<excolor>
-- - unicolor_light_<excolor>
-- - unicolor_<excolor>_s50
-- - unicolor_medium_<excolor>_s50
-- - unicolor_dark_<excolor>_s50
-- This collection of colors is partly a historic thing, partly something else.
2022-12-23 01:25:26 +01:00
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 } } ,
2023-03-11 09:16:25 +01:00
{ " dark_green " , S ( " Green Dye " ) , { basecolor_green = 1 , excolor_green = 1 , unicolor_dark_green = 1 } } ,
2022-12-23 01:25:26 +01:00
{ " green " , S ( " Lime Dye " ) , { basecolor_green = 1 , excolor_green = 1 , unicolor_green = 1 } } ,
2023-03-11 09:16:25 +01:00
{ " yellow " , S ( " Yellow Dye " ) , { basecolor_yellow = 1 , excolor_yellow = 1 , unicolor_yellow = 1 } } ,
2022-12-23 01:25:26 +01:00
{ " 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 } } ,
2023-03-11 09:16:25 +01:00
{ " red " , S ( " Red Dye " ) , { basecolor_red = 1 , excolor_red = 1 , unicolor_red = 1 } } ,
2022-12-23 01:25:26 +01:00
{ " 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 } } ,
2015-06-29 19:55:56 +02:00
}
2022-12-23 01:25:26 +01:00
-- 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 " }
2019-03-23 00:19:17 +01:00
2022-12-23 01:25:26 +01:00
local unicolor_to_dye_id = { }
for d = 1 , # dyes do
for k , _ in pairs ( dyes [ d ] [ 3 ] ) do
2018-05-31 05:45:57 +02:00
if string.sub ( k , 1 , 9 ) == " unicolor_ " then
2022-12-23 01:25:26 +01:00
unicolor_to_dye_id [ k ] = dyes [ d ] [ 1 ]
2018-05-31 05:45:57 +02:00
end
end
end
2022-12-23 01:25:26 +01:00
-- Takes an unicolor group name (e.g. “unicolor_white”) and returns a
-- corresponding dye name (if it exists), nil otherwise.
2021-05-29 16:12:33 +02:00
function mcl_dye . unicolor_to_dye ( u nicolor_group )
2022-12-23 01:25:26 +01:00
local color = unicolor_to_dye_id [ unicolor_group ]
2019-03-15 00:10:07 +01:00
if color then
return " mcl_dye: " .. color
else
return nil
end
2018-05-31 05:45:57 +02:00
end
2022-12-23 01:25:26 +01:00
-- 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 ,
2022-12-22 22:44:21 +01:00
_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. " ) ,
2022-12-23 01:25:26 +01:00
groups = table.update ( { craftitem = 1 , dye = 1 } , grps )
2022-12-22 22:44:21 +01:00
} )
2015-06-29 19:55:56 +02:00
end
2022-05-01 12:33:19 +02:00
-- Legacy support for things now in mcl_bone_meal.
-- These shims will at some time in the future be removed.
2022-12-23 01:25:26 +01:00
--
2021-11-06 14:12:03 +01:00
function mcl_dye . add_bone_meal_particle ( pos , def )
2022-05-01 12:33:19 +02:00
minetest.log ( " warning " , " mcl_dye.add_bone_meal_particles() is deprecated. Read mcl_bone_meal/API.md! " )
mcl_bone_meal.add_bone_meal_particle ( pos , def )
2021-06-03 20:13:13 +02:00
end
2017-02-11 19:03:26 +01:00
2021-11-06 14:12:03 +01:00
function mcl_dye . register_on_bone_meal_apply ( func )
2022-05-01 12:33:19 +02:00
minetest.log ( " warning " , " mcl_dye.register_on_bone_meal_apply() is deprecated. Read mcl_bone_meal/API.md! " )
mcl_bone_meal.register_on_bone_meal_apply ( func )
2017-02-11 19:03:26 +01:00
end
2022-12-23 01:25:26 +01:00
-- Bone meal item registration.
--
-- To be moved into its own mod.
--
2022-12-22 22:44:21 +01:00
minetest.register_craftitem ( " :mcl_bone_meal:bone_meal " , {
inventory_image = " mcl_bone_meal_bone_meal.png " ,
2019-03-08 00:00:09 +01:00
description = S ( " Bone Meal " ) ,
2020-02-19 04:54:17 +01:00
_tt_help = S ( " Speeds up plant growth " ) ,
2019-03-08 00:00:09 +01:00
_doc_items_longdesc = S ( " Bone meal is a white dye and also useful as a fertilizer to speed up the growth of many plants. " ) ,
_doc_items_usagehelp = S ( " Rightclick a sheep to turn its wool white. Rightclick a plant to speed up its growth. Note that not all plants can be fertilized like this. When you rightclick a grass block, tall grass and flowers will grow all over the place. " ) ,
2015-06-29 19:55:56 +02:00
stack_max = 64 ,
2021-05-23 00:01:53 +02:00
on_place = function ( itemstack , user , pointed_thing )
2017-03-02 16:09:13 +01:00
-- Use pointed node's on_rightclick function first, if present
local node = minetest.get_node ( pointed_thing.under )
if user and not user : get_player_control ( ) . sneak then
if minetest.registered_nodes [ node.name ] and minetest.registered_nodes [ node.name ] . on_rightclick then
return minetest.registered_nodes [ node.name ] . on_rightclick ( pointed_thing.under , node , user , itemstack ) or itemstack
end
end
-- Use the bone meal on the ground
2021-11-06 14:12:03 +01:00
if ( apply_bone_meal ( pointed_thing , user ) and ( not minetest.is_creative_enabled ( user : get_player_name ( ) ) ) ) then
2017-01-05 07:23:25 +01:00
itemstack : take_item ( )
end
return itemstack
2015-06-29 19:55:56 +02:00
end ,
2018-02-01 22:45:19 +01:00
_on_dispense = function ( stack , pos , droppos , dropnode , dropdir )
-- Apply bone meal, if possible
local pointed_thing
if dropnode.name == " air " then
pointed_thing = { above = droppos , under = { x = droppos.x , y = droppos.y - 1 , z = droppos.z } }
else
pointed_thing = { above = pos , under = droppos }
end
2021-11-06 14:12:03 +01:00
local success = apply_bone_meal ( pointed_thing , nil )
2018-02-01 22:45:19 +01:00
if success then
stack : take_item ( )
end
return stack
end ,
2021-03-08 10:56:43 +01:00
_dispense_into_walkable = true
2015-06-29 19:55:56 +02:00
} )
2017-01-05 07:23:25 +01:00
minetest.register_craft ( {
2022-12-22 22:44:21 +01:00
output = " mcl_bone_meal:bone_meal 3 " ,
recipe = { { " mcl_mobitems:bone " } } ,
2017-03-15 00:51:11 +01:00
} )
2017-01-05 07:23:25 +01:00
2022-12-23 01:25:26 +01:00
-- Dye creation recipes.
--
2017-01-05 07:23:25 +01:00
minetest.register_craft ( {
2022-12-22 22:44:21 +01:00
output = " mcl_dye:white " ,
recipe = { { " mcl_bone_meal:bone_meal " } } ,
2017-01-05 07:23:25 +01:00
} )
minetest.register_craft ( {
2022-12-22 17:26:13 +01:00
output = " mcl_dye:black " ,
recipe = { { " mcl_mobitems:ink_sac " } } ,
2017-01-05 07:23:25 +01:00
} )
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:yellow " ,
2017-01-31 23:32:56 +01:00
recipe = { { " mcl_flowers:dandelion " } } ,
2017-01-05 07:23:25 +01:00
} )
2022-12-23 01:25:26 +01:00
2017-01-05 07:23:25 +01:00
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:yellow 2 " ,
2017-01-31 12:03:18 +01:00
recipe = { { " mcl_flowers:sunflower " } } ,
2017-01-05 07:23:25 +01:00
} )
2022-12-23 01:25:26 +01:00
2022-12-22 18:10:59 +01:00
minetest.register_craft ( {
output = " mcl_dye:blue " ,
recipe = { { " mcl_core:lapis " } } ,
} )
2022-12-23 01:25:26 +01:00
2023-02-14 03:35:45 +01:00
--[[ Uncomment when crafting blue dye back into lapis is removed.
2023-02-12 03:38:28 +01:00
minetest.register_craft ( {
output = " mcl_dye:blue " ,
recipe = { { " mcl_flowers:cornflower " } } ,
2023-02-14 03:35:45 +01:00
} ) ] ]
2023-02-12 03:38:28 +01:00
2017-01-05 07:23:25 +01:00
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:lightblue " ,
2017-01-31 12:03:18 +01:00
recipe = { { " mcl_flowers:blue_orchid " } } ,
2017-01-05 07:23:25 +01:00
} )
2022-12-23 01:25:26 +01:00
2017-01-05 07:23:25 +01:00
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:grey " ,
2017-01-31 12:03:18 +01:00
recipe = { { " mcl_flowers:azure_bluet " } } ,
2017-01-05 07:23:25 +01:00
} )
2022-12-23 01:25:26 +01:00
2017-01-05 07:23:25 +01:00
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:grey " ,
2017-01-31 12:03:18 +01:00
recipe = { { " mcl_flowers:oxeye_daisy " } } ,
2017-01-05 07:23:25 +01:00
} )
2022-12-23 01:25:26 +01:00
2017-01-05 07:23:25 +01:00
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:grey " ,
2017-01-31 12:03:18 +01:00
recipe = { { " mcl_flowers:tulip_white " } } ,
2017-01-05 07:23:25 +01:00
} )
2022-12-23 01:25:26 +01:00
2017-01-05 07:23:25 +01:00
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:magenta " ,
2017-01-31 12:03:18 +01:00
recipe = { { " mcl_flowers:allium " } } ,
2017-01-05 07:23:25 +01:00
} )
2022-12-23 01:25:26 +01:00
2017-01-05 07:23:25 +01:00
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:magenta 2 " ,
2017-01-31 12:03:18 +01:00
recipe = { { " mcl_flowers:lilac " } } ,
2017-01-05 07:23:25 +01:00
} )
2022-12-23 01:25:26 +01:00
2017-01-05 07:23:25 +01:00
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:orange " ,
2017-01-31 12:03:18 +01:00
recipe = { { " mcl_flowers:tulip_orange " } } ,
2017-01-05 07:23:25 +01:00
} )
2022-12-23 01:25:26 +01:00
2022-12-22 19:32:15 +01:00
minetest.register_craft ( {
output = " mcl_dye:brown " ,
recipe = { { " mcl_cocoas:cocoa_beans " } } ,
} )
2022-12-23 01:25:26 +01:00
2017-01-05 07:23:25 +01:00
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:pink " ,
2017-01-31 12:03:18 +01:00
recipe = { { " mcl_flowers:tulip_pink " } } ,
2017-01-05 07:23:25 +01:00
} )
2022-12-23 01:25:26 +01:00
2017-01-05 07:23:25 +01:00
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:pink 2 " ,
2017-01-31 12:03:18 +01:00
recipe = { { " mcl_flowers:peony " } } ,
2017-01-05 07:23:25 +01:00
} )
2022-12-23 01:25:26 +01:00
2017-03-15 00:51:11 +01:00
minetest.register_craft ( {
output = " mcl_dye:red " ,
recipe = { { " mcl_farming:beetroot_item " } } ,
} )
2022-12-23 01:25:26 +01:00
2017-01-05 07:23:25 +01:00
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:red " ,
2017-01-31 12:03:18 +01:00
recipe = { { " mcl_flowers:poppy " } } ,
2017-01-05 07:23:25 +01:00
} )
2022-12-23 01:25:26 +01:00
2017-01-05 07:23:25 +01:00
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:red " ,
2017-01-31 12:03:18 +01:00
recipe = { { " mcl_flowers:tulip_red " } } ,
2017-01-05 07:23:25 +01:00
} )
2022-12-23 01:25:26 +01:00
2017-01-05 07:23:25 +01:00
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:red 2 " ,
2017-01-31 12:03:18 +01:00
recipe = { { " mcl_flowers:rose_bush " } } ,
2017-01-05 07:23:25 +01:00
} )
2022-12-23 01:25:26 +01:00
2023-02-14 03:35:45 +01:00
--[[Uncomment when crafting white dye back into bonemeal is removed
2023-02-12 03:25:05 +01:00
minetest.register_craft ( {
output = " mcl_dye:white " ,
recipe = { { " mcl_flowers:lily_of_the_valley " } } ,
2023-02-14 03:35:45 +01:00
} ) ] ]
2023-02-12 03:25:05 +01:00
2017-01-05 07:23:25 +01:00
minetest.register_craft ( {
type = " cooking " ,
2017-01-30 15:33:04 +01:00
output = " mcl_dye:dark_green " ,
2017-01-31 23:32:56 +01:00
recipe = " mcl_core:cactus " ,
2017-01-05 07:23:25 +01:00
cooktime = 10 ,
} )
2022-12-22 17:26:13 +01:00
2023-02-11 22:28:54 +01:00
minetest.register_craft ( {
type = " cooking " ,
output = " mcl_dye:green " ,
recipe = " group:sea_pickle " ,
cooktime = 10 ,
} )
2022-12-23 01:25:26 +01:00
-- Dye mixing recipes.
--
2017-01-05 07:23:25 +01:00
minetest.register_craft ( {
2022-12-23 01:25:26 +01:00
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 " } ,
} )
2022-12-22 17:26:13 +01:00
2022-12-23 01:25:26 +01:00
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 " ,
recipe = { " mcl_dye:violet " , " mcl_dye:pink " } ,
} )
minetest.register_craft ( {
type = " shapeless " ,
output = " mcl_dye:pink 2 " ,
recipe = { " mcl_dye:red " , " mcl_dye:white " } ,
} )
minetest.register_craft ( {
type = " shapeless " ,
output = " mcl_dye:cyan 2 " ,
recipe = { " mcl_dye:blue " , " mcl_dye:dark_green " } ,
} )
minetest.register_craft ( {
type = " shapeless " ,
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 " } ,
} )
-- 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.
2022-12-22 22:44:21 +01:00
minetest.register_craft ( {
output = " mcl_bone_meal:bone_meal " ,
recipe = { { " mcl_dye:white " } } ,
} )
2022-12-23 01:25:26 +01:00
2022-12-22 17:26:13 +01:00
minetest.register_craft ( {
output = " mcl_mobitems:ink_sac " ,
recipe = { { " mcl_dye:black " } } ,
} )
2022-12-23 01:25:26 +01:00
2022-12-22 18:10:59 +01:00
minetest.register_craft ( {
output = " mcl_core:lapis " ,
recipe = { { " mcl_dye:blue " } } ,
} )
2022-12-23 01:25:26 +01:00
2022-12-22 19:32:15 +01:00
minetest.register_craft ( {
output = " mcl_cocoas:cocoa_beans " ,
recipe = { { " mcl_dye:brown " } } ,
2017-01-05 07:23:25 +01:00
} )