Fix stack division and nodes orientation

This commit is contained in:
sys4-fr 2018-08-25 01:43:04 +02:00
parent bd490be571
commit 2eeb9f95da
1 changed files with 41 additions and 47 deletions

View File

@ -128,13 +128,13 @@ local function is_stairsplus(name, colorized)
local rest
if class == "stair"
or class == "slab"
or class == "panel"
or class == "micro"
or class == "slope" then
or class == "slab"
or class == "panel"
or class == "micro"
or class == "slope" then
if colorized then
colorshape = string.sub(name, b+6)
local 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
@ -163,13 +163,21 @@ minetest.register_node("coloredwood:wood_block", {
drop = "default:wood"
})
for _, color in ipairs(coloredwood.hues_plus_greys) do
-- moreblocks/stairsplus support
-- moreblocks/stairsplus support
if coloredwood.enable_stairsplus then
if coloredwood.enable_stairsplus then
local on_place_custom = function(itemstack, placer, pointed_thing)
local pos = minetest.get_pointed_thing_position(pointed_thing, true)
minetest.rotate_node(itemstack, placer, pointed_thing)
unifieddyes.recolor_on_place(pos, placer, itemstack, pointed_thing)
return itemstack
end
-- stairsplus:register_all(modname, subname, recipeitem, {fields})
for _, color in ipairs(coloredwood.hues_plus_greys) do
-- stairsplus:register_all(modname, subname, recipeitem, {fields})
stairsplus:register_all(
"coloredwood",
@ -181,41 +189,34 @@ for _, color in ipairs(coloredwood.hues_plus_greys) do
paramtype = "light",
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,
on_place = on_place_custom,
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
if coloredwood.enable_stairsplus then
-- force replacement node type for stairsplus default wood stair/slab/etc nodes
for _, i in pairs(minetest.registered_nodes) do
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
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,
on_place = on_place_custom,
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1, not_in_creative_inventory=1, ud_param2_colorable = 1},
drop = "moreblocks:"..s1.."_wood"..s2
})
end
end
@ -224,22 +225,18 @@ end
-- fix drops and other stuff for colored versions of stairsplus nodes
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)
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
local s1, s2 = is_stairsplus(string.gsub(i.name, "coloredwood:", "moreblocks:"), 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,
on_place = on_place_custom,
drop = "moreblocks:"..s1.."_wood"..s2
})
end
@ -296,7 +293,6 @@ end
table.insert(coloredwood.old_13_color_nodes, "coloredwood:wood_grey")
-- add all of the stairsplus nodes, if moreblocks is installed.
if coloredwood.enable_stairsplus then
for _, shape in ipairs(circular_saw.names) do
@ -351,7 +347,6 @@ minetest.register_lbm({
nodenames = coloredwood.old_static_nodes,
action = function(pos, node)
local meta = minetest.get_meta(pos)
local name = node.name
local hue, sat, val = unifieddyes.get_hsv(name)
local color = val..hue..sat
@ -370,7 +365,6 @@ minetest.register_lbm({
minetest.set_node(pos, { name = newname, param2 = cfdir })
local meta = minetest.get_meta(pos)
meta:set_string("dye", "unifieddyes:"..color)
elseif string.find(name, ":fence") then
local paletteidx, hue = unifieddyes.getpaletteidx("unifieddyes:"..color, "extended")
minetest.set_node(pos, { name = "coloredwood:fence", param2 = paletteidx })