summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README111
-rwxr-xr-xgentextures.sh116
-rw-r--r--modtemplate.lua247
-rw-r--r--modtemplate.lua~235
4 files changed, 61 insertions, 648 deletions
diff --git a/README b/README
index 6472ede..c4b0073 100644
--- a/README
+++ b/README
@@ -120,56 +120,8 @@ the item names follow the same format as the filenames, save for having a colon
(:) instead of the first underscore (_).
-Semi-automatic generation of new textures
-=========================================
-
-Obviously, in order for this mod to be useful, you'll need textures to use with
-your crafting recipes. If you plan to support the entire range of colors
-supplied by this mod, there is a BASH script included in the distribution
-directory, named gentextures.sh, which will, with an appropriately- colored and
-appropriately-named source texture, generate a complete set of colored and
-greyscale textures based on that first one.
-
-This script requires bc (the calculator program) to handle some basic math
-regarding the hue adjustments, and Imagemagick's "convert" program handles all
-of the actual conversions.
-
-To make this script for your mod, open it in your favorite editor and change
-the TEXTURE variable near the top of the file to whatever your particular mod
-will use as the basis of its texture filenames. For example, the default is
-cotton, so the files created by the script will be named cotton_xxxxxx.png for
-each of the supported colors.
-
-Then, using your favorite image editor, create a single version of your desired
-texture. Draw it in the brightest, deepest shade of RED you can muster without
-losing any detail, and save it out. Ideally, you will want the average color
-of the texture, when taking into account all bright and dark areas, to be as
-close as possible to the hex value #FF0000 (0 degrees, 100% saturation, pure
-red) without losing any appreciable #detail
-
-Save this source texture out with a filename of red_base_whatever.png, where
-"whatever" is the same name you used in the TEXTURE variable above. The
-default cotton setting, thus, would need a filename of red_base_cotton.png.
-
-Copy the gentextures.sh script to the same directory where you placed the base
-texture, chmod 755 gentextures.sh if necessary, and run it using the usual
-dot-slash notation: ./gentextures.sh
-
-The program will exit immediately if it can't find the base texture it needs
-(i.e. if you didn't supply it, or if you named it wrong, or if it isn't it in
-the same directory as the script).
-
-Otherwise, the program will create a new folder named generated-textures/ and
-then iterate through all of the hues and shades that are supported by
-unifieddyes (though this is done manually, not by reading anything from the
-mod). All of the output files will be placed in that folder.
-
-Use your favorite image browser or file manager to review the results, and if
-they're right, copy them over to the textures/ folder in your mod.
-
-
-Example Code
-============
+Semi-automatic generation of nodes, crafting recipes, and textures
+==================================================================
Along with this mod, you should also download my modding template, which is
quite easy to transform into whatever mod you want to create that needs
@@ -191,3 +143,62 @@ fetch it separately from here:
Download Template: https://github.com/VanessaE/modtemplate/zipball/master
...or browse the code: https://github.com/VanessaE/modtemplate
+
+Semi-automatic generation of new textures
+=========================================
+
+Obviously, in order for this mod or the above template to be useful, you'll
+need textures. If you plan to support the entire range of colors offered by
+Unified Dyes, there is a BASH script included with that template named
+gentextures.sh, which will, with an appropriately- colored and
+appropriately-named source texture, and possibly an overlay texture, generate a
+complete set of colored and greyscale textures.
+
+The script requires bc (the calculator program) to handle some basic math
+regarding the hue adjustments, and Imagemagick's "convert" program handles all
+of the actual conversions.
+
+First thing's first though - you need source textures. Using your favorite image
+editor, create a single version of your desired texture. Draw it in the
+brightest, deepest shade of RED you can muster without losing any detail, and
+save it out. Ideally, you will want the average color of the texture, when
+taking into account all bright and dark areas, to be as close as possible to
+the hex value #FF0000 (0 degrees, 100% saturation, pure red) without losing any
+appreciable #detail.
+
+Save this source texture out with a filename of red_base_whatever.png, where
+"whatever" is the same name you used in the TEXTURE variable above. The
+default cotton setting, thus, would need a filename of red_base_cotton.png.
+
+If you want to add an image on top of the colored blocks, such as a frame,
+which you want to be the same color throughout all of the textures, create it
+now. It should consist only of those parts of the textures that you want to
+leave unchanged, with transparency everywhere else. Save it out using any
+filename you want.
+
+Now, run the script (make it executable first, if necessary).
+
+If you didn't need the overlay, you just need to supply one command line
+argument: the base name of your mod. The script will use that parameter as the
+basis of its texture filenames. For example:
+
+./gentextures.sh mymod
+
+If you want to use an overlay also, run the script with the base name as the
+first parameter, and the complete filename of your overlay as the second. For
+example:
+
+./gentextures.sh mymod myoverlay.png
+
+The program will exit immediately if the image(s) you've supplied are invalid,
+missing, etc.
+
+Otherwise, the program will iterate through all of the hues and shades that are
+supported by unifieddyes (though this is done manually, not by reading anything
+from the mod), compositing your overlay image in after the recolor step, if
+you're using that option.
+
+All of the output files will be placed in a new folder, generated-textures/
+
+Use your favorite image browser or file manager to review the results, and if
+they're right, copy them over to the textures/ folder in your mod.
diff --git a/gentextures.sh b/gentextures.sh
deleted file mode 100755
index 57d70a7..0000000
--- a/gentextures.sh
+++ /dev/null
@@ -1,116 +0,0 @@
-#!/bin/bash
-
-TEXTURE=$1
-COMPOSITE=$2
-
-base_texture="red_base_"$TEXTURE".png"
-
-if [ -z $TEXTURE ] || [ $TEXTURE == "--help" ] || [ $TEXTURE == "-h" ] ; then {
-
- echo -e "\nUsage:"
- echo -e "\ngentextures.sh basename [overlay filename]"
- echo -e "\nThis script requires one or two parameters which supply the"
- echo -e "base filename of the textures, and an optional overlay. The"
- echo -e "<basename> is the first part of the filename that your textures"
- echo -e "will use when your mod is done. For example, if you supply the"
- echo -e "word 'cotton', this script will produce filenames like cotton_red.png"
- echo -e "or 'cotton_dark_blue_s50.png'. The texture that this script will"
- echo -e "read and recolor is derived from this parameter, and will be of"
- echo -e "the form 'red_base_xxxxx.png', where 'xxxx' is the basename."
- echo -e "\nYou can also supply an optional overlay image filename."
- echo -e "This image will be composited onto the output files after they"
- echo -e "have been colorized, but without being modified. This is useful"
- echo -e "when you have some part of your base image that will either get"
- echo -e "changed unpredictably or undesirably. Simply draw two images -"
- echo -e "one containing the whole image to be colored, and one containing"
- echo -e "the parts that should not be changed, with transparency where the"
- echo -e "base image should show through.\n"
- exit 1
-} fi
-
-
-if [[ ! -z $TEXTURE && ! -e $base_texture ]]; then {
- echo -e "\nThe basename 'red_base_"$TEXTURE".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_texture -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 'red_base_"$TEXTURE".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
-
-composite_file=""
-
-if [ ! -z $COMPOSITE ] ; then {
- convert $base_texture -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
-
- composite_file=$COMPOSITE" -composite"
-} 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_texture
-if [ ! -z $COMPOSITE ] ; then {
- echo ","
- echo -n "using "$COMPOSITE" as an overlay"
-} fi
-echo -e "...\n"
-
-rm -rf generated-textures
-mkdir generated-textures
-
-hue=0
-for name in $base_colors ; do
- hue2=`echo "scale=10; ("$hue"*200/360)+100" |bc`
- echo $name "("$hue" degrees)"
- echo " dark"
- convert $base_texture -modulate 33,100,$hue2 $composite_file "generated-textures/"$TEXTURE"_dark_"$name".png"
- echo " medium"
- convert $base_texture -modulate 66,100,$hue2 $composite_file "generated-textures/"$TEXTURE"_medium_"$name".png"
- echo " bright"
- convert $base_texture -modulate 100,100,$hue2 $composite_file "generated-textures/"$TEXTURE"_"$name".png"
- echo " dark, 50% saturation"
- convert $base_texture -modulate 33,50,$hue2 $composite_file "generated-textures/"$TEXTURE"_dark_"$name"_s50.png"
- echo " medium, 50% saturation"
- convert $base_texture -modulate 66,50,$hue2 $composite_file "generated-textures/"$TEXTURE"_medium_"$name"_s50.png"
- echo " bright, 50% saturation"
- convert $base_texture -modulate 100,50,$hue2 $composite_file "generated-textures/"$TEXTURE"_"$name"_s50.png"
- hue=$((hue+30))
-done
-
-echo "greyscales"
-echo " black"
-convert $base_texture -modulate 15,0,0 $composite_file "generated-textures/"$TEXTURE"_black.png"
-echo " dark grey"
-convert $base_texture -modulate 50,0,0 $composite_file "generated-textures/"$TEXTURE"_darkgrey.png"
-echo " medium grey"
-convert $base_texture -modulate 100,0,0 $composite_file "generated-textures/"$TEXTURE"_mediumgrey.png"
-echo " light grey"
-convert $base_texture -modulate 150,0,0 $composite_file "generated-textures/"$TEXTURE"_lightgrey.png"
-echo " white"
-convert $base_texture -modulate 190,0,0 $composite_file "generated-textures/"$TEXTURE"_white.png"
diff --git a/modtemplate.lua b/modtemplate.lua
deleted file mode 100644
index f8104f0..0000000
--- a/modtemplate.lua
+++ /dev/null
@@ -1,247 +0,0 @@
--- Generic colored-objects template by Vanessa Ezekowitz ~~ 2012-07-13
-
--- License: WTFPL
-
--- Before using this code, consult the README, particularly the "Semi-
--- automatic generation of textures" section at the end, which descibes the
--- use of the gentextures.sh BASH script included in this package. You"ll
--- need to either follow those instructions or create your textures the usual,
--- manual way. Without textures, this code won"t be very useful. :-)
-
--- When configured properly, this code creates node names that follow the
--- naming convention established in Unified Dyes, such as "mymod:red" or
--- "mymod:dark_yellow_s50".
-
-
--- ===========================================================================
--- Edit the next several variables to define what mod this template will
--- generate and how it should behave in general.
--- ===========================================================================
-
--- First, the standard machine-readable name of your mod
-
-colored_block_modname = "template"
-
--- Human-readable description of the category of nodes you want to generate
-
-colored_block_description = "My Colored Block"
-
--- The full node name of the neutral version of your main block as it
--- exists right after crafting or mining it, before any dyes have been
--- applied. Typically, this should refer to the white version of your
--- mod's main block, but it can be anything as long as it makes sense.
-
-neutral_block = colored_block_modname..":white"
-
--- This variable defines just how many of a given block a crafting operation
--- should give. In most cases, the default (1) is correct.
-
-colored_block_yield = "1"
-
--- If this object should let sunlight pass through it, set this to "true".
--- Otherwise, set it to "false" (the default).
-
-colored_block_sunlight = "false"
-
--- If the node should be something you can stand on, set this to "true"
--- (the default). Otherwise, set it to false.
-
-colored_block_walkable = "true"
-
--- What groups should the generated nodes belong to? Note that this must
--- be in the form of a table as in the default.
-
-colored_block_groups = { snappy=3, flammable=2 }
-
--- What sound should be played when the node is digged?
-
-colored_block_sound = "default.node_sound_leaves_defaults()"
-
-
--- ======================================================
--- You shouldn"t need to edit anything below this point.
--- ======================================================
-
-
--- ------------------------------------------------------------------
--- Generate all of the base color node definitions and all variations
--- except for the greyscale stuff.
-
--- Hues are on a 30 degree spacing starting at red = 0 degrees.
--- "s50" in a file/item name means "saturation: 50%".
--- Texture brightness levels for the colors are 100%, 66% ("medium"),
--- and 33% ("dark").
-
-shades = {
- "dark_",
- "medium_",
- "" -- represents "no special shade name", e.g. bright.
-}
-
-shades2 = {
- "Dark ",
- "Medium ",
- "" -- represents "no special shade name", e.g. bright.
-}
-
-hues = {
- "red",
- "orange",
- "yellow",
- "lime",
- "green",
- "aqua",
- "cyan",
- "skyblue",
- "blue",
- "violet",
- "magenta",
- "redviolet"
-}
-
-hues2 = {
- "Red ",
- "Orange ",
- "Yellow ",
- "Lime ",
- "Green ",
- "Aqua ",
- "Cyan ",
- "Sky Blue ",
- "Blue ",
- "Violet ",
- "Magenta ",
- "Red-violet "
-}
-
-greys = {
- "black",
- "darkgrey",
- "mediumgrey",
- "lightgrey",
- "white"
-}
-
-greys2 = {
- "Black ",
- "Dark Grey ",
- "Medium Grey ",
- "Light Grey ",
- "White "
-}
-
-greys3 = {
- "black",
- "darkgrey_paint",
- "mediumgrey_paint",
- "lightgrey_paint",
- "white_paint"
-}
-
-for shade = 1, 3 do
-
- shadename = shades[shade]
- shadename2 = shades2[shade]
-
- for hue = 1, 12 do
-
- huename = hues[hue]
- huename2 = hues2[hue]
-
- colorname = colored_block_modname..":"..shadename..huename
- pngname = colored_block_modname.."_"..shadename..huename..".png"
- nodedesc = shadename2..huename2..colored_block_description
- s50colorname = colored_block_modname..":"..shadename..huename.."_s50"
- s50pngname = colored_block_modname.."_"..shadename..huename.."_s50.png"
- s50nodedesc = shadename2..huename2..colored_block_description.." (50% Saturation)"
-
- minetest.register_node(colorname, {
- description = nodedesc,
- tiles = { pngname },
- inventory_image = pngname,
- wield_image = pngname,
- sunlight_propagates = colored_block_sunlight,
- paramtype = "light",
- walkable = colored_block_walkable,
- groups = colored_block_groups,
- sounds = colored_block_sound
- })
-
- minetest.register_node(s50colorname, {
- description = s50nodedesc,
- tiles = { s50pngname },
- inventory_image = s50pngname,
- wield_image = s50pngname,
- sunlight_propagates = colored_block_sunlight,
- paramtype = "light",
- walkable = colored_block_walkable,
- groups = colored_block_groups,
- sounds = colored_block_sound
- })
-
- minetest.register_craft( {
- type = "shapeless",
- output = colorname.." "..colored_block_yield,
- recipe = {
- neutral_block,
- "unifieddyes:"..shadename.."_"..huename
- }
- })
-
- minetest.register_craft( {
- type = "shapeless",
- output = colorname.." "..colored_block_yield,
- recipe = {
- neutral_block,
- "unifieddyes:"..shadename.."_"..huename.."_s50"
- }
- })
-
- end
-end
-
-
--- ============================================================
--- The 5 levels of greyscale.
---
--- Oficially these are 0, 25, 50, 75, and 100% relative to white,
--- but in practice, they're actually 7.5%, 25%, 50%, 75%, and 95%.
--- (otherwise black and white would wash out).
-
-for grey = 1,5 do
-
- greyname = greys[grey]
- greyname2 = greys2[grey]
- greyname3 = greys3[grey]
-
- greyshadename = colored_block_modname..":"..greyname
- pngname = colored_block_modname.."_"..greyname..".png"
- nodedesc = greyname2..colored_block_description
-
- minetest.register_node(greyshadename, {
- description = nodedesc,
- tiles = { pngname },
- inventory_image = pngname,
- wield_image = pngname,
- sunlight_propagates = colored_block_sunlight,
- paramtype = "light",
- walkable = colored_block_walkable,
- groups = colored_block_groups,
- sounds = colored_block_sound
- })
-
- minetest.register_craft( {
- type = "shapeless",
- output = greyshadename.." "..colored_block_yield,
- recipe = {
- neutral_block,
- "unifieddyes:"..greyname3
- }
- })
-
-end
-
-
-print("[" .. colored_block_modname .. "] Loaded!")
-
-
diff --git a/modtemplate.lua~ b/modtemplate.lua~
deleted file mode 100644
index 20ec900..0000000
--- a/modtemplate.lua~
+++ /dev/null
@@ -1,235 +0,0 @@
--- Generic colored-objects template by Vanessa Ezekowitz ~~ 2012-07-13
-
--- License: WTFPL
-
--- Before using this code, consult the README, particularly the "Semi-
--- automatic generation of textures" section at the end, which descibes the
--- use of the gentextures.sh BASH script included in this package. You"ll
--- need to either follow those instructions or create your textures the usual,
--- manual way. Without textures, this code won"t be very useful. :-)
-
--- When configured properly, this code creates node names that follow the
--- naming convention established in Unified Dyes, such as "mymod:red" or
--- "mymod:dark_yellow_s50".
-
-
--- ===========================================================================
--- Edit the next several variables to define what mod this template will
--- generate and how it should behave in general.
--- ===========================================================================
-
--- First, the standard machine-readable name of your mod
-
-colored_block_modname = "mymod"
-
--- Human-readable description of the category of nodes you want to generate
-
-colored_block_description = "My Colored Block"
-
--- The full node name of the neutral version of your main block as it
--- exists right after crafting or mining it, before any dyes have been
--- applied. Typically, this should refer to the white version of your
--- mod's main block, but it can be anything as long as it makes sense.
-
-neutral_block = colored_block_modname .. ":white"
-
--- This variable defines just how many of a given block a crafting operation
--- should give. In most cases, the default (1) is correct.
-
-colored_block_yield = "1"
-
--- If this object should let sunlight pass through it, set this to "true".
--- Otherwise, set it to "false" (the default).
-
-colored_block_sunlight = "false"
-
--- If the node should be something you can stand on, set this to "true"
--- (the default). Otherwise, set it to false.
-
-colored_block_walkable = "true"
-
--- What groups should the generated nodes belong to?
-
-colored_block_groups = "{ snappy = 3, flammable = 2 }"
-
--- What sound should be played when the node is digged?
-
-colored_block_groups = "default.node_sound_leaves_defaults()"
-
-
--- ======================================================
--- You shouldn"t need to edit anything below this point.
--- ======================================================
-
-
--- ------------------------------------------------------------------
--- Generate all of the base color node definitions and all variations
--- except for the greyscale stuff.
-
--- Hues are on a 30 degree spacing starting at red = 0 degrees.
--- "s50" in a file/item name means "saturation: 50%".
--- Texture brightness levels for the colors are 100%, 66% ("medium"),
--- and 33% ("dark").
-
-shades = {
- "dark",
- "medium",
- "" -- represents "no special shade name", e.g. bright.
-}
-
-shades2 = {
- "Dark ",
- "Medium ",
- "" -- represents "no special shade name", e.g. bright.
-}
-
-hues = {
- "red",
- "orange",
- "yellow",
- "lime",
- "green",
- "aqua",
- "cyan",
- "skyblue",
- "blue",
- "violet",
- "magenta",
- "redviolet"
-}
-
-hues2 = {
- "Red ",
- "Orange ",
- "Yellow ",
- "Lime ",
- "Green ",
- "Aqua ",
- "Cyan ",
- "Sky Blue ",
- "Blue ",
- "Violet ",
- "Magenta ",
- "Red-violet "
-}
-
-greys = {
- "black",
- "darkgrey",
- "mediumgrey",
- "lightgrey",
- "white"
-}
-
-greys2 = {
- "Black ",
- "Dark Grey ",
- "Medium Grey ",
- "Light Grey ",
- "White "
-}
-
-greys3 = {
- "black",
- "darkgrey_paint",
- "mediumgrey_paint",
- "lightgrey_paint",
- "white_paint"
-}
-
-for shade = 1, 3 do
-
- shadename = shades[shade]
- shadename2 = shades2[shade]
-
- for hue = 1, 12 do
-
- huename = hues[hue]
- huename2 = hues2[hue]
-
- minetest.register_node(colored_block_modname .. ":" .. shadename .. "_" .. huename, {
- description = shadename2 .. huename2 .. colored_block_description,
- tiles = { colored_block_modname .. "_" .. shadename .. "_" .. huename .. ".png" },
- inventory_image = colored_block_modname .. "_" .. shadename .. "_" .. huename .. ".png",
- wield_image = colored_block_modname .. "_" .. shadename .. "_" .. huename .. ".png",
- sunlight_propagates = colored_block_sunlight,
- paramtype = "light",
- walkable = colored_block_walkable,
- groups = colored_block_groups,
- sounds = colored_block_groups
- })
-
- minetest.register_node(colored_block_modname .. ":" .. shadename .. "_" .. huename .. "_s50", {
- description = shadename2 .. huename2 .. colored_block_description .. " (50% Saturation)",
- tiles = { colored_block_modname .. "_" .. shadename .. "_" .. huename .. "_s50.png" },
- inventory_image = colored_block_modname .. "_" .. shadename .. "_" .. huename .. "_s50.png",
- wield_image = colored_block_modname .. "_" .. shadename .. "_" .. huename .. "_s50.png",
- sunlight_propagates = colored_block_sunlight,
- paramtype = "light",
- walkable = colored_block_walkable,
- groups = colored_block_groups,
- sounds = colored_block_groups
- })
-
- minetest.register_craft( {
- type = "shapeless",
- output = colored_block_modname .. ":" .. shadename .. "_" .. huename .. " " .. colored_block_yield,
- recipe = {
- neutral_block,
- "unifieddyes:" .. shadename .. "_" .. huename
- }
- })
-
- minetest.register_craft( {
- type = "shapeless",
- output = colored_block_modname .. ":" .. shadename .. "_" .. huename "_s50 " .. colored_block_yield,
- recipe = {
- neutral_block,
- "unifieddyes:" .. shadename .. "_" .. huename .. "_s50"
- }
- })
-
- end
-end
-
-
--- ============================================================
--- The 5 levels of greyscale.
---
--- Oficially these are 0, 25, 50, 75, and 100% relative to white,
--- but in practice, they're actually 7.5%, 25%, 50%, 75%, and 95%.
--- (otherwise black and white would wash out).
-
-for grey = 1,5 do
-
- greyname = greys[grey]
- greyname2 = greys2[grey]
- greyname3 = greys3[grey]
-
- minetest.register_node(colored_block_modname .. ":" .. greyname, {
- description = greyname2 .. colored_block_description,
- tiles = { colored_block_modname .. "_" .. greyname .. ".png" },
- inventory_image = colored_block_modname .. "_" .. greyname .. ".png",
- wield_image = colored_block_modname .. "_" .. greyname .. ".png",
- sunlight_propagates = colored_block_sunlight,
- paramtype = "light",
- walkable = colored_block_walkable,
- groups = colored_block_groups,
- sounds = colored_block_groups
- })
-
- minetest.register_craft( {
- type = "shapeless",
- output = colored_block_modname .. ":" .. greyname .. " " .. colored_block_yield,
- recipe = {
- neutral_block,
- "unifieddyes:" .. greyname3
- }
- })
-
-end
-
-
-print("[" .. colored_block_modname .. "] Loaded!")
-
-