node resilience wip

This commit is contained in:
NatureFreshMilk 2019-07-29 13:37:56 +02:00
parent dc598bb21c
commit 373d1b2033
3 changed files with 20 additions and 8 deletions

@ -6,13 +6,14 @@ spacecannon = {
-- charge value in EU -- charge value in EU
powerrequirement = 2500 powerrequirement = 2500
},
} node_resilience = {}
} }
local MP = minetest.get_modpath("spacecannon") local MP = minetest.get_modpath("spacecannon")
dofile(MP.."/util.lua") dofile(MP.."/util.lua")
dofile(MP.."/cannon.lua") dofile(MP.."/cannon.lua")
dofile(MP.."/node_resilience.lua")
print("[OK] Spacecannon") print("[OK] Spacecannon")

8
node_resilience.lua Normal file

@ -0,0 +1,8 @@
-- default = 1
-- >1 = stronger
-- <1 = weaker
spacecannon.node_resilience["default:obsidian"] = 3
spacecannon.node_resilience["default:obsidian_glass"] = 3

@ -77,6 +77,8 @@ spacecannon.destroy = function(pos, range, intensity)
else else
-- default behavior -- default behavior
local resilience = spacecannon.node_resilience[n.name] or 1
if resilience <= 1 or math.random(resilience) == resilience then
minetest.set_node(np, {name="air"}) minetest.set_node(np, {name="air"})
local itemstacks = minetest.get_node_drops(n.name) local itemstacks = minetest.get_node_drops(n.name)
for _, itemname in ipairs(itemstacks) do for _, itemname in ipairs(itemstacks) do
@ -86,6 +88,7 @@ spacecannon.destroy = function(pos, range, intensity)
end end
end end
end end
end
end end
end end