Skip to main content

Interactions

Contains functions for multiple interactions.

Functions

add(interactionName, position)

Adds a new interaction to the Entity.

Parameters

  • interactionName Name of the interaction.
  • position Position between 1 to 5 (optional).

Example

Add 2 new interactions to a chair.

function onStart()
Interactions.add("Rest")
Interactions.add("Search")
Interactions.add("Destroy")
end

function onInteractStart(clientId, interactionKey, interactionName)
if interactionName == "Rest" then
Furniture.rest(clientId)
elseif interactionName == "Search" then
-- search logic here
elseif interactionName == "Destroy" then
self.destroy()
end
end

remove(nameOrPosition)

Removes an existing interaction in the Entity.

Parameters

  • nameOrPosition Name or position of the interaction to remove.

Example

Remove an interaction if he picks "Remove" interaction.

function onStart()
Interactions.add("Add Interaction")
Interactions.add("Remove Interaction")
Interactions.add("Random Interaction")
end

function onInteractStart(clientId, interactionKey, interactionName)
if interactionName == "Add Interaction" then
Interactions.add("New Interaction")
elseif interactionName == "Remove Interaction" then
Interactions.remove("Random Interaction")
elseif interactionName == "Random Interaction" then
-- random interaction logic here.
end
end

clear()

Clears all existing interactions in the Entity.

Example

Clears Interactions if he picks the wrong option when talking to the NPC.

function onStart()
Interactions.add("Talk")
end

function onInteractStart(clientId, interactionKey, interactionName)
if interactionName == "Talk" then
options = {
"Yes",
"No"
}
response = Speech.prompt("Do you wanna talk to me?", options)

is response == 1 then
Interactions.clear()
end
end
end