2013-02-07 07:38:34 +01:00
|
|
|
--[[
|
|
|
|
|
|
|
|
Unified Dyes
|
|
|
|
|
Refactored the code to use default "common" dyes
rather than directly from flowers.
This mod now depends on "default" and "dye" from the Minetest common
sub-game. Since the default dye mod uses default flowers, this mod no
longer checks for what version of flowers you're using, or even depends
on it.
Bottle-based textures have been replaced with piles of dye powder, based
on the default red dye texture.
All dyes are obtained by crafting, not cooking, for consistency with the
default dye mod.
The somewhat-complicated method using separate "pigment" powders, glass
bottles and "liquid dye base" has been done away with. Now it's just
dry dye powders, as with the default dye mod.
Also, got rid of the whole paint scheme, in favor of dry powders.
All old dyes, paints, and Unified Dyes pigment powders have been aliased
back to the standard dye powders.
2013-04-30 12:02:22 +02:00
|
|
|
This mod provides an extension to the Minetest 0.4.x dye system
|
2013-02-07 07:38:34 +01:00
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
Copyright (C) 2012-2013, Vanessa Ezekowitz
|
|
|
|
Email: vanessaezekowitz@gmail.com
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
|
Refactored the code to use default "common" dyes
rather than directly from flowers.
This mod now depends on "default" and "dye" from the Minetest common
sub-game. Since the default dye mod uses default flowers, this mod no
longer checks for what version of flowers you're using, or even depends
on it.
Bottle-based textures have been replaced with piles of dye powder, based
on the default red dye texture.
All dyes are obtained by crafting, not cooking, for consistency with the
default dye mod.
The somewhat-complicated method using separate "pigment" powders, glass
bottles and "liquid dye base" has been done away with. Now it's just
dry dye powders, as with the default dye mod.
Also, got rid of the whole paint scheme, in favor of dry powders.
All old dyes, paints, and Unified Dyes pigment powders have been aliased
back to the standard dye powders.
2013-04-30 12:02:22 +02:00
|
|
|
--]]
|
2013-02-07 07:38:34 +01:00
|
|
|
|
Refactored the code to use default "common" dyes
rather than directly from flowers.
This mod now depends on "default" and "dye" from the Minetest common
sub-game. Since the default dye mod uses default flowers, this mod no
longer checks for what version of flowers you're using, or even depends
on it.
Bottle-based textures have been replaced with piles of dye powder, based
on the default red dye texture.
All dyes are obtained by crafting, not cooking, for consistency with the
default dye mod.
The somewhat-complicated method using separate "pigment" powders, glass
bottles and "liquid dye base" has been done away with. Now it's just
dry dye powders, as with the default dye mod.
Also, got rid of the whole paint scheme, in favor of dry powders.
All old dyes, paints, and Unified Dyes pigment powders have been aliased
back to the standard dye powders.
2013-04-30 12:02:22 +02:00
|
|
|
--=====================================================================
|
2014-03-20 02:11:30 +01:00
|
|
|
|
2017-01-25 18:31:40 +01:00
|
|
|
unifieddyes = {}
|
|
|
|
|
2017-05-13 04:02:06 +02:00
|
|
|
local creative_mode = minetest.settings:get_bool("creative_mode")
|
2017-01-28 14:05:44 +01:00
|
|
|
|
2014-03-20 02:11:30 +01:00
|
|
|
-- Boilerplate to support localized strings if intllib mod is installed.
|
|
|
|
local S
|
2014-12-27 07:02:35 +01:00
|
|
|
if minetest.get_modpath("intllib") then
|
|
|
|
S = intllib.Getter()
|
2014-03-20 02:11:30 +01:00
|
|
|
else
|
2014-12-27 07:02:35 +01:00
|
|
|
S = function(s) return s end
|
2014-03-20 02:11:30 +01:00
|
|
|
end
|
|
|
|
|
2017-01-26 12:18:37 +01:00
|
|
|
-- helper functions for other mods that use this one
|
|
|
|
|
2017-02-25 04:42:42 +01:00
|
|
|
unifieddyes.HUES = {
|
2017-01-26 12:18:37 +01:00
|
|
|
"red",
|
|
|
|
"orange",
|
|
|
|
"yellow",
|
|
|
|
"lime",
|
|
|
|
"green",
|
|
|
|
"aqua",
|
|
|
|
"cyan",
|
|
|
|
"skyblue",
|
|
|
|
"blue",
|
|
|
|
"violet",
|
|
|
|
"magenta",
|
|
|
|
"redviolet"
|
2017-01-25 23:49:00 +01:00
|
|
|
}
|
|
|
|
|
2017-02-24 23:40:37 +01:00
|
|
|
-- the names of the various colors here came from http://www.procato.com/rgb+index/
|
|
|
|
|
2017-02-25 04:42:42 +01:00
|
|
|
unifieddyes.HUES_EXTENDED = {
|
2017-02-24 23:40:37 +01:00
|
|
|
{ "red", 0xff, 0x00, 0x00 },
|
|
|
|
{ "vermilion", 0xff, 0x40, 0x00 },
|
|
|
|
{ "orange", 0xff, 0x80, 0x00 },
|
|
|
|
{ "amber", 0xff, 0xbf, 0x00 },
|
|
|
|
{ "yellow", 0xff, 0xff, 0x00 },
|
|
|
|
{ "lime", 0xbf, 0xff, 0x00 },
|
|
|
|
{ "chartreuse", 0x80, 0xff, 0x00 },
|
|
|
|
{ "harlequin", 0x40, 0xff, 0x00 },
|
|
|
|
{ "green", 0x00, 0xff, 0x00 },
|
|
|
|
{ "malachite", 0x00, 0xff, 0x40 },
|
|
|
|
{ "spring", 0x00, 0xff, 0x80 },
|
|
|
|
{ "turquoise", 0x00, 0xff, 0xbf },
|
|
|
|
{ "cyan", 0x00, 0xff, 0xff },
|
|
|
|
{ "cerulean", 0x00, 0xbf, 0xff },
|
|
|
|
{ "azure", 0x00, 0x80, 0xff },
|
|
|
|
{ "sapphire", 0x00, 0x40, 0xff },
|
|
|
|
{ "blue", 0x00, 0x00, 0xff },
|
|
|
|
{ "indigo", 0x40, 0x00, 0xff },
|
|
|
|
{ "violet", 0x80, 0x00, 0xff },
|
|
|
|
{ "mulberry", 0xbf, 0x00, 0xff },
|
|
|
|
{ "magenta", 0xff, 0x00, 0xff },
|
|
|
|
{ "fuchsia", 0xff, 0x00, 0xbf },
|
|
|
|
{ "rose", 0xff, 0x00, 0x80 },
|
|
|
|
{ "crimson", 0xff, 0x00, 0x40 }
|
|
|
|
}
|
|
|
|
|
add helper function for crafting param2-colorized items
One call registers the full set of 32, 89, or 256 colors.
Pass it a recipe of the following general form
```lua
unifieddyes.register_color_craft({
output = "mymod:colorized_node",
type = <nil or "shapeless">
palette = <see below>,
neutral_node = "some_mod:neutral_node",
recipe = {
<see below>
}
})
```
palette may be either "wallmounted" (32 colors), false or omitted
entirely (89 colors), or "extended" (256 colors).
The recipe section is either a shapeless list, or a standard three-line
shaped recipe, same as the regular register_craft() function. The key
difference is two placeholder keys that are now supported:
* if an item in the recipe is "MAIN_DYE", then Unified Dyes will, with
each pass of its registration loop, substitute the actual "dye:foo"
craft item in its place which corresponds with the current loop's color.
* if an item in the recipe list is "NEUTRAL_NODE", then the value of the
"neutral_node" field will be substituted in its place.
The expectation here is that the modder probably has some base recipe in
mind that, given no dyes, would result in a neutral, uncolored node. This
call creates all the recipes that would be needed to craft colored versions
of that neutral node either using that base recipe with dye added, or by
crafting the neutral node with some dye after the fact.
2017-06-20 11:02:53 +02:00
|
|
|
unifieddyes.HUES_WALLMOUNTED = {
|
|
|
|
"red",
|
|
|
|
"orange",
|
|
|
|
"yellow",
|
|
|
|
"green",
|
|
|
|
"cyan",
|
|
|
|
"blue",
|
|
|
|
"violet",
|
|
|
|
"magenta"
|
|
|
|
}
|
|
|
|
|
2017-02-25 04:42:42 +01:00
|
|
|
unifieddyes.SATS = {
|
2017-02-24 20:21:59 +01:00
|
|
|
"",
|
|
|
|
"_s50"
|
|
|
|
}
|
|
|
|
|
2017-02-25 04:42:42 +01:00
|
|
|
unifieddyes.VALS = {
|
2017-02-24 20:21:59 +01:00
|
|
|
"",
|
|
|
|
"medium_",
|
|
|
|
"dark_"
|
|
|
|
}
|
|
|
|
|
2017-02-25 04:42:42 +01:00
|
|
|
unifieddyes.VALS_EXTENDED = {
|
2017-02-24 23:40:37 +01:00
|
|
|
"faint_",
|
|
|
|
"pastel_",
|
|
|
|
"light_",
|
|
|
|
"bright_",
|
|
|
|
"",
|
|
|
|
"medium_",
|
|
|
|
"dark_"
|
|
|
|
}
|
|
|
|
|
2017-02-25 04:42:42 +01:00
|
|
|
unifieddyes.GREYS = {
|
2017-02-24 20:21:59 +01:00
|
|
|
"white",
|
|
|
|
"light_grey",
|
|
|
|
"grey",
|
|
|
|
"dark_grey",
|
|
|
|
"black"
|
|
|
|
}
|
|
|
|
|
2018-08-22 05:28:17 +02:00
|
|
|
unifieddyes.GREYS_EXTENDED = table.copy(unifieddyes.GREYS)
|
|
|
|
|
|
|
|
for i = 1, 14 do
|
|
|
|
if i ~= 0 and i ~= 3 and i ~= 7 and i ~= 11 and i ~= 15 then
|
|
|
|
table.insert(unifieddyes.GREYS_EXTENDED, "grey_"..i)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-02-05 01:40:15 +01:00
|
|
|
local default_dyes = {
|
|
|
|
"black",
|
|
|
|
"blue",
|
|
|
|
"brown",
|
|
|
|
"cyan",
|
|
|
|
"dark_green",
|
|
|
|
"dark_grey",
|
|
|
|
"green",
|
|
|
|
"grey",
|
|
|
|
"magenta",
|
|
|
|
"orange",
|
|
|
|
"pink",
|
|
|
|
"red",
|
|
|
|
"violet",
|
|
|
|
"white",
|
|
|
|
"yellow"
|
|
|
|
}
|
|
|
|
|
2017-06-20 11:20:25 +02:00
|
|
|
-- just stubs to keep old mods from crashing when expecting auto-coloring
|
|
|
|
-- or getting back the dye on dig.
|
2017-06-20 11:10:59 +02:00
|
|
|
|
|
|
|
function unifieddyes.recolor_on_place(foo)
|
|
|
|
end
|
|
|
|
|
2017-06-20 11:20:25 +02:00
|
|
|
function unifieddyes.after_dig_node(foo)
|
|
|
|
end
|
|
|
|
|
2018-08-22 05:28:17 +02:00
|
|
|
-- This helper function creates a colored itemstack
|
2017-06-20 11:46:30 +02:00
|
|
|
|
2018-08-22 05:28:17 +02:00
|
|
|
function unifieddyes.make_colored_itemstack(item, palette, color)
|
2017-06-20 11:46:30 +02:00
|
|
|
local paletteidx = unifieddyes.getpaletteidx(color, palette)
|
2018-08-22 05:28:17 +02:00
|
|
|
local stack = ItemStack(item)
|
2017-06-20 11:46:30 +02:00
|
|
|
stack:get_meta():set_int("palette_index", paletteidx)
|
|
|
|
return stack:to_string()
|
|
|
|
end
|
|
|
|
|
2018-08-22 05:28:17 +02:00
|
|
|
-- if your node was once 89-color and uses an LBM to convert to the 256-color palette,
|
|
|
|
-- call this in that node def's on_construct:
|
|
|
|
|
|
|
|
function unifieddyes.on_construct(pos)
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
meta:set_string("palette", "ext")
|
|
|
|
end
|
|
|
|
|
|
|
|
-- these helper functions register all of the recipes needed to create colored
|
|
|
|
-- nodes with any of the dyes supported by that node's palette.
|
|
|
|
|
|
|
|
local function register_c(craft, hue, sat, val)
|
|
|
|
local color = ""
|
|
|
|
if val then
|
2018-08-22 09:14:20 +02:00
|
|
|
if craft.palette == "wallmounted" then
|
|
|
|
color = "dye:"..val..hue..sat
|
|
|
|
else
|
|
|
|
color = "dye:"..val..hue[1]..sat
|
|
|
|
end
|
2018-08-22 05:28:17 +02:00
|
|
|
else
|
|
|
|
color = "dye:"..hue -- if val is nil, then it's grey.
|
|
|
|
end
|
|
|
|
|
|
|
|
local recipe = minetest.serialize(craft.recipe)
|
|
|
|
recipe = string.gsub(recipe, "MAIN_DYE", color)
|
|
|
|
recipe = string.gsub(recipe, "NEUTRAL_NODE", craft.neutral_node)
|
|
|
|
local newrecipe = minetest.deserialize(recipe)
|
|
|
|
|
|
|
|
local colored_itemstack =
|
|
|
|
unifieddyes.make_colored_itemstack(craft.output, craft.palette, color)
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = colored_itemstack,
|
|
|
|
type = craft.type,
|
|
|
|
recipe = newrecipe
|
|
|
|
})
|
|
|
|
|
|
|
|
end
|
add helper function for crafting param2-colorized items
One call registers the full set of 32, 89, or 256 colors.
Pass it a recipe of the following general form
```lua
unifieddyes.register_color_craft({
output = "mymod:colorized_node",
type = <nil or "shapeless">
palette = <see below>,
neutral_node = "some_mod:neutral_node",
recipe = {
<see below>
}
})
```
palette may be either "wallmounted" (32 colors), false or omitted
entirely (89 colors), or "extended" (256 colors).
The recipe section is either a shapeless list, or a standard three-line
shaped recipe, same as the regular register_craft() function. The key
difference is two placeholder keys that are now supported:
* if an item in the recipe is "MAIN_DYE", then Unified Dyes will, with
each pass of its registration loop, substitute the actual "dye:foo"
craft item in its place which corresponds with the current loop's color.
* if an item in the recipe list is "NEUTRAL_NODE", then the value of the
"neutral_node" field will be substituted in its place.
The expectation here is that the modder probably has some base recipe in
mind that, given no dyes, would result in a neutral, uncolored node. This
call creates all the recipes that would be needed to craft colored versions
of that neutral node either using that base recipe with dye added, or by
crafting the neutral node with some dye after the fact.
2017-06-20 11:02:53 +02:00
|
|
|
|
|
|
|
function unifieddyes.register_color_craft(craft)
|
|
|
|
if not craft or not craft.recipe or not craft.output or not craft.neutral_node then return end
|
|
|
|
|
|
|
|
local hues_table = unifieddyes.HUES_EXTENDED
|
|
|
|
local sats_table = unifieddyes.SATS
|
|
|
|
local vals_table = unifieddyes.VALS_EXTENDED
|
2018-08-22 05:28:17 +02:00
|
|
|
local greys_table = unifieddyes.GREYS_EXTENDED
|
add helper function for crafting param2-colorized items
One call registers the full set of 32, 89, or 256 colors.
Pass it a recipe of the following general form
```lua
unifieddyes.register_color_craft({
output = "mymod:colorized_node",
type = <nil or "shapeless">
palette = <see below>,
neutral_node = "some_mod:neutral_node",
recipe = {
<see below>
}
})
```
palette may be either "wallmounted" (32 colors), false or omitted
entirely (89 colors), or "extended" (256 colors).
The recipe section is either a shapeless list, or a standard three-line
shaped recipe, same as the regular register_craft() function. The key
difference is two placeholder keys that are now supported:
* if an item in the recipe is "MAIN_DYE", then Unified Dyes will, with
each pass of its registration loop, substitute the actual "dye:foo"
craft item in its place which corresponds with the current loop's color.
* if an item in the recipe list is "NEUTRAL_NODE", then the value of the
"neutral_node" field will be substituted in its place.
The expectation here is that the modder probably has some base recipe in
mind that, given no dyes, would result in a neutral, uncolored node. This
call creates all the recipes that would be needed to craft colored versions
of that neutral node either using that base recipe with dye added, or by
crafting the neutral node with some dye after the fact.
2017-06-20 11:02:53 +02:00
|
|
|
|
|
|
|
if not craft.palette then
|
|
|
|
hues_table = unifieddyes.HUES
|
|
|
|
sats_table = unifieddyes.SATS
|
|
|
|
vals_table = unifieddyes.VALS
|
2018-08-22 05:28:17 +02:00
|
|
|
greys_table = unifieddyes.GREYS
|
add helper function for crafting param2-colorized items
One call registers the full set of 32, 89, or 256 colors.
Pass it a recipe of the following general form
```lua
unifieddyes.register_color_craft({
output = "mymod:colorized_node",
type = <nil or "shapeless">
palette = <see below>,
neutral_node = "some_mod:neutral_node",
recipe = {
<see below>
}
})
```
palette may be either "wallmounted" (32 colors), false or omitted
entirely (89 colors), or "extended" (256 colors).
The recipe section is either a shapeless list, or a standard three-line
shaped recipe, same as the regular register_craft() function. The key
difference is two placeholder keys that are now supported:
* if an item in the recipe is "MAIN_DYE", then Unified Dyes will, with
each pass of its registration loop, substitute the actual "dye:foo"
craft item in its place which corresponds with the current loop's color.
* if an item in the recipe list is "NEUTRAL_NODE", then the value of the
"neutral_node" field will be substituted in its place.
The expectation here is that the modder probably has some base recipe in
mind that, given no dyes, would result in a neutral, uncolored node. This
call creates all the recipes that would be needed to craft colored versions
of that neutral node either using that base recipe with dye added, or by
crafting the neutral node with some dye after the fact.
2017-06-20 11:02:53 +02:00
|
|
|
elseif craft.palette == "wallmounted" then
|
|
|
|
hues_table = unifieddyes.HUES_WALLMOUNTED
|
|
|
|
sats_table = {""}
|
|
|
|
vals_table = unifieddyes.VALS
|
2018-08-22 05:28:17 +02:00
|
|
|
greys_table = unifieddyes.GREYS
|
add helper function for crafting param2-colorized items
One call registers the full set of 32, 89, or 256 colors.
Pass it a recipe of the following general form
```lua
unifieddyes.register_color_craft({
output = "mymod:colorized_node",
type = <nil or "shapeless">
palette = <see below>,
neutral_node = "some_mod:neutral_node",
recipe = {
<see below>
}
})
```
palette may be either "wallmounted" (32 colors), false or omitted
entirely (89 colors), or "extended" (256 colors).
The recipe section is either a shapeless list, or a standard three-line
shaped recipe, same as the regular register_craft() function. The key
difference is two placeholder keys that are now supported:
* if an item in the recipe is "MAIN_DYE", then Unified Dyes will, with
each pass of its registration loop, substitute the actual "dye:foo"
craft item in its place which corresponds with the current loop's color.
* if an item in the recipe list is "NEUTRAL_NODE", then the value of the
"neutral_node" field will be substituted in its place.
The expectation here is that the modder probably has some base recipe in
mind that, given no dyes, would result in a neutral, uncolored node. This
call creates all the recipes that would be needed to craft colored versions
of that neutral node either using that base recipe with dye added, or by
crafting the neutral node with some dye after the fact.
2017-06-20 11:02:53 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
for _,hue in ipairs(hues_table) do
|
2018-08-22 05:28:17 +02:00
|
|
|
for _,val in ipairs(vals_table) do
|
|
|
|
for _,sat in ipairs(sats_table) do
|
add helper function for crafting param2-colorized items
One call registers the full set of 32, 89, or 256 colors.
Pass it a recipe of the following general form
```lua
unifieddyes.register_color_craft({
output = "mymod:colorized_node",
type = <nil or "shapeless">
palette = <see below>,
neutral_node = "some_mod:neutral_node",
recipe = {
<see below>
}
})
```
palette may be either "wallmounted" (32 colors), false or omitted
entirely (89 colors), or "extended" (256 colors).
The recipe section is either a shapeless list, or a standard three-line
shaped recipe, same as the regular register_craft() function. The key
difference is two placeholder keys that are now supported:
* if an item in the recipe is "MAIN_DYE", then Unified Dyes will, with
each pass of its registration loop, substitute the actual "dye:foo"
craft item in its place which corresponds with the current loop's color.
* if an item in the recipe list is "NEUTRAL_NODE", then the value of the
"neutral_node" field will be substituted in its place.
The expectation here is that the modder probably has some base recipe in
mind that, given no dyes, would result in a neutral, uncolored node. This
call creates all the recipes that would be needed to craft colored versions
of that neutral node either using that base recipe with dye added, or by
crafting the neutral node with some dye after the fact.
2017-06-20 11:02:53 +02:00
|
|
|
|
2018-08-22 09:14:20 +02:00
|
|
|
print("[UD] craft = ")
|
|
|
|
print(dump(craft))
|
|
|
|
print("[UD] hue = "..dump(hue).." ~~ sat = "..dump(sat).." ~~ val = "..dump(val))
|
|
|
|
|
2018-08-22 05:28:17 +02:00
|
|
|
if sat == "_s50" and val ~= "" and val ~= "medium_" and val ~= "dark_" then break end
|
|
|
|
register_c(craft, hue, sat, val)
|
add helper function for crafting param2-colorized items
One call registers the full set of 32, 89, or 256 colors.
Pass it a recipe of the following general form
```lua
unifieddyes.register_color_craft({
output = "mymod:colorized_node",
type = <nil or "shapeless">
palette = <see below>,
neutral_node = "some_mod:neutral_node",
recipe = {
<see below>
}
})
```
palette may be either "wallmounted" (32 colors), false or omitted
entirely (89 colors), or "extended" (256 colors).
The recipe section is either a shapeless list, or a standard three-line
shaped recipe, same as the regular register_craft() function. The key
difference is two placeholder keys that are now supported:
* if an item in the recipe is "MAIN_DYE", then Unified Dyes will, with
each pass of its registration loop, substitute the actual "dye:foo"
craft item in its place which corresponds with the current loop's color.
* if an item in the recipe list is "NEUTRAL_NODE", then the value of the
"neutral_node" field will be substituted in its place.
The expectation here is that the modder probably has some base recipe in
mind that, given no dyes, would result in a neutral, uncolored node. This
call creates all the recipes that would be needed to craft colored versions
of that neutral node either using that base recipe with dye added, or by
crafting the neutral node with some dye after the fact.
2017-06-20 11:02:53 +02:00
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-08-22 05:28:17 +02:00
|
|
|
|
|
|
|
for _, grey in ipairs(greys_table) do
|
|
|
|
register_c(craft, grey)
|
|
|
|
end
|
add helper function for crafting param2-colorized items
One call registers the full set of 32, 89, or 256 colors.
Pass it a recipe of the following general form
```lua
unifieddyes.register_color_craft({
output = "mymod:colorized_node",
type = <nil or "shapeless">
palette = <see below>,
neutral_node = "some_mod:neutral_node",
recipe = {
<see below>
}
})
```
palette may be either "wallmounted" (32 colors), false or omitted
entirely (89 colors), or "extended" (256 colors).
The recipe section is either a shapeless list, or a standard three-line
shaped recipe, same as the regular register_craft() function. The key
difference is two placeholder keys that are now supported:
* if an item in the recipe is "MAIN_DYE", then Unified Dyes will, with
each pass of its registration loop, substitute the actual "dye:foo"
craft item in its place which corresponds with the current loop's color.
* if an item in the recipe list is "NEUTRAL_NODE", then the value of the
"neutral_node" field will be substituted in its place.
The expectation here is that the modder probably has some base recipe in
mind that, given no dyes, would result in a neutral, uncolored node. This
call creates all the recipes that would be needed to craft colored versions
of that neutral node either using that base recipe with dye added, or by
crafting the neutral node with some dye after the fact.
2017-06-20 11:02:53 +02:00
|
|
|
end
|
|
|
|
|
2017-01-25 18:31:40 +01:00
|
|
|
-- code borrowed from homedecor
|
2017-02-18 05:04:47 +01:00
|
|
|
-- call this function to reset the rotation of a "wallmounted" object on place
|
|
|
|
|
|
|
|
function unifieddyes.fix_rotation(pos, placer, itemstack, pointed_thing)
|
|
|
|
local node = minetest.get_node(pos)
|
2017-05-04 08:04:17 +02:00
|
|
|
local yaw = placer:get_look_horizontal()
|
2017-06-04 22:17:37 +02:00
|
|
|
local dir = minetest.yaw_to_dir(yaw) -- -1.5)
|
2017-02-18 05:04:47 +01:00
|
|
|
local pitch = placer:get_look_vertical()
|
|
|
|
|
|
|
|
local fdir = minetest.dir_to_wallmounted(dir)
|
|
|
|
|
2017-02-18 05:13:22 +01:00
|
|
|
if pitch < -(math.pi/8) then
|
2017-02-18 05:04:47 +01:00
|
|
|
fdir = 0
|
2017-02-18 05:13:22 +01:00
|
|
|
elseif pitch > math.pi/8 then
|
2017-02-18 05:04:47 +01:00
|
|
|
fdir = 1
|
|
|
|
end
|
|
|
|
minetest.swap_node(pos, { name = node.name, param2 = fdir })
|
|
|
|
end
|
|
|
|
|
|
|
|
-- use this when you have a "wallmounted" node that should never be oriented
|
2017-02-18 19:00:06 +01:00
|
|
|
-- to floor or ceiling...
|
2017-02-18 05:04:47 +01:00
|
|
|
|
|
|
|
function unifieddyes.fix_rotation_nsew(pos, placer, itemstack, pointed_thing)
|
|
|
|
local node = minetest.get_node(pos)
|
2017-05-04 08:04:17 +02:00
|
|
|
local yaw = placer:get_look_horizontal()
|
2017-06-04 22:17:37 +02:00
|
|
|
local dir = minetest.yaw_to_dir(yaw+1.5)
|
2017-02-18 05:04:47 +01:00
|
|
|
local fdir = minetest.dir_to_wallmounted(dir)
|
|
|
|
minetest.swap_node(pos, { name = node.name, param2 = fdir })
|
|
|
|
end
|
|
|
|
|
2017-02-18 19:00:06 +01:00
|
|
|
-- ... and use this one to force that kind of node off of floor/ceiling
|
|
|
|
-- orientation after the screwdriver rotates it.
|
|
|
|
|
|
|
|
function unifieddyes.fix_after_screwdriver_nsew(pos, node, user, mode, new_param2)
|
|
|
|
local new_fdir = new_param2 % 8
|
|
|
|
local color = new_param2 - new_fdir
|
|
|
|
if new_fdir < 2 then
|
|
|
|
new_fdir = 2
|
|
|
|
minetest.swap_node(pos, { name = node.name, param2 = new_fdir + color })
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-01-25 18:31:40 +01:00
|
|
|
function unifieddyes.select_node(pointed_thing)
|
|
|
|
local pos = pointed_thing.under
|
|
|
|
local node = minetest.get_node_or_nil(pos)
|
|
|
|
local def = node and minetest.registered_nodes[node.name]
|
|
|
|
|
|
|
|
if not def or not def.buildable_to then
|
|
|
|
pos = pointed_thing.above
|
|
|
|
node = minetest.get_node_or_nil(pos)
|
|
|
|
def = node and minetest.registered_nodes[node.name]
|
|
|
|
end
|
|
|
|
return def and pos, def
|
|
|
|
end
|
|
|
|
|
|
|
|
function unifieddyes.is_buildable_to(placer_name, ...)
|
|
|
|
for _, pos in ipairs({...}) do
|
|
|
|
local node = minetest.get_node_or_nil(pos)
|
|
|
|
local def = node and minetest.registered_nodes[node.name]
|
|
|
|
if not (def and def.buildable_to) or minetest.is_protected(pos, placer_name) then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2017-01-26 19:51:38 +01:00
|
|
|
function unifieddyes.get_hsv(name) -- expects a node/item name
|
2017-01-26 19:42:36 +01:00
|
|
|
local hue = ""
|
|
|
|
local a,b
|
2017-02-25 04:42:42 +01:00
|
|
|
for _, i in ipairs(unifieddyes.HUES) do
|
2017-01-26 19:42:36 +01:00
|
|
|
a,b = string.find(name, "_"..i)
|
|
|
|
if a and not ( string.find(name, "_redviolet") and i == "red" ) then
|
|
|
|
hue = i
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-01-26 19:51:38 +01:00
|
|
|
if string.find(name, "_light_grey") then hue = "light_grey"
|
|
|
|
elseif string.find(name, "_lightgrey") then hue = "light_grey"
|
|
|
|
elseif string.find(name, "_dark_grey") then hue = "dark_grey"
|
|
|
|
elseif string.find(name, "_darkgrey") then hue = "dark_grey"
|
|
|
|
elseif string.find(name, "_grey") then hue = "grey"
|
|
|
|
elseif string.find(name, "_white") then hue = "white"
|
|
|
|
elseif string.find(name, "_black") then hue = "black"
|
2017-01-26 19:42:36 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
local sat = ""
|
|
|
|
if string.find(name, "_s50") then sat = "_s50" end
|
|
|
|
|
|
|
|
local val = ""
|
|
|
|
if string.find(name, "dark_") then val = "dark_" end
|
|
|
|
if string.find(name, "medium_") then val = "medium_" end
|
|
|
|
if string.find(name, "light_") then val = "light_" end
|
|
|
|
|
|
|
|
return hue, sat, val
|
|
|
|
end
|
|
|
|
|
2017-02-25 00:38:15 +01:00
|
|
|
-- code partially borrowed from cheapie's plasticbox mod
|
|
|
|
|
|
|
|
-- in the function below, color is just a color string, while
|
|
|
|
-- palette_type can be:
|
|
|
|
--
|
|
|
|
-- false/nil = standard 89 color palette
|
|
|
|
-- true = 89 color palette split into pieces for colorfacedir
|
|
|
|
-- "wallmounted" = 32-color abridged palette
|
|
|
|
-- "extended" = 256 color palette
|
|
|
|
|
|
|
|
function unifieddyes.getpaletteidx(color, palette_type)
|
2017-01-25 18:31:40 +01:00
|
|
|
|
2017-01-26 12:18:37 +01:00
|
|
|
local origcolor = color
|
2017-01-25 18:31:40 +01:00
|
|
|
local aliases = {
|
|
|
|
["pink"] = "light_red",
|
2017-06-20 21:43:39 +02:00
|
|
|
["brown"] = "medium_orange",
|
2017-01-25 18:31:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
local grayscale = {
|
|
|
|
["white"] = 1,
|
|
|
|
["light_grey"] = 2,
|
|
|
|
["grey"] = 3,
|
|
|
|
["dark_grey"] = 4,
|
|
|
|
["black"] = 5,
|
|
|
|
}
|
|
|
|
|
2017-02-25 00:38:15 +01:00
|
|
|
local grayscale_extended = {
|
|
|
|
["white"] = 0,
|
|
|
|
["grey_14"] = 1,
|
|
|
|
["grey_13"] = 2,
|
|
|
|
["grey_12"] = 3,
|
|
|
|
["light_grey"] = 3,
|
|
|
|
["grey_11"] = 4,
|
|
|
|
["grey_10"] = 5,
|
|
|
|
["grey_9"] = 6,
|
|
|
|
["grey_8"] = 7,
|
|
|
|
["grey"] = 7,
|
|
|
|
["grey_7"] = 8,
|
|
|
|
["grey_6"] = 9,
|
|
|
|
["grey_5"] = 10,
|
|
|
|
["grey_4"] = 11,
|
|
|
|
["dark_grey"] = 11,
|
|
|
|
["grey_3"] = 12,
|
|
|
|
["grey_2"] = 13,
|
|
|
|
["grey_1"] = 14,
|
|
|
|
["black"] = 15,
|
|
|
|
}
|
|
|
|
|
add API option for "colorwallmounted" paramtype2
(pass "wallmounted" to the "is_color_fdir" field where needed)
Comes with an abridged, 32-color version of the master palette,
containing Red, Orange, Yellow, Green, Cyan, Blue, Violet, and Magenta,
in three shades each, plus the usual black/three greys/white, plus pink
and brown in two of the extrs spaces.
2017-01-29 03:51:46 +01:00
|
|
|
local grayscale_wallmounted = {
|
|
|
|
["white"] = 0,
|
|
|
|
["light_grey"] = 1,
|
|
|
|
["grey"] = 2,
|
|
|
|
["dark_grey"] = 3,
|
|
|
|
["black"] = 4,
|
|
|
|
}
|
|
|
|
|
2017-01-25 18:31:40 +01:00
|
|
|
local hues = {
|
|
|
|
["red"] = 1,
|
|
|
|
["orange"] = 2,
|
|
|
|
["yellow"] = 3,
|
|
|
|
["lime"] = 4,
|
|
|
|
["green"] = 5,
|
|
|
|
["aqua"] = 6,
|
|
|
|
["cyan"] = 7,
|
|
|
|
["skyblue"] = 8,
|
|
|
|
["blue"] = 9,
|
|
|
|
["violet"] = 10,
|
|
|
|
["magenta"] = 11,
|
|
|
|
["redviolet"] = 12,
|
|
|
|
}
|
|
|
|
|
2017-02-25 00:38:15 +01:00
|
|
|
local hues_extended = {
|
|
|
|
["red"] = 0,
|
|
|
|
["vermilion"] = 1,
|
|
|
|
["orange"] = 2,
|
|
|
|
["amber"] = 3,
|
|
|
|
["yellow"] = 4,
|
|
|
|
["lime"] = 5,
|
|
|
|
["chartreuse"] = 6,
|
|
|
|
["harlequin"] = 7,
|
|
|
|
["green"] = 8,
|
|
|
|
["malachite"] = 9,
|
|
|
|
["spring"] = 10,
|
|
|
|
["turquoise"] = 11,
|
|
|
|
["cyan"] = 12,
|
|
|
|
["cerulean"] = 13,
|
|
|
|
["azure"] = 14,
|
|
|
|
["sapphire"] = 15,
|
|
|
|
["blue"] = 16,
|
|
|
|
["indigo"] = 17,
|
|
|
|
["violet"] = 18,
|
|
|
|
["mulberry"] = 19,
|
|
|
|
["magenta"] = 20,
|
|
|
|
["fuchsia"] = 21,
|
|
|
|
["rose"] = 22,
|
|
|
|
["crimson"] = 23,
|
|
|
|
}
|
|
|
|
|
add API option for "colorwallmounted" paramtype2
(pass "wallmounted" to the "is_color_fdir" field where needed)
Comes with an abridged, 32-color version of the master palette,
containing Red, Orange, Yellow, Green, Cyan, Blue, Violet, and Magenta,
in three shades each, plus the usual black/three greys/white, plus pink
and brown in two of the extrs spaces.
2017-01-29 03:51:46 +01:00
|
|
|
local hues_wallmounted = {
|
|
|
|
["red"] = 0,
|
|
|
|
["orange"] = 1,
|
|
|
|
["yellow"] = 2,
|
|
|
|
["green"] = 3,
|
|
|
|
["cyan"] = 4,
|
|
|
|
["blue"] = 5,
|
|
|
|
["violet"] = 6,
|
|
|
|
["magenta"] = 7
|
|
|
|
}
|
|
|
|
|
2017-01-25 18:31:40 +01:00
|
|
|
local shades = {
|
|
|
|
[""] = 1,
|
|
|
|
["s50"] = 2,
|
|
|
|
["light"] = 3,
|
|
|
|
["medium"] = 4,
|
|
|
|
["mediums50"] = 5,
|
|
|
|
["dark"] = 6,
|
|
|
|
["darks50"] = 7,
|
|
|
|
}
|
|
|
|
|
2017-02-25 00:38:15 +01:00
|
|
|
local shades_extended = {
|
2017-02-25 01:57:48 +01:00
|
|
|
["faint"] = 0,
|
|
|
|
["pastel"] = 1,
|
|
|
|
["light"] = 2,
|
|
|
|
["bright"] = 3,
|
|
|
|
[""] = 4,
|
|
|
|
["s50"] = 5,
|
|
|
|
["medium"] = 6,
|
|
|
|
["mediums50"] = 7,
|
|
|
|
["dark"] = 8,
|
|
|
|
["darks50"] = 9
|
2017-02-25 00:38:15 +01:00
|
|
|
}
|
|
|
|
|
add API option for "colorwallmounted" paramtype2
(pass "wallmounted" to the "is_color_fdir" field where needed)
Comes with an abridged, 32-color version of the master palette,
containing Red, Orange, Yellow, Green, Cyan, Blue, Violet, and Magenta,
in three shades each, plus the usual black/three greys/white, plus pink
and brown in two of the extrs spaces.
2017-01-29 03:51:46 +01:00
|
|
|
local shades_wallmounted = {
|
|
|
|
[""] = 1,
|
|
|
|
["medium"] = 2,
|
|
|
|
["dark"] = 3
|
|
|
|
}
|
|
|
|
|
2017-01-25 18:31:40 +01:00
|
|
|
if string.sub(color,1,4) == "dye:" then
|
|
|
|
color = string.sub(color,5,-1)
|
|
|
|
elseif string.sub(color,1,12) == "unifieddyes:" then
|
|
|
|
color = string.sub(color,13,-1)
|
|
|
|
else
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2017-02-25 00:38:15 +01:00
|
|
|
if palette_type == "wallmounted" then
|
add API option for "colorwallmounted" paramtype2
(pass "wallmounted" to the "is_color_fdir" field where needed)
Comes with an abridged, 32-color version of the master palette,
containing Red, Orange, Yellow, Green, Cyan, Blue, Violet, and Magenta,
in three shades each, plus the usual black/three greys/white, plus pink
and brown in two of the extrs spaces.
2017-01-29 03:51:46 +01:00
|
|
|
if grayscale_wallmounted[color] then
|
2017-01-30 11:32:17 +01:00
|
|
|
return (grayscale_wallmounted[color] * 8), 0
|
add API option for "colorwallmounted" paramtype2
(pass "wallmounted" to the "is_color_fdir" field where needed)
Comes with an abridged, 32-color version of the master palette,
containing Red, Orange, Yellow, Green, Cyan, Blue, Violet, and Magenta,
in three shades each, plus the usual black/three greys/white, plus pink
and brown in two of the extrs spaces.
2017-01-29 03:51:46 +01:00
|
|
|
end
|
2017-02-25 00:38:15 +01:00
|
|
|
elseif palette_type == true then
|
add API option for "colorwallmounted" paramtype2
(pass "wallmounted" to the "is_color_fdir" field where needed)
Comes with an abridged, 32-color version of the master palette,
containing Red, Orange, Yellow, Green, Cyan, Blue, Violet, and Magenta,
in three shades each, plus the usual black/three greys/white, plus pink
and brown in two of the extrs spaces.
2017-01-29 03:51:46 +01:00
|
|
|
if grayscale[color] then
|
2017-01-26 12:18:37 +01:00
|
|
|
return (grayscale[color] * 32), 0
|
2017-01-29 06:06:08 +01:00
|
|
|
end
|
2017-02-25 00:38:15 +01:00
|
|
|
elseif palette_type == "extended" then
|
|
|
|
if grayscale_extended[color] then
|
2017-02-25 01:57:48 +01:00
|
|
|
return grayscale_extended[color]+240, 0
|
2017-02-25 00:38:15 +01:00
|
|
|
end
|
2017-01-29 06:06:08 +01:00
|
|
|
else
|
|
|
|
if grayscale[color] then
|
2017-01-26 12:18:37 +01:00
|
|
|
return grayscale[color], 0
|
|
|
|
end
|
2017-01-25 18:31:40 +01:00
|
|
|
end
|
|
|
|
|
2017-02-25 00:38:15 +01:00
|
|
|
local shade = "" -- assume full
|
|
|
|
if string.sub(color,1,6) == "faint_" then
|
|
|
|
shade = "faint"
|
|
|
|
color = string.sub(color,7,-1)
|
|
|
|
elseif string.sub(color,1,7) == "pastel_" then
|
|
|
|
shade = "pastel"
|
|
|
|
color = string.sub(color,8,-1)
|
|
|
|
elseif string.sub(color,1,6) == "light_" then
|
2017-01-25 18:31:40 +01:00
|
|
|
shade = "light"
|
|
|
|
color = string.sub(color,7,-1)
|
2017-02-25 00:38:15 +01:00
|
|
|
elseif string.sub(color,1,7) == "bright_" then
|
|
|
|
shade = "bright"
|
|
|
|
color = string.sub(color,8,-1)
|
2017-01-25 18:31:40 +01:00
|
|
|
elseif string.sub(color,1,7) == "medium_" then
|
|
|
|
shade = "medium"
|
|
|
|
color = string.sub(color,8,-1)
|
|
|
|
elseif string.sub(color,1,5) == "dark_" then
|
|
|
|
shade = "dark"
|
|
|
|
color = string.sub(color,6,-1)
|
|
|
|
end
|
|
|
|
if string.sub(color,-4,-1) == "_s50" then
|
|
|
|
shade = shade.."s50"
|
|
|
|
color = string.sub(color,1,-5)
|
|
|
|
end
|
|
|
|
|
2017-02-25 00:38:15 +01:00
|
|
|
if palette_type == "wallmounted" then
|
2017-02-06 15:22:10 +01:00
|
|
|
if color == "brown" then return 48,1
|
|
|
|
elseif color == "pink" then return 56,7
|
2017-02-06 15:30:04 +01:00
|
|
|
elseif color == "blue" and shade == "light" then return 40,5
|
add API option for "colorwallmounted" paramtype2
(pass "wallmounted" to the "is_color_fdir" field where needed)
Comes with an abridged, 32-color version of the master palette,
containing Red, Orange, Yellow, Green, Cyan, Blue, Violet, and Magenta,
in three shades each, plus the usual black/three greys/white, plus pink
and brown in two of the extrs spaces.
2017-01-29 03:51:46 +01:00
|
|
|
elseif hues_wallmounted[color] and shades_wallmounted[shade] then
|
|
|
|
return (shades_wallmounted[shade] * 64 + hues_wallmounted[color] * 8), hues_wallmounted[color]
|
|
|
|
end
|
2017-02-06 15:22:10 +01:00
|
|
|
else
|
|
|
|
if color == "brown" then
|
|
|
|
color = "orange"
|
2017-06-20 21:43:39 +02:00
|
|
|
shade = "medium"
|
2017-02-06 15:22:10 +01:00
|
|
|
elseif color == "pink" then
|
|
|
|
color = "red"
|
|
|
|
shade = "light"
|
|
|
|
end
|
2017-02-25 00:38:15 +01:00
|
|
|
if palette_type == true then -- it's colorfacedir
|
|
|
|
if hues[color] and shades[shade] then
|
2017-02-06 15:22:10 +01:00
|
|
|
return (shades[shade] * 32), hues[color]
|
2017-02-25 00:38:15 +01:00
|
|
|
end
|
|
|
|
elseif palette_type == "extended" then
|
|
|
|
if hues_extended[color] and shades_extended[shade] then
|
|
|
|
return (hues_extended[color] + shades_extended[shade]*24), hues_extended[color]
|
|
|
|
end
|
|
|
|
else -- it's the 89-color palette
|
2017-02-25 00:48:02 +01:00
|
|
|
|
|
|
|
-- If using this palette, translate new color names back to old.
|
|
|
|
|
|
|
|
if shade == "" then
|
|
|
|
if color == "spring" then
|
|
|
|
color = "aqua"
|
|
|
|
elseif color == "azure" then
|
|
|
|
color = "skyblue"
|
|
|
|
elseif color == "rose" then
|
|
|
|
color = "redviolet"
|
|
|
|
end
|
|
|
|
end
|
2017-02-25 00:38:15 +01:00
|
|
|
if hues[color] and shades[shade] then
|
2017-02-06 15:22:10 +01:00
|
|
|
return (hues[color] * 8 + shades[shade]), hues[color]
|
|
|
|
end
|
2017-01-26 12:18:37 +01:00
|
|
|
end
|
2017-01-25 18:31:40 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-02-05 01:40:15 +01:00
|
|
|
function unifieddyes.on_use(itemstack, player, pointed_thing)
|
2017-03-18 20:46:08 +01:00
|
|
|
local stackname = itemstack:get_name()
|
2017-03-17 08:10:38 +01:00
|
|
|
local playername = player:get_player_name()
|
|
|
|
|
2018-08-22 05:28:17 +02:00
|
|
|
if pointed_thing and pointed_thing.type == "node" and unifieddyes.select_node(pointed_thing) then
|
2017-03-18 19:34:18 +01:00
|
|
|
if minetest.is_protected(unifieddyes.select_node(pointed_thing), playername)
|
|
|
|
and not minetest.check_player_privs(playername, "protection_bypass") then
|
|
|
|
minetest.chat_send_player(playername, "Sorry, someone else owns that spot.")
|
|
|
|
return
|
|
|
|
end
|
2017-03-17 08:10:38 +01:00
|
|
|
end
|
|
|
|
|
2017-02-21 13:46:38 +01:00
|
|
|
if pointed_thing and pointed_thing.type == "object" then
|
|
|
|
pointed_thing.ref:punch(player, 0, itemstack:get_tool_capabilities())
|
|
|
|
return player:get_wielded_item() -- punch may modified the wielded item, load the new and return it
|
|
|
|
end
|
|
|
|
|
2017-03-18 19:34:18 +01:00
|
|
|
if not (pointed_thing and pointed_thing.type == "node") then return end -- if "using" the dye on nothing at all (e.g. air)
|
2017-02-05 01:40:15 +01:00
|
|
|
|
|
|
|
local pos = minetest.get_pointed_thing_position(pointed_thing)
|
|
|
|
local node = minetest.get_node(pos)
|
2017-03-18 05:19:13 +01:00
|
|
|
|
2017-02-05 01:40:15 +01:00
|
|
|
local nodedef = minetest.registered_nodes[node.name]
|
|
|
|
|
2017-03-12 03:20:10 +01:00
|
|
|
if not nodedef then return end -- target was an unknown node, just bail out
|
|
|
|
|
2017-02-06 15:22:10 +01:00
|
|
|
-- if the node has an on_punch defined, bail out and call that instead, unless "sneak" is pressed.
|
|
|
|
if not player:get_player_control().sneak then
|
|
|
|
local onpunch = nodedef.on_punch(pos, node, player, pointed_thing)
|
|
|
|
if onpunch then
|
|
|
|
return onpunch
|
|
|
|
end
|
2017-02-05 01:40:15 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
-- if the target is unknown, has no groups defined, or isn't UD-colorable, just bail out
|
2017-02-06 02:21:04 +01:00
|
|
|
if not (nodedef and nodedef.groups and nodedef.groups.ud_param2_colorable) then
|
|
|
|
minetest.chat_send_player(playername, "That node can't be colored.")
|
|
|
|
return
|
|
|
|
end
|
2017-02-05 01:40:15 +01:00
|
|
|
|
|
|
|
local newnode = nodedef.ud_replacement_node
|
2017-02-25 00:38:15 +01:00
|
|
|
local palette_type
|
2017-02-05 01:40:15 +01:00
|
|
|
|
2017-02-26 16:55:49 +01:00
|
|
|
if nodedef.palette == "unifieddyes_palette_extended.png" then
|
|
|
|
palette_type = "extended"
|
|
|
|
elseif nodedef.palette == "unifieddyes_palette.png" then
|
|
|
|
palette_type = false
|
2017-02-25 00:38:15 +01:00
|
|
|
elseif nodedef.paramtype2 == "colorfacedir" then
|
|
|
|
palette_type = true
|
|
|
|
elseif nodedef.paramtype2 == "colorwallmounted" then
|
|
|
|
palette_type = "wallmounted"
|
2017-01-25 18:31:40 +01:00
|
|
|
end
|
|
|
|
|
2017-02-05 01:40:15 +01:00
|
|
|
if minetest.is_protected(pos, playername) and not minetest.check_player_privs(playername, {protection_bypass=true}) then
|
|
|
|
minetest.record_protection_violation(pos, playername)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local pos2 = unifieddyes.select_node(pointed_thing)
|
2017-02-25 00:38:15 +01:00
|
|
|
local paletteidx, hue = unifieddyes.getpaletteidx(stackname, palette_type)
|
2017-01-30 11:50:02 +01:00
|
|
|
|
2017-01-25 18:31:40 +01:00
|
|
|
if paletteidx then
|
|
|
|
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
local prevdye = meta:get_string("dye")
|
2017-01-28 15:36:42 +01:00
|
|
|
local inv = player:get_inventory()
|
|
|
|
|
|
|
|
if not (inv:contains_item("main", prevdye) and creative_mode) and minetest.registered_items[prevdye] then
|
2017-01-28 14:05:44 +01:00
|
|
|
if inv:room_for_item("main", prevdye) then
|
|
|
|
inv:add_item("main", prevdye)
|
2017-01-25 18:31:40 +01:00
|
|
|
else
|
2017-01-28 14:05:44 +01:00
|
|
|
minetest.add_item(pos, prevdye)
|
2017-01-25 18:31:40 +01:00
|
|
|
end
|
|
|
|
end
|
2017-01-28 14:05:44 +01:00
|
|
|
|
2017-02-05 01:40:15 +01:00
|
|
|
meta:set_string("dye", stackname)
|
|
|
|
|
|
|
|
if prevdye == stackname then
|
|
|
|
local a,b = string.find(stackname, ":")
|
|
|
|
minetest.chat_send_player(playername, "That node is already "..string.sub(stackname, a + 1).."." )
|
|
|
|
return
|
|
|
|
elseif not creative_mode then
|
|
|
|
itemstack:take_item()
|
2017-01-28 14:05:44 +01:00
|
|
|
end
|
2017-02-05 01:40:15 +01:00
|
|
|
|
2017-01-25 18:31:40 +01:00
|
|
|
node.param2 = paletteidx
|
2017-01-26 12:18:37 +01:00
|
|
|
|
2017-02-25 00:38:15 +01:00
|
|
|
local oldpaletteidx, oldhuenum = unifieddyes.getpaletteidx(prevdye, palette_type)
|
2017-01-26 17:06:06 +01:00
|
|
|
local oldnode = minetest.get_node(pos)
|
|
|
|
|
|
|
|
local oldhue = nil
|
2017-02-25 04:42:42 +01:00
|
|
|
for _, i in ipairs(unifieddyes.HUES) do
|
2017-01-26 17:06:06 +01:00
|
|
|
if string.find(oldnode.name, "_"..i) and not
|
|
|
|
( string.find(oldnode.name, "_redviolet") and i == "red" ) then
|
|
|
|
oldhue = i
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
2017-01-26 12:18:37 +01:00
|
|
|
|
2017-01-26 17:23:18 +01:00
|
|
|
if newnode then -- this path is used when the calling mod want to supply a replacement node
|
2017-02-25 00:38:15 +01:00
|
|
|
if palette_type == "wallmounted" then
|
add API option for "colorwallmounted" paramtype2
(pass "wallmounted" to the "is_color_fdir" field where needed)
Comes with an abridged, 32-color version of the master palette,
containing Red, Orange, Yellow, Green, Cyan, Blue, Violet, and Magenta,
in three shades each, plus the usual black/three greys/white, plus pink
and brown in two of the extrs spaces.
2017-01-29 03:51:46 +01:00
|
|
|
node.param2 = paletteidx + (minetest.get_node(pos).param2 % 8)
|
2017-02-25 00:38:15 +01:00
|
|
|
elseif palette_type == true then -- it's colorfacedir
|
2017-01-26 12:18:37 +01:00
|
|
|
if oldhue ~=0 then -- it's colored, not grey
|
2017-01-26 13:10:48 +01:00
|
|
|
if oldhue ~= nil then -- it's been painted before
|
|
|
|
if hue ~= 0 then -- the player's wielding a colored dye
|
2017-02-25 04:42:42 +01:00
|
|
|
newnode = string.gsub(newnode, "_"..oldhue, "_"..unifieddyes.HUES[hue])
|
2017-01-26 13:10:48 +01:00
|
|
|
else -- it's a greyscale dye
|
2017-01-26 17:06:06 +01:00
|
|
|
newnode = string.gsub(newnode, "_"..oldhue, "_grey")
|
2017-01-26 13:10:48 +01:00
|
|
|
end
|
|
|
|
else -- it's never had a color at all
|
|
|
|
if hue ~= 0 then -- and if the wield is greyscale, don't change the node name
|
2017-02-25 04:42:42 +01:00
|
|
|
newnode = string.gsub(newnode, "_grey", "_"..unifieddyes.HUES[hue])
|
2017-01-26 13:10:48 +01:00
|
|
|
end
|
|
|
|
end
|
2017-01-26 12:18:37 +01:00
|
|
|
else
|
2017-01-26 13:10:48 +01:00
|
|
|
if hue ~= 0 then -- greyscale dye on greyscale node = no hue change
|
2017-02-25 04:42:42 +01:00
|
|
|
newnode = string.gsub(newnode, "_grey", "_"..unifieddyes.HUES[hue])
|
2017-01-26 13:10:48 +01:00
|
|
|
end
|
2017-01-26 12:18:37 +01:00
|
|
|
end
|
2017-01-29 00:19:07 +01:00
|
|
|
node.param2 = paletteidx + (minetest.get_node(pos).param2 % 32)
|
2017-02-25 00:38:15 +01:00
|
|
|
else -- it's the 89-color palette, or the extended palette
|
2017-01-29 00:19:07 +01:00
|
|
|
node.param2 = paletteidx
|
2017-01-26 12:18:37 +01:00
|
|
|
end
|
2017-01-26 17:06:06 +01:00
|
|
|
node.name = newnode
|
2017-01-25 18:31:40 +01:00
|
|
|
minetest.swap_node(pos, node)
|
2017-02-25 01:21:15 +01:00
|
|
|
if palette_type == "extended" then
|
|
|
|
meta:set_string("palette", "ext")
|
|
|
|
end
|
2017-02-05 01:40:15 +01:00
|
|
|
if not creative_mode then
|
|
|
|
return itemstack
|
|
|
|
end
|
2017-01-26 17:23:18 +01:00
|
|
|
else -- this path is used when you're just painting an existing node, rather than replacing one.
|
2017-01-26 17:06:06 +01:00
|
|
|
newnode = oldnode -- note that here, newnode/oldnode are a full node, not just the name.
|
2017-02-25 00:38:15 +01:00
|
|
|
if palette_type == "wallmounted" then
|
add API option for "colorwallmounted" paramtype2
(pass "wallmounted" to the "is_color_fdir" field where needed)
Comes with an abridged, 32-color version of the master palette,
containing Red, Orange, Yellow, Green, Cyan, Blue, Violet, and Magenta,
in three shades each, plus the usual black/three greys/white, plus pink
and brown in two of the extrs spaces.
2017-01-29 03:51:46 +01:00
|
|
|
newnode.param2 = paletteidx + (minetest.get_node(pos).param2 % 8)
|
2017-02-25 00:38:15 +01:00
|
|
|
elseif palette_type == true then -- it's colorfacedir
|
2017-01-26 17:06:06 +01:00
|
|
|
if oldhue then
|
2017-01-26 17:23:18 +01:00
|
|
|
if hue ~= 0 then
|
2017-02-25 04:42:42 +01:00
|
|
|
newnode.name = string.gsub(newnode.name, "_"..oldhue, "_"..unifieddyes.HUES[hue])
|
2017-01-26 17:23:18 +01:00
|
|
|
else
|
|
|
|
newnode.name = string.gsub(newnode.name, "_"..oldhue, "_grey")
|
|
|
|
end
|
|
|
|
elseif string.find(minetest.get_node(pos).name, "_grey") and hue ~= 0 then
|
2017-02-25 04:42:42 +01:00
|
|
|
newnode.name = string.gsub(newnode.name, "_grey", "_"..unifieddyes.HUES[hue])
|
2017-01-26 17:06:06 +01:00
|
|
|
end
|
2017-01-29 00:19:07 +01:00
|
|
|
newnode.param2 = paletteidx + (minetest.get_node(pos).param2 % 32)
|
2017-02-25 00:38:15 +01:00
|
|
|
else -- it's the 89-color palette, or the extended palette
|
2017-01-29 00:19:07 +01:00
|
|
|
newnode.param2 = paletteidx
|
2017-01-26 12:18:37 +01:00
|
|
|
end
|
2017-01-28 15:36:42 +01:00
|
|
|
minetest.swap_node(pos, newnode)
|
2017-02-25 01:21:15 +01:00
|
|
|
if palette_type == "extended" then
|
|
|
|
meta:set_string("palette", "ext")
|
|
|
|
end
|
2017-01-28 14:05:44 +01:00
|
|
|
if not creative_mode then
|
2017-02-05 01:40:15 +01:00
|
|
|
return itemstack
|
2017-01-28 14:05:44 +01:00
|
|
|
end
|
2017-02-05 01:40:15 +01:00
|
|
|
end
|
|
|
|
else
|
|
|
|
local a,b = string.find(stackname, ":")
|
|
|
|
if a then
|
|
|
|
minetest.chat_send_player(playername, "That node can't be colored "..string.sub(stackname, a + 1).."." )
|
2017-01-25 18:31:40 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-02-05 01:40:15 +01:00
|
|
|
-- re-define default dyes slightly, to add on_use
|
|
|
|
|
|
|
|
for _, color in ipairs(default_dyes) do
|
|
|
|
minetest.override_item("dye:"..color, {
|
|
|
|
on_use = unifieddyes.on_use
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2017-02-24 20:21:59 +01:00
|
|
|
-- build a table to convert from classic/89-color palette to extended palette
|
|
|
|
|
2017-02-25 02:13:43 +01:00
|
|
|
-- the first five entries are for the old greyscale - white, light, grey, dark, black
|
|
|
|
unifieddyes.convert_classic_palette = {
|
|
|
|
240,
|
|
|
|
244,
|
|
|
|
247,
|
|
|
|
251,
|
|
|
|
253
|
|
|
|
}
|
2017-02-24 20:21:59 +01:00
|
|
|
|
|
|
|
for hue = 0, 11 do
|
|
|
|
-- light
|
2017-02-25 04:42:42 +01:00
|
|
|
local paletteidx = unifieddyes.getpaletteidx("dye:light_"..unifieddyes.HUES[hue+1], false)
|
2017-02-25 01:57:48 +01:00
|
|
|
unifieddyes.convert_classic_palette[paletteidx] = hue*2 + 48
|
2017-02-24 20:21:59 +01:00
|
|
|
for sat = 0, 1 do
|
|
|
|
for val = 0, 2 do
|
2017-02-25 01:57:48 +01:00
|
|
|
-- all other shades
|
2017-02-25 04:42:42 +01:00
|
|
|
local paletteidx = unifieddyes.getpaletteidx("dye:"..unifieddyes.VALS[val+1]..unifieddyes.HUES[hue+1]..unifieddyes.SATS[sat+1], false)
|
2017-02-25 01:57:48 +01:00
|
|
|
unifieddyes.convert_classic_palette[paletteidx] = hue*2 + sat*24 + (val*48+96)
|
2017-02-24 20:21:59 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-02-24 23:40:37 +01:00
|
|
|
-- Generate all dyes that are not part of the default minetest_game dyes mod
|
2012-07-12 23:49:46 +02:00
|
|
|
|
2017-02-25 04:42:42 +01:00
|
|
|
for _, h in ipairs(unifieddyes.HUES_EXTENDED) do
|
2017-02-24 23:40:37 +01:00
|
|
|
local hue = h[1]
|
|
|
|
local r = h[2]
|
|
|
|
local g = h[3]
|
|
|
|
local b = h[4]
|
2012-07-12 23:49:46 +02:00
|
|
|
|
2017-02-24 23:40:37 +01:00
|
|
|
for v = 0, 6 do
|
2017-02-25 04:42:42 +01:00
|
|
|
local val = unifieddyes.VALS_EXTENDED[v+1]
|
2017-02-24 23:40:37 +01:00
|
|
|
|
|
|
|
local factor = 40
|
2017-02-25 19:22:08 +01:00
|
|
|
if v > 3 then factor = 75 end
|
2017-02-24 23:40:37 +01:00
|
|
|
|
|
|
|
local r2 = math.max(math.min(r + (4-v)*factor, 255), 0)
|
|
|
|
local g2 = math.max(math.min(g + (4-v)*factor, 255), 0)
|
|
|
|
local b2 = math.max(math.min(b + (4-v)*factor, 255), 0)
|
|
|
|
|
|
|
|
-- full-sat color
|
|
|
|
|
|
|
|
local desc = hue:gsub("%a", string.upper, 1).." Dye"
|
|
|
|
|
|
|
|
if val ~= "" then
|
|
|
|
desc = val:sub(1, -2):gsub("%a", string.upper, 1) .." "..desc
|
|
|
|
end
|
|
|
|
|
2017-02-25 22:29:14 +01:00
|
|
|
local color = string.format("%02x", r2)..string.format("%02x", g2)..string.format("%02x", b2)
|
|
|
|
if minetest.registered_items["dye:"..val..hue] then
|
|
|
|
minetest.override_item("dye:"..val..hue, {
|
2017-02-25 22:45:57 +01:00
|
|
|
inventory_image = "unifieddyes_dye.png^[colorize:#"..color..":200",
|
|
|
|
on_use = unifieddyes.on_use
|
2017-02-25 22:29:14 +01:00
|
|
|
})
|
|
|
|
else
|
2017-06-20 21:43:39 +02:00
|
|
|
if (val..hue) ~= "medium_orange"
|
|
|
|
and (val..hue) ~= "light_red" then
|
|
|
|
minetest.register_craftitem(":dye:"..val..hue, {
|
|
|
|
description = S(desc),
|
|
|
|
inventory_image = "unifieddyes_dye.png^[colorize:#"..color..":200",
|
|
|
|
groups = { dye=1, not_in_creative_inventory=1 },
|
|
|
|
on_use = unifieddyes.on_use
|
|
|
|
})
|
|
|
|
end
|
2017-02-24 23:40:37 +01:00
|
|
|
end
|
2017-02-25 22:29:14 +01:00
|
|
|
minetest.register_alias("unifieddyes:"..val..hue, "dye:"..val..hue)
|
2017-02-24 23:40:37 +01:00
|
|
|
|
2017-02-25 19:22:08 +01:00
|
|
|
if v > 3 then -- also register the low-sat version
|
2017-02-24 23:40:37 +01:00
|
|
|
|
|
|
|
local pr = 0.299
|
|
|
|
local pg = 0.587
|
|
|
|
local pb = 0.114
|
|
|
|
|
|
|
|
local p = math.sqrt(r2*r2*pr + g2*g2*pg + b2*b2*pb)
|
|
|
|
local r3 = math.floor(p+(r2-p)*0.5)
|
|
|
|
local g3 = math.floor(p+(g2-p)*0.5)
|
|
|
|
local b3 = math.floor(p+(b2-p)*0.5)
|
|
|
|
|
|
|
|
local color = string.format("%02x", r3)..string.format("%02x", g3)..string.format("%02x", b3)
|
|
|
|
|
|
|
|
minetest.register_craftitem(":dye:"..val..hue.."_s50", {
|
|
|
|
description = S(desc.." (low saturation)"),
|
|
|
|
inventory_image = "unifieddyes_dye.png^[colorize:#"..color..":200",
|
2017-02-25 02:42:04 +01:00
|
|
|
groups = { dye=1, not_in_creative_inventory=1 },
|
2017-02-24 23:40:37 +01:00
|
|
|
on_use = unifieddyes.on_use
|
|
|
|
})
|
|
|
|
minetest.register_alias("unifieddyes:"..val..hue.."_s50", "dye:"..val..hue.."_s50")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- register the greyscales too :P
|
|
|
|
|
|
|
|
for y = 1, 14 do -- colors 0 and 15 are black and white, default dyes
|
|
|
|
|
2017-02-27 00:34:29 +01:00
|
|
|
if y ~= 4 and y ~= 8 and y~= 11 then -- don't register the three greys, they're done separately.
|
2017-02-24 23:40:37 +01:00
|
|
|
|
|
|
|
local rgb = string.format("%02x", y*17)..string.format("%02x", y*17)..string.format("%02x", y*17)
|
|
|
|
local name = "grey_"..y
|
|
|
|
local desc = "Grey Dye #"..y
|
|
|
|
|
|
|
|
minetest.register_craftitem(":dye:"..name, {
|
|
|
|
description = S(desc),
|
|
|
|
inventory_image = "unifieddyes_dye.png^[colorize:#"..rgb..":200",
|
2017-02-25 02:42:04 +01:00
|
|
|
groups = { dye=1, not_in_creative_inventory=1 },
|
2017-02-24 23:40:37 +01:00
|
|
|
on_use = unifieddyes.on_use
|
|
|
|
})
|
|
|
|
minetest.register_alias("unifieddyes:"..name, "dye:"..name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-02-25 22:29:14 +01:00
|
|
|
minetest.override_item("dye:grey", {
|
2017-02-25 22:45:57 +01:00
|
|
|
inventory_image = "unifieddyes_dye.png^[colorize:#888888:200",
|
|
|
|
on_use = unifieddyes.on_use
|
2017-02-25 22:29:14 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.override_item("dye:dark_grey", {
|
2017-02-25 22:45:57 +01:00
|
|
|
inventory_image = "unifieddyes_dye.png^[colorize:#444444:200",
|
|
|
|
on_use = unifieddyes.on_use
|
2017-02-25 22:29:14 +01:00
|
|
|
})
|
|
|
|
|
2017-02-25 18:44:22 +01:00
|
|
|
minetest.register_craftitem(":dye:light_grey", {
|
|
|
|
description = S("Light grey Dye"),
|
|
|
|
inventory_image = "unifieddyes_dye.png^[colorize:#cccccc:200",
|
|
|
|
groups = { dye=1, not_in_creative_inventory=1 },
|
|
|
|
on_use = unifieddyes.on_use
|
2012-08-02 01:14:49 +02:00
|
|
|
})
|
|
|
|
|
2017-02-27 04:32:56 +01:00
|
|
|
unifieddyes.base_color_crafts = {
|
2017-02-27 00:34:29 +01:00
|
|
|
{ "red", "flowers:rose", nil, nil, nil, nil, 4 },
|
|
|
|
{ "vermilion", "dye:red", "dye:orange", nil, nil, nil, 3 },
|
|
|
|
{ "orange", "flowers:tulip", nil, nil, nil, nil, 4 },
|
|
|
|
{ "orange", "dye:red", "dye:yellow", nil, nil, nil, 2 },
|
|
|
|
{ "amber", "dye:orange", "dye:yellow", nil, nil, nil, 2 },
|
|
|
|
{ "yellow", "flowers:dandelion_yellow", nil, nil, nil, nil, 4 },
|
|
|
|
{ "lime", "dye:yellow", "dye:chartreuse", nil, nil, nil, 2 },
|
|
|
|
{ "lime", "dye:yellow", "dye:yellow", "dye:green", nil, nil, 3 },
|
|
|
|
{ "chartreuse", "dye:yellow", "dye:green", nil, nil, nil, 2 },
|
|
|
|
{ "harlequin", "dye:chartreuse", "dye:green", nil, nil, nil, 2 },
|
|
|
|
{ "harlequin", "dye:yellow", "dye:green", "dye:green", nil, nil, 3 },
|
|
|
|
{ "green", "default:cactus", nil, nil, nil, nil, 4 },
|
|
|
|
{ "green", "dye:yellow", "dye:blue", nil, nil, nil, 2 },
|
|
|
|
{ "malachite", "dye:green", "dye:spring", nil, nil, nil, 2 },
|
|
|
|
{ "malachite", "dye:green", "dye:green", "dye:cyan", nil, nil, 3 },
|
|
|
|
{ "malachite", "dye:green", "dye:green", "dye:green", "dye:blue", nil, 4 },
|
|
|
|
{ "spring", "dye:green", "dye:cyan", nil, nil, nil, 2 },
|
|
|
|
{ "spring", "dye:green", "dye:green", "dye:blue", nil, nil, 3 },
|
|
|
|
{ "turquoise", "dye:spring", "dye:cyan", nil, nil, nil, 2 },
|
|
|
|
{ "turquoise", "dye:green", "dye:cyan", "dye:cyan", nil, nil, 3 },
|
|
|
|
{ "turquoise", "dye:green", "dye:green", "dye:green", "dye:blue", "dye:blue", 5 },
|
|
|
|
{ "cyan", "dye:green", "dye:blue", nil, nil, nil, 2 },
|
|
|
|
{ "cerulean", "dye:cyan", "dye:azure", nil, nil, nil, 2 },
|
|
|
|
{ "cerulean", "dye:cyan", "dye:cyan", "dye:blue", nil, nil, 3 },
|
|
|
|
{ "cerulean", "dye:green", "dye:green", "dye:blue", "dye:blue", "dye:blue", 5 },
|
|
|
|
{ "azure", "dye:cyan", "dye:blue", nil, nil, nil, 2 },
|
|
|
|
{ "azure", "dye:green", "dye:blue", "dye:blue", nil, nil, 3 },
|
|
|
|
{ "sapphire", "dye:azure", "dye:blue", nil, nil, nil, 2 },
|
|
|
|
{ "sapphire", "dye:cyan", "dye:blue", "dye:blue", nil, nil, 3 },
|
2017-02-27 00:39:41 +01:00
|
|
|
{ "sapphire", "dye:green", "dye:blue", "dye:blue", "dye:blue", nil, 4 },
|
2017-02-27 00:34:29 +01:00
|
|
|
{ "blue", "flowers:geranium", nil, nil, nil, nil, 4 },
|
|
|
|
{ "indigo", "dye:blue", "dye:violet", nil, nil, nil, 2 },
|
|
|
|
{ "violet", "flowers:viola", nil, nil, nil, nil, 4 },
|
|
|
|
{ "violet", "dye:blue", "dye:magenta", nil, nil, nil, 2 },
|
|
|
|
{ "mulberry", "dye:violet", "dye:magenta", nil, nil, nil, 2 },
|
|
|
|
{ "mulberry", "dye:violet", "dye:blue", "dye:red", nil, nil, 3 },
|
2017-02-27 00:39:41 +01:00
|
|
|
{ "magenta", "dye:blue", "dye:red", nil, nil, nil, 2 },
|
2017-02-27 00:34:29 +01:00
|
|
|
{ "fuchsia", "dye:magenta", "dye:rose", nil, nil, nil, 2 },
|
|
|
|
{ "fuchsia", "dye:blue", "dye:red", "dye:rose", nil, nil, 3 },
|
|
|
|
{ "fuchsia", "dye:red", "dye:violet", nil, nil, nil, 2 },
|
|
|
|
{ "rose", "dye:magenta", "dye:red", nil, nil, nil, 2 },
|
|
|
|
{ "rose", "dye:red", "dye:red", "dye:blue", nil, nil, 3 },
|
|
|
|
{ "crimson", "dye:rose", "dye:red", nil, nil, nil, 2 },
|
|
|
|
{ "crimson", "dye:magenta", "dye:red", "dye:red", nil, nil, 3 },
|
|
|
|
{ "crimson", "dye:red", "dye:red", "dye:red", "dye:blue", nil, 4 },
|
|
|
|
|
|
|
|
{ "black", "default:coal_lump", nil, nil, nil, nil, 4 },
|
|
|
|
{ "white", "flowers:dandelion_white", nil, nil, nil, nil, 4 },
|
2017-02-25 18:44:22 +01:00
|
|
|
}
|
2012-07-12 23:49:46 +02:00
|
|
|
|
2017-02-27 04:32:56 +01:00
|
|
|
unifieddyes.shade_crafts = {
|
2017-02-25 18:44:22 +01:00
|
|
|
{ "faint_", "", "dye:white", "dye:white", "dye:white", 4 },
|
|
|
|
{ "pastel_", "", "dye:white", "dye:white", nil, 3 },
|
|
|
|
{ "light_", "", "dye:white", nil, nil, 2 },
|
|
|
|
{ "bright_", "", "color", "dye:white", nil, 3 },
|
|
|
|
{ "", "_s50", "dye:light_grey", nil, nil, 2 },
|
|
|
|
{ "", "_s50", "dye:black", "dye:white", "dye:white", 3 },
|
|
|
|
{ "medium_", "", "dye:black", nil, nil, 2 },
|
|
|
|
{ "medium_", "_s50", "dye:grey", nil, nil, 2 },
|
|
|
|
{ "medium_", "_s50", "dye:black", "dye:white", nil, 3 },
|
|
|
|
{ "dark_", "", "dye:black", "dye:black", nil, 3 },
|
|
|
|
{ "dark_", "_s50", "dye:dark_grey", nil, nil, 2 },
|
2017-02-25 19:22:08 +01:00
|
|
|
{ "dark_", "_s50", "dye:black", "dye:black", "dye:white", 4 },
|
2017-02-25 18:44:22 +01:00
|
|
|
}
|
2017-02-24 20:28:38 +01:00
|
|
|
|
2017-02-27 04:32:56 +01:00
|
|
|
for _,i in ipairs(unifieddyes.base_color_crafts) do
|
2017-02-25 18:44:22 +01:00
|
|
|
local color = i[1]
|
2017-02-27 00:34:29 +01:00
|
|
|
local yield = i[7]
|
2012-07-12 23:49:46 +02:00
|
|
|
|
|
|
|
minetest.register_craft( {
|
Refactored the code to use default "common" dyes
rather than directly from flowers.
This mod now depends on "default" and "dye" from the Minetest common
sub-game. Since the default dye mod uses default flowers, this mod no
longer checks for what version of flowers you're using, or even depends
on it.
Bottle-based textures have been replaced with piles of dye powder, based
on the default red dye texture.
All dyes are obtained by crafting, not cooking, for consistency with the
default dye mod.
The somewhat-complicated method using separate "pigment" powders, glass
bottles and "liquid dye base" has been done away with. Now it's just
dry dye powders, as with the default dye mod.
Also, got rid of the whole paint scheme, in favor of dry powders.
All old dyes, paints, and Unified Dyes pigment powders have been aliased
back to the standard dye powders.
2013-04-30 12:02:22 +02:00
|
|
|
type = "shapeless",
|
2017-02-25 18:44:22 +01:00
|
|
|
output = "dye:"..color.." "..yield,
|
Refactored the code to use default "common" dyes
rather than directly from flowers.
This mod now depends on "default" and "dye" from the Minetest common
sub-game. Since the default dye mod uses default flowers, this mod no
longer checks for what version of flowers you're using, or even depends
on it.
Bottle-based textures have been replaced with piles of dye powder, based
on the default red dye texture.
All dyes are obtained by crafting, not cooking, for consistency with the
default dye mod.
The somewhat-complicated method using separate "pigment" powders, glass
bottles and "liquid dye base" has been done away with. Now it's just
dry dye powders, as with the default dye mod.
Also, got rid of the whole paint scheme, in favor of dry powders.
All old dyes, paints, and Unified Dyes pigment powders have been aliased
back to the standard dye powders.
2013-04-30 12:02:22 +02:00
|
|
|
recipe = {
|
2017-02-27 00:42:41 +01:00
|
|
|
i[2],
|
|
|
|
i[3],
|
|
|
|
i[4],
|
|
|
|
i[5],
|
|
|
|
i[6],
|
2017-02-25 18:44:22 +01:00
|
|
|
},
|
2012-07-12 23:49:46 +02:00
|
|
|
})
|
|
|
|
|
2017-02-27 04:32:56 +01:00
|
|
|
for _,j in ipairs(unifieddyes.shade_crafts) do
|
2017-02-27 00:42:41 +01:00
|
|
|
local firstdye = j[3]
|
|
|
|
if firstdye == "color" then firstdye = "dye:"..color end
|
2017-02-25 18:44:22 +01:00
|
|
|
|
2017-06-20 22:03:38 +02:00
|
|
|
-- ignore black, white, anything containing the word "grey"
|
2017-06-20 21:43:39 +02:00
|
|
|
|
2017-02-25 18:44:22 +01:00
|
|
|
if color ~= "black" and color ~= "white" and not string.find(color, "grey") then
|
|
|
|
|
|
|
|
minetest.register_craft( {
|
|
|
|
type = "shapeless",
|
2017-02-27 00:42:41 +01:00
|
|
|
output = "dye:"..j[1]..color..j[2].." "..yield,
|
2017-02-25 18:44:22 +01:00
|
|
|
recipe = {
|
|
|
|
"dye:"..color,
|
2017-02-27 00:42:41 +01:00
|
|
|
firstdye,
|
|
|
|
j[4],
|
|
|
|
j[5]
|
2017-02-25 18:44:22 +01:00
|
|
|
},
|
|
|
|
})
|
|
|
|
end
|
Refactored the code to use default "common" dyes
rather than directly from flowers.
This mod now depends on "default" and "dye" from the Minetest common
sub-game. Since the default dye mod uses default flowers, this mod no
longer checks for what version of flowers you're using, or even depends
on it.
Bottle-based textures have been replaced with piles of dye powder, based
on the default red dye texture.
All dyes are obtained by crafting, not cooking, for consistency with the
default dye mod.
The somewhat-complicated method using separate "pigment" powders, glass
bottles and "liquid dye base" has been done away with. Now it's just
dry dye powders, as with the default dye mod.
Also, got rid of the whole paint scheme, in favor of dry powders.
All old dyes, paints, and Unified Dyes pigment powders have been aliased
back to the standard dye powders.
2013-04-30 12:02:22 +02:00
|
|
|
end
|
2012-07-12 23:49:46 +02:00
|
|
|
end
|
|
|
|
|
2017-06-20 21:43:39 +02:00
|
|
|
-- greys
|
|
|
|
|
2017-02-27 04:32:56 +01:00
|
|
|
unifieddyes.greymixes = {
|
2017-02-25 20:41:53 +01:00
|
|
|
{ 1, "dye:black", "dye:black", "dye:black", "dye:dark_grey", 4 },
|
|
|
|
{ 2, "dye:black", "dye:black", "dye:dark_grey", nil, 3 },
|
|
|
|
{ 3, "dye:black", "dye:dark_grey", nil, nil, 2 },
|
2017-02-25 20:53:04 +01:00
|
|
|
{ 4, "dye:white", "dye:black", "dye:black", nil, 3 },
|
|
|
|
{ 5, "dye:dark_grey", "dye:dark_grey", "dye:grey", nil, 3 },
|
|
|
|
{ 6, "dye:dark_grey", "dye:grey", nil, nil, 2 },
|
2017-02-25 20:41:53 +01:00
|
|
|
{ 7, "dye:dark_grey", "dye:grey", "dye:grey", nil, 3 },
|
|
|
|
{ 8, "dye:white", "dye:black", nil, nil, 2 },
|
|
|
|
{ 9, "dye:grey", "dye:grey", "dye:light_grey", nil, 3 },
|
|
|
|
{ 10, "dye:grey", "dye:light_grey", "dye:light_grey", nil, 3 },
|
|
|
|
{ 11, "dye:white", "dye:white", "dye:black", nil, 3 },
|
|
|
|
{ 12, "dye:light_grey", "dye:light_grey", "dye:white", nil, 3 },
|
|
|
|
{ 13, "dye:light_grey", "dye:white", nil, nil, 2 },
|
|
|
|
{ 14, "dye:white", "dye:white", "dye:light_grey", nil, 3 },
|
|
|
|
}
|
|
|
|
|
2017-02-27 04:32:56 +01:00
|
|
|
for _, i in ipairs(unifieddyes.greymixes) do
|
2017-02-25 20:41:53 +01:00
|
|
|
local shade = i[1]
|
|
|
|
local dye1 = i[2]
|
|
|
|
local dye2 = i[3]
|
|
|
|
local dye3 = i[4]
|
|
|
|
local dye4 = i[5]
|
|
|
|
local yield = i[6]
|
|
|
|
local color = "grey_"..shade
|
2017-02-25 20:53:04 +01:00
|
|
|
if shade == 4 then
|
2017-02-25 20:41:53 +01:00
|
|
|
color = "dark_grey"
|
|
|
|
elseif shade == 8 then
|
|
|
|
color = "grey"
|
|
|
|
elseif shade == 11 then
|
|
|
|
color = "light_grey"
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_craft( {
|
|
|
|
type = "shapeless",
|
|
|
|
output = "dye:"..color.." "..yield,
|
|
|
|
recipe = {
|
|
|
|
dye1,
|
|
|
|
dye2,
|
|
|
|
dye3,
|
|
|
|
dye4,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2017-06-20 22:03:38 +02:00
|
|
|
-- we can't make dark orange anymore because brown/medium orange conflicts
|
|
|
|
|
|
|
|
minetest.register_craft( {
|
|
|
|
type = "shapeless",
|
|
|
|
output = "dye:dark_orange",
|
|
|
|
recipe = {
|
|
|
|
"dye:brown",
|
|
|
|
"dye:brown"
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2017-06-20 21:43:39 +02:00
|
|
|
minetest.register_alias("dye:light_red", "dye:pink")
|
|
|
|
minetest.register_alias("dye:medium_orange", "dye:brown")
|
|
|
|
|
2017-01-25 19:19:20 +01:00
|
|
|
minetest.register_alias("unifieddyes:black", "dye:black")
|
2017-02-24 23:40:37 +01:00
|
|
|
minetest.register_alias("unifieddyes:dark_grey", "dye:dark_grey")
|
2018-08-22 05:28:17 +02:00
|
|
|
minetest.register_alias("unifieddyes:grey", "dye:grey")
|
2017-02-24 23:40:37 +01:00
|
|
|
minetest.register_alias("unifieddyes:light_grey", "dye:light_grey")
|
2018-08-22 05:28:17 +02:00
|
|
|
minetest.register_alias("unifieddyes:white", "dye:white")
|
Refactored the code to use default "common" dyes
rather than directly from flowers.
This mod now depends on "default" and "dye" from the Minetest common
sub-game. Since the default dye mod uses default flowers, this mod no
longer checks for what version of flowers you're using, or even depends
on it.
Bottle-based textures have been replaced with piles of dye powder, based
on the default red dye texture.
All dyes are obtained by crafting, not cooking, for consistency with the
default dye mod.
The somewhat-complicated method using separate "pigment" powders, glass
bottles and "liquid dye base" has been done away with. Now it's just
dry dye powders, as with the default dye mod.
Also, got rid of the whole paint scheme, in favor of dry powders.
All old dyes, paints, and Unified Dyes pigment powders have been aliased
back to the standard dye powders.
2013-04-30 12:02:22 +02:00
|
|
|
|
2017-02-24 23:40:37 +01:00
|
|
|
minetest.register_alias("unifieddyes:grey_0", "dye:black")
|
2017-02-25 20:53:04 +01:00
|
|
|
minetest.register_alias("unifieddyes:grey_4", "dye:dark_grey")
|
2017-02-25 20:07:35 +01:00
|
|
|
minetest.register_alias("unifieddyes:grey_8", "dye:grey")
|
|
|
|
minetest.register_alias("unifieddyes:grey_11", "dye:light_grey")
|
2017-02-24 23:40:37 +01:00
|
|
|
minetest.register_alias("unifieddyes:grey_15", "dye:white")
|
|
|
|
|
Refactored the code to use default "common" dyes
rather than directly from flowers.
This mod now depends on "default" and "dye" from the Minetest common
sub-game. Since the default dye mod uses default flowers, this mod no
longer checks for what version of flowers you're using, or even depends
on it.
Bottle-based textures have been replaced with piles of dye powder, based
on the default red dye texture.
All dyes are obtained by crafting, not cooking, for consistency with the
default dye mod.
The somewhat-complicated method using separate "pigment" powders, glass
bottles and "liquid dye base" has been done away with. Now it's just
dry dye powders, as with the default dye mod.
Also, got rid of the whole paint scheme, in favor of dry powders.
All old dyes, paints, and Unified Dyes pigment powders have been aliased
back to the standard dye powders.
2013-04-30 12:02:22 +02:00
|
|
|
minetest.register_alias("unifieddyes:white_paint", "dye:white")
|
|
|
|
minetest.register_alias("unifieddyes:titanium_dioxide", "dye:white")
|
|
|
|
minetest.register_alias("unifieddyes:lightgrey_paint", "dye:light_grey")
|
|
|
|
minetest.register_alias("unifieddyes:grey_paint", "dye:grey")
|
|
|
|
minetest.register_alias("unifieddyes:darkgrey_paint", "dye:dark_grey")
|
|
|
|
minetest.register_alias("unifieddyes:carbon_black", "dye:black")
|
|
|
|
|
2017-02-24 23:40:37 +01:00
|
|
|
-- aqua -> spring, skyblue -> azure, and redviolet -> rose aliases
|
|
|
|
-- note that technically, lime should be aliased, but can't be (there IS
|
|
|
|
-- lime in the new color table, it's just shifted up a bit)
|
|
|
|
|
|
|
|
minetest.register_alias("unifieddyes:aqua", "unifieddyes:spring")
|
|
|
|
minetest.register_alias("unifieddyes:skyblue", "unifieddyes:azure")
|
|
|
|
minetest.register_alias("unifieddyes:redviolet", "unifieddyes:rose")
|
2018-08-22 05:28:17 +02:00
|
|
|
minetest.register_alias("unifieddyes:brown", "dye:brown")
|
2017-02-24 23:40:37 +01:00
|
|
|
|
2014-03-20 02:11:30 +01:00
|
|
|
print(S("[UnifiedDyes] Loaded!"))
|
2012-07-12 23:49:46 +02:00
|
|
|
|