no_toolranks in defs in throwing.register_bow

This commit is contained in:
Louis 2020-02-12 18:07:44 +01:00 committed by upsilon
parent 52db64c20c
commit 259386aa60
2 changed files with 6 additions and 5 deletions

View File

@ -49,7 +49,7 @@ Definition: definition table, containing:
* function spawn_arrow_entity(position, arrow, player): defaults to throwing.spawn_arrow_entity
* sound: sound to be played when the bow is used
* delay: delay before throwing the arrow
No_toolranks: Disable toolranks support on this item. Defaults to false.
* no_toolranks: Disable toolranks support on this item. Defaults to false.
]]
-- Example:

View File

@ -304,7 +304,8 @@ end
---------- Bows -----------
function throwing.register_bow(name, def, no_toolranks)
function throwing.register_bow(name, def)
local enable_toolrank = use_toolranks and not def.no_toolranks and not def.original_description
if not def.allow_shot then
def.allow_shot = function(player, itemstack, index)
if index >= player:get_inventory():get_size("main") and not def.throw_itself then
@ -355,8 +356,8 @@ function throwing.register_bow(name, def, no_toolranks)
if not minetest.settings:get_bool("creative_mode") then
local uses = 65535 / (def.uses or 50)
itemstack:add_wear(uses)
if use_toolranks and not no_toolranks then
toolranks.new_afteruse(itemstack, user, nil, {wear= uses})
if enable_toolranks then
toolranks.new_afteruse(itemstack, user, nil, {wear = uses})
end
end
end
@ -375,7 +376,7 @@ function throwing.register_bow(name, def, no_toolranks)
end)
return itemstack
end
if use_toolranks and not no_toolranks and not def.original_description then
if enable_toolranks then
def.original_description = def.description
def.description = toolranks.create_description(def.description, 0, 1)
end