forked from mtcontrib/mobs_redo
tweak capture function
This commit is contained in:
parent
52cf9be8eb
commit
feb26ed940
19
api.lua
19
api.lua
|
@ -3060,6 +3060,14 @@ function mobs:capture_mob(self, clicker, chance_hand, chance_net, chance_lasso,
|
||||||
end
|
end
|
||||||
|
|
||||||
local name = clicker:get_player_name()
|
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?
|
-- is mob tamed?
|
||||||
if self.tamed == false
|
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!"))
|
minetest.chat_send_player(name, S("Not tamed!"))
|
||||||
|
|
||||||
return false
|
return true -- false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- cannot pick up if not owner
|
-- 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))
|
minetest.chat_send_player(name, S("@1 is owner!", self.owner))
|
||||||
|
|
||||||
return false
|
return true -- false
|
||||||
end
|
end
|
||||||
|
|
||||||
if clicker:get_inventory():room_for_item("main", mobname) then
|
if clicker:get_inventory():room_for_item("main", mobname) then
|
||||||
|
|
||||||
-- was mob clicked with hand, net, or lasso?
|
-- was mob clicked with hand, net, or lasso?
|
||||||
local tool = clicker:get_wielded_item()
|
|
||||||
local chance = 0
|
local chance = 0
|
||||||
|
|
||||||
if tool:is_empty() then
|
if tool:get_name() == "" then
|
||||||
chance = chance_hand
|
chance = chance_hand
|
||||||
|
|
||||||
elseif tool:get_name() == "mobs:net" then
|
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
|
tool:add_wear(650) -- 100 uses
|
||||||
|
|
||||||
clicker:set_wielded_item(tool)
|
clicker:set_wielded_item(tool)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- calculate chance.. add to inventory if successful?
|
-- 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()
|
self.object:remove()
|
||||||
|
|
||||||
return true
|
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(name, S("Missed!"))
|
minetest.chat_send_player(name, S("Missed!"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user