mods that hopefully work for a TechAge-based pack
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
Creative Commons Legal Code
|
||||
|
||||
CC0 1.0 Universal
|
||||
|
||||
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
||||
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
||||
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
||||
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
||||
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
||||
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
||||
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
||||
HEREUNDER.
|
||||
|
||||
Statement of Purpose
|
||||
|
||||
The laws of most jurisdictions throughout the world automatically confer
|
||||
exclusive Copyright and Related Rights (defined below) upon the creator
|
||||
and subsequent owner(s) (each and all, an "owner") of an original work of
|
||||
authorship and/or a database (each, a "Work").
|
||||
|
||||
Certain owners wish to permanently relinquish those rights to a Work for
|
||||
the purpose of contributing to a commons of creative, cultural and
|
||||
scientific works ("Commons") that the public can reliably and without fear
|
||||
of later claims of infringement build upon, modify, incorporate in other
|
||||
works, reuse and redistribute as freely as possible in any form whatsoever
|
||||
and for any purposes, including without limitation commercial purposes.
|
||||
These owners may contribute to the Commons to promote the ideal of a free
|
||||
culture and the further production of creative, cultural and scientific
|
||||
works, or to gain reputation or greater distribution for their Work in
|
||||
part through the use and efforts of others.
|
||||
|
||||
For these and/or other purposes and motivations, and without any
|
||||
expectation of additional consideration or compensation, the person
|
||||
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
||||
is an owner of Copyright and Related Rights in the Work, voluntarily
|
||||
elects to apply CC0 to the Work and publicly distribute the Work under its
|
||||
terms, with knowledge of his or her Copyright and Related Rights in the
|
||||
Work and the meaning and intended legal effect of CC0 on those rights.
|
||||
|
||||
1. Copyright and Related Rights. A Work made available under CC0 may be
|
||||
protected by copyright and related or neighboring rights ("Copyright and
|
||||
Related Rights"). Copyright and Related Rights include, but are not
|
||||
limited to, the following:
|
||||
|
||||
i. the right to reproduce, adapt, distribute, perform, display,
|
||||
communicate, and translate a Work;
|
||||
ii. moral rights retained by the original author(s) and/or performer(s);
|
||||
iii. publicity and privacy rights pertaining to a person's image or
|
||||
likeness depicted in a Work;
|
||||
iv. rights protecting against unfair competition in regards to a Work,
|
||||
subject to the limitations in paragraph 4(a), below;
|
||||
v. rights protecting the extraction, dissemination, use and reuse of data
|
||||
in a Work;
|
||||
vi. database rights (such as those arising under Directive 96/9/EC of the
|
||||
European Parliament and of the Council of 11 March 1996 on the legal
|
||||
protection of databases, and under any national implementation
|
||||
thereof, including any amended or successor version of such
|
||||
directive); and
|
||||
vii. other similar, equivalent or corresponding rights throughout the
|
||||
world based on applicable law or treaty, and any national
|
||||
implementations thereof.
|
||||
|
||||
2. Waiver. To the greatest extent permitted by, but not in contravention
|
||||
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
||||
irrevocably and unconditionally waives, abandons, and surrenders all of
|
||||
Affirmer's Copyright and Related Rights and associated claims and causes
|
||||
of action, whether now known or unknown (including existing as well as
|
||||
future claims and causes of action), in the Work (i) in all territories
|
||||
worldwide, (ii) for the maximum duration provided by applicable law or
|
||||
treaty (including future time extensions), (iii) in any current or future
|
||||
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
||||
including without limitation commercial, advertising or promotional
|
||||
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
||||
member of the public at large and to the detriment of Affirmer's heirs and
|
||||
successors, fully intending that such Waiver shall not be subject to
|
||||
revocation, rescission, cancellation, termination, or any other legal or
|
||||
equitable action to disrupt the quiet enjoyment of the Work by the public
|
||||
as contemplated by Affirmer's express Statement of Purpose.
|
||||
|
||||
3. Public License Fallback. Should any part of the Waiver for any reason
|
||||
be judged legally invalid or ineffective under applicable law, then the
|
||||
Waiver shall be preserved to the maximum extent permitted taking into
|
||||
account Affirmer's express Statement of Purpose. In addition, to the
|
||||
extent the Waiver is so judged Affirmer hereby grants to each affected
|
||||
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
||||
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
||||
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
||||
maximum duration provided by applicable law or treaty (including future
|
||||
time extensions), (iii) in any current or future medium and for any number
|
||||
of copies, and (iv) for any purpose whatsoever, including without
|
||||
limitation commercial, advertising or promotional purposes (the
|
||||
"License"). The License shall be deemed effective as of the date CC0 was
|
||||
applied by Affirmer to the Work. Should any part of the License for any
|
||||
reason be judged legally invalid or ineffective under applicable law, such
|
||||
partial invalidity or ineffectiveness shall not invalidate the remainder
|
||||
of the License, and in such case Affirmer hereby affirms that he or she
|
||||
will not (i) exercise any of his or her remaining Copyright and Related
|
||||
Rights in the Work or (ii) assert any associated claims and causes of
|
||||
action with respect to the Work, in either case contrary to Affirmer's
|
||||
express Statement of Purpose.
|
||||
|
||||
4. Limitations and Disclaimers.
|
||||
|
||||
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
||||
surrendered, licensed or otherwise affected by this document.
|
||||
b. Affirmer offers the Work as-is and makes no representations or
|
||||
warranties of any kind concerning the Work, express, implied,
|
||||
statutory or otherwise, including without limitation warranties of
|
||||
title, merchantability, fitness for a particular purpose, non
|
||||
infringement, or the absence of latent or other defects, accuracy, or
|
||||
the present or absence of errors, whether or not discoverable, all to
|
||||
the greatest extent permissible under applicable law.
|
||||
c. Affirmer disclaims responsibility for clearing rights of other persons
|
||||
that may apply to the Work or any use thereof, including without
|
||||
limitation any person's Copyright and Related Rights in the Work.
|
||||
Further, Affirmer disclaims responsibility for obtaining any necessary
|
||||
consents, permissions or other rights required for any use of the
|
||||
Work.
|
||||
d. Affirmer understands and acknowledges that Creative Commons is not a
|
||||
party to this document and has no duty or obligation with respect to
|
||||
this CC0 or use of the Work.
|
||||
@@ -0,0 +1,35 @@
|
||||
# Toolranks Extras
|
||||
|
||||
 [](https://content.minetest.net/packages/louisroyer/toolranks_extras/) [](https://content.minetest.net/packages/louisroyer/toolranks_extras/)
|
||||
|
||||
This minetest mod extends [toolranks](https://github.com/lisacvuk/minetest-toolranks). It adds support for `minetest-games`’s mods (except `default`).
|
||||
This mod currently adds support for hoes from `farming` mod.
|
||||
This mod is compatible with [farming redo](https://notabug.org/tenplus1/farming) (nothing breaks if you have both installed).
|
||||
|
||||
This mod also adds an API to register new types of tools for toolranks.
|
||||
|
||||
## API
|
||||
|
||||
```lua
|
||||
--[[
|
||||
-- `keyword` is a string to be detected in tool description
|
||||
-- `tool_type` is a localized tool type (if nil, then unregister the keyword)
|
||||
-- `node_dug_display` is an (optional) alternative localized display
|
||||
-- of "Node Dug" (if false, then unregister the display)
|
||||
--]]
|
||||
toolranks_extras.register_tool_type(keyword, tool_type, [node_dug_display])
|
||||
|
||||
-- example
|
||||
toolranks_extras.register_tool_type("battle_axe", S("battle axe"))
|
||||
toolranks_extras.register_tool_type("bow", S("bow"), S("Arrows thrown"))
|
||||
```
|
||||
|
||||

|
||||
|
||||
## License
|
||||
- CC0-1.0, Louis Royer 2020
|
||||
|
||||
## Settings
|
||||
- Settings are available to disable support of some mods (currently only `farming`). This is useful if you want to reimplement minetest-games modules
|
||||
with a `toolranks` support. It is also possible to ask me to automatically disabling support if your mod is detected (like it is done with farming redo).
|
||||
- Extras tool types registering can be disabled (registering function will still be available, but will do nothing).
|
||||
@@ -0,0 +1,49 @@
|
||||
local function add_hoe(material)
|
||||
-- registering as tool
|
||||
local name = "farming:hoe_"..material
|
||||
toolranks.add_tool(name)
|
||||
|
||||
-- getting after_use
|
||||
local def = minetest.registered_items[name]
|
||||
local hoe_on_use = def.on_use
|
||||
local hoe_after_use = def.after_use
|
||||
|
||||
if (hoe_on_use == nil) or (hoe_after_use == nil) then
|
||||
return
|
||||
end
|
||||
minetest.override_item(name, {
|
||||
-- we also want hoes to increase dugnodes when farming soil
|
||||
on_use = function(itemstack, user, pointed_thing, uses)
|
||||
-- if no node is pointed, the hoe cannot be used
|
||||
if pointed_thing.under == nil then
|
||||
return nil
|
||||
end
|
||||
local under = minetest.get_node(pointed_thing.under)
|
||||
-- get origin wear
|
||||
local wear = itemstack:get_wear()
|
||||
-- apply previous on_use
|
||||
local ret_itemstack = hoe_on_use(itemstack, user, pointed_thing, uses)
|
||||
if ret_itemstack == nil then
|
||||
return nil
|
||||
end
|
||||
-- compute wear diff
|
||||
local hoe_uses = ret_itemstack:get_wear() - wear
|
||||
-- set wear back because it is up to hoe_after_use to add wear
|
||||
ret_itemstack:set_wear(wear)
|
||||
-- apply afteruse
|
||||
return hoe_after_use(ret_itemstack, user, under, {wear = hoe_uses})
|
||||
end
|
||||
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
add_hoe("wood")
|
||||
add_hoe("stone")
|
||||
add_hoe("steel")
|
||||
|
||||
-- Following hoes are not available in creative inventory, but
|
||||
-- it is possible to /give them
|
||||
add_hoe("bronze")
|
||||
add_hoe("mese")
|
||||
add_hoe("diamond")
|
||||
@@ -0,0 +1,42 @@
|
||||
local MP = minetest.get_modpath("toolranks_extras")
|
||||
|
||||
toolranks_extras = {}
|
||||
|
||||
-- mod information
|
||||
toolranks_extras.mod = {version = "1.4.2", author = "Louis Royer"}
|
||||
|
||||
-- settings
|
||||
toolranks_extras.settings = {
|
||||
enable_farming_tools = minetest.settings:get_bool("toolranks_extras.farming", true),
|
||||
enable_tool_types = minetest.settings:get_bool("toolranks_extras.tool_types", true),
|
||||
}
|
||||
|
||||
-- XXX: when https://github.com/minetest/minetest/pull/7377
|
||||
-- is merged, we can remove this function
|
||||
-- and %s/toolranks_extras\.log/minetest\.log/g
|
||||
toolranks_extras.log = function(level, text)
|
||||
local prefix = "[toolranks_extra] "
|
||||
if text then
|
||||
minetest.log(level, prefix..text)
|
||||
else
|
||||
minetest.log(prefix..level)
|
||||
end
|
||||
end
|
||||
|
||||
-- mods detection
|
||||
local use_farming = minetest.get_modpath("farming")
|
||||
-- farming redo (https://notabug.org/tenplus1/farming)
|
||||
-- already implements toolranks support
|
||||
local use_farming_redo = use_farming and (farming.mod == "redo") or false
|
||||
|
||||
-- toolranks version
|
||||
if toolranks.add_tool == nil then
|
||||
toolranks_extras.log("error", "Please a more recent version of"
|
||||
.." toolranks (at least version 1.2).")
|
||||
end
|
||||
|
||||
dofile(MP.."/tool_types.lua")
|
||||
if use_farming and (not use_farming_redo)
|
||||
and toolranks_extras.settings.enable_farming_tools then
|
||||
dofile(MP.."/hoe.lua")
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
# textdomain: toolranks_extras
|
||||
|
||||
|
||||
### tool_types.lua ###
|
||||
|
||||
@1@2@n@3Level @4 @5@n@6@7: @8=
|
||||
@@ -0,0 +1,6 @@
|
||||
# textdomain: toolranks_extras
|
||||
|
||||
|
||||
### tool_types.lua ###
|
||||
|
||||
@1@2@n@3Level @4 @5@n@6@7: @8=@1@2@n@3@5 niveau @4@n@6@7 : @8
|
||||
@@ -0,0 +1,5 @@
|
||||
name = toolranks_extras
|
||||
description = Extended Tool Ranks support.
|
||||
depends = toolranks
|
||||
optional_depends = farming
|
||||
min_minetest_version = 5.0
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
@@ -0,0 +1,2 @@
|
||||
toolranks_extras.farming (Enable toolranks on farming tools) bool true
|
||||
toolranks_extras.tool_types (Enable registering of extras tool types) bool true
|
||||
@@ -0,0 +1,110 @@
|
||||
local S = minetest.get_translator("toolranks_extras")
|
||||
toolranks_extras.registered_tool_types = {}
|
||||
toolranks_extras.node_dug_display = {}
|
||||
--[[
|
||||
-- `keyword` is a string to be detected in tool description
|
||||
-- `tool_type` is a localized tool type (if nil, then unregister the keyword)
|
||||
-- `node_dug_display` is an (optional) alternative localized display
|
||||
-- of "Node Dug" (if false, then unregister the display)
|
||||
-- example
|
||||
-- `toolranks_extras.register_tool_type("battle_axe", S("battle axe"))`
|
||||
-- `toolranks_extras.register_tool_type("bow", S("bow"), S("Arrows thrown"))`
|
||||
--]]
|
||||
toolranks_extras.register_tool_type = function(keyword, tool_type, node_dug_display)
|
||||
local k = string.lower(keyword)
|
||||
toolranks_extras.registered_tool_types[k] = tool_type
|
||||
if node_dug_display == false then
|
||||
toolranks_extras.node_dug_display[k] = nil
|
||||
elseif node_dug_display ~= nil then
|
||||
toolranks_extras.node_dug_display[k] = node_dug_display
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
-- Returns alternative node dug display if registered, or nil.
|
||||
--]]
|
||||
toolranks_extras.get_node_dug_display = function(description)
|
||||
local d = string.lower(description)
|
||||
for k, desc in pairs(toolranks_extras.node_dug_display) do
|
||||
if string.find(d, k) then
|
||||
return desc
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
toolranks_extras.ignored_toolranks_tool_types = {}
|
||||
--[[
|
||||
-- `keyword` is a string to be detected in tool description
|
||||
-- `tool_type` is a localized tool type
|
||||
--
|
||||
-- example
|
||||
-- `toolranks_extras.ignore_toolranks_tool_type("pickaxe")`
|
||||
-- This only works with tool types built in toolranks default get_tool_types function.
|
||||
--]]
|
||||
toolranks_extras.ignore_toolranks_tool_type = function(keyword)
|
||||
table.insert(toolranks_extras.ignored_toolranks_tool_types, string.lower(keyword))
|
||||
end
|
||||
toolranks_extras.ignore_toolranks_tool_type("tool")
|
||||
|
||||
if toolranks_extras.settings.enable_tool_types then
|
||||
local TR = minetest.get_translator("toolranks")
|
||||
local origin_get_tool_type = toolranks.get_tool_type
|
||||
--[[
|
||||
-- Returns nil if the keyword is ignored, else returns the keyword.
|
||||
--]]
|
||||
local function check_ignore(keyword)
|
||||
for _, k in ipairs(toolranks_extras.ignored_toolranks_tool_types) do
|
||||
if keyword == k then
|
||||
return
|
||||
end
|
||||
end
|
||||
return keyword
|
||||
end
|
||||
|
||||
-- overwrite of toolranks.get_tool_type(description)
|
||||
toolranks.get_tool_type = function(description)
|
||||
-- execute original function
|
||||
local tool_type = check_ignore(origin_get_tool_type(description))
|
||||
if tool_type ~= nil then
|
||||
return TR(tool_type)
|
||||
end
|
||||
-- search for registered tool types
|
||||
local d = string.lower(description)
|
||||
for k, desc in pairs(toolranks_extras.registered_tool_types) do
|
||||
if string.find(d, k) then
|
||||
return desc
|
||||
end
|
||||
end
|
||||
-- fallback
|
||||
return TR("tool")
|
||||
end
|
||||
|
||||
-- overwrite of toolranks.create_description(name, uses)
|
||||
toolranks.create_description = function(name, uses)
|
||||
local tooltype = toolranks.get_tool_type(name)
|
||||
local alt_display = toolranks_extras.get_node_dug_display(name)
|
||||
if alt_display ~= nil then
|
||||
return S("@1@2\n@3Level @4 @5\n@6@7: @8",
|
||||
toolranks.colors.green,
|
||||
name,
|
||||
toolranks.colors.gold,
|
||||
toolranks.get_level(uses),
|
||||
tooltype,
|
||||
toolranks.colors.grey,
|
||||
alt_display,
|
||||
(type(uses) == "number" and uses or 0)
|
||||
)
|
||||
end
|
||||
return TR(
|
||||
"@1@2\n@3Level @4 @5\n@6@Node dug: @7",
|
||||
toolranks.colors.green,
|
||||
name,
|
||||
toolranks.colors.gold,
|
||||
toolranks.get_level(uses),
|
||||
tooltype,
|
||||
toolranks.colors.grey,
|
||||
(type(uses) == "number" and uses or 0)
|
||||
)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user