summaryrefslogtreecommitdiff
path: root/api.lua
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2016-11-08 16:11:00 +0000
committerTenPlus1 <kinsellaja@yahoo.com>2016-11-08 16:11:00 +0000
commit127dad97a799a619d64e6dd77e741844caeec91e (patch)
treee0085dbbffcf12bd2a163117d5e3bb8bd1d552e8 /api.lua
parentc16c083d31242dc79d7dfa581c393fd2affc6d08 (diff)
added ability to protect tamed mobs
Diffstat (limited to 'api.lua')
-rw-r--r--api.lua35
1 files changed, 34 insertions, 1 deletions
diff --git a/api.lua b/api.lua
index 1c27238..bd9e969 100644
--- a/api.lua
+++ b/api.lua
@@ -1,5 +1,5 @@
--- Mobs Api (31st October 2016)
+-- Mobs Api (8th November 2016)
mobs = {}
mobs.mod = "redo"
@@ -1848,6 +1848,14 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
return
end
+-- is mob protected?
+if self.protected
+and minetest.is_protected(self.object:getpos(), hitter:get_player_name()) then
+ minetest.chat_send_player(hitter:get_player_name(), "Mob has been protected!")
+ return
+end
+
+
-- weapon wear
local weapon = hitter:get_wielded_item()
local punch_interval = 1.4
@@ -2949,6 +2957,31 @@ function mobs:capture_mob(self, clicker, chance_hand, chance_net, chance_lasso,
end
end
+-- protect tamed mob with rune iten
+function mobs:protect(self, clicker)
+
+ if self.tamed == false then
+ minetest.chat_send_player(name, S("Not tamed!"))
+ return false
+ end
+
+ local tool = clicker:get_wielded_item()
+ local name = clicker:get_player_name()
+
+ if tool:get_name() == "mobs:protector" then
+
+ tool:take_item() -- take 1 protection rune
+ clicker:set_wielded_item(tool)
+
+ self.protected = true
+ minetest.chat_send_player(name, S("Protected!"))
+
+ return true
+ end
+
+ return false
+end
+
local mob_obj = {}
local mob_sta = {}