Skip to content

script

The global variable script provides access to the entity attached with the running script.

Properties

DamageableComponent DamageableComponent
The DamageableComponent component or nil if not exists.
YaBackpackComponent YaBackpackComponent
The YaBackpackComponent component or nil if not exists.
YaBackpackConfigComponent YaBackpackConfigComponent
The YaBackpackConfigComponent component or nil if not exists.
YaForcerComponent YaForcerComponent
The YaForcerComponent component or nil if not exists.
YaGroupConfigComponent YaGroupConfigComponent
The YaGroupConfigComponent component or nil if not exists.
YaItemConfigComponent YaItemConfigComponent
The YaItemConfigComponent component or nil if not exists.
YaMovableComponent YaMovableComponent
The YaMovableComponent component or nil if not exists.
YaMoverComponent YaMoverComponent
The YaMoverComponent component or nil if not exists.
YaPendulumComponent YaPendulumComponent
The YaPendulumComponent component or nil if not exists.
YaPlayerComponent YaPlayerComponent
The YaPlayerComponent component or nil if not exists.
YaSpinnerComponent YaSpinnerComponent
The YaSpinnerComponent component or nil if not exists.
YaTraceMoverComponent YaTraceMoverComponent
The YaTraceMoverComponent component or nil if not exists.
YaVfxComponent YaVfxComponent
The YaVfxComponent component or nil if not exists.

Functions

table GetYaComponent(string name)
Returns the component of the entity.
  • name The name of the component.
YaEntity SelfEntity()
Gets the object of the attached entity.
void AddAutoRemoveListener(table component, string eventName, function handler)
Adds a handler to the component or object for the eventName event, and the handler will be removed when the game object is destroyed.

Note: only components and objects with the AddListener and RemoveListener function can be called.

  • component An instance with the AddListener and RemoveListener function, such as YaMoverComponent

-- the lifecycle of the global name script is the same with the game object to which the lua script attached. script:AddAutoRemoveListener(YaTime:WaitFor(10), "TimeEvent", function() end)