rat.lua 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. local S = mobs.intllib
  2. -- Rat by PilzAdam
  3. mobs:register_mob("mobs_animal:rat", {
  4. type = "animal",
  5. passive = true,
  6. hp_min = 1,
  7. hp_max = 4,
  8. armor = 200,
  9. collisionbox = {-0.2, -1, -0.2, 0.2, -0.8, 0.2},
  10. visual = "mesh",
  11. mesh = "mobs_rat.b3d",
  12. textures = {
  13. {"mobs_rat.png"},
  14. {"mobs_rat2.png"},
  15. },
  16. makes_footstep_sound = false,
  17. sounds = {
  18. random = "mobs_rat",
  19. },
  20. walk_velocity = 1,
  21. run_velocity = 2,
  22. runaway = true,
  23. jump = true,
  24. water_damage = 0,
  25. lava_damage = 4,
  26. light_damage = 0,
  27. fear_height = 2,
  28. on_rightclick = function(self, clicker)
  29. mobs:capture_mob(self, clicker, 50, 90, 0, true, "mobs_animal:rat")
  30. end,
  31. --[[
  32. do_custom = function(self, dtime)
  33. self.rat_timer = (self.rat_timer or 0) + dtime
  34. if self.rat_timer < 1 then return end -- every 1 second
  35. self.rat_timer = 0
  36. local pos = self.object:getpos()
  37. print("rat pos", pos.x, pos.y, pos.z, dtime)
  38. return false -- return but skip doing rest of API
  39. end,
  40. ]]
  41. --[[
  42. on_blast = function(obj, damage)
  43. print ("--- damage is", damage)
  44. print ("--- mob is", obj.object:get_luaentity().name)
  45. -- return's do_damage, do_knockback and drops
  46. return false, true, {"default:mese"}
  47. end,
  48. ]]
  49. })
  50. local function rat_spawn(self, pos)
  51. self = self:get_luaentity()
  52. print (self.name, pos.x, pos.y, pos.z)
  53. self.hp_max = 100
  54. self.health = 100
  55. end
  56. mobs:spawn({
  57. name = "mobs_animal:rat",
  58. nodes = {"default:stone"},
  59. min_light = 3,
  60. active_object_count = 2,
  61. max_height = 0,
  62. -- on_spawn = rat_spawn,
  63. })
  64. mobs:register_egg("mobs_animal:rat", S("Rat"), "mobs_rat_inventory.png", 0)
  65. mobs:alias_mob("mobs:rat", "mobs_animal:rat") -- compatibility
  66. -- cooked rat, yummy!
  67. minetest.register_craftitem(":mobs:rat_cooked", {
  68. description = S("Cooked Rat"),
  69. inventory_image = "mobs_cooked_rat.png",
  70. on_use = minetest.item_eat(3),
  71. })
  72. minetest.register_craft({
  73. type = "cooking",
  74. output = "mobs:rat_cooked",
  75. recipe = "mobs:rat",
  76. cooktime = 5,
  77. })