Merge pull request #12 from farooqkz/master
Add eggs and replace follow strings with tables
3
TODO.txt
Normal file
@ -0,0 +1,3 @@
|
||||
this file was added by farooghkz.
|
||||
TODO list:
|
||||
- better images for eggs
|
20
api.lua
@ -1,4 +1,17 @@
|
||||
mobs = {}
|
||||
|
||||
function mobs:is_in_tbl(a_tbl, a_val)
|
||||
if not a_tbl then
|
||||
return false
|
||||
end
|
||||
for key, val in ipairs(a_tbl) do
|
||||
if val == a_val then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function mobs:register_mob(name, def)
|
||||
minetest.register_entity(name, {
|
||||
hp_max = def.hp_max,
|
||||
@ -117,6 +130,10 @@ function mobs:register_mob(name, def)
|
||||
self.object:remove()
|
||||
end
|
||||
|
||||
if self.hp_max == 5 and self.type == "animal" then
|
||||
-- TODO: if its sheep, it will eat grass!
|
||||
end
|
||||
|
||||
self.lifetimer = self.lifetimer - dtime
|
||||
if self.lifetimer <= 0 and not self.tamed then
|
||||
local player_count = 0
|
||||
@ -248,7 +265,8 @@ function mobs:register_mob(name, def)
|
||||
end
|
||||
|
||||
if self.following and self.following:is_player() then
|
||||
if self.following:get_wielded_item():get_name() ~= self.follow then
|
||||
item_name = self.following:get_wielded_item():get_name()
|
||||
if not mobs:is_in_tbl(self.follow, item_name) then
|
||||
self.following = nil
|
||||
self.v_start = false
|
||||
else
|
||||
|
87
init.lua
@ -199,12 +199,12 @@ mobs:register_mob("mobs:sheep", {
|
||||
walk_start = 81,
|
||||
walk_end = 100,
|
||||
},
|
||||
follow = "farming:wheat",
|
||||
follow = {"farming:wheat", "farming:bread"},
|
||||
view_range = 5,
|
||||
|
||||
on_rightclick = function(self, clicker)
|
||||
local item = clicker:get_wielded_item()
|
||||
if item:get_name() == "farming:wheat" then
|
||||
if mobs:is_in_tbl({"farming:wheat", "farming:bread"}, item:get_name()) then
|
||||
if not self.tamed then
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
item:take_item()
|
||||
@ -242,6 +242,7 @@ mobs:register_mob("mobs:sheep", {
|
||||
})
|
||||
mobs:register_spawn("mobs:sheep", {"default:dirt_with_grass"}, 20, 8, 9000, 1, 31000)
|
||||
|
||||
|
||||
minetest.register_craftitem("mobs:meat_raw", {
|
||||
description = "Raw Meat",
|
||||
inventory_image = "mobs_meat_raw.png",
|
||||
@ -275,6 +276,7 @@ mobs:register_mob("mobs:rat", {
|
||||
water_damage = 0,
|
||||
lava_damage = 1,
|
||||
light_damage = 0,
|
||||
view_range = 3,
|
||||
|
||||
on_rightclick = function(self, clicker)
|
||||
if clicker:is_player() and clicker:get_inventory() then
|
||||
@ -297,6 +299,87 @@ minetest.register_craftitem("mobs:rat", {
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craftitem("mobs:sheep_egg", {
|
||||
description = "Sheep Egg",
|
||||
inventory_image = "mobs_sheep_egg.png",
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.above then
|
||||
minetest.env:add_entity(pointed_thing.above, "mobs:sheep")
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craftitem("mobs:dirt_monster_egg", {
|
||||
description = "Dirt Monster Egg",
|
||||
inventory_image = "mobs_dirt_monster_egg.png",
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.above then
|
||||
minetest.env:add_entity(pointed_thing.above, "mobs:dirt_monster")
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craftitem("mobs:sand_monster_egg", {
|
||||
description = "Sand Monster Egg",
|
||||
inventory_image = "mobs_sand_monster_egg.png",
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.above then
|
||||
minetest.env:add_entity(pointed_thing.above, "mobs:sand_monster")
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craftitem("mobs:stone_monster_egg", {
|
||||
description = "Stone Monster Egg",
|
||||
inventory_image = "mobs_stone_monster_egg.png",
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.above then
|
||||
minetest.env:add_entity(pointed_thing.above, "mobs:stone_monster")
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craftitem("mobs:dungeon_master_egg", {
|
||||
description = "Dungeon Master Egg",
|
||||
inventory_image = "mobs_dungeon_master_egg.png",
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.above then
|
||||
minetest.env:add_entity(pointed_thing.above, "mobs:dungeon_master")
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craftitem("mobs:oerkki_egg", {
|
||||
description = "Oerkki Egg",
|
||||
inventory_image = "mobs_oerkki_egg.png",
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.above then
|
||||
minetest.env:add_entity(pointed_thing.above, "mobs:oerkki")
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craftitem("mobs:rat_cooked", {
|
||||
description = "Cooked Rat",
|
||||
|
BIN
textures/mobs_dirt_monster_egg.png
Normal file
After Width: | Height: | Size: 294 B |
BIN
textures/mobs_dungeon_master_egg.png
Normal file
After Width: | Height: | Size: 291 B |
BIN
textures/mobs_oerkki_egg.png
Normal file
After Width: | Height: | Size: 291 B |
BIN
textures/mobs_sand_monster_egg.png
Normal file
After Width: | Height: | Size: 294 B |
BIN
textures/mobs_sheep_egg.png
Normal file
After Width: | Height: | Size: 284 B |
BIN
textures/mobs_stone_monster_egg.png
Normal file
After Width: | Height: | Size: 292 B |
BIN
textures/mobs_tree_monster_egg.png
Normal file
After Width: | Height: | Size: 278 B |