Z-inverted the model for the back half of the pool table
so that it doesn't have to be facedir-flipped in software use the aforementioned function to handle placing it added an abm to convert the old node.
@ -693,8 +693,6 @@ minetest.register_node("homedecor:doghouse_roof", {
|
||||
groups = {snappy=3, not_in_creative_inventory=1},
|
||||
})
|
||||
|
||||
local swap_fdir = { 2, 3, 0, 1 }
|
||||
|
||||
minetest.register_node("homedecor:pool_table", {
|
||||
tiles = {
|
||||
"homedecor_pool_table_top1.png",
|
||||
@ -743,43 +741,20 @@ minetest.register_node("homedecor:pool_table", {
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, 0.3125, 1.5 }
|
||||
},
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local pos = pointed_thing.under
|
||||
local pnode = minetest.get_node(pointed_thing.under)
|
||||
local rnodedef = minetest.registered_nodes[pnode.name]
|
||||
|
||||
if not rnodedef["buildable_to"] then
|
||||
pos = pointed_thing.above
|
||||
end
|
||||
|
||||
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
|
||||
local pos2 = { x = pos.x + homedecor.fdir_to_fwd[fdir+1][1], y=pos.y, z = pos.z + homedecor.fdir_to_fwd[fdir+1][2] }
|
||||
|
||||
local tnode = minetest.get_node(pos)
|
||||
local tnode2 = minetest.get_node(pos2)
|
||||
|
||||
if homedecor.get_nodedef_field(tnode.name, "buildable_to")
|
||||
and homedecor.get_nodedef_field(tnode2.name, "buildable_to")
|
||||
and not minetest.is_protected(pos, placer:get_player_name())
|
||||
and not minetest.is_protected(pos2, placer:get_player_name()) then
|
||||
minetest.add_node(pos, { name = "homedecor:pool_table", param2 = fdir })
|
||||
minetest.add_node(pos2, { name = "homedecor:pool_table2", param2 = swap_fdir[fdir+1] })
|
||||
if not homedecor.expect_infinite_stacks then
|
||||
itemstack:take_item()
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
return homedecor.stack_sideways(itemstack, placer, pointed_thing,
|
||||
"homedecor:pool_table", "homedecor:pool_table_2", false)
|
||||
end,
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
local fdir = oldnode.param2
|
||||
if not fdir or fdir > 3 then return end
|
||||
local pos2 = { x = pos.x + homedecor.fdir_to_fwd[fdir+1][1], y=pos.y, z = pos.z + homedecor.fdir_to_fwd[fdir+1][2] }
|
||||
if minetest.get_node(pos2).name == "homedecor:pool_table2" then
|
||||
if minetest.get_node(pos2).name == "homedecor:pool_table_2" then
|
||||
minetest.remove_node(pos2)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("homedecor:pool_table2", {
|
||||
minetest.register_node("homedecor:pool_table_2", {
|
||||
tiles = {
|
||||
"homedecor_pool_table_top2.png",
|
||||
"homedecor_pool_table_bottom2.png",
|
||||
@ -795,29 +770,29 @@ minetest.register_node("homedecor:pool_table2", {
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.375, -0.5, -0.375, -0.25, 0.1875, -0.25}, -- NodeBox1
|
||||
{0.25, -0.5, -0.375, 0.375, 0.1875, -0.25}, -- NodeBox2
|
||||
{-0.25, -0.125, -0.3125, 0.25, -0.0625, 0}, -- NodeBox3
|
||||
{-0.3125, -0.0625, -0.3125, -0.25, 0.1875, 0}, -- NodeBox4
|
||||
{0.25, -0.0625, -0.3125, 0.3125, 0.1875, 0}, -- NodeBox5
|
||||
{-0.3125, -0.125, 0, 0.3125, 0.1875, 0.0625}, -- NodeBox6
|
||||
{0.25, -0.125, -0.25, 0.3125, 0.1875, 0.5}, -- NodeBox7
|
||||
{-0.3125, -0.125, -0.25, -0.25, 0.1875, 0.5}, -- NodeBox8
|
||||
{-0.5, 0.1875, -0.5, -0.4375, 0.25, 0.5}, -- NodeBox9
|
||||
{-0.5, 0.1875, -0.5, 0.5, 0.25, -0.4375}, -- NodeBox10
|
||||
{0.4375, 0.1875, -0.5, 0.5, 0.25, 0.5}, -- NodeBox11
|
||||
{-0.3125, 0.1875, -0.3125, 0.3125, 0.25, 0.5}, -- NodeBox12
|
||||
{-0.4375, 0.1875, -0.3125, 0.4375, 0.25, 0.4375}, -- NodeBox13
|
||||
{-0.3125, 0.1875, -0.5, 0.3125, 0.25, -0.3125}, -- NodeBox14
|
||||
{-0.25, -0.125, -0.325, 0.25, 0, -0.3125}, -- NodeBox15
|
||||
{0.25, 0.125, -0.4375, 0.4375, 0.1875, 0.5}, -- NodeBox16
|
||||
{-0.4375, 0.125, -0.4375, -0.25, 0.1875, 0.5}, -- NodeBox17
|
||||
{-0.5, 0.25, -0.5, -0.4375, 0.3125, 0.5}, -- NodeBox18
|
||||
{-0.5, 0.25, -0.5, 0.5, 0.3125, -0.4375}, -- NodeBox19
|
||||
{0.4375, 0.25, -0.5, 0.5, 0.3125, 0.5}, -- NodeBox20
|
||||
{-0.4375, 0.25, -0.3125, -0.375, 0.3125, 0.4375}, -- NodeBox23
|
||||
{-0.3125, 0.25, -0.4375, 0.3125, 0.3125, -0.375}, -- NodeBox24
|
||||
{0.375, 0.25, -0.3125, 0.4375, 0.3125, 0.4375}, -- NodeBox25
|
||||
{-0.375, -0.5, 0.25, -0.25, 0.1875, 0.375}, -- NodeBox1
|
||||
{0.25, -0.5, 0.25, 0.375, 0.1875, 0.375}, -- NodeBox2
|
||||
{-0.25, -0.125, 0, 0.25, -0.0625, 0.3125}, -- NodeBox3
|
||||
{-0.3125, -0.0625, 0, -0.25, 0.1875, 0.3125}, -- NodeBox4
|
||||
{0.25, -0.0625, 0, 0.3125, 0.1875, 0.3125}, -- NodeBox5
|
||||
{-0.3125, -0.125, -0.0625, 0.3125, 0.1875, 0}, -- NodeBox6
|
||||
{0.25, -0.125, -0.5, 0.3125, 0.1875, 0.25}, -- NodeBox7
|
||||
{-0.3125, -0.125, -0.5, -0.25, 0.1875, 0.25}, -- NodeBox8
|
||||
{-0.5, 0.1875, -0.5, -0.4375, 0.25, 0.5}, -- NodeBox9
|
||||
{-0.5, 0.1875, 0.4375, 0.5, 0.25, 0.5}, -- NodeBox10
|
||||
{0.4375, 0.1875, -0.5, 0.5, 0.25, 0.5}, -- NodeBox11
|
||||
{-0.3125, 0.1875, -0.5, 0.3125, 0.25, 0.3125}, -- NodeBox12
|
||||
{-0.4375, 0.1875, -0.4375, 0.4375, 0.25, 0.3125}, -- NodeBox13
|
||||
{-0.3125, 0.1875, 0.3125, 0.3125, 0.25, 0.5}, -- NodeBox14
|
||||
{-0.25, -0.125, 0.3125, 0.25, 0, 0.325}, -- NodeBox15
|
||||
{0.25, 0.125, -0.5, 0.4375, 0.1875, 0.4375}, -- NodeBox16
|
||||
{-0.4375, 0.125, -0.5, -0.25, 0.1875, 0.4375}, -- NodeBox17
|
||||
{-0.5, 0.25, -0.5, -0.4375, 0.3125, 0.5}, -- NodeBox18
|
||||
{-0.5, 0.25, 0.4375, 0.5, 0.3125, 0.5}, -- NodeBox19
|
||||
{0.4375, 0.25, -0.5, 0.5, 0.3125, 0.5}, -- NodeBox20
|
||||
{-0.4375, 0.25, -0.4375, -0.375, 0.3125, 0.3125}, -- NodeBox23
|
||||
{-0.3125, 0.25, 0.375, 0.3125, 0.3125, 0.4375}, -- NodeBox24
|
||||
{0.375, 0.25, -0.4375, 0.4375, 0.3125, 0.3125}, -- NodeBox25
|
||||
}
|
||||
},
|
||||
selection_box = {
|
||||
@ -1366,3 +1341,17 @@ minetest.register_node("homedecor:toaster_loaf", {
|
||||
drop = "homedecor:toaster"
|
||||
})
|
||||
|
||||
-- convert old pool tables into newer model
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = { "homedecor:pool_table2" },
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local swap_fdir = { 2, 3, 0, 1 }
|
||||
local fdir = swap_fdir[node.param2+1]
|
||||
minetest.set_node(pos, {name = "homedecor:pool_table_2", param2 = fdir})
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 367 B After Width: | Height: | Size: 370 B |
Before Width: | Height: | Size: 259 B After Width: | Height: | Size: 258 B |
Before Width: | Height: | Size: 255 B After Width: | Height: | Size: 253 B |
Before Width: | Height: | Size: 309 B After Width: | Height: | Size: 310 B |