mirror of
https://github.com/minetest-mods/throwing.git
synced 2024-09-27 15:00:21 +02:00
Toolranks support: minor changes
Reword documentation in README.md, fix a typo in init.lua and enable toolranks even if def.original_description exists---but do not overwrite it.
This commit is contained in:
parent
259386aa60
commit
4e9e6a8596
|
@ -26,7 +26,7 @@ throwing.bow_cooldown = 0.2
|
||||||
|
|
||||||
There are two available functions in the mod API:
|
There are two available functions in the mod API:
|
||||||
```lua
|
```lua
|
||||||
function throwing.register_bow(name, definition, no_toolranks)
|
function throwing.register_bow(name, definition)
|
||||||
--[[
|
--[[
|
||||||
Name: Bow name. If it doesn't contain ":", the "throwing:" prefix will be added.
|
Name: Bow name. If it doesn't contain ":", the "throwing:" prefix will be added.
|
||||||
Definition: definition table, containing:
|
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
|
* 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: If true, toolranks support is disabled for this item. Defaults to false.
|
||||||
]]
|
]]
|
||||||
|
|
||||||
-- Example:
|
-- Example:
|
||||||
|
|
4
init.lua
4
init.lua
|
@ -305,7 +305,7 @@ end
|
||||||
|
|
||||||
---------- Bows -----------
|
---------- Bows -----------
|
||||||
function throwing.register_bow(name, def)
|
function throwing.register_bow(name, def)
|
||||||
local enable_toolrank = use_toolranks and not def.no_toolranks and not def.original_description
|
local enable_toolranks = use_toolranks and not def.no_toolranks
|
||||||
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
|
||||||
|
@ -377,7 +377,7 @@ function throwing.register_bow(name, def)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
if enable_toolranks then
|
if enable_toolranks then
|
||||||
def.original_description = def.description
|
def.original_description = def.original_description or def.description
|
||||||
def.description = toolranks.create_description(def.description, 0, 1)
|
def.description = toolranks.create_description(def.description, 0, 1)
|
||||||
end
|
end
|
||||||
minetest.register_tool(name, def)
|
minetest.register_tool(name, def)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user