2018-09-12 22:25:42 +02:00
|
|
|
-- Colored Wood mod by Vanessa "VanessaE" Dannenberg
|
2012-07-18 05:23:06 +02:00
|
|
|
-- based on my unifieddyes template.
|
|
|
|
--
|
2018-11-09 01:05:57 +01:00
|
|
|
-- This mod provides many colors of wood and fences, with crafting recipes
|
|
|
|
-- as appropriate. Works with the airbrush, too.
|
2012-07-18 05:23:06 +02:00
|
|
|
--
|
|
|
|
-- All materials are flammable and can be used as fuel.
|
2018-09-12 22:25:13 +02:00
|
|
|
|
2014-10-29 21:33:57 +01:00
|
|
|
|
|
|
|
coloredwood = {}
|
|
|
|
|
2017-01-26 20:24:57 +01:00
|
|
|
coloredwood.enable_stairsplus = true
|
2017-05-13 11:54:04 +02:00
|
|
|
if minetest.settings:get_bool("coloredwood_enable_stairsplus") == false or not minetest.get_modpath("moreblocks") then
|
2017-01-26 20:24:57 +01:00
|
|
|
coloredwood.enable_stairsplus = false
|
|
|
|
end
|
|
|
|
|
|
|
|
-- helper functions
|
|
|
|
|
2017-03-14 04:43:06 +01:00
|
|
|
local function is_stairsplus(name, colorized)
|
|
|
|
|
|
|
|
-- the format of a coloredwood stairsplus node is:
|
2018-08-22 12:41:06 +02:00
|
|
|
-- "coloredwood:$CLASS_wood_$COLOR_$SHAPE"
|
|
|
|
-- where $CLASS is "slab", "stair", etc., $SHAPE is "three quarter", "alt", etc.,
|
|
|
|
-- and $COLOR is one of the 13 color sets (counting "grey")
|
2017-03-14 04:43:06 +01:00
|
|
|
|
|
|
|
local a = string.find(name, ":")
|
|
|
|
local b = string.find(name, "_")
|
|
|
|
|
|
|
|
local class = string.sub(name, a+1, b-1) -- from colon to underscore is the class
|
|
|
|
local shape = ""
|
|
|
|
local rest
|
2018-08-22 12:41:06 +02:00
|
|
|
local colorshape
|
2017-03-14 04:43:06 +01:00
|
|
|
|
|
|
|
if class == "stair"
|
|
|
|
or class == "slab"
|
|
|
|
or class == "panel"
|
|
|
|
or class == "micro"
|
|
|
|
or class == "slope" then
|
|
|
|
|
|
|
|
if colorized then
|
|
|
|
colorshape = string.sub(name, b+6)
|
|
|
|
local c = string.find(colorshape, "_") or 0 -- first word after "_wood_" is color
|
|
|
|
shape = string.sub(colorshape, c) -- everything after the color is the shape
|
|
|
|
if colorshape == shape then shape = "" end -- if there was no shape
|
|
|
|
else
|
|
|
|
shape = string.sub(name, b+5) -- everything after "_wood_" is the shape
|
2017-02-22 17:15:10 +01:00
|
|
|
end
|
2017-01-26 20:24:57 +01:00
|
|
|
end
|
2017-03-14 04:43:06 +01:00
|
|
|
return class, shape
|
2017-01-26 20:24:57 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
-- the actual nodes!
|
|
|
|
|
2019-05-31 20:52:06 +02:00
|
|
|
local groups = table.copy(minetest.registered_items["default:wood"].groups)
|
|
|
|
groups.ud_param2_colorable = 1
|
|
|
|
groups.not_in_creative_inventory=1
|
|
|
|
|
2017-02-25 07:06:40 +01:00
|
|
|
minetest.register_node("coloredwood:wood_block", {
|
|
|
|
description = "Colored wooden planks",
|
|
|
|
tiles = { "coloredwood_base.png" },
|
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "color",
|
|
|
|
palette = "unifieddyes_palette_extended.png",
|
|
|
|
walkable = true,
|
|
|
|
sunlight_propagates = false,
|
2019-05-31 20:52:06 +02:00
|
|
|
groups = groups,
|
2017-02-25 07:06:40 +01:00
|
|
|
sounds = default.node_sound_wood_defaults(),
|
|
|
|
})
|
|
|
|
|
2018-09-12 22:23:39 +02:00
|
|
|
for _, color in ipairs(unifieddyes.HUES_WITH_GREY) do
|
2017-01-26 20:24:57 +01:00
|
|
|
|
|
|
|
-- moreblocks/stairsplus support
|
|
|
|
|
|
|
|
if coloredwood.enable_stairsplus then
|
|
|
|
|
|
|
|
-- stairsplus:register_all(modname, subname, recipeitem, {fields})
|
|
|
|
|
|
|
|
stairsplus:register_all(
|
|
|
|
"coloredwood",
|
|
|
|
"wood_"..color,
|
|
|
|
"coloredwood:wood_"..color,
|
|
|
|
{
|
|
|
|
description = "Colored wood",
|
|
|
|
tiles = { "coloredwood_base.png" },
|
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "colorfacedir",
|
|
|
|
palette = "unifieddyes_palette_"..color.."s.png",
|
2017-03-18 08:26:57 +01:00
|
|
|
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
|
|
|
minetest.rotate_node(itemstack, placer, pointed_thing)
|
|
|
|
end,
|
2017-02-05 01:41:01 +01:00
|
|
|
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=2, not_in_creative_inventory=1, ud_param2_colorable = 1},
|
2017-01-26 20:24:57 +01:00
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-08-22 12:41:06 +02:00
|
|
|
local coloredwood_cuts = {}
|
2012-07-18 05:23:06 +02:00
|
|
|
|
2018-08-22 12:41:06 +02:00
|
|
|
-- force settings for stairsplus default wood stair/slab/etc nodes
|
|
|
|
-- and fix other stuff for colored versions of stairsplus nodes
|
|
|
|
|
|
|
|
if coloredwood.enable_stairsplus then
|
2017-01-26 20:24:57 +01:00
|
|
|
|
|
|
|
for _, i in pairs(minetest.registered_nodes) do
|
2018-08-22 12:41:06 +02:00
|
|
|
|
2018-09-12 23:15:58 +02:00
|
|
|
local chk = string.sub(i.name, 1, 20)
|
2018-09-12 23:15:58 +02:00
|
|
|
|
|
|
|
if chk == "moreblocks:stair_woo"
|
|
|
|
or chk == "moreblocks:slab_wood"
|
|
|
|
or chk == "moreblocks:panel_woo"
|
|
|
|
or chk == "moreblocks:micro_woo"
|
|
|
|
or chk == "moreblocks:slope_woo"
|
2018-08-22 12:41:06 +02:00
|
|
|
and not string.find(i.name, "wood_tile") then
|
2017-01-26 20:24:57 +01:00
|
|
|
|
2018-09-12 23:15:58 +02:00
|
|
|
local class = string.sub(i.name, 12, 15)
|
|
|
|
local shape = string.sub(i.name, 22)
|
|
|
|
|
2018-08-22 12:41:06 +02:00
|
|
|
table.insert(coloredwood_cuts, i.name)
|
2017-01-26 20:24:57 +01:00
|
|
|
|
2018-09-12 23:15:58 +02:00
|
|
|
if chk ~= "moreblocks:slab_wood" then
|
|
|
|
class = string.sub(i.name, 12, 16)
|
|
|
|
shape = string.sub(i.name, 23)
|
|
|
|
end
|
|
|
|
|
2017-01-26 20:24:57 +01:00
|
|
|
minetest.override_item(i.name, {
|
2018-08-22 12:41:06 +02:00
|
|
|
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1, not_in_creative_inventory=1, ud_param2_colorable = 1},
|
2018-09-12 23:15:58 +02:00
|
|
|
paramtype2 = "colorfacedir",
|
2018-09-14 04:33:11 +02:00
|
|
|
palette = "unifieddyes_palette_greys.png",
|
2018-09-12 23:15:58 +02:00
|
|
|
airbrush_replacement_node = "coloredwood:"..class.."_wood_grey_"..shape
|
2017-01-26 20:24:57 +01:00
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-08-22 12:41:06 +02:00
|
|
|
-- "coloredwood:slope_wood_outer_half_raised"
|
|
|
|
|
|
|
|
for _, mname in ipairs(coloredwood_cuts) do
|
|
|
|
|
|
|
|
local class, shape = is_stairsplus(mname, nil)
|
|
|
|
|
|
|
|
unifieddyes.register_color_craft({
|
|
|
|
output_prefix = "coloredwood:"..class.."_wood_",
|
|
|
|
output_suffix = shape,
|
2018-09-08 17:51:55 +02:00
|
|
|
palette = "split",
|
2018-08-22 12:41:06 +02:00
|
|
|
type = "shapeless",
|
|
|
|
neutral_node = mname,
|
|
|
|
recipe = {
|
|
|
|
"NEUTRAL_NODE",
|
|
|
|
"MAIN_DYE"
|
|
|
|
}
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2019-05-31 20:52:06 +02:00
|
|
|
groups = table.copy(minetest.registered_items["default:wood"].groups)
|
|
|
|
groups.ud_param2_colorable = 1
|
|
|
|
|
2017-01-26 20:24:57 +01:00
|
|
|
minetest.override_item("default:wood", {
|
2017-02-25 07:06:40 +01:00
|
|
|
palette = "unifieddyes_palette_extended.png",
|
2018-08-26 13:24:24 +02:00
|
|
|
airbrush_replacement_node = "coloredwood:wood_block",
|
2019-05-31 20:52:06 +02:00
|
|
|
groups = groups,
|
2017-01-26 20:24:57 +01:00
|
|
|
})
|
|
|
|
|
2017-02-26 21:05:00 +01:00
|
|
|
default.register_fence("coloredwood:fence", {
|
2017-01-26 20:24:57 +01:00
|
|
|
description = "Colored wooden fence",
|
2017-02-26 21:05:00 +01:00
|
|
|
texture = "coloredwood_fence_base.png",
|
2017-01-26 20:24:57 +01:00
|
|
|
paramtype2 = "color",
|
2017-02-25 07:06:40 +01:00
|
|
|
palette = "unifieddyes_palette_extended.png",
|
2019-05-14 18:42:53 +02:00
|
|
|
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, ud_param2_colorable = 1, not_in_creative_inventory=1},
|
2017-01-26 20:24:57 +01:00
|
|
|
sounds = default.node_sound_wood_defaults(),
|
2018-10-11 09:59:44 +02:00
|
|
|
material = "coloredwood:wood_block"
|
2017-01-26 20:24:57 +01:00
|
|
|
})
|
|
|
|
|
2019-05-31 20:52:06 +02:00
|
|
|
groups = table.copy(minetest.registered_items["default:fence_wood"].groups)
|
|
|
|
groups.ud_param2_colorable = 1
|
|
|
|
|
2017-01-26 20:24:57 +01:00
|
|
|
minetest.override_item("default:fence_wood", {
|
2017-02-25 07:06:40 +01:00
|
|
|
palette = "unifieddyes_palette_extended.png",
|
2019-05-14 18:44:36 +02:00
|
|
|
airbrush_replacement_node = "coloredwood:fence",
|
2019-05-31 20:52:06 +02:00
|
|
|
groups = groups
|
2017-01-26 20:24:57 +01:00
|
|
|
})
|
|
|
|
|
2018-08-22 12:41:06 +02:00
|
|
|
-- Crafts
|
|
|
|
|
|
|
|
unifieddyes.register_color_craft({
|
|
|
|
output = "coloredwood:wood_block",
|
|
|
|
palette = "extended",
|
|
|
|
type = "shapeless",
|
|
|
|
neutral_node = "default:wood",
|
|
|
|
recipe = {
|
|
|
|
"NEUTRAL_NODE",
|
|
|
|
"MAIN_DYE"
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
unifieddyes.register_color_craft({
|
|
|
|
output = "coloredwood:fence",
|
|
|
|
palette = "extended",
|
|
|
|
type = "shapeless",
|
|
|
|
neutral_node = "default:fence_wood",
|
|
|
|
recipe = {
|
|
|
|
"NEUTRAL_NODE",
|
|
|
|
"MAIN_DYE"
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2018-10-11 09:59:44 +02:00
|
|
|
unifieddyes.register_color_craft({
|
|
|
|
output = "coloredwood:fence",
|
|
|
|
palette = "extended",
|
|
|
|
type = "shapeless",
|
|
|
|
neutral_node = "coloredwood:fence",
|
|
|
|
recipe = {
|
|
|
|
"NEUTRAL_NODE",
|
|
|
|
"MAIN_DYE"
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2017-01-26 20:24:57 +01:00
|
|
|
print("[Colored Wood] Loaded!")
|