summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2017-09-01 12:28:10 +0100
committerTenPlus1 <kinsellaja@yahoo.com>2017-09-01 12:28:10 +0100
commite2d9579401463e96964755acaeae61fc39b7dde8 (patch)
tree6fddd987e7c4e9aec1c064ae091441fab24d598c
parentaabb410ec967c9a4bef3ac6c836aa4ad20d1eda8 (diff)
bunny uses on_spawn to check wether to place snow, desert or random bunny
-rw-r--r--bunny.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/bunny.lua b/bunny.lua
index 32b31f3..e405e4f 100644
--- a/bunny.lua
+++ b/bunny.lua
@@ -74,7 +74,22 @@ mobs:register_mob("mobs_animal:bunny", {
return
end
end,
+ on_spawn = function(self)
+
+ local pos = self.object:getpos() ; pos.y = pos.y - 1
+
+ -- snow bunny
+ if minetest.find_node_near(pos, 2, {"default:snow", "default:snowblock"}) then
+ self.base_texture = {"mobs_bunny_white.png"}
+ self.object:set_properties({textures = self.base_texture})
+ -- desert bunny
+ elseif minetest.find_node_near(pos, 2, {"default:desert_sand", "default:desert_stone"}) then
+ self.base_texture = {"mobs_bunny_brown.png"}
+ self.object:set_properties({textures = self.base_texture})
+ end
+ return true -- run only once, false/nil runs every activation
+ end,
attack_type = "dogfight",
damage = 5,
})