1
0
mirror of https://github.com/mt-mods/coloredwood.git synced 2024-12-23 17:30:21 +01:00

switch to colored itemstacks

with full crafting recipes
(requires Unified Dyes commit d2512952 or later)
This commit is contained in:
Vanessa Dannenberg 2018-08-22 06:41:06 -04:00
parent bd490be571
commit f74bdd224f

113
init.lua
View File

@ -117,8 +117,9 @@ table.insert(coloredwood.hues_plus_greys, "grey")
local function is_stairsplus(name, colorized)
-- the format of a coloredwood stairsplus node is:
-- moreblocks:class_wood_color_shape
-- where class is "slab", "stair", etc. and shape is "three quarter", "alt", etc.
-- "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")
local a = string.find(name, ":")
local b = string.find(name, "_")
@ -126,6 +127,7 @@ local function is_stairsplus(name, colorized)
local class = string.sub(name, a+1, b-1) -- from colon to underscore is the class
local shape = ""
local rest
local colorshape
if class == "stair"
or class == "slab"
@ -153,14 +155,10 @@ minetest.register_node("coloredwood:wood_block", {
paramtype = "light",
paramtype2 = "color",
palette = "unifieddyes_palette_extended.png",
place_param2 = 240,
walkable = true,
sunlight_propagates = false,
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=2, not_in_creative_inventory=1, ud_param2_colorable = 1},
sounds = default.node_sound_wood_defaults(),
after_place_node = unifieddyes.recolor_on_place,
after_dig_node = unifieddyes.after_dig_node,
drop = "default:wood"
})
for _, color in ipairs(coloredwood.hues_plus_greys) do
@ -182,74 +180,60 @@ for _, color in ipairs(coloredwood.hues_plus_greys) do
paramtype2 = "colorfacedir",
palette = "unifieddyes_palette_"..color.."s.png",
after_place_node = function(pos, placer, itemstack, pointed_thing)
print("after_place_node on "..minetest.get_node(pos).name)
minetest.rotate_node(itemstack, placer, pointed_thing)
unifieddyes.recolor_on_place(pos, placer, itemstack, pointed_thing)
end,
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=2, not_in_creative_inventory=1, ud_param2_colorable = 1},
after_dig_node = unifieddyes.after_dig_node
}
)
end
end
-- force replacement node type for stairsplus default wood stair/slab/etc nodes
local coloredwood_cuts = {}
if coloredwood.enable_stairsplus then
-- 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
for _, i in pairs(minetest.registered_nodes) do
if string.find(i.name, "moreblocks:stair_wood")
if (string.find(i.name, "moreblocks:stair_wood")
or string.find(i.name, "moreblocks:slab_wood")
or string.find(i.name, "moreblocks:panel_wood")
or string.find(i.name, "moreblocks:micro_wood")
or string.find(i.name, "moreblocks:slope_wood") then
local a,b = string.find(i.name, "wood_tile")
if not a then
local s1, s2 = is_stairsplus(i.name, false)
minetest.override_item(i.name, {
ud_replacement_node = "coloredwood:"..s1.."_wood_grey"..s2,
paramtype2 = "colorfacedir",
after_place_node = function(pos, placer, itemstack, pointed_thing)
print("overridden after_place_node on "..i.name)
minetest.rotate_node(itemstack, placer, pointed_thing)
unifieddyes.recolor_on_place(pos, placer, itemstack, pointed_thing)
end,
on_place = minetest.item_place,
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1, not_in_creative_inventory=1, ud_param2_colorable = 1},
})
end
end
end
or string.find(i.name, "moreblocks:slope_wood"))
and not string.find(i.name, "wood_tile") then
-- fix drops and other stuff for colored versions of stairsplus nodes
table.insert(coloredwood_cuts, i.name)
for _, i in pairs(minetest.registered_nodes) do
if string.find(i.name, "coloredwood:stair_")
or string.find(i.name, "coloredwood:slab_")
or string.find(i.name, "coloredwood:panel_")
or string.find(i.name, "coloredwood:micro_")
or string.find(i.name, "coloredwood:slope_")
then
mname = string.gsub(i.name, "coloredwood:", "moreblocks:")
local s1, s2 = is_stairsplus(mname, true)
minetest.override_item(i.name, {
after_place_node = function(pos, placer, itemstack, pointed_thing)
print("overridden after_place_node on "..i.name)
minetest.rotate_node(itemstack, placer, pointed_thing)
unifieddyes.recolor_on_place(pos, placer, itemstack, pointed_thing)
end,
on_place = minetest.item_place,
drop = "moreblocks:"..s1.."_wood"..s2
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1, not_in_creative_inventory=1, ud_param2_colorable = 1},
})
end
end
end
-- "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,
palette = true,
type = "shapeless",
neutral_node = mname,
recipe = {
"NEUTRAL_NODE",
"MAIN_DYE"
}
})
end
minetest.override_item("default:wood", {
palette = "unifieddyes_palette_extended.png",
ud_replacement_node = "coloredwood:wood_block",
after_place_node = unifieddyes.recolor_on_place,
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1, ud_param2_colorable = 1},
})
@ -260,19 +244,38 @@ default.register_fence("coloredwood:fence", {
palette = "unifieddyes_palette_extended.png",
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, ud_param2_colorable = 1},
sounds = default.node_sound_wood_defaults(),
after_place_node = unifieddyes.recolor_on_place,
after_dig_node = unifieddyes.after_dig_node,
drop = "default:fence_wood",
material = "default:wood"
})
minetest.override_item("default:fence_wood", {
palette = "unifieddyes_palette_extended.png",
ud_replacement_node = "coloredwood:fence",
after_place_node = unifieddyes.recolor_on_place,
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, ud_param2_colorable = 1}
})
-- 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"
}
})
-- ============================
-- convert the old static nodes