1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-12-24 01:30:38 +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.mod = "redo"
@ -236,7 +236,7 @@ function mobs:register_mob(name, def)
if v.y > 0.1 then
self.object:setacceleration({
x = 0,
y= self.fall_speed,
y = self.fall_speed,
z = 0
})
end
@ -347,7 +347,7 @@ function mobs:register_mob(name, def)
if self.jumptimer < 3 then
local pos = self.object:getpos()
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)
if not nod
or not minetest.registered_nodes[nod.name]
@ -355,7 +355,7 @@ function mobs:register_mob(name, def)
return
end
if self.direction then
pos.y = pos.y + 0.5
pos.y = pos.y + 0.5
local nod = minetest.get_node_or_nil({
x = pos.x + self.direction.x,
y = pos.y,

View File

@ -50,7 +50,7 @@ mobs:register_mob("mobs:bunny", {
replace_with = "air",
-- right click to pick up rabbit
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
local item = clicker:get_wielded_item()
if item:get_name() == "mobs:lava_orb" then

View File

@ -58,7 +58,7 @@ mobs:register_mob("mobs:chicken", {
replace_what = {"air"},
replace_with = "mobs:egg",
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)
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_with = "air",
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()
-- milk cow with empty bucket

View File

@ -47,9 +47,9 @@ mobs:register_mob("mobs:kitten", {
view_range = 10,
-- feed with raw fish to tame or right click to pick up
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)
end
})
mobs:spawn_specific("mobs:kitten", {"default:dirt_with_grass"}, {"air"}, 0, 20, 30, 10000, 1, -31000, 31000, true)
mobs:register_egg("mobs:kitten", "Kitten", "mobs_kitten_inv.png", 0)
mobs:register_egg("mobs:kitten", "Kitten", "mobs_kitten_inv.png", 0)

View File

@ -91,7 +91,7 @@ mobs:register_mob("mobs:npc", {
end
return
-- 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
if item:get_name() == "default:gold_lump" then
if not minetest.setting_getbool("creative_mode") then

View File

@ -95,7 +95,7 @@ mobs:register_mob("mobs:npc_female", {
end
return
-- 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
if item:get_name() == "default:gold_lump" then
if not minetest.setting_getbool("creative_mode") then

View File

@ -68,7 +68,7 @@ for _, col in ipairs(all_colours) do
end
--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 self.gotten == false then
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)
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)
end,
})
@ -83,4 +83,4 @@ minetest.register_craft({
output = "mobs:pork_cooked",
recipe = "mobs:pork_raw",
cooktime = 5,
})
})