From 3ff7c802debb75cf4f1dbe5072a367dc40dfa231 Mon Sep 17 00:00:00 2001 From: Juraj Vajda Date: Wed, 26 Oct 2022 23:59:36 -0400 Subject: [PATCH] add checks for optional default mod --- api.lua | 12 +++++++----- nodes.lua | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/api.lua b/api.lua index 7d41d4f..a92ecb9 100644 --- a/api.lua +++ b/api.lua @@ -1308,12 +1308,14 @@ end ---@param damage number|integer ---@return boolean function XBowsEntityDef.on_punch(self, selfObj, puncher, time_from_last_punch, tool_capabilities, dir, damage) - local wood_sound_def = default.node_sound_wood_defaults() + local wood_sound_def = minetest.global_exists('default') and default.node_sound_wood_defaults() or nil - minetest.sound_play(wood_sound_def.dig.name, { - pos = selfObj.object:get_pos(), - gain = wood_sound_def.dig.gain - }) + if wood_sound_def then + minetest.sound_play(wood_sound_def.dig.name, { + pos = selfObj.object:get_pos(), + gain = wood_sound_def.dig.gain + }) + end return false end diff --git a/nodes.lua b/nodes.lua index 30ddb46..3ab9071 100644 --- a/nodes.lua +++ b/nodes.lua @@ -3,7 +3,7 @@ minetest.register_node('x_bows:target', { tiles = {'x_bows_target.png'}, is_ground_content = false, groups = {snappy=3, flammable=4, fall_damage_add_percent = -30}, - sounds = default.node_sound_leaves_defaults(), + sounds = minetest.global_exists('default') and default.node_sound_leaves_defaults() or {}, mesecons = {receptor = {state = 'off'}}, ---@param pos Vector ---@param elapsed number