Fix and weaken the broken mcl_tnt dependencies

Had possible crash because of missing mcl_death_messages dep.
This commit is contained in:
Wuzzy 2017-08-09 13:38:47 +02:00
parent 5023e0247d
commit 6fa426741e
2 changed files with 28 additions and 15 deletions

View file

@ -1,5 +1,5 @@
mcl_core mcl_sounds?
mcl_sounds mcl_mobitems?
mcl_fire mcl_hunger?
mcl_hunger mcl_death_messages?
doc_identifier? doc_identifier?

View file

@ -1,3 +1,6 @@
local mod_death_messages = minetest.get_modpath("mcl_death_messages")
local mod_hunger = minetest.get_modpath("mcl_hunger")
local function spawn_tnt(pos, entname) local function spawn_tnt(pos, entname)
minetest.sound_play("tnt_ignite", {pos = pos,gain = 1.0,max_hear_distance = 15,}) minetest.sound_play("tnt_ignite", {pos = pos,gain = 1.0,max_hear_distance = 15,})
local tnt = minetest.add_entity(pos, entname) local tnt = minetest.add_entity(pos, entname)
@ -27,9 +30,13 @@ local function do_tnt_physics(tnt_np,tntr)
local dist = math.max(1, vector.distance(tnt_np, p)) local dist = math.max(1, vector.distance(tnt_np, p))
local damage = (4 / dist) * tntr local damage = (4 / dist) * tntr
if obj:is_player() == true then if obj:is_player() == true then
if mod_death_messages then
mcl_death_messages.player_damage(obj, string.format("%s was caught in an explosion.", obj:get_player_name())) mcl_death_messages.player_damage(obj, string.format("%s was caught in an explosion.", obj:get_player_name()))
end
if mod_hunger then
mcl_hunger.exhaust(obj:get_player_name(), mcl_hunger.EXHAUST_DAMAGE) mcl_hunger.exhaust(obj:get_player_name(), mcl_hunger.EXHAUST_DAMAGE)
end end
end
obj:set_hp(obj:get_hp() - damage) obj:set_hp(obj:get_hp() - damage)
end end
end end
@ -45,6 +52,10 @@ end
local TNT_RANGE = 3 local TNT_RANGE = 3
local sounds
if minetest.get_modpath("mcl_sounds") then
sounds = mcl_sounds.node_sound_wood_defaults()
end
minetest.register_node("mcl_tnt:tnt", { minetest.register_node("mcl_tnt:tnt", {
tiles = {"default_tnt_top.png", "default_tnt_bottom.png", tiles = {"default_tnt_top.png", "default_tnt_bottom.png",
"default_tnt_side.png", "default_tnt_side.png", "default_tnt_side.png", "default_tnt_side.png",
@ -63,7 +74,7 @@ minetest.register_node("mcl_tnt:tnt", {
_on_ignite = function(pos, player) _on_ignite = function(pos, player)
tnt.ignite(pos) tnt.ignite(pos)
end, end,
sounds = mcl_sounds.node_sound_wood_defaults(), sounds = sounds,
}) })
local TNT = { local TNT = {
@ -218,14 +229,16 @@ end
minetest.register_entity("mcl_tnt:tnt", TNT) minetest.register_entity("mcl_tnt:tnt", TNT)
minetest.register_craft({ if minetest.get_modpath("mcl_mobitems") then
minetest.register_craft({
output = "mcl_tnt:tnt", output = "mcl_tnt:tnt",
recipe = { recipe = {
{'mcl_mobitems:gunpowder','group:sand','mcl_mobitems:gunpowder'}, {'mcl_mobitems:gunpowder','group:sand','mcl_mobitems:gunpowder'},
{'group:sand','mcl_mobitems:gunpowder','group:sand'}, {'group:sand','mcl_mobitems:gunpowder','group:sand'},
{'mcl_mobitems:gunpowder','group:sand','mcl_mobitems:gunpowder'} {'mcl_mobitems:gunpowder','group:sand','mcl_mobitems:gunpowder'}
} }
}) })
end
if minetest.get_modpath("doc_identifier") then if minetest.get_modpath("doc_identifier") then
doc.sub.identifier.register_object("mcl_tnt:tnt", "nodes", "mcl_tnt:tnt") doc.sub.identifier.register_object("mcl_tnt:tnt", "nodes", "mcl_tnt:tnt")