Function

onUse

(action: (obj: GameObj, id: string) => void): KEventController

Register an event that runs when an object starts using a component.

param action- The function that runs when the event happens.

returns The event controller.

since v3001.1

group Events

Function

onUse

(tag: Tag, action: (obj: GameObj, compId: string) => void): KEventController

Register an event that runs when an object with the provided tag starts using a component.

param tag- The tag to match, only called for objects with a matching tag.

param action- The function that runs when the event happens.

// This will run when the tagged object uses a new component.
onUse("taggedObjTag", (obj, compId) => {
    debug.log(obj, component);
});

returns The event controller.

since v2000.0

group Events

kaplay logo

Components

Miscellaneous