diff options
Diffstat (limited to 'kitten.lua')
-rw-r--r-- | kitten.lua | 78 |
1 files changed, 76 insertions, 2 deletions
@@ -32,6 +32,7 @@ reach = 1, random = "mobs_kitten", }, walk_velocity = 0.6, + walk_chance = 15, run_velocity = 2, runaway = true, jump = false, @@ -47,15 +48,54 @@ reach = 1, stand_end = 192, walk_start = 0, walk_end = 96, + stoodup_start = 0, + stoodup_end = 0, }, follow = {"mobs_animal:rat", "ethereal:fish_raw", "mobs_fish:clownfish", "mobs_fish:tropical"}, view_range = 8, + on_rightclick = function(self, clicker) if mobs:feed_tame(self, clicker, 4, true, true) then return end if mobs:protect(self, clicker) then return end if mobs:capture_mob(self, clicker, 50, 50, 90, false, nil) then return end - end + + -- by right-clicking owner can switch between staying and walking + if self.owner and self.owner == clicker:get_player_name() then + + if self.order ~= "stand" then + self.order = "stand" + mobs:set_animation(self, "stand") + else + self.order = "" + mobs:set_animation(self, "stoodup") + end + end + end, + + do_custom = function(self, dtime) + + self.hairball_timer = (self.hairball_timer or 0) + dtime + if self.hairball_timer < 10 then + return + end + self.hairball_timer = 0 + + if self.child + or math.random(1, 10) > 1 then + return + end + + local pos = self.object:get_pos() + + minetest.add_item(pos, "mobs:hairball") + + minetest.sound_play("default_dig_snappy", { + pos = pos, + gain = 1.0, + max_hear_distance = 5, + }) + end, }) @@ -73,7 +113,7 @@ mobs:spawn({ interval = 60, chance = 10000, -- 22000 min_height = 5, - max_height = 200, + max_height = 50, day_toggle = true, }) @@ -82,3 +122,37 @@ mobs:register_egg("mobs_animal:kitten", S("Kitten"), "mobs_kitten_inv.png", 0) mobs:alias_mob("mobs:kitten", "mobs_animal:kitten") -- compatibility + + +local hairball_items = { + "default:stick", "default:coal_lump", "default:dry_shrub", "flowers:rose", + "mobs_animal:rat", "default:grass_1", "farming:seed_wheat", "dye:green", + "farming:seed_cotton", "default:flint", "default:sapling", "dye:white", + "default:clay_lump", "default:paper", "default:dry_grass_1", "dye:red", + "farming:string", "mobs:chicken_feather", "default:acacia_bush_sapling", + "default:bush_sapling", "default:copper_lump", "default:iron_lump", +} + +minetest.register_craftitem(":mobs:hairball", { + description = S("Hairball"), + inventory_image = "mobs_hairball.png", + on_use = function(itemstack, user, pointed_thing) + + local pos = user:get_pos() + local dir = user:get_look_dir() + local newpos = {x = pos.x + dir.x, y = pos.y + dir.y + 1.5, z = pos.z + dir.z} + local item = hairball_items[math.random(1, #hairball_items)] + + minetest.add_item(newpos, {name = item}) + + minetest.sound_play("default_place_node_hard", { + pos = newpos, + gain = 1.0, + max_hear_distance = 5, + }) + + itemstack:take_item() + + return itemstack + end, +}) |