tweak capture function

This commit is contained in:
TenPlus1 2017-04-27 14:37:30 +01:00
parent 52cf9be8eb
commit feb26ed940
1 changed files with 13 additions and 6 deletions

19
api.lua
View File

@ -3060,6 +3060,14 @@ function mobs:capture_mob(self, clicker, chance_hand, chance_net, chance_lasso,
end
local name = clicker:get_player_name()
local tool = clicker:get_wielded_item()
-- are we using hand, net or lasso to pick up mob?
if tool:get_name() ~= ""
and tool:get_name() ~= "mobs:net"
and tool:get_name() ~= "mobs:magic_lasso" then
return false
end
-- is mob tamed?
if self.tamed == false
@ -3067,7 +3075,7 @@ function mobs:capture_mob(self, clicker, chance_hand, chance_net, chance_lasso,
minetest.chat_send_player(name, S("Not tamed!"))
return false
return true -- false
end
-- cannot pick up if not owner
@ -3076,16 +3084,15 @@ function mobs:capture_mob(self, clicker, chance_hand, chance_net, chance_lasso,
minetest.chat_send_player(name, S("@1 is owner!", self.owner))
return false
return true -- false
end
if clicker:get_inventory():room_for_item("main", mobname) then
-- was mob clicked with hand, net, or lasso?
local tool = clicker:get_wielded_item()
local chance = 0
if tool:is_empty() then
if tool:get_name() == "" then
chance = chance_hand
elseif tool:get_name() == "mobs:net" then
@ -3103,6 +3110,7 @@ function mobs:capture_mob(self, clicker, chance_hand, chance_net, chance_lasso,
tool:add_wear(650) -- 100 uses
clicker:set_wielded_item(tool)
end
-- calculate chance.. add to inventory if successful?
@ -3143,13 +3151,12 @@ function mobs:capture_mob(self, clicker, chance_hand, chance_net, chance_lasso,
self.object:remove()
return true
else
minetest.chat_send_player(name, S("Missed!"))
end
end
return false
return true
end