diff --git a/init.lua b/init.lua index 42ac1f8..713a367 100644 --- a/init.lua +++ b/init.lua @@ -6,13 +6,14 @@ spacecannon = { -- charge value in EU powerrequirement = 2500 - - } + }, + node_resilience = {} } local MP = minetest.get_modpath("spacecannon") dofile(MP.."/util.lua") dofile(MP.."/cannon.lua") +dofile(MP.."/node_resilience.lua") print("[OK] Spacecannon") \ No newline at end of file diff --git a/node_resilience.lua b/node_resilience.lua new file mode 100644 index 0000000..14c9f28 --- /dev/null +++ b/node_resilience.lua @@ -0,0 +1,8 @@ + +-- default = 1 +-- >1 = stronger +-- <1 = weaker + + +spacecannon.node_resilience["default:obsidian"] = 3 +spacecannon.node_resilience["default:obsidian_glass"] = 3 \ No newline at end of file diff --git a/util.lua b/util.lua index 7d5ecf2..fde32e9 100644 --- a/util.lua +++ b/util.lua @@ -77,12 +77,15 @@ spacecannon.destroy = function(pos, range, intensity) else -- default behavior - minetest.set_node(np, {name="air"}) - local itemstacks = minetest.get_node_drops(n.name) - for _, itemname in ipairs(itemstacks) do - if math.random(5) == 5 then - -- chance drop - minetest.add_item(np, itemname) + local resilience = spacecannon.node_resilience[n.name] or 1 + if resilience <= 1 or math.random(resilience) == resilience then + minetest.set_node(np, {name="air"}) + local itemstacks = minetest.get_node_drops(n.name) + for _, itemname in ipairs(itemstacks) do + if math.random(5) == 5 then + -- chance drop + minetest.add_item(np, itemname) + end end end end