Skip to content

ObjectInteract

The ObjectInteract function allows a specified object or unit to interact with another object in the game world. This function is commonly used for interactions with NPCs and lootable objects such as corpses, herbs, ores, and other interactable entities.

Parameters

  • object: The object identifier (GUID) or unit identifier (such as "player", "target", "focus", etc.) that will be interacted with.

Returns

This function does not return any value. It simply performs the interaction with the specified object.

Example Usage in Lua

Here is an example of how to use the ObjectInteract function in Lua:

local api = ...

-- Function to make the player interact with the target
function PlayerInteractWithTarget()
    local target = "target"
    api.ObjectInteract(target)
    print("Player interacted with the target.")
end

-- Function to make the player interact with a specific object by GUID
function PlayerInteractWithObject(objectGUID)
    api.ObjectInteract(objectGUID)
    print("Player interacted with the object with GUID " .. objectGUID .. ".")
end

-- Call the functions
PlayerInteractWithTarget()

-- Example object GUID (replace with an actual GUID in your game)
local exampleObjectGUID = "1234-5678-9012-3456"
PlayerInteractWithObject(exampleObjectGUID)