Module playermodel
PlayerModel is a system that adds a player model complete with animations.
activate () |
Activates the system, if it is not disabled by the configuration. |
activate_internal () |
Activates the system, without checking the configuration. |
activate_model_on_player (player) |
Activates the model on the given player. |
default_animation_provider (player) |
The default animation provider that is registered as first provider. |
determine_animation (player) |
Determines the animation and frame speed for the current state of
the given player. |
get_animation (name, default_x, default_y) |
Gets the specified animation from the configuration. |
init () |
Initializes all necessary variables. |
perform_animation_updates () |
Performs animation updates on all players. |
register_animation_provider (provider) |
Registers a provider for player animations. |
set_player_animation (player, animation, frame_speed) |
Sets the player information on the given player, but only if it has changed. |
set_player_model (player, model, textures, size) |
Sets the given model, textures and size on the player. |
update_player_animation (player) |
Updates the animation of the given player. |
Functions
-
activate ()
-
Activates the system, if it is not disabled by the configuration.
-
activate_internal ()
-
Activates the system, without checking the configuration.
-
activate_model_on_player (player)
-
Activates the model on the given player.
Parameters:
- player
The Player object on which to activate the model.
-
default_animation_provider (player)
-
The default animation provider that is registered as first provider.
Parameters:
- player
The Player object for which to get the animation.
Returns:
The animation and the frame speed.
-
determine_animation (player)
-
Determines the animation and frame speed for the current state of
the given player. Invokes all registered providers.
Parameters:
- player
The Player Object.
Returns:
The animation and the frame speed.
-
get_animation (name, default_x, default_y)
-
Gets the specified animation from the configuration.
Parameters:
- name
The name of the animation.
- default_x
The default value for x.
- default_y
The default value for y.
Returns:
The table of the animation, with x, y and speed values.
-
init ()
-
Initializes all necessary variables.
-
perform_animation_updates ()
-
Performs animation updates on all players.
-
register_animation_provider (provider)
-
Registers a provider for player animations.
Animation providers are invoked on every global step of Minetest by default,
that means it should be as lightweight as possible.
Parameters:
- provider
The provider. A function that accepts a Player object and
returns the animation that should be used, or nil.
-
set_player_animation (player, animation, frame_speed)
-
Sets the player information on the given player, but only if it has changed.
Parameters:
- player
The Player object on which to set the animation.
- animation
The animation.
- frame_speed
The frame speed.
-
set_player_model (player, model, textures, size)
-
Sets the given model, textures and size on the player.
Parameters:
- player
The Player object on which to set the model.
- model
The name of the model/mesh to use. Can be nil to keep
the current value.
- textures
The textures to use. Can be nil to keep the current value.
- size
The size of the mode, a table with x and y values. Can be nil
to keep the current value.
-
update_player_animation (player)
-
Updates the animation of the given player.
Parameters:
- player
The Player object which to update.
Tables
-
player_information
-
A cache so that animations are not needlessly set.
-
texture
-
The texture of the model that is used. Defaults to "character.png".
Fields:
Fields
-
activate_automatically
-
If the system should be automatically activated.
-
active
-
If the system is active/has been activated.
-
animation_digging
-
The animation for when the player is digging. Defaults to 189/199.
-
animation_laying
-
The animation for when the player is laying on the ground. Defaults
to 162/167.
-
animation_providers
-
The providers for the animations.
-
animation_sitting
-
The animation for when the player is sitting. Defaults to 81/161.
-
animation_standing
-
The animation for when the player is standing still. Defaults to 0/80.
-
animation_walking
-
The animation for when the player is walking. Defaults to 168/188.
-
animation_walking_digging
-
The animation for when the player is walking and digging. Defaults
to 200/220.
-
frame_speed
-
The frame speed of the animations. Defaults to 30.
-
frame_speed_sneaking
-
The frame speed of the animations when the player is sneaking.
Defaults to 15.
-
model
-
The name of the model that will be used. Defaults to "character.x".
-
size
-
The size of the model. Defaults to 1/1.