summaryrefslogtreecommitdiff
path: root/api.lua
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2017-04-27 14:37:30 +0100
committerTenPlus1 <kinsellaja@yahoo.com>2017-04-27 14:37:30 +0100
commitfeb26ed9401f244637362fad4f7fcc2300b11d8c (patch)
tree489b6dbfb41508c63972d8d5a8f84bb3770f1009 /api.lua
parent52cf9be8eb87ca9ab0b5fd1f1fcfd0bb8b91bbd1 (diff)
tweak capture function
Diffstat (limited to 'api.lua')
-rw-r--r--api.lua19
1 files changed, 13 insertions, 6 deletions
diff --git a/api.lua b/api.lua
index 6d352ed..9a48dc4 100644
--- a/api.lua
+++ b/api.lua
@@ -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