1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-12-25 18:20:36 +01:00

update mobs, fix tame and tidy code

This commit is contained in:
crabman77 2015-09-22 00:01:24 +02:00
parent 428127f43d
commit a038ed0128
9 changed files with 14 additions and 14 deletions

View File

@ -1,4 +1,4 @@
-- Mobs Api (9th September 2015) -- Mobs Api (17th September 2015)
mobs = {} mobs = {}
mobs.mod = "redo" mobs.mod = "redo"
@ -236,7 +236,7 @@ function mobs:register_mob(name, def)
if v.y > 0.1 then if v.y > 0.1 then
self.object:setacceleration({ self.object:setacceleration({
x = 0, x = 0,
y= self.fall_speed, y = self.fall_speed,
z = 0 z = 0
}) })
end end
@ -347,7 +347,7 @@ function mobs:register_mob(name, def)
if self.jumptimer < 3 then if self.jumptimer < 3 then
local pos = self.object:getpos() local pos = self.object:getpos()
pos.y = (pos.y + self.collisionbox[2]) - 0.2 pos.y = (pos.y + self.collisionbox[2]) - 0.2
local nod = minetest.get_node(pos) local nod = minetest.get_node_or_nil(pos)
--print ("standing on:", nod.name, pos.y) --print ("standing on:", nod.name, pos.y)
if not nod if not nod
or not minetest.registered_nodes[nod.name] or not minetest.registered_nodes[nod.name]

View File

@ -50,7 +50,7 @@ mobs:register_mob("mobs:bunny", {
replace_with = "air", replace_with = "air",
-- right click to pick up rabbit -- right click to pick up rabbit
on_rightclick = function(self, clicker) on_rightclick = function(self, clicker)
if not mobs:feed_tame(self, clicker, 4, true) then if not mobs:feed_tame(self, clicker, 4, true, true) then
-- Monty Python tribute -- Monty Python tribute
local item = clicker:get_wielded_item() local item = clicker:get_wielded_item()
if item:get_name() == "mobs:lava_orb" then if item:get_name() == "mobs:lava_orb" then

View File

@ -58,7 +58,7 @@ mobs:register_mob("mobs:chicken", {
replace_what = {"air"}, replace_what = {"air"},
replace_with = "mobs:egg", replace_with = "mobs:egg",
on_rightclick = function(self, clicker) on_rightclick = function(self, clicker)
mobs:feed_tame(self, clicker, 8, true) mobs:feed_tame(self, clicker, 8, true, true)
mobs:capture_mob(self, clicker, 30, 50, 80, false, nil) mobs:capture_mob(self, clicker, 30, 50, 80, false, nil)
end, end,
}) })

View File

@ -59,7 +59,7 @@ mobs:register_mob("mobs:cow", {
replace_what = {"default:grass_3", "default:grass_4", "default:grass_5", "farming:wheat_8"}, replace_what = {"default:grass_3", "default:grass_4", "default:grass_5", "farming:wheat_8"},
replace_with = "air", replace_with = "air",
on_rightclick = function(self, clicker) on_rightclick = function(self, clicker)
if not mobs:feed_tame(self, clicker, 8, true) then if not mobs:feed_tame(self, clicker, 8, true, true) then
local tool = clicker:get_wielded_item() local tool = clicker:get_wielded_item()
-- milk cow with empty bucket -- milk cow with empty bucket

View File

@ -47,7 +47,7 @@ mobs:register_mob("mobs:kitten", {
view_range = 10, view_range = 10,
-- feed with raw fish to tame or right click to pick up -- feed with raw fish to tame or right click to pick up
on_rightclick = function(self, clicker) on_rightclick = function(self, clicker)
mobs:feed_tame(self, clicker, 4, true) mobs:feed_tame(self, clicker, 4, true, true)
mobs:capture_mob(self, clicker, 50, 50, 90, false, nil) mobs:capture_mob(self, clicker, 50, 50, 90, false, nil)
end end
}) })

View File

@ -91,7 +91,7 @@ mobs:register_mob("mobs:npc", {
end end
return return
-- feed to heal npc -- feed to heal npc
elseif not mobs:feed_tame(self, clicker, 8, true) then elseif not mobs:feed_tame(self, clicker, 8, true, true) then
-- right clicking with gold lump drops random item from mobs.npc_drops -- right clicking with gold lump drops random item from mobs.npc_drops
if item:get_name() == "default:gold_lump" then if item:get_name() == "default:gold_lump" then
if not minetest.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then

View File

@ -95,7 +95,7 @@ mobs:register_mob("mobs:npc_female", {
end end
return return
-- feed to heal npc -- feed to heal npc
elseif not mobs:feed_tame(self, clicker, 8, true) then elseif not mobs:feed_tame(self, clicker, 8, true, true) then
-- right clicking with gold lump drops random item from mobs.npc_drops -- right clicking with gold lump drops random item from mobs.npc_drops
if item:get_name() == "default:gold_lump" then if item:get_name() == "default:gold_lump" then
if not minetest.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then

View File

@ -68,7 +68,7 @@ for _, col in ipairs(all_colours) do
end end
--are we feeding? --are we feeding?
if mobs:feed_tame(self, clicker, 8, true) then if mobs:feed_tame(self, clicker, 8, true, true) then
--if full grow fuzz --if full grow fuzz
if self.gotten == false then if self.gotten == false then
self.object:set_properties({ self.object:set_properties({

View File

@ -55,7 +55,7 @@ mobs:register_mob("mobs:pumba", {
}, },
-- can be tamed by feeding 8 wheat (will not attack when tamed) -- can be tamed by feeding 8 wheat (will not attack when tamed)
on_rightclick = function(self, clicker) on_rightclick = function(self, clicker)
mobs:feed_tame(self, clicker, 8, true) mobs:feed_tame(self, clicker, 8, true, true)
mobs:capture_mob(self, clicker, 0, 5, 50, false, nil) mobs:capture_mob(self, clicker, 0, 5, 50, false, nil)
end, end,
}) })