summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2016-05-01 19:41:50 +0100
committerTenPlus1 <kinsellaja@yahoo.com>2016-05-01 19:41:50 +0100
commit6e89f8f696d0505d9b608da11efc333a16c134e9 (patch)
treef63cef4b2e78795cf7aa890eec9f8085963fef7f
parent8fa1a0e1cb3e4c3b28721183a54a632de8f5f20a (diff)
Added default on_blast function
-rw-r--r--api.lua56
1 files changed, 16 insertions, 40 deletions
diff --git a/api.lua b/api.lua
index 283147c..056167f 100644
--- a/api.lua
+++ b/api.lua
@@ -2091,6 +2091,19 @@ local mob_step = function(self, dtime)
end
+-- default function when mobs are blown up with TNT
+local do_tnt = function(obj, damage)
+
+ --print ("----- Damage", damage)
+
+ obj.object:punch(obj.object, 1.0, {
+ full_punch_interval = 1.0,
+ damage_groups = {fleshy = damage},
+ }, nil)
+
+ return false, true, {}
+end
+
mobs.spawning_mobs = {}
-- register mob function
@@ -2177,7 +2190,8 @@ minetest.register_entity(name, {
immune_to = def.immune_to or {},
explosion_radius = def.explosion_radius,
custom_attack = def.custom_attack,
- on_blast = def.on_blast,
+
+ on_blast = def.on_blast or do_tnt,
on_step = mob_step,
@@ -2250,7 +2264,7 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
chance = new_chance
- print ("[Mobs Redo] Chance setting for " .. name .. " is now " .. chance)
+ print ("[Mobs Redo] Chance setting for " .. name .. " changed to " .. chance)
end
@@ -2827,44 +2841,6 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end
end)
--- used to drop items inside a chest or container
-local drop_items = function(pos, invstring)
-
- local meta = minetest.get_meta(pos)
- local inv = meta:get_inventory()
-
- for i = 1, inv:get_size(invstring) do
-
- local m_stack = inv:get_stack(invstring, i)
- local obj = minetest.add_item(pos, m_stack)
-
- if obj then
-
- obj:setvelocity({
- x = math.random(-10, 10) / 9,
- y = 3,
- z = math.random(-10, 10) / 9
- })
- end
- end
-
-end
-
--- override chest node so it drops items on explode
-minetest.override_item("default:chest", {
-
- on_blast = function(p)
-
- minetest.after(0, function()
-
- drop_items(p, "main")
-
- minetest.remove_node(p)
- end)
- end,
-
-})
-
-- compatibility function for old entities to new modpack entities
function mobs:alias_mob(old_name, new_name)