Merge pull request #9 from berengma/main

protect planes, add settings
This commit is contained in:
Alexsandro Percy 2023-11-15 09:40:08 -03:00 committed by GitHub
commit 2ae0bde0c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 15 deletions

View file

@ -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

View file

@ -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

14
settingtypes.txt Normal file
View file

@ -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