mirror of
https://github.com/luanti-org/minetest_game.git
synced 2025-05-21 06:43:17 -04:00
Player animation bug
The thing in default/player.lua was causing a crash if anyone used a player model besides character.x. kaeza said they also needed a way to register animations for models. (an animation being constants for a finite state machine inside the model, which cannot be introspected from the model?) So now it assumes the character.x animation is the right constants for all models, except those who have an animation registered, instead of crashing for all models besides character.x
This commit is contained in:
parent
eb71e01887
commit
bbf47e4e67
1 changed files with 22 additions and 3 deletions
|
@ -16,9 +16,28 @@ animation_blend = 0
|
||||||
default_model = "character.x"
|
default_model = "character.x"
|
||||||
default_textures = {"character.png", }
|
default_textures = {"character.png", }
|
||||||
|
|
||||||
|
if default.player == nil then
|
||||||
|
default.player = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Each model (character.x weild3d_character.x pony.x etc)
|
||||||
|
-- may have different uh... indexes(?) for the state changes
|
||||||
|
-- such as beginning to stand or done sitting.
|
||||||
|
|
||||||
|
local animations = {}
|
||||||
|
default.player.register_model_animation = function(model,animation)
|
||||||
|
animations[model] = animation
|
||||||
|
end
|
||||||
|
|
||||||
-- Frame ranges for each player model
|
-- Frame ranges for each player model
|
||||||
function player_get_animations(model)
|
function player_get_animations(model)
|
||||||
if model == "character.x" then
|
local animation = animations[model]
|
||||||
|
if animation then
|
||||||
|
return animation
|
||||||
|
end
|
||||||
|
if default.player.default_animation then
|
||||||
|
return default.player.default_animation
|
||||||
|
end
|
||||||
return {
|
return {
|
||||||
stand_START = 0,
|
stand_START = 0,
|
||||||
stand_END = 79,
|
stand_END = 79,
|
||||||
|
@ -34,7 +53,6 @@ function player_get_animations(model)
|
||||||
walk_mine_END = 219
|
walk_mine_END = 219
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- End of configuration area.
|
-- End of configuration area.
|
||||||
|
@ -70,6 +88,7 @@ end
|
||||||
-- Update appearance when the player joins
|
-- Update appearance when the player joins
|
||||||
minetest.register_on_joinplayer(player_update_visuals)
|
minetest.register_on_joinplayer(player_update_visuals)
|
||||||
|
|
||||||
|
|
||||||
-- Check each player and apply animations
|
-- Check each player and apply animations
|
||||||
function player_step(dtime)
|
function player_step(dtime)
|
||||||
for _, pl in pairs(minetest.get_connected_players()) do
|
for _, pl in pairs(minetest.get_connected_players()) do
|
||||||
|
|
Loading…
Add table
Reference in a new issue