interact

Make the agent interact with an item located in the selected direction.

agent.interact(SixDirection.Forward)

Parameters

  • direction: the direction in which to interact with the item:
    • forward
    • back
    • left
    • right
    • up
    • down

Example

Make two chat commands. One has the agent teleport to the player and then place a dark oak door from an inventory slot. The other chat command has the agent open and walk through the door.

player.onChat("placedoor", function () {
    agent.teleportToPlayer()
    agent.setItem(DARK_OAK_DOOR, 1, 1)
    agent.setSlot(1)
    agent.place(FORWARD)
})
player.onChat("opendoor", function () {
    agent.interact(FORWARD)
    agent.move(FORWARD, 2)
})

See also

set item, set slot