Regnum/mods/dye/init.lua

101 lines
2.1 KiB
Lua
Raw Normal View History

2018-06-27 09:07:46 -07:00
dye = {}
-- Make dye names and descriptions available globally
dye.dyes = {
{"white", "White"},
{"grey", "Grey"},
{"dark_grey", "Dark grey"},
{"black", "Black"},
{"violet", "Violet"},
{"blue", "Blue"},
{"cyan", "Cyan"},
{"dark_green", "Dark green"},
{"green", "Green"},
{"yellow", "Yellow"},
{"brown", "Brown"},
{"orange", "Orange"},
{"red", "Red"},
{"magenta", "Magenta"},
{"pink", "Pink"},
}
-- Define items
2019-04-03 17:30:08 -07:00
for _, row in ipairs(dye.dyes) do
2018-06-27 09:07:46 -07:00
local name = row[1]
local description = row[2]
2019-04-03 17:30:08 -07:00
local groups = {dye = 1}
groups["color_" .. name] = 1
minetest.register_craftitem("dye:" .. name, {
inventory_image = "dye_" .. name .. ".png",
description = description .. " Dye",
2018-06-27 09:07:46 -07:00
groups = groups
})
2019-04-03 17:30:08 -07:00
2018-06-27 09:07:46 -07:00
minetest.register_craft({
2019-04-03 17:30:08 -07:00
output = "dye:" .. name .. " 4",
recipe = {
{"group:flower,color_" .. name}
},
2018-06-27 09:07:46 -07:00
})
end
2019-04-03 17:30:08 -07:00
-- Manually add coal -> black dye
2018-06-27 09:07:46 -07:00
minetest.register_craft({
output = "dye:black 4",
2019-04-03 17:30:08 -07:00
recipe = {
{"group:coal"}
},
})
-- Manually add blueberries->violet dye
minetest.register_craft({
output = "dye:violet 2",
recipe = {
{"default:blueberries"}
},
2018-06-27 09:07:46 -07:00
})
-- Mix recipes
2019-04-03 17:30:08 -07:00
2018-06-27 09:07:46 -07:00
local dye_recipes = {
-- src1, src2, dst
-- RYB mixes
{"red", "blue", "violet"}, -- "purple"
{"yellow", "red", "orange"},
{"yellow", "blue", "green"},
-- RYB complementary mixes
{"yellow", "violet", "dark_grey"},
{"blue", "orange", "dark_grey"},
-- CMY mixes - approximation
{"cyan", "yellow", "green"},
{"cyan", "magenta", "blue"},
{"yellow", "magenta", "red"},
-- other mixes that result in a color we have
{"red", "green", "brown"},
{"magenta", "blue", "violet"},
{"green", "blue", "cyan"},
{"pink", "violet", "magenta"},
-- mixes with black
{"white", "black", "grey"},
{"grey", "black", "dark_grey"},
{"green", "black", "dark_green"},
{"orange", "black", "brown"},
-- mixes with white
{"white", "red", "pink"},
{"white", "dark_grey", "grey"},
{"white", "dark_green", "green"},
}
for _, mix in pairs(dye_recipes) do
minetest.register_craft({
type = "shapeless",
output = 'dye:' .. mix[3] .. ' 2',
recipe = {'dye:' .. mix[1], 'dye:' .. mix[2]},
})
end