forked from minetest-mods/technic
Fix broken concrete posts.
This commit is contained in:
parent
0de4fec07c
commit
0defb2e66d
|
@ -123,10 +123,10 @@ minetest.register_node(":technic:concrete_post_platform", {
|
||||||
return minetest.item_place_node(itemstack, placer, pointed_thing)
|
return minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||||
end
|
end
|
||||||
local links = technic.concrete_posts[node.name]
|
local links = technic.concrete_posts[node.name]
|
||||||
if links[5] ~= 0 then -- The post already has a platform
|
if links[6] ~= 0 then -- The post already has a platform
|
||||||
return minetest.item_place_node(itemstack, placer, pointed_thing)
|
return minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||||
end
|
end
|
||||||
local id = technic.get_post_id({links[1], links[2], links[3], links[4], 1})
|
local id = technic.get_post_id({links[1], links[2], links[3], links[4], links[5], 1})
|
||||||
minetest.set_node(pointed_thing.under, {name="technic:concrete_post"..id})
|
minetest.set_node(pointed_thing.under, {name="technic:concrete_post"..id})
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
placer:set_wielded_item(itemstack)
|
placer:set_wielded_item(itemstack)
|
||||||
|
@ -134,8 +134,15 @@ minetest.register_node(":technic:concrete_post_platform", {
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
local function gen_post_nodebox(x1, x2, z1, z2, platform)
|
local function gen_post_nodebox(x1, x2, z1, z2, y, platform)
|
||||||
local box = {box_center}
|
local box
|
||||||
|
local xx = x1 + x2
|
||||||
|
local zz = z1 + z2
|
||||||
|
if ((xx == 2 and zz == 0) or (xx == 0 and zz == 2)) and y == 0 then
|
||||||
|
box = {}
|
||||||
|
else
|
||||||
|
box = {box_center}
|
||||||
|
end
|
||||||
if x1 ~= 0 then
|
if x1 ~= 0 then
|
||||||
table.insert(box, box_x1)
|
table.insert(box, box_x1)
|
||||||
end
|
end
|
||||||
|
@ -170,9 +177,9 @@ function technic.posts_should_connect(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
function technic.get_post_id(links)
|
function technic.get_post_id(links)
|
||||||
return (links[4] * 1) + (links[3] * 2)
|
return (links[1] * 1) + (links[2] * 2)
|
||||||
+ (links[2] * 4) + (links[1] * 8)
|
+ (links[3] * 4) + (links[4] * 8)
|
||||||
+ (links[5] * 16)
|
+ (links[5] * 16) + (links[6] * 32)
|
||||||
end
|
end
|
||||||
|
|
||||||
function technic.update_posts(pos, set, secondrun)
|
function technic.update_posts(pos, set, secondrun)
|
||||||
|
@ -182,9 +189,11 @@ function technic.update_posts(pos, set, secondrun)
|
||||||
{x=pos.x-1, y=pos.y, z=pos.z},
|
{x=pos.x-1, y=pos.y, z=pos.z},
|
||||||
{x=pos.x, y=pos.y, z=pos.z+1},
|
{x=pos.x, y=pos.y, z=pos.z+1},
|
||||||
{x=pos.x, y=pos.y, z=pos.z-1},
|
{x=pos.x, y=pos.y, z=pos.z-1},
|
||||||
|
{x=pos.x, y=pos.y-1, z=pos.z},
|
||||||
|
{x=pos.x, y=pos.y+1, z=pos.z},
|
||||||
}
|
}
|
||||||
|
|
||||||
local links = {0, 0, 0, 0, 0}
|
local links = {0, 0, 0, 0, 0, 0}
|
||||||
|
|
||||||
for i, link_pos in pairs(link_positions) do
|
for i, link_pos in pairs(link_positions) do
|
||||||
local connecttype = technic.posts_should_connect(link_pos)
|
local connecttype = technic.posts_should_connect(link_pos)
|
||||||
|
@ -198,13 +207,19 @@ function technic.update_posts(pos, set, secondrun)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if links[5] == 1 or links[6] == 1 then
|
||||||
|
links[5] = 1
|
||||||
|
links[6] = 0
|
||||||
|
end
|
||||||
|
|
||||||
-- We don't want to set ourselves if we have been removed or we are
|
-- We don't want to set ourselves if we have been removed or we are
|
||||||
-- updating a concrete node
|
-- updating a concrete node
|
||||||
if set then
|
if set then
|
||||||
-- Preserve platform
|
-- Preserve platform
|
||||||
local oldlinks = technic.concrete_posts[node.name]
|
local oldlinks = technic.concrete_posts[node.name]
|
||||||
if oldlinks then
|
if oldlinks then
|
||||||
links[5] = oldlinks[5]
|
links[6] = oldlinks[6]
|
||||||
end
|
end
|
||||||
minetest.set_node(pos, {name="technic:concrete_post"
|
minetest.set_node(pos, {name="technic:concrete_post"
|
||||||
..technic.get_post_id(links)})
|
..technic.get_post_id(links)})
|
||||||
|
@ -215,8 +230,9 @@ for x1 = 0, 1 do
|
||||||
for x2 = 0, 1 do
|
for x2 = 0, 1 do
|
||||||
for z1 = 0, 1 do
|
for z1 = 0, 1 do
|
||||||
for z2 = 0, 1 do
|
for z2 = 0, 1 do
|
||||||
|
for y = 0, 1 do
|
||||||
for platform = 0, 1 do
|
for platform = 0, 1 do
|
||||||
local links = {x1, x2, z1, z2, platform}
|
local links = {x1, x2, z1, z2, y, platform}
|
||||||
local id = technic.get_post_id(links)
|
local id = technic.get_post_id(links)
|
||||||
technic.concrete_posts["technic:concrete_post"..id] = links
|
technic.concrete_posts["technic:concrete_post"..id] = links
|
||||||
|
|
||||||
|
@ -247,7 +263,7 @@ for platform = 0, 1 do
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = gen_post_nodebox(x1, x2, z1, z2, platform),
|
fixed = gen_post_nodebox(x1, x2, z1, z2, y, platform),
|
||||||
},
|
},
|
||||||
after_place_node = function(pos, placer, itemstack)
|
after_place_node = function(pos, placer, itemstack)
|
||||||
technic.update_posts(pos, true)
|
technic.update_posts(pos, true)
|
||||||
|
@ -259,4 +275,5 @@ end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user