1
0
mirror of https://github.com/mt-mods/unifieddyes.git synced 2025-06-28 14:26:21 +02:00

Compare commits

...

36 Commits

Author SHA1 Message Date
34299b01a0 fix not being able to pick up dropped objects while wielding dye 2017-02-21 07:46:38 -05:00
295cd027f2 add on_rotate handler
to correct rotation for "fake wallmounted" nodes so that they always appear
to be on the floor, pointing at one of the four NSEW directions.
2017-02-18 13:00:06 -05:00
aacb377f8c "widen" the range for floor/ceiling placement checking
in fix_rotation function
2017-02-17 23:13:22 -05:00
80e5429bf3 add helper functions for rotation correction 2017-02-17 23:04:47 -05:00
0aa55cc4d7 re-generated all of the palettes
Some colors were a little bit "off" from the official spec.  Started
from the standard 12 hues, with their RGB values manually set to exactly
0, 128, or 255 as appropriate, then brightness and saturation adjusted
as needed for each shade band.  Black is set at 8 percent (0x141414).
2017-02-07 15:42:13 -05:00
b0ccff164d add light_blue to wallmounted palette 2017-02-06 09:30:04 -05:00
4d11406f8d Pink/brown color translation tweaks
Only perform pink -> light_red and brown -> dark_orange translations if
not using the "colorwallmounted" palette.
2017-02-06 09:22:10 -05:00
e3b7e9d534 fix broken check-for-colorable 2017-02-05 20:21:04 -05:00
e981b29cd2 use on_use instead of on_rightclick to apply dyes
also add some useful messages if the target was already
the same color as the dye, can't be colored, can't take
the requested color, etc.
2017-02-04 19:40:15 -05:00
112ba73ed6 better pink shade in the colorwallmounted palette
(now it's standard web pink, but shifted 15 degrees toward red and
saturation maxed out)
2017-01-30 18:27:07 -05:00
935f15c343 don't set a custom param2 if the placed node has no facedir/wallmount 2017-01-30 05:50:02 -05:00
de61a1333b fix wallmounted grey numbering 2017-01-30 05:32:17 -05:00
1b0e384278 fix messed-up grayscale color select logic 2017-01-29 00:06:08 -05:00
3b942c352f remove some debug statements 2017-01-28 21:57:14 -05:00
8ea8b01dcc 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-28 21:51:46 -05:00
966166b1b9 only crop the palleteidx if param2 is colorfacedir
(prevent a potential bug later: some day, maybe there
will be more than 89 colors in UD)
2017-01-28 18:19:58 -05:00
aef03c1932 colorfdir -> is_color_fdir
(preparing for later inclusion of some kind of wallmounted palette)
2017-01-28 18:18:27 -05:00
e146c55ca0 fix a couple more missing aliases 2017-01-28 09:37:10 -05:00
2fcae9d17d fix several dye-handling bugs 2017-01-28 09:02:14 -05:00
aeb179a129 API CHANGE: after_dig_node instead of on_destruct
This also fixes the case where digging a block just drops
the dye on the ground instead of putting it in the player's inv.
2017-01-28 08:05:44 -05:00
0fbf6baa72 fix facedir not being set when simple node placement fall-through is called 2017-01-28 07:19:30 -05:00
525a143398 removed obsolete scripts and image 2017-01-26 19:37:29 -05:00
4622d25e76 fix wrong param2 setting 2017-01-26 19:02:55 -05:00
3e93c10cfd handle both cases of nodes being set with facedir 2017-01-26 15:49:06 -05:00
2959698111 remove debug statements 2017-01-26 14:21:54 -05:00
b42376ba3d improve handling of greyscale in get-hsv function 2017-01-26 13:51:38 -05:00
1c5d79800f add an alternate "find HSV" function.
Note that if the result is greyscale, the name ("black", "grey", ...) is
returned in the "hue" field, sat is empty string, and val is "light",
"dark", or empty string.
2017-01-26 13:42:36 -05:00
b1ad76ab72 handle a few more color-to-grey and grey-to-color cases 2017-01-26 11:23:34 -05:00
3f7fb1af74 Just do the node's color search manually
(to handle cases where the node has more than just the standard-format
nodename:[shade_]hue[_s50] naming, e.g. stairsplus nodes like:

nodename:stair_[shade_]hue[_s50][_some_extra_details]
2017-01-26 11:06:31 -05:00
4f1303aac1 handle special cases for greyscale dyes and unpainted nodes 2017-01-26 07:10:48 -05:00
1773af6868 rework how split palettes are handled 2017-01-26 06:18:37 -05:00
1c7f403f29 add "split" palette for mods that need facedir + param2 color 2017-01-25 18:21:26 -05:00
00459f8859 only allow placing the wielded thing if it's actually a node 2017-01-25 16:05:24 -05:00
1426efb517 include standard 89-color UD palette 2017-01-25 13:56:31 -05:00
7c48587c6a add a few missing aliases 2017-01-25 13:19:20 -05:00
17522711de Add some helper functions to support the new param2-style coloring
Most of the code came from cheapie's plasticbox mod
2017-01-25 12:59:49 -05:00
20 changed files with 498 additions and 491 deletions

View File

@ -1,183 +0,0 @@
#!/bin/bash
# This program auto-generates colorized textures for all 89 of the Unified
# Dyes colors, based on one or two input files.
# 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.
if [ -z "`which convert`" ] ; then {
echo "Please install Imagemagick."
exit 1
} fi
if [ -z "`which bc`" ] ; then {
echo "Please install GNU bc."
exit 1
} fi
if [ $1 = "-t" ] ; then {
TINT_OVERLAY=$1
BASE=$2
COMPOSITE=$3
} else {
TINT_OVERLAY=""
BASE=$1
COMPOSITE=$2
} fi
if [ -z $1 ] || [ $1 == "--help" ] || [ $1 == "-h" ] || [[ $1 == "-t" && -z $3 ]] ; then {
echo -e "\nUsage:
\ngentextures.sh basename [overlay_filename]
gentextures.sh -t basename overlay_filename
\nThis script requires up to three parameters which supply the base
filename of the textures, an optional .png overlay, and possibly the
'-t' switch. The 'basename' is the first part of the filename that your
textures will use when your mod is done, which should almost always be
the same as the one-word name of your mod. For example, if you supply
the word 'mymod', this script will produce filenames like mymod_red.jpg
or 'mymod_dark_blue_s50.jpg'. The texture that this script will read
and recolor is derived from this parameter, and will be of the form
'basename_base.jpg', i.e. 'mymod_base.jpg'. \nYou can also supply an
overlay image filename. This image needs to be a .png or .gif or some
other alpha-capable format supported by ImageMagick, and will be
composited onto the output files after they have been colorized, but
without being modified. This is useful when you have some part of your
base image that will either get changed undesirably (for example, the
mortar among several bricks, or the shading detail of a stone pattern).
Simply draw two images: one containing the whole image to be colored,
and one containing the parts that should not be changed, with either
full or partial alpha transparency where the re-colored base image
should show through. Skilled use of color and alpha on this overlay can
lead to some interesting effects. \nIf you add '-t' as the first
parameter, the script will switch to 'tint overlay' mode. For this mode
to work, you must also supply the base name as usual, and you must
include an overlay image filename. Rather than re-color the base
texture, the script will alter the hue/saturation/value of the overlay
texture file instead, and leave the base texture unchanged. When using
this mode, the base texture should be drawn in some neutral color, but
any color is fine if it results in what you wanted.\n"
exit 1
} fi
if [[ ! -e $BASE"_base.jpg" ]]; then {
echo -e "\nThe basename '"$BASE"_base.jpg' was not found."
echo -e "\nAborting.\n"
exit 1
} fi
if [[ ! -z $COMPOSITE && ! -e $COMPOSITE ]]; then {
echo -e "\nThe requested composite file '"$COMPOSITE"' was not found."
echo -e "\nAborting.\n"
exit 1
} fi
convert $BASE"_base.jpg" -modulate 1,2,3 tempfile.jpg 1>/dev/null 2>/dev/null
if (( $? )) ; then {
echo -e "\nImagemagick failed while testing the base texture file."
echo -e "\nEither the base file '"$BASE"_base.jpg' isn't an image,"
echo "or it is broken, or Imagemagick itself just didn't work."
echo -e "\nPlease check and correct your base image and try again."
echo -e "\nAborting.\n"
exit 1
} fi
if [ ! -z $COMPOSITE ] ; then {
convert $BASE"_base.jpg" -modulate 1,2,3 $COMPOSITE -composite tempfile.jpg 1>/dev/null 2>/dev/null
if (( $? )) ; then {
echo -e "\nImagemagick failed while testing the composite file."
echo -e "\nEither the composite file '"$COMPOSITE"' isn't an image"
echo "or it is broken, or Imagemagick itself just didn't work."
echo -e "\nPlease check and correct your composite image and try again."
echo -e "\nAborting.\n"
exit 1
} fi
} fi
rm tempfile.jpg
base_colors="red orange yellow lime green aqua cyan skyblue blue violet magenta redviolet"
echo -e -n "\nGenerating filenames based on "$BASE"_base.jpg"
if [ ! -z $COMPOSITE ] ; then {
echo ","
echo -n "using "$COMPOSITE" as an overlay"
} fi
if [ ! -z $TINT_OVERLAY ] ; then {
echo ","
echo -n "and tinting the overlay instead of the base texture"
} fi
echo -e "...\n"
mkdir -p generated-textures
function generate_texture () {
name=$1
h=$2
s=$3
v=$4
if [ -z $TINT_OVERLAY ]; then {
if [ -z $COMPOSITE ]; then {
convert $BASE"_base.jpg" -modulate $v,$s,$h -quality 97 "generated-textures/"$BASE"_"$name".jpg"
} else {
convert $BASE"_base.jpg" -modulate $v,$s,$h -quality 97 $COMPOSITE -composite "generated-textures/"$BASE"_"$name".jpg"
} fi
} else {
convert $COMPOSITE -modulate $v,$s,$h -quality 97 MIFF:- | composite MIFF:- $BASE"_base.jpg" "generated-textures/"$BASE"_"$name".jpg"
} fi
}
hue=0
for color_name in $base_colors ; do
hue2=`echo "scale=10; ("$hue"*200/360)+100" |bc`
echo $color_name "("$hue" degrees)"
echo " dark"
generate_texture "dark_"$color_name $hue2 100 33
echo " medium"
generate_texture "medium_"$color_name $hue2 100 66
echo " full"
generate_texture $color_name $hue2 100 100
echo " light"
generate_texture "light_"$color_name $hue2 100 150
echo " dark, 50% saturation"
generate_texture "dark_"$color_name"_s50" $hue2 50 33
echo " medium, 50% saturation"
generate_texture "medium_"$color_name"_s50" $hue2 50 66
echo " full, 50% saturation"
generate_texture $color_name"_s50" $hue2 50 100
hue=$((hue+30))
done
echo "greyscales"
echo " black"
generate_texture black 0 0 15
echo " dark grey"
generate_texture darkgrey 0 0 50
echo " medium grey"
generate_texture grey 0 0 100
echo " light grey"
generate_texture lightgrey 0 0 150
echo " white"
generate_texture white 0 0 190

View File

@ -1,177 +0,0 @@
#!/bin/bash
# This program auto-generates colorized textures for all 89 of the Unified
# Dyes colors, based on one or two input files.
# 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.
if [ -z "`which convert`" ] ; then {
echo "Please install Imagemagick."
exit 1
} fi
if [ -z "`which bc`" ] ; then {
echo "Please install GNU bc."
exit 1
} fi
if [ $1 = "-t" ] ; then {
TINT_OVERLAY=$1
BASE=$2
COMPOSITE=$3
} else {
TINT_OVERLAY=""
BASE=$1
COMPOSITE=$2
} fi
if [ -z $1 ] || [ $1 == "--help" ] || [ $1 == "-h" ] || [[ $1 == "-t" && -z $3 ]] ; then {
echo -e "\nUsage:
\ngentextures.sh basename [overlay_filename]
gentextures.sh -t basename overlay_filename
\nThis script requires up to three parameters which supply the base filename
of the textures, an optional overlay, and possibly the '-t' switch. The
'basename' is the first part of the filename that your textures will use when
your mod is done, which should almost always be the same as the one-word name
of your mod. For example, if you supply the word 'mymod', this script will
produce filenames like mymod_red.png or 'mymod_dark_blue_s50.png'. The
texture that this script will read and recolor is derived from this parameter,
and will be of the form 'basename_base.png', i.e. 'mymod_base.png'.
\nYou can also supply an optional overlay image filename. This image will be
composited onto the output files after they have been colorized, but without
being modified. This is useful when you have some part of your base image
that will either get changed undesirably (for example, the mortar among
several bricks, or the shading detail of a stone pattern). Simply draw two
images: one containing the whole image to be colored, and one containing the
parts that should not be changed, with either full or partial alpha
transparency where the re-colored base image should show through. Skilled use
of color and alpha on this overlay can lead to some interesting effects.
\nIf you add '-t' as the first parameter, the script will switch to 'tint
overlay' mode. For this mode to work, you must also supply the base name as
usual, and you must include an overlay image filename. Rather than re-color
the base texture, the script will alter the hue/saturation/value of the
overlay texture file instead, and leave the base texture unchanged. When
using this mode, the base texture should be drawn in some neutral color, but
any color is fine if it results in what you wanted.\n"
exit 1
} fi
if [[ ! -e $BASE"_base.png" ]]; then {
echo -e "\nThe basename '"$BASE"_base.png' was not found."
echo -e "\nAborting.\n"
exit 1
} fi
if [[ ! -z $COMPOSITE && ! -e $COMPOSITE ]]; then {
echo -e "\nThe requested composite file '"$COMPOSITE"' was not found."
echo -e "\nAborting.\n"
exit 1
} fi
convert $BASE"_base.png" -modulate 1,2,3 tempfile.png 1>/dev/null 2>/dev/null
if (( $? )) ; then {
echo -e "\nImagemagick failed while testing the base texture file."
echo -e "\nEither the base file '"$BASE"_base.png' isn't an image,"
echo "or it is broken, or Imagemagick itself just didn't work."
echo -e "\nPlease check and correct your base image and try again."
echo -e "\nAborting.\n"
exit 1
} fi
if [ ! -z $COMPOSITE ] ; then {
convert $BASE"_base.png" -modulate 1,2,3 $COMPOSITE -composite tempfile.png 1>/dev/null 2>/dev/null
if (( $? )) ; then {
echo -e "\nImagemagick failed while testing the composite file."
echo -e "\nEither the composite file '"$COMPOSITE"' isn't an image"
echo "or it is broken, or Imagemagick itself just didn't work."
echo -e "\nPlease check and correct your composite image and try again."
echo -e "\nAborting.\n"
exit 1
} fi
} fi
rm tempfile.png
base_colors="red orange yellow lime green aqua cyan skyblue blue violet magenta redviolet"
echo -e -n "\nGenerating filenames based on "$BASE"_base.png"
if [ ! -z $COMPOSITE ] ; then {
echo ","
echo -n "using "$COMPOSITE" as an overlay"
} fi
if [ ! -z $TINT_OVERLAY ] ; then {
echo ","
echo -n "and tinting the overlay instead of the base texture"
} fi
echo -e "...\n"
mkdir -p generated-textures
function generate_texture () {
name=$1
h=$2
s=$3
v=$4
if [ -z $TINT_OVERLAY ]; then {
if [ -z $COMPOSITE ]; then {
convert $BASE"_base.png" -modulate $v,$s,$h "generated-textures/"$BASE"_"$name".png"
} else {
convert $BASE"_base.png" -modulate $v,$s,$h $COMPOSITE -composite "generated-textures/"$BASE"_"$name".png"
} fi
} else {
convert $COMPOSITE -modulate $v,$s,$h MIFF:- | composite MIFF:- $BASE"_base.png" "generated-textures/"$BASE"_"$name".png"
} fi
}
hue=0
for color_name in $base_colors ; do
hue2=`echo "scale=10; ("$hue"*200/360)+100" |bc`
echo $color_name "("$hue" degrees)"
echo " dark"
generate_texture "dark_"$color_name $hue2 100 33
echo " medium"
generate_texture "medium_"$color_name $hue2 100 66
echo " full"
generate_texture $color_name $hue2 100 100
echo " light"
generate_texture "light_"$color_name $hue2 100 150
echo " dark, 50% saturation"
generate_texture "dark_"$color_name"_s50" $hue2 50 33
echo " medium, 50% saturation"
generate_texture "medium_"$color_name"_s50" $hue2 50 66
echo " full, 50% saturation"
generate_texture $color_name"_s50" $hue2 50 100
hue=$((hue+30))
done
echo "greyscales"
echo " black"
generate_texture black 0 0 15
echo " dark grey"
generate_texture darkgrey 0 0 50
echo " medium grey"
generate_texture grey 0 0 100
echo " light grey"
generate_texture lightgrey 0 0 150
echo " white"
generate_texture white 0 0 190

550
init.lua
View File

@ -29,6 +29,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
--=====================================================================
unifieddyes = {}
local creative_mode = minetest.setting_getbool("creative_mode")
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if minetest.get_modpath("intllib") then
@ -37,15 +41,470 @@ else
S = function(s) return s end
end
-- helper functions for other mods that use this one
local HUES = {
"red",
"orange",
"yellow",
"lime",
"green",
"aqua",
"cyan",
"skyblue",
"blue",
"violet",
"magenta",
"redviolet"
}
local HUES2 = {
"Red",
"Orange",
"Yellow",
"Lime",
"Green",
"Aqua",
"Cyan",
"Sky-blue",
"Blue",
"Violet",
"Magenta",
"Red-violet"
}
local default_dyes = {
"black",
"blue",
"brown",
"cyan",
"dark_green",
"dark_grey",
"green",
"grey",
"magenta",
"orange",
"pink",
"red",
"violet",
"white",
"yellow"
}
-- code borrowed from homedecor
-- 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)
local yaw = placer:get_look_yaw()
local dir = minetest.yaw_to_dir(yaw-1.5)
local pitch = placer:get_look_vertical()
local fdir = minetest.dir_to_wallmounted(dir)
if pitch < -(math.pi/8) then
fdir = 0
elseif pitch > math.pi/8 then
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
-- to floor or ceiling...
function unifieddyes.fix_rotation_nsew(pos, placer, itemstack, pointed_thing)
local node = minetest.get_node(pos)
local yaw = placer:get_look_yaw()
local dir = minetest.yaw_to_dir(yaw)
local fdir = minetest.dir_to_wallmounted(dir)
minetest.swap_node(pos, { name = node.name, param2 = fdir })
end
-- ... 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
print(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
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
function unifieddyes.get_hsv(name) -- expects a node/item name
local hue = ""
local a,b
for _, i in ipairs(HUES) do
a,b = string.find(name, "_"..i)
if a and not ( string.find(name, "_redviolet") and i == "red" ) then
hue = i
break
end
end
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"
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
-- code borrowed from cheapie's plasticbox mod
function unifieddyes.getpaletteidx(color, is_color_fdir)
local origcolor = color
local aliases = {
["pink"] = "light_red",
["brown"] = "dark_orange",
}
local grayscale = {
["white"] = 1,
["light_grey"] = 2,
["grey"] = 3,
["dark_grey"] = 4,
["black"] = 5,
}
local grayscale_wallmounted = {
["white"] = 0,
["light_grey"] = 1,
["grey"] = 2,
["dark_grey"] = 3,
["black"] = 4,
}
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,
}
local hues_wallmounted = {
["red"] = 0,
["orange"] = 1,
["yellow"] = 2,
["green"] = 3,
["cyan"] = 4,
["blue"] = 5,
["violet"] = 6,
["magenta"] = 7
}
local shades = {
[""] = 1,
["s50"] = 2,
["light"] = 3,
["medium"] = 4,
["mediums50"] = 5,
["dark"] = 6,
["darks50"] = 7,
}
local shades_wallmounted = {
[""] = 1,
["medium"] = 2,
["dark"] = 3
}
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
if is_color_fdir == "wallmounted" then
if grayscale_wallmounted[color] then
return (grayscale_wallmounted[color] * 8), 0
end
elseif is_color_fdir then
if grayscale[color] then
return (grayscale[color] * 32), 0
end
else
if grayscale[color] then
return grayscale[color], 0
end
end
local shade = ""
if string.sub(color,1,6) == "light_" then
shade = "light"
color = string.sub(color,7,-1)
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
if is_color_fdir == "wallmounted" then
if color == "brown" then return 48,1
elseif color == "pink" then return 56,7
elseif color == "blue" and shade == "light" then return 40,5
elseif hues_wallmounted[color] and shades_wallmounted[shade] then
return (shades_wallmounted[shade] * 64 + hues_wallmounted[color] * 8), hues_wallmounted[color]
end
else
if color == "brown" then
color = "orange"
shade = "dark"
elseif color == "pink" then
color = "red"
shade = "light"
end
if hues[color] and shades[shade] then
if is_color_fdir then
return (shades[shade] * 32), hues[color]
else
return (hues[color] * 8 + shades[shade]), hues[color]
end
end
end
end
function unifieddyes.after_dig_node(pos, oldnode, oldmetadata, digger)
local prevdye
if oldmetadata and oldmetadata.fields then
prevdye = oldmetadata.fields.dye
end
local inv = digger:get_inventory()
if prevdye and not (inv:contains_item("main", prevdye) and creative_mode) and minetest.registered_items[prevdye] then
if inv:room_for_item("main", prevdye) then
inv:add_item("main", prevdye)
else
minetest.add_item(pos, prevdye)
end
end
end
function unifieddyes.on_use(itemstack, player, pointed_thing)
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
if not (pointed_thing and pointed_thing.type == "node") then return end -- if "using" the dye not on a node
local pos = minetest.get_pointed_thing_position(pointed_thing)
local node = minetest.get_node(pos)
local nodedef = minetest.registered_nodes[node.name]
local playername = player:get_player_name()
-- 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
end
-- if the target is unknown, has no groups defined, or isn't UD-colorable, just bail out
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
local newnode = nodedef.ud_replacement_node
local is_color_fdir
if nodedef.paramtype2 == "color" then
is_color_fdir = false
elseif nodedef.paramtype2 == "colorfacedir"
then is_color_fdir = true
elseif nodedef.paramtype2 == "colorwallmounted"
then is_color_fdir = "wallmounted"
end
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 stackname = itemstack:get_name()
local pos2 = unifieddyes.select_node(pointed_thing)
local paletteidx, hue = unifieddyes.getpaletteidx(stackname, is_color_fdir)
if paletteidx then
local meta = minetest.get_meta(pos)
local prevdye = meta:get_string("dye")
local inv = player:get_inventory()
if not (inv:contains_item("main", prevdye) and creative_mode) and minetest.registered_items[prevdye] then
if inv:room_for_item("main", prevdye) then
inv:add_item("main", prevdye)
else
minetest.add_item(pos, prevdye)
end
end
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()
end
node.param2 = paletteidx
local oldpaletteidx, oldhuenum = unifieddyes.getpaletteidx(prevdye, is_color_fdir)
local oldnode = minetest.get_node(pos)
local oldhue = nil
for _, i in ipairs(HUES) do
if string.find(oldnode.name, "_"..i) and not
( string.find(oldnode.name, "_redviolet") and i == "red" ) then
oldhue = i
break
end
end
if newnode then -- this path is used when the calling mod want to supply a replacement node
if is_color_fdir == "wallmounted" then
node.param2 = paletteidx + (minetest.get_node(pos).param2 % 8)
elseif is_color_fdir then -- we probably need to change the hue of the node too
if oldhue ~=0 then -- it's colored, not grey
if oldhue ~= nil then -- it's been painted before
if hue ~= 0 then -- the player's wielding a colored dye
newnode = string.gsub(newnode, "_"..oldhue, "_"..HUES[hue])
else -- it's a greyscale dye
newnode = string.gsub(newnode, "_"..oldhue, "_grey")
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
newnode = string.gsub(newnode, "_grey", "_"..HUES[hue])
end
end
else
if hue ~= 0 then -- greyscale dye on greyscale node = no hue change
newnode = string.gsub(newnode, "_grey", "_"..HUES[hue])
end
end
node.param2 = paletteidx + (minetest.get_node(pos).param2 % 32)
else
node.param2 = paletteidx
end
node.name = newnode
minetest.swap_node(pos, node)
if not creative_mode then
return itemstack
end
else -- this path is used when you're just painting an existing node, rather than replacing one.
newnode = oldnode -- note that here, newnode/oldnode are a full node, not just the name.
if is_color_fdir == "wallmounted" then
newnode.param2 = paletteidx + (minetest.get_node(pos).param2 % 8)
elseif is_color_fdir then
if oldhue then
if hue ~= 0 then
newnode.name = string.gsub(newnode.name, "_"..oldhue, "_"..HUES[hue])
else
newnode.name = string.gsub(newnode.name, "_"..oldhue, "_grey")
end
elseif string.find(minetest.get_node(pos).name, "_grey") and hue ~= 0 then
newnode.name = string.gsub(newnode.name, "_grey", "_"..HUES[hue])
end
newnode.param2 = paletteidx + (minetest.get_node(pos).param2 % 32)
else
newnode.param2 = paletteidx
end
minetest.swap_node(pos, newnode)
if not creative_mode then
return itemstack
end
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).."." )
end
end
end
-- 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
-- Items/recipes needed to generate the few base colors that are not
-- provided by the standard dyes mod.
-- Lime
minetest.register_craftitem(":dye:lime", {
description = S("Lime Dye"),
inventory_image = "unifieddyes_lime.png",
groups = { dye=1, excolor_lime=1, unicolor_lime=1, not_in_creative_inventory=1 }
description = S("Lime Dye"),
inventory_image = "unifieddyes_lime.png",
groups = { dye=1, excolor_lime=1, unicolor_lime=1, not_in_creative_inventory=1 },
on_use = unifieddyes.on_use
})
minetest.register_craft( {
@ -60,9 +519,10 @@ minetest.register_craft( {
-- Aqua
minetest.register_craftitem(":dye:aqua", {
description = S("Aqua Dye"),
inventory_image = "unifieddyes_aqua.png",
groups = { dye=1, excolor_aqua=1, unicolor_aqua=1, not_in_creative_inventory=1 }
description = S("Aqua Dye"),
inventory_image = "unifieddyes_aqua.png",
groups = { dye=1, excolor_aqua=1, unicolor_aqua=1, not_in_creative_inventory=1 },
on_use = unifieddyes.on_use
})
minetest.register_craft( {
@ -77,9 +537,10 @@ minetest.register_craft( {
-- Sky blue
minetest.register_craftitem(":dye:skyblue", {
description = S("Sky-blue Dye"),
inventory_image = "unifieddyes_skyblue.png",
groups = { dye=1, excolor_sky_blue=1, unicolor_sky_blue=1, not_in_creative_inventory=1 }
description = S("Sky-blue Dye"),
inventory_image = "unifieddyes_skyblue.png",
groups = { dye=1, excolor_sky_blue=1, unicolor_sky_blue=1, not_in_creative_inventory=1 },
on_use = unifieddyes.on_use
})
minetest.register_craft( {
@ -94,9 +555,10 @@ minetest.register_craft( {
-- Red-violet
minetest.register_craftitem(":dye:redviolet", {
description = S("Red-violet Dye"),
inventory_image = "unifieddyes_redviolet.png",
groups = { dye=1, excolor_red_violet=1, unicolor_red_violet=1, not_in_creative_inventory=1 }
description = S("Red-violet Dye"),
inventory_image = "unifieddyes_redviolet.png",
groups = { dye=1, excolor_red_violet=1, unicolor_red_violet=1, not_in_creative_inventory=1 },
on_use = unifieddyes.on_use
})
minetest.register_craft( {
@ -112,9 +574,10 @@ minetest.register_craft( {
-- Light grey
minetest.register_craftitem(":dye:light_grey", {
description = S("Light Grey Dye"),
inventory_image = "unifieddyes_lightgrey.png",
groups = { dye=1, excolor_lightgrey=1, unicolor_light_grey=1, not_in_creative_inventory=1 }
description = S("Light Grey Dye"),
inventory_image = "unifieddyes_lightgrey.png",
groups = { dye=1, excolor_lightgrey=1, unicolor_light_grey=1, not_in_creative_inventory=1 },
on_use = unifieddyes.on_use
})
minetest.register_craft( {
@ -179,36 +642,6 @@ minetest.register_craft( {
-- Brightness levels in the textures are 33% ("dark"), 66% ("medium"),
-- 100% ("full", but not so-named), and 150% ("light").
local HUES = {
"red",
"orange",
"yellow",
"lime",
"green",
"aqua",
"cyan",
"skyblue",
"blue",
"violet",
"magenta",
"redviolet"
}
local HUES2 = {
"Red",
"Orange",
"Yellow",
"Lime",
"Green",
"Aqua",
"Cyan",
"Sky-blue",
"Blue",
"Violet",
"Magenta",
"Red-violet"
}
for i = 1, 12 do
@ -321,48 +754,61 @@ for i = 1, 12 do
minetest.register_craftitem("unifieddyes:dark_" .. hue .. "_s50", {
description = S("Dark " .. hue2 .. " Dye (low saturation)"),
inventory_image = "unifieddyes_dark_" .. hue .. "_s50.png",
groups = { dye=1, ["unicolor_dark_"..hue.."_s50"]=1, not_in_creative_inventory=1 }
groups = { dye=1, ["unicolor_dark_"..hue.."_s50"]=1, not_in_creative_inventory=1 },
on_use = unifieddyes.on_use
})
if hue ~= "green" then
minetest.register_craftitem("unifieddyes:dark_" .. hue, {
description = S("Dark " .. hue2 .. " Dye"),
inventory_image = "unifieddyes_dark_" .. hue .. ".png",
groups = { dye=1, ["unicolor_dark_"..hue]=1, not_in_creative_inventory=1 }
groups = { dye=1, ["unicolor_dark_"..hue]=1, not_in_creative_inventory=1 },
on_use = unifieddyes.on_use
})
end
minetest.register_craftitem("unifieddyes:medium_" .. hue .. "_s50", {
description = S("Medium " .. hue2 .. " Dye (low saturation)"),
inventory_image = "unifieddyes_medium_" .. hue .. "_s50.png",
groups = { dye=1, ["unicolor_medium_"..hue.."_s50"]=1, not_in_creative_inventory=1 }
groups = { dye=1, ["unicolor_medium_"..hue.."_s50"]=1, not_in_creative_inventory=1 },
on_use = unifieddyes.on_use
})
minetest.register_craftitem("unifieddyes:medium_" .. hue, {
description = S("Medium " .. hue2 .. " Dye"),
inventory_image = "unifieddyes_medium_" .. hue .. ".png",
groups = { dye=1, ["unicolor_medium_"..hue]=1, not_in_creative_inventory=1 }
groups = { dye=1, ["unicolor_medium_"..hue]=1, not_in_creative_inventory=1 },
on_use = unifieddyes.on_use
})
minetest.register_craftitem("unifieddyes:" .. hue .. "_s50", {
description = S(hue2 .. " Dye (low saturation)"),
inventory_image = "unifieddyes_" .. hue .. "_s50.png",
groups = { dye=1, ["unicolor_"..hue.."_s50"]=1, not_in_creative_inventory=1 }
groups = { dye=1, ["unicolor_"..hue.."_s50"]=1, not_in_creative_inventory=1 },
on_use = unifieddyes.on_use
})
if hue ~= "red" then
minetest.register_craftitem("unifieddyes:light_" .. hue, {
description = S("Light " .. hue2 .. " Dye"),
inventory_image = "unifieddyes_light_" .. hue .. ".png",
groups = { dye=1, ["unicolor_light_"..hue]=1, not_in_creative_inventory=1 }
groups = { dye=1, ["unicolor_light_"..hue]=1, not_in_creative_inventory=1 },
on_use = unifieddyes.on_use
})
end
minetest.register_alias("unifieddyes:"..hue, "dye:"..hue)
minetest.register_alias("unifieddyes:pigment_"..hue, "dye:"..hue)
end
minetest.register_alias("unifieddyes:light_red", "dye:pink")
minetest.register_alias("unifieddyes:light_red", "dye:pink")
minetest.register_alias("unifieddyes:dark_green", "dye:dark_green")
minetest.register_alias("unifieddyes:black", "dye:black")
minetest.register_alias("unifieddyes:darkgrey", "dye:dark_grey")
minetest.register_alias("unifieddyes:dark_grey", "dye:dark_grey")
minetest.register_alias("unifieddyes:grey", "dye:grey")
minetest.register_alias("unifieddyes:lightgrey", "dye:light_grey")
minetest.register_alias("unifieddyes:light_grey", "dye:light_grey")
minetest.register_alias("unifieddyes:white", "dye:white")
minetest.register_alias("unifieddyes:white_paint", "dye:white")
minetest.register_alias("unifieddyes:titanium_dioxide", "dye:white")

View File

@ -1,79 +0,0 @@
#!/bin/bash
# This program lists out the RGB triads for the colors used in each of the 89
# dyes found in the Unified Dyes mod.
# 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.
pushd . >/dev/null
cd textures
echo -e "\n\nFull-saturation colors:"
echo -e "-----------------------\n"
for i in `ls *dark*.png|grep -v _s50|grep -v paint|grep -v black` ; do
rgb=`convert $i -crop 1x1+8+11 -depth 8 txt: |grep "0,0: (" |cut -f 2- -d "(" |cut -f 1-3 -d ","`
color=`basename $i .png | sed 's/_/ /g; s/unifieddyes //; s/s50/50% saturation/'`
printf "%-32s %-12s %s\n" "$color" "$rgb" "$i"
done |sort
for i in `ls *medium*.png|grep -v _s50|grep -v paint|grep -v black` ; do
rgb=`convert $i -crop 1x1+8+11 -depth 8 txt: |grep "0,0: (" |cut -f 2- -d "(" |cut -f 1-3 -d ","`
color=`basename $i .png | sed 's/_/ /g; s/unifieddyes //; s/s50/50% saturation/'`
printf "%-32s %-12s %s\n" "$color" "$rgb" "$i"
done |sort
for i in `ls *.png|grep -v medium |grep -v dark|grep -v _s50|grep -v paint|grep -v black|grep -v titanium` ; do
rgb=`convert $i -crop 1x1+8+11 -depth 8 txt: |grep "0,0: (" |cut -f 2- -d "(" |cut -f 1-3 -d ","`
color=`basename $i .png | sed 's/_/ /g; s/unifieddyes //; s/s50/50% saturation/'`
printf "%-32s %-12s %s\n" "$color" "$rgb" "$i"
done |sort
echo -e "\nLow-saturation colors:"
echo -e "----------------------\n"
for i in `ls *dark*_s50.png|grep -v paint|grep -v black` ; do
rgb=`convert $i -crop 1x1+8+11 -depth 8 txt: |grep "0,0: (" |cut -f 2- -d "(" |cut -f 1-3 -d ","`
color=`basename $i .png | sed 's/_/ /g; s/unifieddyes //; s/s50/50% saturation/'`
printf "%-32s %-12s %s\n" "$color" "$rgb" "$i"
done |sort
for i in `ls *medium*_s50.png|grep -v paint|grep -v black` ; do
rgb=`convert $i -crop 1x1+8+11 -depth 8 txt: |grep "0,0: (" |cut -f 2- -d "(" |cut -f 1-3 -d ","`
color=`basename $i .png | sed 's/_/ /g; s/unifieddyes //; s/s50/50% saturation/'`
printf "%-32s %-12s %s\n" "$color" "$rgb" "$i"
done |sort
for i in `ls *_s50.png|grep -v dark|grep -v medium|grep -v paint|grep -v black` ; do
rgb=`convert $i -crop 1x1+8+11 -depth 8 txt: |grep "0,0: (" |cut -f 2- -d "(" |cut -f 1-3 -d ","`
color=`basename $i .png | sed 's/_/ /g; s/unifieddyes //; s/s50/50% saturation/'`
printf "%-32s %-12s %s\n" "$color" "$rgb" "$i"
done |sort
echo -e "\nGreyscale:"
echo -e "----------\n"
printf "%-32s %-12s %s\n" "black" " 0, 0, 0" "unifieddyes_black.png"
printf "%-32s %-12s %s\n" "dark grey" " 64, 64, 64" "unifieddyes_darkgrey_paint.png"
printf "%-32s %-12s %s\n" "medium grey" "128,128,128" "unifieddyes_grey_paint.png"
printf "%-32s %-12s %s\n" "light grey" "192,192,192" "unifieddyes_lightgrey_paint.png"
printf "%-32s %-12s %s\n" "white" "255,255,255" "unifieddyes_white_paint.png"
popd >/dev/null

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 B