diff options
author | DS <vorunbekannt75@web.de> | 2017-10-08 18:21:19 +0200 |
---|---|---|
committer | Vitaliy <silverunicorn2011@yandex.ru> | 2017-10-08 19:21:19 +0300 |
commit | 928f04fa9c57bda699f7819cae89741c61d89b05 (patch) | |
tree | 294d59b4d0e20d977b55d68e12e92280f1e1ff5d /mesecons_pistons/legacy.lua | |
parent | c4a1aa0b98e4ee204d51b128df6bb253469a564a (diff) |
Rewrite pistons (#362)
Diffstat (limited to 'mesecons_pistons/legacy.lua')
-rw-r--r-- | mesecons_pistons/legacy.lua | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/mesecons_pistons/legacy.lua b/mesecons_pistons/legacy.lua new file mode 100644 index 0000000..0c6dcb3 --- /dev/null +++ b/mesecons_pistons/legacy.lua @@ -0,0 +1,48 @@ +local ground_dir = { + [0] = {x = 0, y = -1, z = 0}, + {x = 0, y = 0, z = -1}, + {x = 0, y = 0, z = 1}, + {x = -1, y = 0, z = 0}, + {x = 1, y = 0, z = 0}, + {x = 0, y = 1, z = 0}, +} + +minetest.register_lbm({ + label = "Upgrade legacy pistons pointing up", + name = "mesecons_pistons:replace_legacy_piston_up", + nodenames = { + "mesecons_pistons:piston_up_normal_off", + "mesecons_pistons:piston_up_normal_on", + "mesecons_pistons:piston_up_pusher_normal", + "mesecons_pistons:piston_up_sticky_off", + "mesecons_pistons:piston_up_sticky_on", + "mesecons_pistons:piston_up_pusher_sticky", + }, + run_at_every_load = false, + action = function(pos, node) + local dir = ground_dir[math.floor(node.param2/4)] + node.param2 = minetest.dir_to_facedir(dir, true) + node.name = node.name:sub(1, 24)..node.name:sub(28) + minetest.swap_node(pos, node) + end, +}) + +minetest.register_lbm({ + label = "Upgrade legacy pistons pointing down", + name = "mesecons_pistons:replace_legacy_piston_down", + nodenames = { + "mesecons_pistons:piston_down_normal_off", + "mesecons_pistons:piston_down_normal_on", + "mesecons_pistons:piston_down_pusher_normal", + "mesecons_pistons:piston_down_sticky_off", + "mesecons_pistons:piston_down_sticky_on", + "mesecons_pistons:piston_down_pusher_sticky", + }, + run_at_every_load = false, + action = function(pos, node) + local dir = vector.multiply(ground_dir[math.floor(node.param2/4)], -1) + node.param2 = minetest.dir_to_facedir(dir, true) + node.name = node.name:sub(1, 24)..node.name:sub(30) + minetest.swap_node(pos, node) + end, +}) |