Add toolranks support (#4)

This commit is contained in:
Louis Royer 2020-07-18 00:19:50 +02:00 committed by GitHub
parent 3f3b140265
commit 3b515295f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 11 deletions

View File

@ -10,5 +10,5 @@ read_globals = {
string = {fields = {"split", "trim"}}, string = {fields = {"split", "trim"}},
table = {fields = {"copy", "getn"}}, table = {fields = {"copy", "getn"}},
"armor", "PseudoRandom", "armor", "PseudoRandom", "toolranks",
} }

View File

@ -22,7 +22,7 @@ USA
========================================================================== ==========================================================================
Dependencies: default (included in minetest_game) Dependencies: default (included in minetest_game)
Optional dependencies: 3D Armor Optional dependencies: 3D Armor, ToolRanks
--]] --]]
-- Translation support -- Translation support
@ -283,8 +283,11 @@ minetest.register_craftitem("cloud_items:cloud_ingot", {
-- Tools -- -- Tools --
------------ ------------
local toolranks_loaded = minetest.get_modpath("toolranks")
local sword_desc = S("Cloud Sword")
minetest.register_tool("cloud_items:cloud_sword", { minetest.register_tool("cloud_items:cloud_sword", {
description = S("Cloud Sword"), description = toolranks_loaded and toolranks.create_description(sword_desc) or sword_desc,
inventory_image = "cloud_items_tool_cloudsword.png", inventory_image = "cloud_items_tool_cloudsword.png",
range = 5, range = 5,
tool_capabilities = { tool_capabilities = {
@ -296,11 +299,15 @@ minetest.register_tool("cloud_items:cloud_sword", {
damage_groups = {fleshy=11}, damage_groups = {fleshy=11},
}, },
sound = {breaks = "default_tool_breaks"}, sound = {breaks = "default_tool_breaks"},
groups = {sword = 1} groups = {sword = 1},
-- toolranks support
original_description = toolranks_loaded and sword_desc or nil,
after_use = toolranks_loaded and toolranks.new_afteruse or nil,
}) })
local pickaxe_desc = S("Cloud Pickaxe")
minetest.register_tool("cloud_items:cloud_pickaxe", { minetest.register_tool("cloud_items:cloud_pickaxe", {
description = S("Cloud Pickaxe"), description = toolranks_loaded and toolranks.create_description(pickaxe_desc) or pickaxe_desc,
inventory_image = "cloud_items_tool_cloudpick.png", inventory_image = "cloud_items_tool_cloudpick.png",
tool_capabilities = { tool_capabilities = {
full_punch_interval = 0.9, full_punch_interval = 0.9,
@ -311,11 +318,15 @@ minetest.register_tool("cloud_items:cloud_pickaxe", {
damage_groups = {fleshy=6}, damage_groups = {fleshy=6},
}, },
sound = {breaks = "default_tool_breaks"}, sound = {breaks = "default_tool_breaks"},
groups = {pickaxe = 1} groups = {pickaxe = 1},
-- toolranks support
original_description = toolranks_loaded and pickaxe_desc or nil,
after_use = toolranks_loaded and toolranks.new_afteruse or nil,
}) })
local shovel_desc = S("Cloud Shovel")
minetest.register_tool("cloud_items:cloud_shovel", { minetest.register_tool("cloud_items:cloud_shovel", {
description = S("Cloud Shovel"), description = toolranks_loaded and toolranks.create_description(pickaxe_desc) or shovel_desc,
inventory_image = "cloud_items_tool_cloudshovel.png", inventory_image = "cloud_items_tool_cloudshovel.png",
wield_image = "cloud_items_tool_cloudshovel.png^[transformR90", wield_image = "cloud_items_tool_cloudshovel.png^[transformR90",
tool_capabilities = { tool_capabilities = {
@ -327,11 +338,15 @@ minetest.register_tool("cloud_items:cloud_shovel", {
damage_groups = {fleshy=4.50}, damage_groups = {fleshy=4.50},
}, },
sound = {breaks = "default_tool_breaks"}, sound = {breaks = "default_tool_breaks"},
groups = {shovel = 1} groups = {shovel = 1},
-- toolranks support
original_description = toolranks_loaded and shovel_desc or nil,
after_use = toolranks_loaded and toolranks.new_afteruse or nil,
}) })
local axe_desc = S("Cloud Axe")
minetest.register_tool("cloud_items:cloud_axe", { minetest.register_tool("cloud_items:cloud_axe", {
description = S("Cloud Axe"), description = toolranks_loaded and toolranks.create_description(pickaxe_desc) or axe_desc,
inventory_image = "cloud_items_tool_cloudaxe.png", inventory_image = "cloud_items_tool_cloudaxe.png",
tool_capabilities = { tool_capabilities = {
full_punch_interval = 0.9, full_punch_interval = 0.9,
@ -342,7 +357,10 @@ minetest.register_tool("cloud_items:cloud_axe", {
damage_groups = {fleshy=7.50}, damage_groups = {fleshy=7.50},
}, },
sound = {breaks = "default_tool_breaks"}, sound = {breaks = "default_tool_breaks"},
groups = {axe = 1} groups = {axe = 1},
-- toolranks support
original_description = toolranks_loaded and axe_desc or nil,
after_use = toolranks_loaded and toolranks.new_afteruse or nil,
}) })
------------- -------------

View File

@ -1,6 +1,6 @@
name = cloud_items name = cloud_items
depends = default depends = default
optional_depends = 3d_armor optional_depends = 3d_armor, toolranks
description = Adds powerful cloud tools for Minetest. description = Adds powerful cloud tools for Minetest.
min_minetest_version = 5.0.0 min_minetest_version = 5.0.0
license = LGPLv2.1 license = LGPLv2.1