From: Pilcrow Date: Fri, 13 Sep 2013 15:09:57 +0000 (-0400) Subject: Fix hacky_swap_node to not repeatedly swap the same node in over and over X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=cedb49d887b3a6782c4472813dc7b6ebeeedc2ea;p=zefram%2Fminetest%2Fpipeworks.git Fix hacky_swap_node to not repeatedly swap the same node in over and over --- diff --git a/deployer.lua b/deployer.lua index 4a17ddf..1e8ae17 100644 --- a/deployer.lua +++ b/deployer.lua @@ -88,13 +88,16 @@ minetest.register_craft({ }) function hacky_swap_node(pos,name) - local node=minetest.get_node(pos) - local meta=minetest.get_meta(pos) - local meta0=meta:to_table() - node.name=name - minetest.add_node(pos, node) - local meta=minetest.get_meta(pos) - meta:from_table(meta0) + local node=minetest.get_node(pos) + local meta=minetest.get_meta(pos) + local meta0=meta:to_table() + if node.name == name then + return + end + node.name=name + minetest.add_node(pos, node) + local meta=minetest.get_meta(pos) + meta:from_table(meta0) end deployer_on = function(pos, node) diff --git a/node_breaker.lua b/node_breaker.lua index ed12d9e..5ed7f86 100644 --- a/node_breaker.lua +++ b/node_breaker.lua @@ -15,13 +15,16 @@ minetest.register_craft({ }) function hacky_swap_node(pos,name) - local node=minetest.get_node(pos) - local meta=minetest.get_meta(pos) - local meta0=meta:to_table() - node.name=name - minetest.add_node(pos, node) - local meta=minetest.get_meta(pos) - meta:from_table(meta0) + local node=minetest.get_node(pos) + local meta=minetest.get_meta(pos) + local meta0=meta:to_table() + if node.name == name then + return + end + node.name=name + minetest.add_node(pos, node) + local meta=minetest.get_meta(pos) + meta:from_table(meta0) end --define the functions from https://github.com/minetest/minetest/pull/834 while waiting for the devs to notice it