Constructor


ActorSprite(actor: any)

Arguments:

actor: any




Methods


ActorSprite:_setSprite(texture: string?, keep_anim: boolean?)

(Called internally) Sets the current sprite

Arguments:

texture: string?
keep_anim: boolean?




ActorSprite:canTalk()

Whether this sprite can talk using it's current sprite

@return can_talk — Whether a talksprite is defined

@return talk_speed — The speed at which the talk sprite should animate, in seconds

Returns:

can_talk: boolean

Whether a talksprite is defined

talk_speed: number

The speed at which the talk sprite should animate, in seconds





ActorSprite:getDirectionalPath(sprite: string)

(Called internally) Gets the path for a directional sprite based on the current facing direction

Arguments:

sprite: string

Returns:

new_sprite: string




ActorSprite:getValueForSprite(tbl: table)

Selects from the given table tbl the relevant value for the current sprite, if it exists

Arguments:

tbl: table

Returns:

1: any


ActorSprite:isDirectional(texture: string)

(Called internally) Checks whether a particular texture has sprites defined for multiple facing directions
Note: Assumes that all four directions are always defined

Arguments:

texture: string

Returns:

directional: boolean?
separator: string?


ActorSprite:isSprite(sprite: string)

Checks whether sprite matches the sprite's current texture

Arguments:

sprite: string

Returns:

1: boolean


ActorSprite:resetSprite(ignore_actor_callback: boolean?)

Resets this sprite to the default animation or sprite.

@param ignore_actor_callback — When set to true, will not call the actor's preResetSprite() function.

Arguments:

ignore_actor_callback: boolean?

When set to true, will not call the actor's preResetSprite() function.



ActorSprite:set(name: string|nil, callback: fun( ActorSprite)?, ignore_actor_callback: boolean?)

Sets the sprite to either a texture or an animation
If the current actor has an animation with a name matching name, it will be passed into ActorSprite:setAnimation().
Otherwise, it will be passed into ActorSprite:setSprite().

Arguments:

name: string|nil
callback: fun( ActorSprite)?
ignore_actor_callback: boolean?


ActorSprite:setActor(actor: string|Actor)

Sets or replaces the current actor on the sprite.
Will also reset the sprite through ActorSprite:setSprite()

Arguments:

actor: string|Actor

Actors are a type of data class that represent the visuals of a character - anything that is some type of character, be it the player, an NPC, or an enemy in battle, it will require an actor.
As a data class, actors are stored in scripts/data/actors/, and extend this class. Their filepath starting from here becomes their id, unless an id is specified as an argument to Class().



ActorSprite:setAnimation(anim: (string|function|table)?, callback: fun( ActorSprite)?, ignore_actor_callback: boolean?)

Sets the animation of the current sprite.
The animation specified in anim can be one of the following:

  • string - The name of an animation defined on the sprite's current actor.
  • table - a table of animation data. Refer to Sprite:setAnimation(anim) for how to use this, as well as the additional keys supported on ActorSprite listed below:
    • temp: boolean - Whether the previous aniamtion/sprite should be set once the new animation is stops (Defaults to false)
  • function - An animation routine

@param callback — A callback to run when the animation finishes

@param ignore_actor_callback — Whether to skip calling Actor:preSetAnimation()

Arguments:

anim: (string|function|table)?
callback: fun( ActorSprite)?

A callback to run when the animation finishes

ignore_actor_callback: boolean?

Whether to skip calling Actor:preSetAnimation()

Returns:

1: boolean?


ActorSprite:setCustomSprite(texture: string?, ox: number?, oy: number?, keep_anim: boolean?)

Sets the sprite relative to assets/sprites, with a custom offset.

@param texture — The path to the sprite to use, relative to assets/sprites

@param ox — The x-offset of the sprite

@param oy — The y-offset of the sprite

Arguments:

texture: string?

The path to the sprite to use, relative to assets/sprites

ox: number?

The x-offset of the sprite

oy: number?

The y-offset of the sprite

keep_anim: boolean?


ActorSprite:setFacing(facing: "down"|"left"|"right"|"up")

Sets the facing direction of the current sprite

facing:
    | "up"
    | "down"
    | "left"
    | "right"

Arguments:

facing: "down"|"left"|"right"|"up"


ActorSprite:setSprite(texture: string?, keep_anim: boolean?, ignore_actor_callback: boolean?)

Sets the current sprite

Arguments:

texture: string?
keep_anim: boolean?
ignore_actor_callback: boolean?


ActorSprite:setTextureExact(texture: any)

(Called internally) Sets the current sprite to a single texture.
Note: Only for internal overrides. Use Sprite:setSprite() instead.

Arguments:

texture: any


ActorSprite:setWalkSprite(texture: string)

Sets the current sprite and starts animating it based on walk_speed and walking

Arguments:

texture: string




ActorSprite:updateDirection()

(Called internally) Updates the current sprite to match the current facing direction




Fields


ActorSprite.actor: Actor

(Read-only) The actor associated with this sprite


ActorSprite.anim: (string|function|table)?

(Read-only) The current animation set on the sprite


ActorSprite.aura: boolean

Whether the sprite currently has a glowing aura (used for ChaserEnemy objects)


ActorSprite.aura_siner: number

A timer used for the aura effect


ActorSprite.dir_sep: string?

(Read-only) The separator the current sprite uses for its directional sprites. Either "_" or "/"


ActorSprite.directional: boolean?

(Read-only) Whether the current sprite changes based on the facing direction


ActorSprite.facing: "down"|"left"|"right"|"up"

(Read-only) The sprite's current facing direction


ActorSprite.freeze_progress: number

The percentage of the enemy that is frozen, as a number ranging from 0 to 1


ActorSprite.frozen: boolean

Whether the sprite has a frozen overlay


ActorSprite.full_sprite: string?

(Read-only) The full string path of the current texture, if it exists


ActorSprite.last_facing: "down"|"left"|"right"|"up"

(Read-only) The direction the sprite was facing on the previous frame



ActorSprite.offsets: table<string, [number, number]>

(Read-only) A table of offset positions for sprites (inherited from Actor.offsets)


ActorSprite.on_footstep: fun( Sprite, cycle)?

A callback function that is run whenever the character is in the "step" part of their animation while walking


ActorSprite.run_away: boolean

Special draw mode for enemies running away from battle on defeat


ActorSprite.run_away_timer: number

A timer used for the run away animation


ActorSprite.sprite: string?

(Read-only) The current texture of the sprite, if it exists



ActorSprite.temp_anim: (string|function|table)?

(Read-only) The animation that will be set when the current temporary animation stops


ActorSprite.temp_sprite: string?

(Read-only) The sprite that will be set when the current temporary animation stops


ActorSprite.walk_frame: number

(Read-only) The current frame of the walking animation


ActorSprite.walk_override: boolean

(Read-only) Enables special update code for the walk animation


ActorSprite.walk_speed: number

The movement speed of the character attached to this sprite


ActorSprite.walking: boolean

Whether the sprite is currently walking



Undocumented