From 52a03d22cfab454d2b489cf8991a3e672f1640c0 Mon Sep 17 00:00:00 2001 From: Louis <55180044+louisroyer@users.noreply.github.com> Date: Wed, 12 Feb 2020 17:50:38 +0100 Subject: [PATCH] Change enable_toolranks to no_toolranks --- README.md | 4 ++-- init.lua | 10 +++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0e8aefa..bddaff9 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ throwing.bow_cooldown = 0.2 There are two available functions in the mod API: ```lua -function throwing.register_bow(name, definition, enable_toolranks) +function throwing.register_bow(name, definition, no_toolranks) --[[ Name: Bow name. If it doesn't contain ":", the "throwing:" prefix will be added. Definition: definition table, containing: @@ -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 -Enable_toolranks: Enable toolranks support on this item. Defaults to true. +No_toolranks: Disable toolranks support on this item. Defaults to false. ]] -- Example: diff --git a/init.lua b/init.lua index 46761dc..e4df821 100644 --- a/init.lua +++ b/init.lua @@ -304,11 +304,7 @@ end ---------- Bows ----------- -function throwing.register_bow(name, def, enable_toolranks) - if enable_toolranks == nil then - -- default value for enable_toolranks - enable_toolranks = true - end +function throwing.register_bow(name, def, no_toolranks) 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 @@ -359,7 +355,7 @@ function throwing.register_bow(name, def, enable_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 enable_toolranks then + if use_toolranks and not no_toolranks then toolranks.new_afteruse(itemstack, user, nil, {wear= uses}) end end @@ -380,7 +376,7 @@ function throwing.register_bow(name, def, enable_toolranks) return itemstack end minetest.register_tool(name, def) - if use_toolranks and enable_toolranks then + if use_toolranks and not no_toolranks then if name:sub(1, 1) == ":" then local sub_name = name:sub(2) end