diff --git a/README.txt b/README.txt index 8802edd..7e9f14e 100644 --- a/README.txt +++ b/README.txt @@ -1,6 +1,6 @@ Minetest mod "Torches" ======================= -version: 1.3 +version: 1.3.1 License of source code and textures: WTFPL ----------------------------------------- @@ -31,3 +31,7 @@ Changelog: 1.3: - Torches only show flames when player is near (13 blocks) - Old torches are converted to new, ceiling torches are dropped + +1.3.1: +- fix dropping torches when digging a block next to it +- all torches attached to a block get droped when dug diff --git a/init.lua b/init.lua index 580fa38..e554734 100644 --- a/init.lua +++ b/init.lua @@ -163,6 +163,11 @@ minetest.register_node("torches:floor", { after_dig_node = function(pos, oldnode, oldmetadata, digger) if not digger:is_player() then minetest.add_item(pos, {name="default:torch"}) end end, + update = function(pos,node, pos2) + if pos2.y < pos.y then + minetest.dig_node(pos) + end + end, }) local wall_ndbx = { @@ -204,15 +209,27 @@ minetest.register_node("torches:wand", { after_dig_node = function(pos, oldnode, oldmetadata, digger) if not digger:is_player() then minetest.add_item(pos, {name="default:torch"}) end end, + update = function(pos,node) + if not check_attached_node_fdir(pos, node) then + minetest.dig_node(pos) + end + end, }) minetest.register_on_dignode(function(pos, oldnode, digger) - local p = minetest.find_node_near(pos, 1, {"group:torch"}) - if p and p ~= nil then - if not check_attached_node_fdir(p, minetest.get_node(p)) then - minetest.dig_node(p) + for ix=-1,1 do + for iz=-1,1 do + for iy=0,1 do + if ix ~=0 and iz ~= 0 then iy=0 end + local p = {x=pos.x+ix,y=pos.y+iy,z=pos.z+iz} + local n = minetest.get_node_or_nil(p) + local fd = minetest.registered_nodes[n.name].update or nil + if fd ~= nil then + fd(p, n, pos) end end + end + end end)