diff --git a/init.lua b/init.lua index 088d592..ab35576 100644 --- a/init.lua +++ b/init.lua @@ -1,8 +1,7 @@ -- Minetest 5.4.1 : airutils +airutils = {} -airutils = { - storage = minetest.get_mod_storage() -} +airutils.storage = minetest.get_mod_storage() local storage = airutils.storage @@ -36,13 +35,15 @@ airutils.fuel = {['biofuel:biofuel'] = 1,['biofuel:bottle_fuel'] = 1, ['biofuel:phial_fuel'] = 0.25, ['biofuel:fuel_can'] = 10, ['airutils:biofuel'] = 1,} -if not minetest.settings:get_bool('airutils.disable_papi') then +airutils.protect_in_areas = minetest.settings:get_bool('airutils_protect_in_areas') + +if not minetest.settings:get_bool('airutils_disable_papi') then dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "airutils_papi.lua") end -if not minetest.settings:get_bool('airutils.disable_tug') then +if not minetest.settings:get_bool('airutils_disable_tug') then dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "airutils_tug.lua") end -if not minetest.settings:get_bool('airutils.disable_repair') then +if not minetest.settings:get_bool('airutils_disable_repair') then dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "airutils_repair.lua") end diff --git a/lib_planes/entities.lua b/lib_planes/entities.lua index 6073497..776f764 100644 --- a/lib_planes/entities.lua +++ b/lib_planes/entities.lua @@ -631,22 +631,32 @@ local function damage_vehicle(self, toolcaps, ttime, damage) end function airutils.on_punch(self, puncher, ttime, toolcaps, dir, damage) - local name = puncher:get_player_name() + local name = "" + local ppos = {} + + if not puncher or not puncher:is_player() then + return + end + + if (puncher:is_player()) then + name = puncher:get_player_name() + ppos = puncher:get_pos() + if (minetest.is_protected(ppos, name) and + airutils.protect_in_areas) then + return + end + end + if self.hp_max <= 0 then airutils.destroy(self, name) end airutils.setText(self, self._vehicle_name) - if (puncher and puncher:is_player() and - (string.find(puncher:get_wielded_item():get_name(), "rayweapon") or - toolcaps.damage_groups.vehicle)) then - damage_vehicle(self, toolcaps, ttime, damage) + if (string.find(puncher:get_wielded_item():get_name(), "rayweapon") or + toolcaps.damage_groups.vehicle) then + damage_vehicle(self, toolcaps, ttime, damage) end - if not puncher or not puncher:is_player() then - return - end - local is_admin = false is_admin = minetest.check_player_privs(puncher, {server=true}) if self.owner and self.owner ~= name and self.owner ~= "" then diff --git a/settingtypes.txt b/settingtypes.txt new file mode 100644 index 0000000..e479705 --- /dev/null +++ b/settingtypes.txt @@ -0,0 +1,14 @@ +# all settings for client menu or in minetest.conf on servers + + +# protect airplanes from player damage in protected areas +airutils_protect_in_areas (protect in area) bool true + +# disable PAPI (Precision Approach Path Indicator) +airutils_disable_papi (disable PAPI) bool false + +# disable tug tool (reposition of not owning planes) +airutils_disable_tug (disable tug tool) bool false + +# disable repair tool for planes +airutils_disable_repair (planes cannot be repaired) bool false