visuals.lua 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. -- Minimal test entities to test visuals
  2. minetest.register_entity("testentities:sprite", {
  3. initial_properties = {
  4. visual = "sprite",
  5. textures = { "testentities_sprite.png" },
  6. },
  7. })
  8. minetest.register_entity("testentities:upright_sprite", {
  9. initial_properties = {
  10. visual = "upright_sprite",
  11. textures = {
  12. "testentities_upright_sprite1.png",
  13. "testentities_upright_sprite2.png",
  14. },
  15. },
  16. })
  17. minetest.register_entity("testentities:cube", {
  18. initial_properties = {
  19. visual = "cube",
  20. textures = {
  21. "testentities_cube1.png",
  22. "testentities_cube2.png",
  23. "testentities_cube3.png",
  24. "testentities_cube4.png",
  25. "testentities_cube5.png",
  26. "testentities_cube6.png",
  27. },
  28. },
  29. })
  30. minetest.register_entity("testentities:item", {
  31. initial_properties = {
  32. visual = "item",
  33. wield_item = "testnodes:normal",
  34. },
  35. })
  36. minetest.register_entity("testentities:wielditem", {
  37. initial_properties = {
  38. visual = "wielditem",
  39. wield_item = "testnodes:normal",
  40. },
  41. })
  42. minetest.register_entity("testentities:mesh", {
  43. initial_properties = {
  44. visual = "mesh",
  45. mesh = "testnodes_pyramid.obj",
  46. textures = {
  47. "testnodes_mesh_stripes2.png"
  48. },
  49. },
  50. })
  51. minetest.register_entity("testentities:mesh_unshaded", {
  52. initial_properties = {
  53. visual = "mesh",
  54. mesh = "testnodes_pyramid.obj",
  55. textures = {
  56. "testnodes_mesh_stripes2.png"
  57. },
  58. shaded = false,
  59. },
  60. })
  61. -- Advanced visual tests
  62. -- An entity for testing animated and yaw-modulated sprites
  63. minetest.register_entity("testentities:yawsprite", {
  64. initial_properties = {
  65. selectionbox = {-0.3, -0.5, -0.3, 0.3, 0.3, 0.3},
  66. visual = "sprite",
  67. visual_size = {x=0.6666, y=1},
  68. textures = {"testentities_dungeon_master.png^[makealpha:128,0,0^[makealpha:128,128,0"},
  69. spritediv = {x=6, y=5},
  70. initial_sprite_basepos = {x=0, y=0},
  71. },
  72. on_activate = function(self, staticdata)
  73. self.object:set_sprite({x=0, y=0}, 3, 0.5, true)
  74. end,
  75. })
  76. -- An entity for testing animated upright sprites
  77. minetest.register_entity("testentities:upright_animated", {
  78. initial_properties = {
  79. visual = "upright_sprite",
  80. textures = {"testnodes_anim.png"},
  81. spritediv = {x = 1, y = 4},
  82. },
  83. on_activate = function(self)
  84. self.object:set_sprite({x=0, y=0}, 4, 1.0, false)
  85. end,
  86. })
  87. minetest.register_entity("testentities:nametag", {
  88. initial_properties = {
  89. visual = "sprite",
  90. textures = { "testentities_sprite.png" },
  91. },
  92. on_activate = function(self, staticdata)
  93. if staticdata ~= "" then
  94. local data = minetest.deserialize(staticdata)
  95. self.color = data.color
  96. self.bgcolor = data.bgcolor
  97. else
  98. self.color = {
  99. r = math.random(0, 255),
  100. g = math.random(0, 255),
  101. b = math.random(0, 255),
  102. }
  103. if math.random(0, 10) > 5 then
  104. self.bgcolor = {
  105. r = math.random(0, 255),
  106. g = math.random(0, 255),
  107. b = math.random(0, 255),
  108. a = math.random(0, 255),
  109. }
  110. end
  111. end
  112. assert(self.color)
  113. self.object:set_properties({
  114. nametag = tostring(math.random(1000, 10000)),
  115. nametag_color = self.color,
  116. nametag_bgcolor = self.bgcolor,
  117. })
  118. end,
  119. get_staticdata = function(self)
  120. return minetest.serialize({ color = self.color, bgcolor = self.bgcolor })
  121. end,
  122. })