Seperate area flak and custom checks

This commit is contained in:
Niklp 2024-03-01 15:31:00 +01:00
parent 7e8832f523
commit 4e40e3400c
No known key found for this signature in database
GPG Key ID: 05D6F5035E66267A
2 changed files with 11 additions and 4 deletions

View File

@ -37,7 +37,9 @@ When using a hang glider in an area with flak enabled, you will get shot down a
#### Custom "can fly" checks
```lua
hangglider.add_fly_check(function(name, pos)
hangglider.add_fly_check(function(name, player)
-- `name` is the playername
-- `player` is the PlayerRef
-- Add your code here
-- Must return `true` (can fly) or `false` (can't fly)
return true

View File

@ -80,7 +80,7 @@ function hangglider.add_fly_check(func)
table.insert(fly_checks, func)
end
local function can_fly(name, pos)
local function can_fly_area(name, pos)
-- Area flak check
if enable_flak then
local flak = false
@ -95,10 +95,12 @@ local function can_fly(name, pos)
return false
end
end
end
local function can_fly_custom(name, player)
-- Custom checks set by other mods
for _, func in ipairs(fly_checks) do
local ret = func(name, pos)
local ret = func(name, player)
if ret == false then
return false
end
@ -157,7 +159,7 @@ local function hangglider_step(self, dtime)
})
end
end
if not can_fly(name, pos) then
if not can_fly_area(name, pos) then
if not self.flak_timer then
self.flak_timer = 0
shoot_flak_sound(pos)
@ -172,6 +174,9 @@ local function hangglider_step(self, dtime)
gliding = false
end
end
if not can_fly_custom(name, player) then
gliding = false
end
if not gliding then
remove_physics_overrides(player)
hanggliding_players[name] = nil