mckaygerhard 62f9150940 player_Api - dinamically set the model player on client conection
* improves previous commit 13cd243a031ca6c52457032e0bffc8576b549b3a ,
  the problem is that both server and client must be equal protocol, so
  this ugly hack check if this was loaded into FinalMinetest or Multicraft
  to dinamically check client nature and re-registering the model when
  server and client do not have same player models due the colisionbox check
* NOTE: the check already need to check if the engine is old and the server not,
  so the conditional just try to do exact check agains TRUE boolean.
* Closed https://codeberg.org/minenux/minetest-game-minetest/issues/12
  fixed the problem of collisionbox for the lufix player in ugly way but
  much more effectivelly due can be mixed in FinalMinetest and Multicraft
2023-08-13 19:22:40 -04:00

39 lines
1007 B
Lua

-- player/init.lua
dofile(minetest.get_modpath("player_api") .. "/api.lua")
player_api.dynamicmodel(nil)
-- Default player appearance
player_api.register_model(player_api.modelchar, {
animation_speed = 30,
textures = {"character.png", },
animations = {
-- Standard 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 = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3},
stepheight = 0.6,
eye_height = player_api.eyeheithg,
})
-- Update appearance when the player joins
minetest.register_on_joinplayer(function(player)
local player_name = player:get_player_name()
player_api.dynamicmodel(player_name)
player_api.player_attached[player_name] = false
player_api.set_model(player, player_api.modelchar)
player:set_local_animation(
{x = 0, y = 79},
{x = 168, y = 187},
{x = 189, y = 198},
{x = 200, y = 219},
30
)
end)