Non-loose nodes inherit crush damage from loose alternatives.

This commit is contained in:
Aaron Suen 2019-09-21 08:38:16 -04:00
parent 3b16be70d4
commit 6536276430
2 changed files with 8 additions and 8 deletions

View File

@ -17,10 +17,6 @@ ISSUES: Bugs, Cleanup and Refinements
- Flammable/igniter ABM should be reversed, so we scan over few igniters
instead of many flammables?
- Fix thrown item damage for non-loose nodes that have loose versions,
e.g. cobble hasn't needed a crushing_damage before. If absent, look
for alternative_loose definition and pull from there.
- Sponges grow way too much.
- Inhibit growth based on total in area.
- Allow transplantation of colonies.

View File

@ -3,15 +3,19 @@ local ItemStack, minetest, nodecore, pairs
= ItemStack, minetest, nodecore, pairs
-- LUALOCALS > ---------------------------------------------------------
local function getcrushdamage(name, alreadyloose)
local def = minetest.registered_items[name]
if def and def.crush_damage then return def.crush_damage end
if alreadyloose then return 0 end
return getcrushdamage(name .. "_loose", true)
end
local function register(fallname, mult, getname)
local fallnode = minetest.registered_entities[fallname]
local oldtick = fallnode.on_step
fallnode.on_step = function(self, dtime, ...)
if not self.crush_damage then
local def = minetest.registered_items[getname(self)]
self.crush_damage = def and def.crush_damage or 0
end
self.crush_damage = self.crush_damage or getcrushdamage(getname(self))
if self.crush_damage <= 0 then
return oldtick(self, dtime, ...)
end