model.lua 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. -- Bone alias
  2. local BODY = "Body"
  3. local HEAD = "Head"
  4. local CAPE = "Cape"
  5. local LARM = "Arm_Left"
  6. local RARM = "Arm_Right"
  7. local LLEG = "Leg_Left"
  8. local RLEG = "Leg_Right"
  9. -- Version of player model
  10. local DEFAULT_PLAYER_MODEL_VERSION = "MTG_4_Jun_2017"
  11. local VALID_PLAYER_MODEL_VERSIONS = {
  12. MTG_4_Jun_2017 = true,
  13. MTG_4_Nov_2017 = true,
  14. }
  15. local LEGACY_PLAYER_MODEL_VERSIONS = {
  16. default_character_v1 = true,
  17. default_character_v2 = true,
  18. default_character_v3 = true,
  19. }
  20. local BONE_POSITIONS = {
  21. MTG_4_Jun_2017 = {
  22. [BODY] = {x = 0, y = -3.5, z = 0},
  23. [HEAD] = {x = 0, y = 6.5, z = 0},
  24. [CAPE] = {x = 0, y = 6.5, z = 1.2},
  25. [LARM] = {x = 3, y = 5.5, z = 0},
  26. [RARM] = {x = -3, y = 5.5, z = 0},
  27. [LLEG] = {x = 1, y = 0, z = 0},
  28. [RLEG] = {x = -1, y = 0, z = 0},
  29. body_sit = {x = 0, y = -5.5, z = 0},
  30. body_lay = {x = 0, y = -5.5, z = 0},
  31. },
  32. MTG_4_Nov_2017 = {
  33. [BODY] = {x = 0, y = 6.25, z = 0},
  34. [HEAD] = {x = 0, y = 6.5, z = 0},
  35. [CAPE] = {x = 0, y = 6.5, z = 1.2},
  36. [LARM] = {x = 3, y = 5.5, z = 0},
  37. [RARM] = {x = -3, y = 5.5, z = 0},
  38. [LLEG] = {x = 1, y = 0, z = 0},
  39. [RLEG] = {x = -1, y = 0, z = 0},
  40. body_sit = {x = 0, y = -5, z = 0},
  41. body_lay = {x = 0, y = -5, z = 0},
  42. },
  43. }
  44. local BONE_ROTATIONS = {
  45. MTG_4_Jun_2017 = {
  46. [BODY] = {x = 0, y = 0, z = 0},
  47. [HEAD] = {x = 0, y = 0, z = 0},
  48. [CAPE] = {x = 0, y = 0, z = 0},
  49. [LARM] = {x = 0, y = 0, z = 0},
  50. [RARM] = {x = 0, y = 0, z = 0},
  51. [LLEG] = {x = 0, y = 0, z = 0},
  52. [RLEG] = {x = 0, y = 0, z = 0},
  53. body_sit = {x = 0, y = 0, z = 0},
  54. body_lay = {x = 270, y = 0, z = 0},
  55. },
  56. MTG_4_Nov_2017 = {
  57. [BODY] = {x = 0, y = 0, z = 0},
  58. [HEAD] = {x = 0, y = 0, z = 0},
  59. [CAPE] = {x = 0, y = 0, z = 0},
  60. [LARM] = {x = 0, y = 0, z = 0},
  61. [RARM] = {x = 0, y = 0, z = 0},
  62. [LLEG] = {x = 0, y = 0, z = 0},
  63. [RLEG] = {x = 0, y = 0, z = 0},
  64. body_sit = {x = 0, y = 0, z = 0},
  65. body_lay = {x = 270, y = 0, z = 0},
  66. },
  67. }
  68. local PLAYER_MODEL_VERSION = (function()
  69. local version = minetest.settings:get("playeranim.model_version")
  70. if version == nil or version == "" then
  71. version = DEFAULT_PLAYER_MODEL_VERSION
  72. end
  73. if LEGACY_PLAYER_MODEL_VERSIONS[version] then
  74. error("The model version '" .. version .. "' is no longer suppported")
  75. elseif not VALID_PLAYER_MODEL_VERSIONS[version] then
  76. error("Invalid value for playeranim.model_version in minetest.conf: " .. version)
  77. end
  78. return version
  79. end)()
  80. local BONE_POSITION = BONE_POSITIONS[PLAYER_MODEL_VERSION]
  81. local BONE_ROTATION = BONE_ROTATIONS[PLAYER_MODEL_VERSION]
  82. if not BONE_POSITION or not BONE_ROTATION then
  83. error("Internal error: invalid player_model_version: " .. PLAYER_MODEL_VERSION)
  84. end
  85. return BONE_POSITION, BONE_ROTATION