local function P()local P=player:DistanceFromCharacter(target.Position)return P>0 and P<=MAX_DISTANCE end local function N()if not(MainFrame.Visible or SelectionFrame.Visible or TopBar.Enabled)and P()then show()else hide()end end local function X()if not IS_CONSOLE then if not(MainFrame.Visible or SelectionFrame.Visible or TopBar.Enabled)and P()then InteractionButton.Visible=true elseif not P()then InteractionButton.Visible=false end end if MainFrame.Visible and not P()then hide()end end
-- * Indicates whether the local player is in range of the `target` object
--
--   Arguments: None
--   Return: Boolean whether player is in range
-- *
local function inRange()
	local distance = player:DistanceFromCharacter(target.Position)
	return distance > 0 and distance <= MAX_DISTANCE -- Distance should only be 0 when character doesnt exist
end

local function toggleInteraction()
	if (not (MainFrame.Visible or SelectionFrame.Visible or TopBar.Enabled)) and inRange() then
		show()
	else
		hide()
	end
end

local function interactionCheck()
	if not IS_CONSOLE then
		if (not (MainFrame.Visible or SelectionFrame.Visible or TopBar.Enabled)) and inRange() then
			InteractionButton.Visible = true
		elseif not inRange() then
			InteractionButton.Visible = false
		end
	end

	if MainFrame.Visible and not inRange() then
		hide()
	end
end
