rat.lua 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. local S = mobs.intllib
  2. -- Rat by PilzAdam
  3. mobs:register_mob("mobs_animal:rat", {
  4. stepheight = 0.6,
  5. type = "animal",
  6. passive = true,
  7. hp_min = 1,
  8. hp_max = 4,
  9. armor = 200,
  10. collisionbox = {-0.2, -1, -0.2, 0.2, -0.8, 0.2},
  11. visual = "mesh",
  12. mesh = "mobs_rat.b3d",
  13. textures = {
  14. {"mobs_rat.png"},
  15. {"mobs_rat2.png"},
  16. },
  17. makes_footstep_sound = false,
  18. sounds = {
  19. random = "mobs_rat",
  20. },
  21. walk_velocity = 1,
  22. run_velocity = 2,
  23. runaway = true,
  24. jump = true,
  25. water_damage = 0,
  26. lava_damage = 4,
  27. light_damage = 0,
  28. fear_height = 2,
  29. follow = {"mobs:cheese"},
  30. view_range = 3,
  31. on_rightclick = function(self, clicker)
  32. if mobs:feed_tame(self, clicker, 8, true, true) then return end
  33. if mobs:capture_mob(self, clicker, 50, 90, 0, true, "mobs_animal:rat") then return end
  34. end,
  35. })
  36. local function rat_spawn(self, pos)
  37. self = self:get_luaentity()
  38. print (self.name, pos.x, pos.y, pos.z)
  39. self.hp_max = 100
  40. self.health = 100
  41. end
  42. mobs:spawn({
  43. name = "mobs_animal:rat",
  44. nodes = {"default:stone"},
  45. min_light = 3,
  46. max_light = 9,
  47. interval = 60,
  48. chance = 8000,
  49. max_height = 0,
  50. -- on_spawn = rat_spawn,
  51. })
  52. mobs:register_egg("mobs_animal:rat", S("Rat"), "mobs_rat_inventory.png", 0)
  53. mobs:alias_mob("mobs:rat", "mobs_animal:rat") -- compatibility
  54. -- cooked rat, yummy!
  55. minetest.register_craftitem(":mobs:rat_cooked", {
  56. description = S("Cooked Rat"),
  57. inventory_image = "mobs_cooked_rat.png",
  58. on_use = minetest.item_eat(3),
  59. groups = {food_rat = 1, flammable = 2},
  60. })
  61. minetest.register_craft({
  62. type = "cooking",
  63. output = "mobs:rat_cooked",
  64. recipe = "mobs_animal:rat",
  65. cooktime = 5,
  66. })