minetest/mods/player_api/init.lua
paramat fc86bf5a5f Player API: Animation-dependent collisionbox and eye_height
Backwards compatible with previous model definition format.
For the Minetest Game player model, this avoids dead players having
obstructive tall collision and selection boxes.
2020-09-26 22:54:31 +01:00

45 lines
1.2 KiB
Lua

dofile(minetest.get_modpath("player_api") .. "/api.lua")
-- Default player appearance
player_api.register_model("character.b3d", {
animation_speed = 30,
textures = {"character.png"},
stepheight = 0.6,
animations = {
stand = {x = 0, y = 79},
lay = {x = 162, y = 166},
walk = {x = 168, y = 187},
mine = {x = 189, y = 198},
walk_mine = {x = 200, y = 219},
sit = {x = 81, y = 160},
},
collisionbox = {
stand = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3},
walk = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3},
mine = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3},
walk_mine = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3},
lay = {-0.6, 0.0, -0.6, 0.6, 0.3, 0.6},
sit = {-0.3, 0.0, -0.3, 0.3, 1.0, 0.3},
},
eye_height = {
stand = 1.47,
walk = 1.47,
mine = 1.47,
walk_mine = 1.47,
lay = 0.3,
sit = 0.8,
},
})
-- Update appearance when the player joins
minetest.register_on_joinplayer(function(player)
player_api.player_attached[player:get_player_name()] = false
player_api.set_model(player, "character.b3d")
player:set_local_animation(
{x = 0, y = 79},
{x = 168, y = 187},
{x = 189, y = 198},
{x = 200, y = 219},
30
)
end)