make eggs mroe agnostic, switch methods

This commit is contained in:
wsor 2021-07-01 22:25:00 -04:00
parent 1b126a0b43
commit 9f91aee192
7 changed files with 21 additions and 7 deletions

View File

@ -19,7 +19,7 @@ end
--dirty dev egg registration
function fl_wildlife.egg_it(t_name, d_name, color)
minetest.register_craftitem("fl_wildlife:" .. d_name .. "_egg", {
minetest.register_craftitem(":fl_wildlife:" .. d_name .. "_egg", {
description = "spawn egg for " .. d_name,
inventory_image = "farlands_egg.png^(farlands_egg_overlay.png^[colorize:" .. color .. ")", --"404.png",
stack_max = 99,
@ -34,6 +34,14 @@ function fl_wildlife.egg_it(t_name, d_name, color)
})
end
minetest.register_on_mods_loaded(function()
for mob, def in pairs(minetest.registered_entities) do
if def._egg_it then
fl_wildlife.egg_it(mob, def._egg_it[1], def._egg_it[2])
end
end
end)
--used from wildlife demo
function fl_wildlife.node_dps_dmg(self)
local pos = self.object:get_pos()

View File

@ -130,6 +130,7 @@ minetest.register_entity("fl_wildlife:cavecrab", {
},
brainfunc = cc_brain,
_egg_it = {"cavecrab", "#76716f"},
_spawner = {},
--more mte properties
@ -150,4 +151,4 @@ minetest.register_entity("fl_wildlife:cavecrab", {
end,
})
fl_wildlife.egg_it("fl_wildlife:cavecrab", "cavecrab", "#76716f")
--fl_wildlife.egg_it("fl_wildlife:cavecrab", "cavecrab", "#76716f")

View File

@ -67,6 +67,7 @@ minetest.register_entity("fl_wildlife:cow", {
},
brainfunc = cow_brain,
_egg_it = {"cow", "#100c0c"},
bucket = function(itemstack, user, self)
--very op, needs some time limit till can be milked again
@ -100,4 +101,4 @@ minetest.register_entity("fl_wildlife:cow", {
end,
})
fl_wildlife.egg_it("fl_wildlife:cow", "cow", "#100c0c")
--fl_wildlife.egg_it("fl_wildlife:cow", "cow", "#100c0c")

View File

@ -63,6 +63,7 @@ minetest.register_entity("fl_wildlife:riverfish", {
drops = "fl_wildlife.villager.drops",
brainfunc = fish_brain,
_egg_it = {"riverfish", "#978166"},
bucket = function(itemstack, user, self)
--note this gives a bucket that can place water, but fish doesnt have to be in water
@ -97,7 +98,7 @@ minetest.register_entity("fl_wildlife:riverfish", {
})
--register eggs
fl_wildlife.egg_it("fl_wildlife:riverfish", "riverfish", "#978166")
--fl_wildlife.egg_it("fl_wildlife:riverfish", "riverfish", "#978166")
--fish still jump out,
--fish die in pen on in water on base?

View File

@ -120,6 +120,7 @@ minetest.register_entity("fl_wildlife:sheep", {
brainfunc = sheep_brain,--villager_brain, --function for the brain
--_spawner = {},
_egg_it = {"sheep", "#a49b95"},
--more mte properties
on_punch=function(self, puncher, time_from_last_punch, tool_capabilities, dir)
@ -201,4 +202,4 @@ minetest.register_entity("fl_wildlife:sheep", {
end,
})
fl_wildlife.egg_it("fl_wildlife:sheep", "sheep", "#a49b95")
--fl_wildlife.egg_it("fl_wildlife:sheep", "sheep", "#a49b95")

View File

@ -36,6 +36,7 @@ minetest.register_entity("fl_wildlife:trader", {
drops = "fl_wildlife.trader.drops",
brainfunc = fl_brains.villager_brain,--villager_brain, --function for the brain
_egg_it = {"trader", "#3c521d"},
--experiments
on_rightclick = function(self, clicker)
@ -123,4 +124,4 @@ minetest.register_entity("fl_wildlife:trader", {
end,
})
fl_wildlife.egg_it("fl_wildlife:trader", "trader", "#3c521d")
--fl_wildlife.egg_it("fl_wildlife:trader", "trader", "#3c521d")

View File

@ -78,6 +78,7 @@ minetest.register_entity("fl_wildlife:villager", {
drops = "fl_wildlife.villager.drops",
brainfunc = fl_brains.villager_brain,--villager_brain, --function for the brain
_egg_it = {"villager", "#654321"},
--more mte properties
on_punch=function(self, puncher, time_from_last_punch, tool_capabilities, dir)
@ -97,4 +98,4 @@ minetest.register_entity("fl_wildlife:villager", {
})
--register eggs
fl_wildlife.egg_it("fl_wildlife:villager", "villager", "#654321")
--fl_wildlife.egg_it("fl_wildlife:villager", "villager", "#654321")