removeById
Removes an existing interaction associated with an id. this wont work for global interactions
Parameters
id
(number | string
): The unique identifier of the interaction you wish to remove. This ID is returned by the function used to add the interaction initially.similar
(boolean
): determines wether the id search is strict or notDeepEqual. i.e. if similar is true and id is 'hello', it would also remove 'hello:world'
Examples
local interactionId = interact.addCoords({
id = "uniqueInteractionId", --id that is stored in variable
coords = vec3(123.4, 567.8, 250.0),
options = {
{
label = "Interact Option 1",
icon = "hand", -- Example simple FA icon name
onSelect =function(data) print("Action 1 triggered") end,
canInteract = function(entity, distance, coords, id)
return distance < 2.0 -- Example condition based on distance
end
}
},
renderDistance = 10.0,
activeDistance = 2.0,
cooldown = 1500
})
-- To remove the specific interaction by its ID:
interact.removeById(interactionId)
local interactionId = interact.addCoords({
id = "uniqueInteractionId", --id that is stored in variable
coords = {
vec3(123.4, 567.8, 250.0),
vec3(421.4, 567.8, 125.0)
},
options = {
{
label = "Interact Option 1",
icon = "hand", -- Example simple FA icon name
onSelect =function(data) print("Action 1 triggered") end,
canInteract = function(entity, distance, coords, id)
return true
end
}
},
renderDistance = 10.0,
activeDistance = 2.0,
cooldown = 1500
})
-- To remove the specific interaction by its ID:
interact.removeById(interactionId, true)
export
exports.sleepless_interact:removeById(id, similar)