summaryrefslogtreecommitdiff
path: root/api.lua
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2018-07-01 14:08:17 +0100
committerTenPlus1 <kinsellaja@yahoo.com>2018-07-01 14:08:17 +0100
commit40416aa4fdf8cb12c3212e064af3c4d0f6c3a3f8 (patch)
tree0a000e0be4660bc91e62b79b99db9e285001be02 /api.lua
parente145fe098d8458fe75d841a6e26f2de189fcb685 (diff)
Added ToolRanks support when attacking mobs with tools/swords
Diffstat (limited to 'api.lua')
-rw-r--r--api.lua24
1 files changed, 22 insertions, 2 deletions
diff --git a/api.lua b/api.lua
index 5001f54..3ee2257 100644
--- a/api.lua
+++ b/api.lua
@@ -3,7 +3,7 @@
mobs = {}
mobs.mod = "redo"
-mobs.version = "20180627"
+mobs.version = "20180701"
-- Intllib
@@ -2313,6 +2313,9 @@ local falling = function(self, pos)
end
+-- is Took Ranks mod active?
+local tr = minetest.get_modpath("toolranks")
+
-- deal damage and effects when mob punched
local mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
@@ -2414,7 +2417,24 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
if weapon:get_definition()
and weapon:get_definition().tool_capabilities then
- weapon:add_wear(floor((punch_interval / 75) * 9000))
+ -- toolrank support
+ local wear = floor((punch_interval / 75) * 9000)
+
+ if mobs.is_creative(hitter:get_player_name()) then
+
+ if tr then
+ wear = 1
+ else
+ wear = 0
+ end
+ end
+
+ if tr then
+ weapon:add_wear(toolranks.new_afteruse(weapon, hitter, nil, {wear = wear}))
+ else
+ weapon:add_wear(wear)
+ end
+
hitter:set_wielded_item(weapon)
end