mirror of
https://github.com/minetest-mods/throwing.git
synced 2025-07-04 17:30:26 +02:00
no_toolranks in defs in throwing.register_bow
This commit is contained in:
@ -49,7 +49,7 @@ Definition: definition table, containing:
|
|||||||
* function spawn_arrow_entity(position, arrow, player): defaults to throwing.spawn_arrow_entity
|
* function spawn_arrow_entity(position, arrow, player): defaults to throwing.spawn_arrow_entity
|
||||||
* sound: sound to be played when the bow is used
|
* sound: sound to be played when the bow is used
|
||||||
* delay: delay before throwing the arrow
|
* 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:
|
-- Example:
|
||||||
|
7
init.lua
7
init.lua
@ -304,7 +304,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
---------- Bows -----------
|
---------- 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
|
if not def.allow_shot then
|
||||||
def.allow_shot = function(player, itemstack, index)
|
def.allow_shot = function(player, itemstack, index)
|
||||||
if index >= player:get_inventory():get_size("main") and not def.throw_itself then
|
if index >= player:get_inventory():get_size("main") and not def.throw_itself then
|
||||||
@ -355,7 +356,7 @@ function throwing.register_bow(name, def, no_toolranks)
|
|||||||
if not minetest.settings:get_bool("creative_mode") then
|
if not minetest.settings:get_bool("creative_mode") then
|
||||||
local uses = 65535 / (def.uses or 50)
|
local uses = 65535 / (def.uses or 50)
|
||||||
itemstack:add_wear(uses)
|
itemstack:add_wear(uses)
|
||||||
if use_toolranks and not no_toolranks then
|
if enable_toolranks then
|
||||||
toolranks.new_afteruse(itemstack, user, nil, {wear = uses})
|
toolranks.new_afteruse(itemstack, user, nil, {wear = uses})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -375,7 +376,7 @@ function throwing.register_bow(name, def, no_toolranks)
|
|||||||
end)
|
end)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
if use_toolranks and not no_toolranks and not def.original_description then
|
if enable_toolranks then
|
||||||
def.original_description = def.description
|
def.original_description = def.description
|
||||||
def.description = toolranks.create_description(def.description, 0, 1)
|
def.description = toolranks.create_description(def.description, 0, 1)
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user