2015-06-29 20:55:56 +03:00
-- minetest/dye/init.lua
-- 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",
-- output = '<mod>:item_yellow',
-- recipe = {'<mod>:item_no_color', 'group:basecolor_yellow'},
-- })
-- Other mods can use these for looping through available colors
2017-02-14 19:20:54 +02:00
mcl_dye = { }
2015-06-29 20:55:56 +03:00
local dye = { }
dye.basecolors = { " white " , " grey " , " black " , " red " , " yellow " , " green " , " cyan " , " blue " , " magenta " }
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
-- - 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
-- Local stuff
local dyelocal = { }
-- This collection of colors is partly a historic thing, partly something else.
dyelocal.dyes = {
2017-01-20 05:54:09 +02:00
{ " white " , " Bone Meal " , { dye = 1 , craftitem = 1 , basecolor_white = 1 , excolor_white = 1 , unicolor_white = 1 } } ,
{ " grey " , " Light Grey Dye " , { dye = 1 , craftitem = 1 , basecolor_grey = 1 , excolor_grey = 1 , unicolor_grey = 1 } } ,
{ " dark_grey " , " Grey Dye " , { dye = 1 , craftitem = 1 , basecolor_grey = 1 , excolor_darkgrey = 1 , unicolor_darkgrey = 1 } } ,
{ " black " , " Ink Sac " , { dye = 1 , craftitem = 1 , basecolor_black = 1 , excolor_black = 1 , unicolor_black = 1 } } ,
2017-02-07 02:31:40 +02:00
{ " violet " , " Purple Dye " , { dye = 1 , craftitem = 1 , basecolor_magenta = 1 , excolor_violet = 1 , unicolor_violet = 1 } } ,
2017-01-20 05:54:09 +02:00
{ " blue " , " Lapis Lazuli " , { dye = 1 , craftitem = 1 , basecolor_blue = 1 , excolor_blue = 1 , unicolor_blue = 1 } } ,
{ " lightblue " , " Light Blue Dye " , { dye = 1 , craftitem = 1 , basecolor_blue = 1 , excolor_blue = 1 , unicolor_light_blue = 1 } } ,
{ " cyan " , " Cyan Dye " , { dye = 1 , craftitem = 1 , basecolor_cyan = 1 , excolor_cyan = 1 , unicolor_cyan = 1 } } ,
{ " dark_green " , " Cactus Green " , { dye = 1 , craftitem = 1 , basecolor_green = 1 , excolor_green = 1 , unicolor_dark_green = 1 } } ,
{ " green " , " Lime Dye " , { dye = 1 , craftitem = 1 , basecolor_green = 1 , excolor_green = 1 , unicolor_green = 1 } } ,
{ " yellow " , " Dandelion Yellow " , { dye = 1 , craftitem = 1 , basecolor_yellow = 1 , excolor_yellow = 1 , unicolor_yellow = 1 } } ,
{ " brown " , " Cocoa Beans " , { dye = 1 , craftitem = 1 , basecolor_yellow = 1 , excolor_orange = 1 , unicolor_dark_orange = 1 } } ,
{ " orange " , " Orange Dye " , { dye = 1 , craftitem = 1 , basecolor_orange = 1 , excolor_orange = 1 , unicolor_orange = 1 } } ,
{ " red " , " Rose Red " , { dye = 1 , craftitem = 1 , basecolor_red = 1 , excolor_red = 1 , unicolor_red = 1 } } ,
{ " magenta " , " Magenta Dye " , { dye = 1 , craftitem = 1 , basecolor_magenta = 1 , excolor_red_violet = 1 , unicolor_red_violet = 1 } } ,
{ " pink " , " Pink Dye " , { dye = 1 , craftitem = 1 , basecolor_red = 1 , excolor_red = 1 , unicolor_light_red = 1 } } ,
2015-06-29 20:55:56 +03:00
}
-- Define items
for _ , row in ipairs ( dyelocal.dyes ) do
local name = row [ 1 ]
2017-02-18 17:06:18 +02:00
-- White and brown dyes are defined explicitly below
if name ~= " white " and name ~= " brown " then
local description = row [ 2 ]
local groups = row [ 3 ]
local item_name = " mcl_dye: " .. name
local item_image = " dye_ " .. name .. " .png "
minetest.register_craftitem ( item_name , {
inventory_image = item_image ,
description = description ,
2017-03-10 04:29:48 +02:00
_doc_items_longdesc = " This item is a dye which is used for dyeing and crafting. " ,
_doc_items_usagehelp = " Rightclick on a sheep to dye its wool. Other things are dyed by crafting. " ,
2017-02-18 17:06:18 +02:00
groups = groups ,
stack_max = 64 ,
} )
end
2015-06-29 20:55:56 +03:00
end
2017-02-11 20:03:26 +02:00
-- Bone Meal
2017-02-14 19:20:54 +02:00
mcl_dye.apply_bone_meal = function ( pointed_thing )
2017-02-11 20:03:26 +02:00
local plant_tab = {
" air " ,
2017-02-11 21:57:56 +02:00
" mcl_core:tallgrass " ,
" mcl_core:tallgrass " ,
" mcl_core:tallgrass " ,
" mcl_core:tallgrass " ,
" mcl_core:tallgrass " ,
2017-02-11 20:03:26 +02:00
" mcl_flowers:dandelion " ,
" mcl_flowers:blue_orchid " ,
" mcl_flowers:oxeye_daisy " ,
" mcl_flowers:tulip_orange " ,
" mcl_flowers:tulip_red " ,
" mcl_flowers:tulip_white " ,
" mcl_flowers:tulip_pink " ,
" mcl_flowers:allium " ,
" mcl_flowers:poppy " ,
" mcl_flowers:azure_bluet " ,
}
pos = pointed_thing.under
n = minetest.get_node ( pos )
if n.name == " " then return false end
local stage = " "
if n.name == " mcl_core:sapling " then
minetest.add_node ( pos , { name = " air " } )
mcl_core.generate_tree ( pos , " mcl_core:tree " , " mcl_core:leaves " , 1 )
return true
elseif string.find ( n.name , " mcl_farming:wheat_ " ) ~= nil then
stage = string.sub ( n.name , - 1 )
if stage == " 3 " then
minetest.add_node ( pos , { name = " mcl_farming:wheat " } )
elseif math.random ( 1 , 5 ) < 3 then
minetest.add_node ( pos , { name = " mcl_farming:wheat " } )
else
minetest.add_node ( pos , { name = " mcl_farming:wheat_ " .. math.random ( 2 , 3 ) } )
end
return true
elseif string.find ( n.name , " mcl_farming:potato_ " ) ~= nil then
stage = tonumber ( string.sub ( n.name , - 1 ) )
if stage == 1 then
minetest.add_node ( pos , { name = " mcl_farming:potato_ " .. math.random ( stage , 2 ) } )
else
minetest.add_node ( pos , { name = " mcl_farming:potato " } )
end
return true
elseif string.find ( n.name , " mcl_farming:beetroot_ " ) ~= nil then
stage = tonumber ( string.sub ( n.name , - 1 ) )
if stage == 1 then
minetest.add_node ( pos , { name = " mcl_farming:beetroot_ " .. math.random ( stage , 2 ) } )
else
minetest.add_node ( pos , { name = " mcl_farming:beetroot " } )
end
return true
elseif string.find ( n.name , " mcl_farming:carrot_ " ) ~= nil then
stage = tonumber ( string.sub ( n.name , - 1 ) )
if stage == 1 then
minetest.add_node ( pos , { name = " mcl_farming:carrot_ " .. math.random ( stage , 2 ) } )
else
minetest.add_node ( pos , { name = " mcl_farming:carrot " } )
end
return true
elseif string.find ( n.name , " mcl_farming:pumpkin_ " ) ~= nil then
stage = tonumber ( string.sub ( n.name , - 1 ) )
2017-03-14 03:37:42 +02:00
if stage then
stage = stage + math.random ( 2 , 5 )
if stage >= 8 then
minetest.add_node ( pos , { name = " mcl_farming:pumpkintige_unconnect " } )
else
minetest.add_node ( pos , { name = " mcl_farming:pumpkin_ " .. stage } )
end
2017-02-11 20:03:26 +02:00
end
return true
elseif string.find ( n.name , " mcl_farming:melontige_ " ) ~= nil then
stage = tonumber ( string.sub ( n.name , - 1 ) )
2017-03-14 03:37:42 +02:00
if stage then
stage = stage + math.random ( 2 , 5 )
if stage >= 8 then
minetest.add_node ( pos , { name = " mcl_farming:melontige_unconnect " } )
else
minetest.add_node ( pos , { name = " mcl_farming:melontige_ " .. stage } )
end
2017-02-11 20:03:26 +02:00
end
return true
2017-02-18 21:23:26 +02:00
elseif n.name == " mcl_cocoas:cocoa_1 " or n.name == " mcl_cocoas:cocoa_2 " then
mcl_cocoas.grow ( pos )
2017-02-18 20:25:34 +02:00
return true
2017-02-11 20:03:26 +02:00
elseif n.name ~= " " and n.name == " mcl_core:junglesapling " then
minetest.add_node ( pos , { name = " air " } )
mcl_core.generate_tree ( pos , " mcl_core:jungletree " , " mcl_core:jungleleaves " , 2 )
return true
elseif n.name == " mcl_core:dirt_with_grass " then
for i = - 2 , 3 , 1 do
for j = - 3 , 2 , 1 do
pos = pointed_thing.above
pos = { x = pos.x + i , y = pos.y , z = pos.z + j }
n = minetest.get_node ( pos )
n2 = minetest.get_node ( { x = pos.x , y = pos.y - 1 , z = pos.z } )
if n.name ~= " " and n.name == " air " and n2.name == " mcl_core:dirt_with_grass " then
if math.random ( 0 , 5 ) > 3 then
minetest.add_node ( pos , { name = plant_tab [ math.random ( 1 , # plant_tab ) ] } )
else
minetest.add_node ( pos , { name = plant_tab [ math.random ( 1 , 6 ) ] } )
end
end
end
end
return true
else
return false
end
end
2017-01-30 16:33:04 +02:00
minetest.register_craftitem ( " mcl_dye:white " , {
2015-06-29 20:55:56 +03:00
inventory_image = " dye_white.png " ,
description = " Bone Meal " ,
2017-03-10 04:29:48 +02:00
_doc_items_longdesc = " Bone meal is a white dye and also useful as a fertilizer to speed up the growth of many plants. " ,
_doc_items_usagehelp = " 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 20:55:56 +03:00
stack_max = 64 ,
2017-02-18 17:06:18 +02:00
groups = dyelocal.dyes [ 1 ] [ 3 ] ,
2015-06-29 20:55:56 +03:00
on_place = function ( itemstack , user , pointed_thing )
2017-03-02 17:09:13 +02: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
2017-02-14 19:20:54 +02:00
if ( mcl_dye.apply_bone_meal ( pointed_thing ) and not minetest.setting_getbool ( " creative_mode " ) ) then
2017-01-05 08:23:25 +02:00
itemstack : take_item ( )
end
return itemstack
2015-06-29 20:55:56 +03:00
end ,
} )
2017-02-18 17:06:18 +02:00
minetest.register_craftitem ( " mcl_dye:brown " , {
inventory_image = " dye_brown.png " ,
2017-03-10 04:29:48 +02:00
_doc_items_longdesc = " Cocoa beans are a brown dye and can be used to plant cocoas. " ,
_doc_items_usagehelp = " Rightclick a sheep to turn its wool brown. Rightclick on the side of a jungle tree trunk (Jungle Wood) to plant a young cocoa. " ,
2017-02-18 17:06:18 +02:00
description = " Cocoa Beans " ,
stack_max = 64 ,
groups = dyelocal.dyes [ 4 ] [ 3 ] ,
2017-03-02 16:50:53 +02:00
on_place = function ( itemstack , placer , pointed_thing )
2017-02-18 21:23:26 +02:00
return mcl_cocoas.place ( itemstack , placer , pointed_thing , " mcl_cocoas:cocoa_1 " )
2017-02-18 17:06:18 +02:00
end ,
} )
2017-01-05 08:23:25 +02:00
-- Dye mixing
minetest.register_craft ( {
type = " shapeless " ,
2017-01-30 16:33:04 +02:00
output = " mcl_dye:dark_grey 2 " ,
recipe = { " mcl_dye:black " , " mcl_dye:white " } ,
2017-01-05 08:23:25 +02:00
} )
minetest.register_craft ( {
type = " shapeless " ,
2017-01-30 16:33:04 +02:00
output = " mcl_dye:lightblue 2 " ,
recipe = { " mcl_dye:blue " , " mcl_dye:white " } ,
2017-01-05 08:23:25 +02:00
} )
minetest.register_craft ( {
type = " shapeless " ,
2017-01-30 16:33:04 +02:00
output = " mcl_dye:grey 3 " ,
recipe = { " mcl_dye:black " , " mcl_dye:white " , " mcl_dye:white " } ,
2017-01-05 08:23:25 +02:00
} )
minetest.register_craft ( {
type = " shapeless " ,
2017-01-30 16:33:04 +02:00
output = " mcl_dye:grey 2 " ,
recipe = { " mcl_dye:dark_grey " , " mcl_dye:white " } ,
2017-01-05 08:23:25 +02:00
} )
minetest.register_craft ( {
type = " shapeless " ,
2017-01-30 16:33:04 +02:00
output = " mcl_dye:green 2 " ,
recipe = { " mcl_dye:dark_green " , " mcl_dye:white " } ,
2017-01-05 08:23:25 +02:00
} )
minetest.register_craft ( {
type = " shapeless " ,
2017-01-30 16:33:04 +02:00
output = " mcl_dye:magenta 4 " ,
recipe = { " mcl_dye:blue " , " mcl_dye:white " , " mcl_dye:red " , " mcl_dye:red " } ,
2017-01-05 08:23:25 +02:00
} )
minetest.register_craft ( {
type = " shapeless " ,
2017-01-30 16:33:04 +02:00
output = " mcl_dye:pink 2 " ,
recipe = { " mcl_dye:red " , " mcl_dye:white " } ,
2017-01-05 08:23:25 +02:00
} )
minetest.register_craft ( {
type = " shapeless " ,
2017-01-30 16:33:04 +02:00
output = " mcl_dye:cyan 2 " ,
recipe = { " mcl_dye:blue " , " mcl_dye:dark_green " } ,
2017-01-05 08:23:25 +02:00
} )
minetest.register_craft ( {
type = " shapeless " ,
2017-01-30 16:33:04 +02:00
output = " mcl_dye:violet 2 " ,
recipe = { " mcl_dye:blue " , " mcl_dye:red " } ,
2017-01-05 08:23:25 +02:00
} )
minetest.register_craft ( {
type = " shapeless " ,
2017-01-30 16:33:04 +02:00
output = " mcl_dye:orange 2 " ,
recipe = { " mcl_dye:yellow " , " mcl_dye:red " } ,
2017-01-05 08:23:25 +02:00
} )
minetest.register_craft ( {
type = " shapeless " ,
2017-01-30 16:33:04 +02:00
output = " mcl_dye:magenta 2 " ,
recipe = { " mcl_dye:violet " , " mcl_dye:pink " } ,
2017-01-05 08:23:25 +02:00
} )
minetest.register_craft ( {
type = " shapeless " ,
2017-01-30 16:33:04 +02:00
output = " mcl_dye:magenta 3 " ,
recipe = { " mcl_dye:pink " , " mcl_dye:red " , " mcl_dye:blue " } ,
2017-01-05 08:23:25 +02:00
} )
-- Dye creation
minetest.register_craft ( {
2017-01-30 16:33:04 +02:00
output = " mcl_dye:yellow " ,
2017-02-01 00:32:56 +02:00
recipe = { { " mcl_flowers:dandelion " } } ,
2017-01-05 08:23:25 +02:00
} )
minetest.register_craft ( {
2017-01-30 16:33:04 +02:00
output = " mcl_dye:yellow 2 " ,
2017-01-31 13:03:18 +02:00
recipe = { { " mcl_flowers:sunflower " } } ,
2017-01-05 08:23:25 +02:00
} )
minetest.register_craft ( {
2017-01-30 16:33:04 +02:00
output = " mcl_dye:lightblue " ,
2017-01-31 13:03:18 +02:00
recipe = { { " mcl_flowers:blue_orchid " } } ,
2017-01-05 08:23:25 +02:00
} )
minetest.register_craft ( {
2017-01-30 16:33:04 +02:00
output = " mcl_dye:grey " ,
2017-01-31 13:03:18 +02:00
recipe = { { " mcl_flowers:azure_bluet " } } ,
2017-01-05 08:23:25 +02:00
} )
minetest.register_craft ( {
2017-01-30 16:33:04 +02:00
output = " mcl_dye:grey " ,
2017-01-31 13:03:18 +02:00
recipe = { { " mcl_flowers:oxeye_daisy " } } ,
2017-01-05 08:23:25 +02:00
} )
minetest.register_craft ( {
2017-01-30 16:33:04 +02:00
output = " mcl_dye:grey " ,
2017-01-31 13:03:18 +02:00
recipe = { { " mcl_flowers:tulip_white " } } ,
2017-01-05 08:23:25 +02:00
} )
minetest.register_craft ( {
2017-01-30 16:33:04 +02:00
output = " mcl_dye:magenta " ,
2017-01-31 13:03:18 +02:00
recipe = { { " mcl_flowers:allium " } } ,
2017-01-05 08:23:25 +02:00
} )
minetest.register_craft ( {
2017-01-30 16:33:04 +02:00
output = " mcl_dye:magenta 2 " ,
2017-01-31 13:03:18 +02:00
recipe = { { " mcl_flowers:lilac " } } ,
2017-01-05 08:23:25 +02:00
} )
minetest.register_craft ( {
2017-01-30 16:33:04 +02:00
output = " mcl_dye:orange " ,
2017-01-31 13:03:18 +02:00
recipe = { { " mcl_flowers:tulip_orange " } } ,
2017-01-05 08:23:25 +02:00
} )
minetest.register_craft ( {
2017-01-30 16:33:04 +02:00
output = " mcl_dye:pink " ,
2017-01-31 13:03:18 +02:00
recipe = { { " mcl_flowers:tulip_pink " } } ,
2017-01-05 08:23:25 +02:00
} )
minetest.register_craft ( {
2017-01-30 16:33:04 +02:00
output = " mcl_dye:pink 2 " ,
2017-01-31 13:03:18 +02:00
recipe = { { " mcl_flowers:peony " } } ,
2017-01-05 08:23:25 +02:00
} )
minetest.register_craft ( {
2017-01-30 16:33:04 +02:00
output = " mcl_dye:red " ,
2017-01-31 13:03:18 +02:00
recipe = { { " mcl_flowers:poppy " } } ,
2017-01-05 08:23:25 +02:00
} )
minetest.register_craft ( {
2017-01-30 16:33:04 +02:00
output = " mcl_dye:red " ,
2017-01-31 13:03:18 +02:00
recipe = { { " mcl_flowers:tulip_red " } } ,
2017-01-05 08:23:25 +02:00
} )
minetest.register_craft ( {
2017-01-30 16:33:04 +02:00
output = " mcl_dye:red 2 " ,
2017-01-31 13:03:18 +02:00
recipe = { { " mcl_flowers:rose_bush " } } ,
2017-01-05 08:23:25 +02:00
} )
2017-02-01 14:27:49 +02:00
minetest.register_craft ( {
output = " mcl_dye:red " ,
recipe = { { " mcl_farming:beetroot_item " } } ,
} )
2017-01-05 08:23:25 +02:00
minetest.register_craft ( {
type = " cooking " ,
2017-01-30 16:33:04 +02:00
output = " mcl_dye:dark_green " ,
2017-02-01 00:32:56 +02:00
recipe = " mcl_core:cactus " ,
2017-01-05 08:23:25 +02:00
cooktime = 10 ,
} )
minetest.register_craft ( {
2017-01-30 16:33:04 +02:00
output = " mcl_dye:white 3 " ,
2017-02-01 18:59:15 +02:00
recipe = { { " mcl_mobitems:bone " } } ,
2017-01-05 08:23:25 +02:00
} )
2017-02-07 06:02:35 +02:00
2017-02-07 06:11:23 +02:00