mirror of
https://github.com/pandorabox-io/spacecannon.git
synced 2024-12-30 01:27:29 +01:00
node resilience wip
This commit is contained in:
parent
dc598bb21c
commit
373d1b2033
5
init.lua
5
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")
|
8
node_resilience.lua
Normal file
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
|
15
util.lua
15
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
|
||||
|
Loading…
Reference in New Issue
Block a user