Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follows invisibility API changes upstream #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions compat/invisibility.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
-- TODO: make this part of an external API? it should just be part of invisibility, honestly
]]

if invisibility and
not (type(invisibility.is_visible) == "function") and
not (type(invisibility.invisible) == "function")
then
mobs_balrog.log(
"warning",
"Please upgrade to latest version of invisibility"
)
return false
end

-- TODO: configurable?
local sense_phrases = {
"Fee fie foe fum, I smell the blood of an adventurer...",
Expand Down Expand Up @@ -43,7 +54,7 @@ mobs_balrog.api.register_on_do_custom(function(self, dtime)
if p:distance(player:get_pos()) <= mobs_balrog.settings.invisibility_radius then
local pname = player:get_player_name()
local is_staff = minetest.check_player_privs(pname, { staff = true })
local is_invisible = invisibility[pname]
local is_invisible = not invisibility.is_visible(pname)
local is_target = self.player_invisibility_target == pname

if is_invisible and not is_target and not is_staff then
Expand All @@ -53,11 +64,7 @@ mobs_balrog.api.register_on_do_custom(function(self, dtime)
elseif is_invisible and is_target then
local str = reveal_phrases[math.random(1, #reveal_phrases)]
minetest.chat_send_player(pname, str)
if minetest.global_exists("invisible") then
invisible(player, false)
else
invisibility[pname] = nil
end
invisibility.invisible(player, false)
end
end
end
Expand Down