IsObjectSubmerged
The IsObjectSubmerged function checks whether a specified object in the game world is submerged in water or another liquid. This function is useful for determining if an object, such as a player or NPC, is underwater, which can affect gameplay mechanics like movement, breathing, and visibility.
Parameters
object: The object identifier (GUID) or unit identifier (such as "player", "target", "focus", etc.) for which to check submersion status.
Returns
submerged: A boolean value indicating whether the specified object is submerged (trueif submerged,falseotherwise).
Example Usage in Lua
Here is an example of how to use the IsObjectSubmerged function in Lua:
local api = ...
-- Function to check if the player is submerged
function CheckIfPlayerIsSubmerged()
local player = "player"
local isSubmerged = api.IsObjectSubmerged(player)
if isSubmerged then
print("The player is submerged.")
else
print("The player is not submerged.")
end
end
-- Function to check if the target is submerged
function CheckIfTargetIsSubmerged()
local target = "target"
local isSubmerged = api.IsObjectSubmerged(target)
if isSubmerged then
print("The target is submerged.")
else
print("The target is not submerged.")
end
end
-- Function to check if a specific object by GUID is submerged
function CheckIfObjectIsSubmerged(objectGUID)
local isSubmerged = api.IsObjectSubmerged(objectGUID)
if isSubmerged then
print("The object with GUID " .. objectGUID .. " is submerged.")
else
print("The object with GUID " .. objectGUID .. " is not submerged.")
end
end
-- Call the functions
CheckIfPlayerIsSubmerged()
CheckIfTargetIsSubmerged()
-- Example object GUID (replace with an actual GUID in your game)
local exampleObjectGUID = "1234-5678-9012-3456"
CheckIfObjectIsSubmerged(exampleObjectGUID)