From 3f00c1d1cb3823f405558b2bd23465813580d5e3 Mon Sep 17 00:00:00 2001 From: HybridDog Date: Tue, 9 Feb 2016 11:32:09 +0100 Subject: [PATCH 1/2] fix pistons not working in every buildable_to node --- mesecons_mvps/init.lua | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mesecons_mvps/init.lua b/mesecons_mvps/init.lua index beec94b..6f455f7 100644 --- a/mesecons_mvps/init.lua +++ b/mesecons_mvps/init.lua @@ -47,6 +47,17 @@ function mesecon.mvps_process_stack(stack) end end +-- tests if the node can't be pushed +local replaceable_cache = {air = true, ignore = false} +local function node_replaceable(name) + if replaceable_cache[name] ~= nil then + return replaceable_cache[name] + end + local replaceable = not minetest.registered_nodes[name] or minetest.registered_nodes[name].buildable_to or false + replaceable_cache[name] = replaceable + return replaceable +end + function mesecon.mvps_get_stack(pos, dir, maximum, all_pull_sticky) -- determine the number of nodes to be pushed local nodes = {} @@ -56,9 +67,7 @@ function mesecon.mvps_get_stack(pos, dir, maximum, all_pull_sticky) local np = frontiers[1] local nn = minetest.get_node(np) - if nn.name ~= "air" - and minetest.registered_nodes[nn.name] - and minetest.registered_nodes[nn.name].liquidtype == "none" then + if not node_replaceable(nn.name) then table.insert(nodes, {node = nn, pos = np}) if #nodes > maximum then return nil end From cf45e24c57306450215b27d9bcbca43084d57d32 Mon Sep 17 00:00:00 2001 From: HybridDog Date: Tue, 9 Feb 2016 16:58:49 +0100 Subject: [PATCH 2/2] this way it works better because unknown nodes may not stay unknown --- mesecons_mvps/init.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mesecons_mvps/init.lua b/mesecons_mvps/init.lua index 6f455f7..bfbd774 100644 --- a/mesecons_mvps/init.lua +++ b/mesecons_mvps/init.lua @@ -19,6 +19,12 @@ function mesecon.is_mvps_stopper(node, pushdir, stack, stackid) if type (get_stopper) == "function" then get_stopper = get_stopper(node, pushdir, stack, stackid) end + if get_stopper == nil + and not minetest.registered_nodes[node.name] then + -- unknown nodes must be stoppers + mesecon.mvps_stoppers[node.name] = true + get_stopper = true + end return get_stopper end @@ -53,7 +59,8 @@ local function node_replaceable(name) if replaceable_cache[name] ~= nil then return replaceable_cache[name] end - local replaceable = not minetest.registered_nodes[name] or minetest.registered_nodes[name].buildable_to or false + --local replaceable = not minetest.registered_nodes[name] or minetest.registered_nodes[name].buildable_to or false + local replaceable = (minetest.registered_nodes[name] and minetest.registered_nodes[name].buildable_to) or false replaceable_cache[name] = replaceable return replaceable end