summaryrefslogtreecommitdiff
path: root/mesecons_pistons
diff options
context:
space:
mode:
Diffstat (limited to 'mesecons_pistons')
-rw-r--r--mesecons_pistons/doc/piston/description.html2
-rw-r--r--mesecons_pistons/doc/piston_sticky/description.html3
-rw-r--r--mesecons_pistons/init.lua17
3 files changed, 17 insertions, 5 deletions
diff --git a/mesecons_pistons/doc/piston/description.html b/mesecons_pistons/doc/piston/description.html
index d95dfb9..b9dffaa 100644
--- a/mesecons_pistons/doc/piston/description.html
+++ b/mesecons_pistons/doc/piston/description.html
@@ -1 +1,3 @@
Pistons are effectors, they push up to 20 blocks in front of them. The push direction can be set by placing them from different angles.
+A piston pointing into an unloaded block won't extend.
+A piston retracting from an unloaded block works, but gravity-sensitive nodes above the empty space may not fall.
diff --git a/mesecons_pistons/doc/piston_sticky/description.html b/mesecons_pistons/doc/piston_sticky/description.html
index 3974097..580b76f 100644
--- a/mesecons_pistons/doc/piston_sticky/description.html
+++ b/mesecons_pistons/doc/piston_sticky/description.html
@@ -1 +1,4 @@
Sticky pistons are effectors, they push up to 20 blocks in front of them. The push direction can be set by placing them from different angles. Sticky ones also pull 1 block.
+A sticky piston pointing into an unloaded block won't extend.
+A sticky piston retracting from within an unloaded block works and pulls a node, but if it doesn't pull anything, then gravity-sensitive nodes above the empty space may not fall.
+An extended sticky piston that touches the surface of an unloaded block and loses signal retracts but doesn't pull anything.
diff --git a/mesecons_pistons/init.lua b/mesecons_pistons/init.lua
index 386cffa..56a3f73 100644
--- a/mesecons_pistons/init.lua
+++ b/mesecons_pistons/init.lua
@@ -55,7 +55,7 @@ local function piston_get_rules(node)
return rules
end
-local function piston_remove_pusher(pos, node)
+local function piston_remove_pusher(pos, node, check_falling)
local pistonspec = get_pistonspec(node.name, "onname")
local dir = vector.multiply(minetest.facedir_to_dir(node.param2), -1)
local pusherpos = vector.add(pos, dir)
@@ -72,7 +72,14 @@ local function piston_remove_pusher(pos, node)
max_hear_distance = 20,
gain = 0.3,
})
- minetest.check_for_falling(pusherpos)
+
+ if check_falling then
+ minetest.check_for_falling(pusherpos)
+ end
+end
+
+local function piston_after_dig(pos, node)
+ piston_remove_pusher(pos, node, true)
end
local piston_on = function(pos, node)
@@ -97,7 +104,7 @@ end
local function piston_off(pos, node)
local pistonspec = get_pistonspec(node.name, "onname")
minetest.set_node(pos, {param2 = node.param2, name = pistonspec.offname})
- piston_remove_pusher(pos, node)
+ piston_remove_pusher(pos, node, not pistonspec.sticky)
if not pistonspec.sticky then
return
@@ -293,7 +300,7 @@ minetest.register_node("mesecons_pistons:piston_normal_on", {
paramtype2 = "facedir",
is_ground_content = false,
drop = "mesecons_pistons:piston_normal_off",
- after_dig_node = piston_remove_pusher,
+ after_dig_node = piston_after_dig,
node_box = piston_on_box,
selection_box = piston_on_box,
sounds = default.node_sound_wood_defaults(),
@@ -371,7 +378,7 @@ minetest.register_node("mesecons_pistons:piston_sticky_on", {
paramtype2 = "facedir",
is_ground_content = false,
drop = "mesecons_pistons:piston_sticky_off",
- after_dig_node = piston_remove_pusher,
+ after_dig_node = piston_after_dig,
node_box = piston_on_box,
selection_box = piston_on_box,
sounds = default.node_sound_wood_defaults(),