Added toolranks

master
NathanSalapat 2020-07-26 12:12:06 -05:00
parent 2de3ba7031
commit 67a78de58c
44 changed files with 2452 additions and 900 deletions

504
mods/anvils/LICENSE Normal file
View File

@ -0,0 +1,504 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random
Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

11
mods/anvils/README.md Normal file
View File

@ -0,0 +1,11 @@
# Anvils
Mod provide anvil that can repair tools (like at MC)
Created by Wuzzy
Adapted for default minetest by JonyQ and Jozet
minetest 0.4.16 / 17
(c) 2018
![Screenshot](https://image.ibb.co/iwWmid/ezgif_3_d6689edae4_min.gif)

25
mods/anvils/Readme.txt Normal file
View File

@ -0,0 +1,25 @@
# Anvils
Mod provide anvil that can repair tools (like at MC)
Created by Wuzzy
Adapted for default minetest by JonyQ and Jozet
minetest 0.4.16 / 17
(c) 2018
![Screenshot](https://image.ibb.co/iwWmid/ezgif_3_d6689edae4_min.gif)
---------------------------------------------------------------------
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

387
mods/anvils/anvils.lua Normal file
View File

@ -0,0 +1,387 @@
local MAX_NAME_LENGTH = 30
local MAX_WEAR = 65535
local SAME_TOOL_REPAIR_BOOST = math.ceil(MAX_WEAR * 0.12) -- 12%
local MATERIAL_TOOL_REPAIR_BOOST = {
math.ceil(MAX_WEAR * 0.34), -- 25%
math.ceil(MAX_WEAR * 0.68), -- 50%
math.ceil(MAX_WEAR * 1), -- 75%
MAX_WEAR, -- 100%
}
local NAME_COLOR = "#FFFF4C"
local function get_anvil_formspec(set_name)
if not set_name then
set_name = ""
end
return "size[8,8.5]"..
"background[1,1;1,1;gui_formbg2.png;true]"..
"bgcolor[#080808BB;true]"..
"list[current_player;main;0,4.5;8,4]"..
"list[context;input;1,2.5;1,1;]"..
"list[context;input;3.5,2.5;1,1;1]"..
"list[context;output;6,2.5;1,1;]"..
"image[2.35,2.6;0.8,0.8;plus.png]" ..
"image[4.75,2.5;1,1;arrow0.png]" ..
"image[2.6,0.65;3,1;rep.png]" ..
"image[5.3,0.5;1.3,1.3;ham.png]" ..
"image[1.3,0.5;1.3,1.3;pick.png]" ..
"bgcolor[#080808BB;true]" ..
default.gui_slots..
"field_close_on_enter[name;false]"..
"listring[context;input]"..
"listring[context;output]"..
"listring[current_player;main]"..
"listring[current_player;main]"
end
-- Given a tool and material stack, returns how many items of the material stack
-- needs to be used up to repair the tool.
local function get_consumed_materials(tool, material)
local wear = tool:get_wear()
if wear == 0 then
return 0
end
local health = (MAX_WEAR - wear)
local matsize = material:get_count()
local materials_used = 0
for m=1, math.min(4, matsize) do
materials_used = materials_used + 1
if (wear - MATERIAL_TOOL_REPAIR_BOOST[m]) <= 0 then
break
end
end
return materials_used
end
-- Given 2 input stacks, tells you which is the tool and which is the material.
-- Returns ("tool", input1, input2) if input1 is tool and input2 is material.
-- Returns ("material", input2, input1) if input1 is material and input2 is tool.
-- Returns nil otherwise.
local function distinguish_tool_and_material(input1, input2)
local def1 = input1:get_definition()
local def2 = input2:get_definition()
if def1.type == "tool" and def1._repair_material then
return "tool", input1, input2
elseif def2.type == "tool" and def2._repair_material then
return "material", input2, input1
else
return nil
end
end
-- Update the inventory slots of an anvil node.
-- meta: Metadata of anvil node
local function update_anvil_slots(meta)
local inv = meta:get_inventory()
local new_name = meta:get_string("set_name")
local input1, input2, output
input1 = inv:get_stack("input", 1)
input2 = inv:get_stack("input", 2)
output = inv:get_stack("output", 1)
local new_output, name_item
local just_rename = false
-- Both input slots occupied
if (not input1:is_empty() and not input2:is_empty()) then
-- Repair, if tool
local def1 = input1:get_definition()
local def2 = input2:get_definition()
-- Repair calculation helper.
-- Adds the “inverse” values of wear1 and wear2.
-- Then adds a boost health value directly.
-- Returns the resulting (capped) wear.
local function calculate_repair(wear1, wear2, boost)
local new_health = (MAX_WEAR - wear1) + (MAX_WEAR - wear2)
if boost then
new_health = new_health + boost
end
return math.max(0, math.min(MAX_WEAR, MAX_WEAR - new_health))
end
-- Same tool twice
if input1:get_name() == input2:get_name() and def1.type == "tool" and (input1:get_wear() > 0 or input2:get_wear() > 0) then
-- Add tool health together plus a small bonus
-- TODO: Combine tool enchantments
local new_wear = calculate_repair(input1:get_wear(), input2:get_wear(), SAME_TOOL_REPAIR_BOOST)
input1:set_wear(new_wear)
name_item = input1
new_output = name_item
-- Tool + repair item
else
-- Any tool can have a repair item. This may be defined in the tool's item definition
-- as an itemstring in the field `_repair_material`. Only if this field is set, the
-- tool can be repaired with a material item.
-- Example: Steel Pickaxe + Steel Ingot. `_repair_material = default:steel_ingot`
-- Big repair bonus
-- TODO: Combine tool enchantments
local distinguished, tool, material = distinguish_tool_and_material(input1, input2)
if distinguished then
local tooldef = tool:get_definition()
local has_correct_material = false
if string.sub(tooldef._repair_material, 1, 6) == "group:" then
has_correct_material = minetest.get_item_group(material:get_name(), string.sub(tooldef._repair_material, 7)) ~= 0
elseif material:get_name() == tooldef._repair_material then
has_correct_material = true
end
if has_correct_material and tool:get_wear() > 0 then
local materials_used = get_consumed_materials(tool, material)
local new_wear = calculate_repair(tool:get_wear(), MAX_WEAR, MATERIAL_TOOL_REPAIR_BOOST[materials_used])
tool:set_wear(new_wear)
name_item = tool
new_output = name_item
else
new_output = ""
end
else
new_output = ""
end
end
-- Exactly 1 input slot occupied
elseif (not input1:is_empty() and input2:is_empty()) or (input1:is_empty() and not input2:is_empty()) then
-- Just rename item
if input1:is_empty() then
name_item = input2
else
name_item = input1
end
just_rename = true
else
new_output = ""
end
-- Rename handling
if name_item then
-- No renaming allowed with group no_rename=1
if minetest.get_item_group(name_item:get_name(), "no_rename") == 1 then
new_output = ""
else
if new_name == nil then
new_name = ""
end
local meta = name_item:get_meta()
local old_name = meta:get_string("name")
-- Limit name length
new_name = string.sub(new_name, 1, MAX_NAME_LENGTH)
-- Don't rename if names are identical
if new_name ~= old_name then
-- Rename item
if new_name == "" then
-- Empty name
if name_item:get_definition()._generate_description then
-- _generate_description(itemstack): If defined, set custom item description of itemstack.
name_item:get_definition()._generate_description(name_item)
else
-- Otherwise, just clear description
meta:set_string("description", "")
end
else
-- Custom name set. Colorize it!
-- This makes the name visually different from unnamed items
meta:set_string("description", core.colorize(NAME_COLOR, new_name))
end
-- Save the raw name internally, too
meta:set_string("name", new_name)
new_output = name_item
elseif just_rename then
new_output = ""
end
end
end
-- Set the new output slot
if new_output ~= nil then
inv:set_stack("output", 1, new_output)
end
end
-- Drop input items of anvil at pos with metadata meta
local function drop_anvil_items(pos, meta)
local inv = meta:get_inventory()
for i=1, inv:get_size("input") do
local stack = inv:get_stack("input", i)
if not stack:is_empty() then
local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5}
minetest.add_item(p, stack)
end
end
end
local anvildef = {
groups = {cracky = 1},
tiles = {'stations_anvil.png'},
paramtype = "light",
sunlight_propagates = true,
is_ground_content = false,
paramtype2 = "facedir",
drawtype = "mesh",
mesh = 'anvils_anvil.obj',
sounds = default.node_sound_metal_defaults(),
after_place_node = function(pos, placer)
local name = placer:get_player_name()
local pinv = placer:get_inventory()
local meta = minetest.get_meta(pos);
local owner = placer:get_player_name() or "";
local privs = minetest.get_player_privs(owner);
meta:set_string("owner",owner);
meta:set_string("infotext","Anvil (owned by " .. owner .. "): ");
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
local meta = minetest.get_meta(pos)
local meta2 = meta
meta:from_table(oldmetadata)
drop_anvil_items(pos, meta)
meta:from_table(meta2:to_table())
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos);
local privs = minetest.get_player_privs(player:get_player_name());
if meta:get_string("owner")~=player:get_player_name() and not privs.privs then return 0 end
if listname == "output" then
return 0
else
return stack:get_count()
end
end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local meta = minetest.get_meta(pos);
local privs = minetest.get_player_privs(player:get_player_name());
if meta:get_string("owner")~=player:get_player_name() and not privs.privs then return 0 end
if to_list == "output" then
return 0
elseif from_list == "output" and to_list == "input" then
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if inv:get_stack(to_list, to_index):is_empty() then
return count
else
return 0
end
else
return count
end
end,
on_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
update_anvil_slots(meta)
end,
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local meta = minetest.get_meta(pos)
if from_list == "output" and to_list == "input" then
local inv = meta:get_inventory()
for i=1, inv:get_size("input") do
if i ~= to_index then
local istack = inv:get_stack("input", i)
istack:set_count(math.max(0, istack:get_count() - count))
inv:set_stack("input", i, istack)
end
end
end
update_anvil_slots(meta)
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos);
local privs = minetest.get_player_privs(player:get_player_name());
if meta:get_string("owner")~=player:get_player_name() and not privs.privs then return 0 end
return stack:get_count();
end,
on_metadata_inventory_take = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
if listname == "output" then
local inv = meta:get_inventory()
local input1 = inv:get_stack("input", 1)
local input2 = inv:get_stack("input", 2)
-- Both slots occupied?
if not input1:is_empty() and not input2:is_empty() then
-- Take as many items as needed
local distinguished, tool, material = distinguish_tool_and_material(input1, input2)
if distinguished then
-- Tool + material: Take tool and as many materials as needed
local materials_used = get_consumed_materials(tool, material)
material:set_count(material:get_count() - materials_used)
tool:take_item()
local player_name = player:get_player_name()
minetest.sound_play("anvil_use", {to_player=player_name, gain = 1.0})
if distinguished == "tool" then
input1, input2 = tool, material
else
input1, input2 = material, tool
end
inv:set_stack("input", 1, input1)
inv:set_stack("input", 2, input2)
else
-- Else take 1 item from each stack
input1:take_item()
input2:take_item()
inv:set_stack("input", 1, input1)
inv:set_stack("input", 2, input2)
end
else
-- Otherwise: Rename mode. Remove the same amount of items from input
-- as has been taken from output
if not input1:is_empty() then
input1:set_count(math.max(0, input1:get_count() - stack:get_count()))
inv:set_stack("input", 1, input1)
end
if not input2:is_empty() then
input2:set_count(math.max(0, input2:get_count() - stack:get_count()))
inv:set_stack("input", 2, input2)
end
end
elseif listname == "input" then
update_anvil_slots(meta)
end
end,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
inv:set_size("input", 2)
inv:set_size("output", 1)
local form = get_anvil_formspec()
meta:set_string("formspec", form)
end,
on_receive_fields = function(pos, formname, fields, sender)
if fields.name_button or fields.name then
local set_name
if fields.name == nil then
set_name = ""
else
set_name = fields.name
end
local meta = minetest.get_meta(pos)
-- Limit name length
set_name = string.sub(set_name, 1, MAX_NAME_LENGTH)
meta:set_string("set_name", set_name)
update_anvil_slots(meta)
meta:set_string("formspec", get_anvil_formspec(set_name))
end
end,
}
if minetest.get_modpath("screwdriver") then
anvildef.on_rotate = screwdriver.rotate_simple
end
local anvildef0 = table.copy(anvildef)
anvildef0.description = "Anvil"
anvildef0._doc_items_longdesc =
[[The anvil allows you to repair tools and armor, and to give names to items.]]
anvildef0._doc_items_usagehelp =
"To use an anvil, rightclick it. An anvil has 2 input slots (on the left) and one output slot.\n"..
"To rename items, put an item stack in one of the item slots while keeping the other input slot empty. Type in a name, hit enter or “Set Name”, then take the renamed item from the output slot.\n"..
"There are two possibilities to repair tools (and armor):\n"..
"• Tool + Tool: Place two tools of the same type in the input slots. The “health” of the repaired tool is the sum of the “health” of both input tools, plus a 12% bonus.\n"..
"• Tool + Material: Some tools can also be repaired by combining them with an item that it's made of. For example, iron pickaxes can be repaired with iron ingots. This repairs the tool by 25%.\n"..
"Armor counts as a tool. It is possible to repair and rename a tool in a single step."
minetest.register_node("anvils:anvil", anvildef0)
minetest.register_craft({
output = "anvils:anvil",
recipe = {
{ "default:steelblock", "default:steelblock", "default:steelblock" },
{ "", "default:steel_ingot", "" },
{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" },
}
})

View File

@ -0,0 +1,5 @@
Mod provide anvil that can repair tools (like at MC)
Created by Wuzzy
Adapted by JonyQ and Jozet

3
mods/anvils/init.lua Normal file
View File

@ -0,0 +1,3 @@
dofile(minetest.get_modpath("anvils").."/anvils.lua")
dofile(minetest.get_modpath("anvils").."/tools.lua")

3
mods/anvils/mod.conf Normal file
View File

@ -0,0 +1,3 @@
name = anvils
depends = default, farming
optional_depends = screwdriver

View File

@ -0,0 +1,393 @@
# Blender v2.82 (sub 7) OBJ File: 'stations.blend'
# www.blender.org
o Anvil_Cylinder.002
v 0.500000 0.375000 0.125000
v 0.500000 0.437500 0.125000
v -0.062500 0.375000 0.125000
v -0.062500 0.437500 0.125000
v 0.500000 0.375000 -0.375000
v 0.500000 0.437500 -0.375000
v -0.062500 0.375000 -0.375000
v -0.062500 0.437500 -0.375000
v -0.062500 0.375000 -0.312500
v -0.062500 0.437500 -0.312500
v 0.500000 0.375000 -0.312500
v 0.500000 0.437500 -0.312500
v -0.062500 0.375000 0.062500
v 0.500000 0.437500 0.062500
v -0.062500 0.437500 0.062500
v 0.500000 0.375000 0.062500
v 0.375000 0.187500 0.000000
v 0.375000 0.187500 -0.250000
v -0.062500 0.187500 -0.250000
v -0.062500 0.187500 0.000000
v -0.375000 0.375000 -0.250000
v -0.375000 0.375000 0.000000
v -0.250000 0.187500 -0.250000
v -0.250000 0.187500 0.000000
v 0.375000 0.062500 0.000000
v 0.375000 0.062500 -0.250000
v -0.062500 0.062500 -0.250000
v -0.062500 0.062500 0.000000
v 0.437500 -0.062500 -0.312500
v -0.125000 -0.062500 -0.312500
v -0.437500 -0.062500 -0.312500
v -0.437500 -0.500000 -0.312500
v -0.437500 -0.500000 -0.375000
v -0.437500 -0.500000 0.437500
v -0.437500 -0.062500 -0.375000
v -0.437500 -0.062500 0.437500
v 0.437500 -0.062500 -0.375000
v 0.437500 -0.062500 0.437500
v -0.125000 -0.062500 0.437500
v -0.125000 -0.062500 -0.375000
v 0.437500 -0.500000 0.375000
v -0.125000 0.062500 0.375000
v 0.250000 -0.187500 -0.312500
v 0.437500 -0.062500 0.375000
v -0.437500 -0.500000 0.375000
v -0.437500 -0.062500 0.375000
v -0.125000 -0.062500 0.375000
v 0.437500 0.062500 0.375000
v 0.437500 -0.500000 -0.312500
v -0.125000 0.062500 -0.312500
v 0.437500 0.062500 -0.312500
v 0.250000 -0.062500 -0.312500
v -0.125000 -0.500000 0.437500
v 0.437500 -0.500000 0.437500
v -0.125000 -0.500000 -0.375000
v 0.437500 -0.500000 -0.375000
v 0.437500 0.062500 -0.375000
v -0.125000 0.062500 -0.375000
v 0.437500 0.062500 0.437500
v -0.125000 0.062500 0.437500
v 0.187500 -0.156250 0.250000
v 0.312500 -0.156250 -0.187500
v -0.125000 -0.156250 -0.187500
v -0.375000 -0.156250 -0.187500
v 0.062500 -0.125000 -0.187500
v -0.250000 -0.156250 -0.187500
v 0.187500 -0.156250 -0.187500
v -0.375000 -0.156250 0.250000
v 0.062500 -0.156250 0.250000
v -0.125000 -0.125000 0.250000
v -0.250000 -0.156250 0.250000
v 0.187500 -0.156250 -0.312500
v 0.187500 -0.125000 0.125000
v 0.187500 -0.156250 -0.062500
v -0.250000 -0.156250 -0.312500
v -0.250000 -0.156250 0.125000
v -0.250000 -0.156250 0.375000
v -0.250000 -0.125000 -0.062500
v 0.312500 -0.156250 -0.062500
v 0.062500 -0.093750 -0.062500
v -0.375000 -0.156250 -0.062500
v -0.125000 -0.093750 -0.062500
v -0.125000 -0.156250 -0.312500
v -0.125000 -0.156250 0.375000
v 0.312500 -0.156250 0.125000
v -0.375000 -0.156250 0.125000
v 0.062500 -0.093750 0.125000
v 0.062500 -0.156250 -0.312500
v 0.062500 -0.156250 0.375000
v -0.375000 -0.156250 0.375000
v -0.125000 -0.093750 0.125000
v -0.375000 -0.156250 -0.312500
v 0.312500 -0.156250 -0.312500
v -0.375000 -0.500000 -0.375000
v -0.375000 -0.062500 -0.375000
v -0.375000 -0.062500 0.437500
v -0.375000 -0.500000 0.437500
v -0.375000 -0.062500 0.375000
v -0.375000 -0.062500 -0.312500
v 0.250000 -0.062500 0.375000
v 0.250000 -0.187500 0.375000
v -0.125000 -0.187500 0.375000
v -0.125000 -0.187500 -0.312500
v -0.375000 -0.187500 0.375000
v -0.375000 -0.187500 -0.312500
vt 0.343750 0.671875
vt 0.359375 0.671875
vt 0.359375 0.812500
vt 0.343750 0.812500
vt 0.468750 0.828125
vt 0.468750 0.812500
vt 0.484375 0.812500
vt 0.484375 0.828125
vt 0.500000 0.812500
vt 0.484375 0.671875
vt 0.500000 0.671875
vt 0.375000 0.656250
vt 0.375000 0.671875
vt 0.359375 0.656250
vt 0.515625 0.812500
vt 0.515625 0.671875
vt 0.375000 0.812500
vt 0.468750 0.671875
vt 0.664062 0.703125
vt 0.523438 0.703125
vt 0.554688 0.656250
vt 0.664062 0.656250
vt 0.484375 0.656250
vt 0.468750 0.656250
vt 0.375000 0.828125
vt 0.359375 0.828125
vt 0.328125 0.812500
vt 0.328125 0.671875
vt 0.406250 0.632812
vt 0.343750 0.632812
vt 0.343750 0.601562
vt 0.406250 0.601562
vt 0.812500 0.687500
vt 0.750000 0.687500
vt 0.750000 0.640625
vt 0.812500 0.640625
vt 0.617188 0.812500
vt 0.523438 0.812500
vt 0.539062 0.765625
vt 0.601562 0.765625
vt 0.523438 0.757812
vt 0.664062 0.757812
vt 0.664062 0.710938
vt 0.554688 0.710938
vt 0.750000 0.585938
vt 0.812500 0.585938
vt 0.710938 0.656250
vt 0.742188 0.703125
vt 0.734375 0.710938
vt 0.828125 0.710938
vt 0.812500 0.789062
vt 0.750000 0.789062
vt 0.742188 0.757812
vt 0.710938 0.710938
vt 0.585938 0.953125
vt 0.414062 0.953125
vt 0.414062 0.843750
vt 0.585938 0.843750
vt 0.609375 0.632812
vt 0.546875 0.632812
vt 0.546875 0.601562
vt 0.609375 0.601562
vt 0.531250 0.648438
vt 0.421875 0.648438
vt 0.421875 0.617188
vt 0.531250 0.617188
vt 0.734375 0.648438
vt 0.625000 0.648438
vt 0.625000 0.617188
vt 0.734375 0.617188
vt 0.187500 0.632812
vt 0.015625 0.632812
vt 0.015625 0.492188
vt 0.187500 0.492188
vt 0.195312 0.843750
vt 0.195312 0.953125
vt 0.179688 0.953125
vt 0.179688 0.843750
vt 0.460938 0.906250
vt 0.445312 0.906250
vt 0.445312 0.890625
vt 0.460938 0.890625
vt 0.234375 0.953125
vt 0.218750 0.953125
vt 0.218750 0.843750
vt 0.234375 0.843750
vt 0.234375 0.984375
vt 0.218750 0.984375
vt 0.218750 0.953125
vt 0.234375 0.953125
vt 0.398438 0.984375
vt 0.257812 0.984375
vt 0.257812 0.953125
vt 0.398438 0.953125
vt 0.414062 0.984375
vt 0.140625 0.984375
vt 0.000000 0.984375
vt 0.000000 0.953125
vt 0.140625 0.953125
vt 0.601562 0.984375
vt 0.585938 0.984375
vt 0.601562 0.953125
vt 0.203125 0.953125
vt 0.203125 0.843750
vt 0.257812 0.843750
vt 0.398438 0.843750
vt 0.421875 0.953125
vt 0.406250 0.953125
vt 0.406250 0.843750
vt 0.421875 0.843750
vt 0.601562 0.843750
vt 0.421875 0.984375
vt 0.406250 0.984375
vt 0.406250 0.953125
vt 0.421875 0.953125
vt 0.000000 0.632812
vt 0.000000 0.492188
vt 0.617188 0.906250
vt 0.601562 0.906250
vt 0.601562 0.890625
vt 0.617188 0.890625
vt 0.000000 0.843750
vt 0.140625 0.843750
vt 0.093750 0.968750
vt 0.093750 1.000000
vt 0.000000 1.000000
vt 0.000000 0.968750
vt 0.203125 0.632812
vt 0.203125 0.492188
vt 0.117188 0.757812
vt 0.148438 0.757812
vt 0.148438 0.789062
vt 0.179688 0.789062
vt 0.179688 0.820312
vt 0.179688 0.757812
vt 0.117188 0.648438
vt 0.148438 0.648438
vt 0.148438 0.679688
vt 0.117188 0.679688
vt 0.226562 0.648438
vt 0.257812 0.648438
vt 0.257812 0.679688
vt 0.226562 0.679688
vt 0.179688 0.648438
vt 0.179688 0.679688
vt 0.289062 0.648438
vt 0.289062 0.679688
vt 0.226562 0.757812
vt 0.257812 0.757812
vt 0.257812 0.789062
vt 0.226562 0.789062
vt 0.289062 0.757812
vt 0.289062 0.789062
vt 0.148438 0.710938
vt 0.117188 0.710938
vt 0.257812 0.710938
vt 0.226562 0.710938
vt 0.257812 0.820312
vt 0.226562 0.820312
vt 0.179688 0.710938
vt 0.289062 0.710938
vt 0.289062 0.820312
vt 0.617188 0.953125
vt 0.601562 0.953125
vt 0.460938 0.953125
vt 0.445312 0.953125
vt 0.359375 1.000000
vt 0.359375 0.968750
vt 0.453125 0.968750
vt 0.453125 1.000000
vt 0.156250 0.968750
vt 0.156250 1.000000
vt 0.296875 0.968750
vt 0.296875 1.000000
vn 0.0000 0.0000 1.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
vn 0.0000 -0.3162 -0.9487
vn 0.8321 -0.5547 0.0000
vn 0.0000 -0.3162 0.9487
vn -0.8321 -0.5547 0.0000
vn -0.1215 -0.2024 -0.9717
vn -0.1215 -0.2024 0.9717
vn 0.2357 0.9428 0.2357
vn 0.1162 0.9300 0.3487
vn -0.0824 0.9889 -0.1236
vn 0.1231 0.9847 -0.1231
vn -0.3487 0.9300 0.1162
vn 0.0778 0.9335 0.3501
vn -0.1162 0.9300 -0.3487
vn -0.3501 0.9335 0.0778
vn -0.1231 0.9847 0.1231
vn -0.0778 0.9335 -0.3501
vn 0.3487 0.9300 -0.1162
vn -0.1231 0.9847 -0.1231
vn 0.0824 0.9889 0.1236
vn 0.3501 0.9335 -0.0778
vn -0.1236 0.9889 0.0824
vn 0.1236 0.9889 -0.0824
s off
f 1/1/1 2/2/1 4/3/1 3/4/1
f 9/5/2 10/6/2 8/7/2 7/8/2
f 7/9/3 8/7/3 6/10/3 5/11/3
f 16/12/4 14/13/4 2/2/4 1/14/4
f 9/15/5 7/9/5 5/11/5 11/16/5
f 15/17/6 4/3/6 2/2/6 14/13/6
f 8/7/6 10/6/6 12/18/6 6/10/6
f 9/19/7 11/20/7 18/21/7 19/22/7
f 5/23/4 6/10/4 12/18/4 11/24/4
f 13/25/2 15/17/2 10/6/2 9/5/2
f 3/26/2 4/3/2 15/17/2 13/25/2
f 3/4/5 13/27/5 16/28/5 1/1/5
f 10/6/6 15/17/6 14/13/6 12/18/6
f 11/24/4 12/18/4 14/13/4 16/12/4
f 20/29/2 19/30/2 27/31/2 28/32/2
f 19/33/5 20/34/5 24/35/5 23/36/5
f 11/37/8 16/38/8 17/39/8 18/40/8
f 16/41/9 13/42/9 20/43/9 17/44/9
f 22/45/10 21/46/10 23/36/10 24/35/10
f 9/19/11 19/22/11 23/47/11 21/48/11
f 13/49/6 9/50/6 21/51/6 22/52/6
f 20/43/12 13/42/12 22/53/12 24/54/12
f 44/55/2 29/56/2 49/57/2 41/58/2
f 18/59/4 17/60/4 25/61/4 26/62/4
f 17/63/1 20/64/1 28/65/1 25/66/1
f 19/67/3 18/68/3 26/69/3 27/70/3
f 42/71/5 50/72/5 51/73/5 48/74/5
f 94/75/1 95/76/1 35/77/1 33/78/1
f 98/79/5 96/80/5 36/81/5 46/82/5
f 46/83/4 36/84/4 34/85/4 45/86/4
f 42/87/4 60/88/4 39/89/4 47/90/4
f 57/91/1 58/92/1 40/93/1 37/94/1
f 51/95/2 57/91/2 37/94/2 29/56/2
f 60/96/3 59/97/3 38/98/3 39/99/3
f 59/100/2 48/101/2 44/55/2 38/102/2
f 96/103/3 97/104/3 34/85/3 36/84/3
f 37/94/1 40/93/1 55/105/1 56/106/1
f 29/56/2 37/94/2 56/106/2 49/57/2
f 35/107/4 31/108/4 32/109/4 33/110/4
f 38/102/2 44/55/2 41/58/2 54/111/2
f 58/112/4 50/113/4 30/114/4 40/115/4
f 50/72/5 58/116/5 57/117/5 51/73/5
f 48/101/2 51/95/2 29/56/2 44/55/2
f 31/108/4 46/83/4 45/86/4 32/109/4
f 95/118/5 99/119/5 31/120/5 35/121/5
f 99/119/5 98/79/5 46/82/5 31/120/5
f 50/113/4 42/87/4 47/90/4 30/114/4
f 39/99/3 38/98/3 54/122/3 53/123/3
f 47/124/1 102/125/1 101/126/1 100/127/1
f 60/128/5 42/71/5 48/74/5 59/129/5
f 85/130/13 73/131/13 61/132/13
f 61/132/6 69/133/6 89/134/6
f 61/132/14 73/131/14 87/135/14 69/133/14
f 93/136/6 72/137/6 67/138/6 62/139/6
f 83/140/6 75/141/6 66/142/6 63/143/6
f 88/144/15 83/140/15 63/143/15 65/145/15
f 72/137/16 88/144/16 65/145/16 67/138/16
f 75/141/6 92/146/6 64/147/6 66/142/6
f 91/148/17 76/149/17 71/150/17 70/151/17
f 87/135/18 91/148/18 70/151/18 69/133/18
f 76/149/6 86/152/6 68/153/6 71/150/6
f 62/139/6 67/138/6 74/154/6 79/155/6
f 63/143/19 66/142/19 78/156/19 82/157/19
f 82/157/20 78/156/20 76/149/20 91/148/20
f 70/151/21 71/150/21 77/158/21 84/159/21
f 65/145/22 63/143/22 82/157/22 80/160/22
f 67/138/23 65/145/23 80/160/23 74/154/23
f 66/142/24 64/147/24 81/161/24 78/156/24
f 80/160/6 82/157/6 91/148/6 87/135/6
f 69/133/25 70/151/25 84/159/25 89/134/25
f 74/154/26 80/160/26 87/135/26 73/131/26
f 78/156/27 81/161/27 86/152/27 76/149/27
f 79/155/28 74/154/28 73/131/28 85/130/28
f 71/150/6 68/153/6 90/162/6 77/158/6
f 40/163/5 30/164/5 99/119/5 95/118/5
f 39/99/3 53/123/3 97/104/3 96/103/3
f 47/165/5 39/166/5 96/80/5 98/79/5
f 55/105/1 40/93/1 95/76/1 94/75/1
f 103/167/3 30/168/3 52/169/3 43/170/3
f 47/124/1 98/171/1 104/172/1 102/125/1
f 98/171/2 99/173/2 105/174/2 104/172/2
f 99/173/3 30/168/3 103/167/3 105/174/3

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 588 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 718 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 B

154
mods/anvils/tools.lua Normal file
View File

@ -0,0 +1,154 @@
local mod_storage = minetest.get_mod_storage()
anvils = {}
minetest.override_item("farming:hoe_diamond", {
groups = { tool=1 },
_repair_material = "default:diamond"}
)
minetest.override_item("default:pick_diamond", {
groups = { tool=1 },
_repair_material = "default:diamond"}
)
minetest.override_item("default:axe_diamond", {
groups = { tool=1 },
_repair_material = "default:diamond"}
)
minetest.override_item("default:shovel_diamond", {
groups = { tool=1 },
_repair_material = "default:diamond"}
)
minetest.override_item("farming:hoe_wood", {
groups = { tool=1 },
_repair_material = "default:wood"}
)
minetest.override_item("default:pick_wood", {
groups = { tool=1 },
_repair_material = "default:wood"}
)
minetest.override_item("default:axe_wood", {
groups = { tool=1 },
_repair_material = "default:wood"}
)
minetest.override_item("default:shovel_wood", {
groups = { tool=1 },
_repair_material = "default:wood"}
)
minetest.override_item("farming:hoe_steel", {
groups = { tool=1 },
_repair_material = "default:steel_ingot"}
)
minetest.override_item("default:pick_steel", {
groups = { tool=1 },
_repair_material = "default:steel_ingot"}
)
minetest.override_item("default:axe_steel", {
groups = { tool=1 },
_repair_material = "default:steel_ingot"}
)
minetest.override_item("default:shovel_steel", {
groups = { tool=1 },
_repair_material = "default:steel_ingot"}
)
minetest.override_item("farming:hoe_stone", {
groups = { tool=1 },
_repair_material = "default:cobble"}
)
minetest.override_item("default:pick_stone", {
groups = { tool=1 },
_repair_material = "default:cobble"}
)
minetest.override_item("default:axe_stone", {
groups = { tool=1 },
_repair_material = "default:cobble"}
)
minetest.override_item("default:shovel_stone", {
groups = { tool=1 },
_repair_material = "default:cobble"}
)
minetest.override_item("farming:hoe_bronze", {
groups = { tool=1 },
_repair_material = "default:bronze_ingot"}
)
minetest.override_item("default:pick_bronze", {
groups = { tool=1 },
_repair_material = "default:bronze_ingot"}
)
minetest.override_item("default:axe_bronze", {
groups = { tool=1 },
_repair_material = "default:bronze_ingot"}
)
minetest.override_item("default:shovel_bronze", {
groups = { tool=1 },
_repair_material = "default:bronze_ingot"}
)
minetest.override_item("farming:hoe_mese", {
groups = { tool=1 },
_repair_material = "default:mese_crystal"}
)
minetest.override_item("default:pick_mese", {
groups = { tool=1 },
_repair_material = "default:mese_crystal"}
)
minetest.override_item("default:axe_mese", {
groups = { tool=1 },
_repair_material = "default:mese_crystal"}
)
minetest.override_item("default:shovel_mese", {
groups = { tool=1 },
_repair_material = "default:mese_crystal"}
)
-- add swords for snappy nodes
minetest.override_item("default:sword_wood", {
groups = { weapon=1 },
_repair_material = "default:wood"}
)
minetest.override_item("default:sword_stone", {
groups = { weapon=1 },
_repair_material = "default:cobble"}
)
minetest.override_item("default:sword_steel", {
groups = { weapon=1 },
_repair_material = "default:steel_ingot"}
)
minetest.override_item("default:sword_bronze", {
groups = { weapon=1 },
_repair_material = "default:bronze_ingot"}
)
minetest.override_item("default:sword_mese", {
groups = { weapon=1 },
_repair_material = "default:mese_crystal"}
)
minetest.override_item("default:sword_diamond", {
groups = { weapon=1 },
_repair_material = "default:diamond"}
)

View File

@ -1,5 +1,3 @@
-- boats/init.lua
-- Load support for MT game translation.
local S = minetest.get_translator("boats")
@ -8,20 +6,20 @@ local S = minetest.get_translator("boats")
--
local function is_water(pos)
local nn = minetest.get_node(pos).name
return minetest.get_item_group(nn, "water") ~= 0
local nn = minetest.get_node(pos).name
return minetest.get_item_group(nn, "water") ~= 0
end
local function get_velocity(v, yaw, y)
local x = -math.sin(yaw) * v
local z = math.cos(yaw) * v
return {x = x, y = y, z = z}
local x = -math.sin(yaw) * v
local z = math.cos(yaw) * v
return {x = x, y = y, z = z}
end
local function get_v(v)
return math.sqrt(v.x ^ 2 + v.z ^ 2)
return math.sqrt(v.x ^ 2 + v.z ^ 2)
end
--
@ -29,207 +27,208 @@ end
--
local boat = {
initial_properties = {
physical = true,
-- Warning: Do not change the position of the collisionbox top surface,
-- lowering it causes the boat to fall through the world if underwater
collisionbox = {-0.5, -0.35, -0.5, 0.5, 0.3, 0.5},
visual = "mesh",
mesh = "boats_boat.obj",
textures = {"default_wood.png"},
},
initial_properties = {
physical = true,
-- Warning: Do not change the position of the collisionbox top surface,
-- lowering it causes the boat to fall through the world if underwater
collisionbox = {-0.5, -0.35, -0.5, 0.5, 0.3, 0.5},
visual = "mesh",
mesh = "boats_boat.obj",
textures = {"default_wood.png"},
},
driver = nil,
v = 0,
last_v = 0,
removed = false,
auto = false
driver = nil,
v = 0,
last_v = 0,
removed = false,
auto = false
}
function boat.on_rightclick(self, clicker)
if not clicker or not clicker:is_player() then
return
end
local name = clicker:get_player_name()
if self.driver and name == self.driver then
self.driver = nil
self.auto = false
clicker:set_detach()
player_api.player_attached[name] = false
player_api.set_animation(clicker, "stand" , 30)
local pos = clicker:get_pos()
pos = {x = pos.x, y = pos.y + 0.2, z = pos.z}
minetest.after(0.1, function()
clicker:set_pos(pos)
end)
elseif not self.driver then
local attach = clicker:get_attach()
if attach and attach:get_luaentity() then
local luaentity = attach:get_luaentity()
if luaentity.driver then
luaentity.driver = nil
end
clicker:set_detach()
end
self.driver = name
clicker:set_attach(self.object, "",
{x = 0.5, y = 1, z = -3}, {x = 0, y = 0, z = 0})
player_api.player_attached[name] = true
minetest.after(0.2, function()
player_api.set_animation(clicker, "sit" , 30)
end)
clicker:set_look_horizontal(self.object:get_yaw())
end
if not clicker or not clicker:is_player() then
return
end
local name = clicker:get_player_name()
if self.driver and name == self.driver then
self.driver = nil
self.auto = false
clicker:set_detach()
player_api.player_attached[name] = false
player_api.set_animation(clicker, "stand" , 30)
local pos = clicker:get_pos()
pos = {x = pos.x, y = pos.y + 0.2, z = pos.z}
minetest.after(0.1, function()
clicker:set_pos(pos)
end)
elseif not self.driver then
local attach = clicker:get_attach()
if attach and attach:get_luaentity() then
local luaentity = attach:get_luaentity()
if luaentity.driver then
luaentity.driver = nil
end
clicker:set_detach()
end
self.driver = name
clicker:set_attach(self.object, "",
{x = 0.5, y = 1, z = -3}, {x = 0, y = 0, z = 0})
player_api.player_attached[name] = true
minetest.after(0.2, function()
player_api.set_animation(clicker, "sit" , 30)
end)
clicker:set_look_horizontal(self.object:get_yaw())
end
end
-- If driver leaves server while driving boat
function boat.on_detach_child(self, child)
self.driver = nil
self.auto = false
self.driver = nil
self.auto = false
end
function boat.on_activate(self, staticdata, dtime_s)
self.object:set_armor_groups({immortal = 1})
if staticdata then
self.v = tonumber(staticdata)
end
self.last_v = self.v
--self.object:set_armor_groups({immortal = 1})
if staticdata then
self.v = tonumber(staticdata)
end
self.last_v = self.v
self.object:set_hp(200)
end
function boat.get_staticdata(self)
return tostring(self.v)
return tostring(self.v)
end
function boat.on_punch(self, puncher)
if not puncher or not puncher:is_player() or self.removed then
return
end
function boat.on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir, damage)
if not puncher or not puncher:is_player() or self.removed then
return
end
local name = puncher:get_player_name()
if self.driver and name == self.driver then
self.driver = nil
puncher:set_detach()
player_api.player_attached[name] = false
end
if not self.driver then
self.removed = true
local inv = puncher:get_inventory()
if not (creative and creative.is_enabled_for
and creative.is_enabled_for(name))
or not inv:contains_item("main", "boats:boat") then
local leftover = inv:add_item("main", "boats:boat")
-- if no room in inventory add a replacement boat to the world
if not leftover:is_empty() then
minetest.add_item(self.object:get_pos(), leftover)
end
end
-- delay remove to ensure player is detached
minetest.after(0.1, function()
self.object:remove()
end)
end
local name = puncher:get_player_name()
if self.driver and name == self.driver then
self.driver = nil
puncher:set_detach()
player_api.player_attached[name] = false
end
if not self.driver then
self.removed = true
local inv = puncher:get_inventory()
if not (creative and creative.is_enabled_for
and creative.is_enabled_for(name))
or not inv:contains_item("main", "boats:boat") then
local leftover = inv:add_item("main", "boats:boat")
-- if no room in inventory add a replacement boat to the world
if not leftover:is_empty() then
minetest.add_item(self.object:get_pos(), leftover)
end
end
-- delay remove to ensure player is detached
minetest.after(0.1, function()
self.object:remove()
end)
end
end
function boat.on_step(self, dtime)
self.v = get_v(self.object:get_velocity()) * math.sign(self.v)
if self.driver then
local driver_objref = minetest.get_player_by_name(self.driver)
if driver_objref then
local ctrl = driver_objref:get_player_control()
if ctrl.up and ctrl.down then
if not self.auto then
self.auto = true
minetest.chat_send_player(self.driver, S("Boat cruise mode on"))
end
elseif ctrl.down then
self.v = self.v - dtime * 2.0
if self.auto then
self.auto = false
minetest.chat_send_player(self.driver, S("Boat cruise mode off"))
end
elseif ctrl.up or self.auto then
self.v = self.v + dtime * 2.0
end
if ctrl.left then
if self.v < -0.001 then
self.object:set_yaw(self.object:get_yaw() - dtime * 0.9)
else
self.object:set_yaw(self.object:get_yaw() + dtime * 0.9)
end
elseif ctrl.right then
if self.v < -0.001 then
self.object:set_yaw(self.object:get_yaw() + dtime * 0.9)
else
self.object:set_yaw(self.object:get_yaw() - dtime * 0.9)
end
end
end
end
local velo = self.object:get_velocity()
if self.v == 0 and velo.x == 0 and velo.y == 0 and velo.z == 0 then
self.object:set_pos(self.object:get_pos())
return
end
-- We need to preserve velocity sign to properly apply drag force
-- while moving backward
local drag = dtime * math.sign(self.v) * (0.01 + 0.0796 * self.v * self.v)
-- If drag is larger than velocity, then stop horizontal movement
if math.abs(self.v) <= math.abs(drag) then
self.v = 0
else
self.v = self.v - drag
end
self.v = get_v(self.object:get_velocity()) * math.sign(self.v)
if self.driver then
local driver_objref = minetest.get_player_by_name(self.driver)
if driver_objref then
local ctrl = driver_objref:get_player_control()
if ctrl.up and ctrl.down then
if not self.auto then
self.auto = true
minetest.chat_send_player(self.driver, S("Boat cruise mode on"))
end
elseif ctrl.down then
self.v = self.v - dtime * 2.0
if self.auto then
self.auto = false
minetest.chat_send_player(self.driver, S("Boat cruise mode off"))
end
elseif ctrl.up or self.auto then
self.v = self.v + dtime * 2.0
end
if ctrl.left then
if self.v < -0.001 then
self.object:set_yaw(self.object:get_yaw() - dtime * 0.9)
else
self.object:set_yaw(self.object:get_yaw() + dtime * 0.9)
end
elseif ctrl.right then
if self.v < -0.001 then
self.object:set_yaw(self.object:get_yaw() + dtime * 0.9)
else
self.object:set_yaw(self.object:get_yaw() - dtime * 0.9)
end
end
end
end
local velo = self.object:get_velocity()
if self.v == 0 and velo.x == 0 and velo.y == 0 and velo.z == 0 then
self.object:set_pos(self.object:get_pos())
return
end
-- We need to preserve velocity sign to properly apply drag force
-- while moving backward
local drag = dtime * math.sign(self.v) * (0.01 + 0.0796 * self.v * self.v)
-- If drag is larger than velocity, then stop horizontal movement
if math.abs(self.v) <= math.abs(drag) then
self.v = 0
else
self.v = self.v - drag
end
local p = self.object:get_pos()
p.y = p.y - 0.5
local new_velo
local new_acce = {x = 0, y = 0, z = 0}
if not is_water(p) then
local nodedef = minetest.registered_nodes[minetest.get_node(p).name]
if (not nodedef) or nodedef.walkable then
self.v = 0
new_acce = {x = 0, y = 1, z = 0}
else
new_acce = {x = 0, y = -9.8, z = 0}
end
new_velo = get_velocity(self.v, self.object:get_yaw(),
self.object:get_velocity().y)
self.object:set_pos(self.object:get_pos())
else
p.y = p.y + 1
if is_water(p) then
local y = self.object:get_velocity().y
if y >= 5 then
y = 5
elseif y < 0 then
new_acce = {x = 0, y = 20, z = 0}
else
new_acce = {x = 0, y = 5, z = 0}
end
new_velo = get_velocity(self.v, self.object:get_yaw(), y)
self.object:set_pos(self.object:get_pos())
else
new_acce = {x = 0, y = 0, z = 0}
if math.abs(self.object:get_velocity().y) < 1 then
local pos = self.object:get_pos()
pos.y = math.floor(pos.y) + 0.5
self.object:set_pos(pos)
new_velo = get_velocity(self.v, self.object:get_yaw(), 0)
else
new_velo = get_velocity(self.v, self.object:get_yaw(),
self.object:get_velocity().y)
self.object:set_pos(self.object:get_pos())
end
end
end
self.object:set_velocity(new_velo)
self.object:set_acceleration(new_acce)
local p = self.object:get_pos()
p.y = p.y - 0.5
local new_velo
local new_acce = {x = 0, y = 0, z = 0}
if not is_water(p) then
local nodedef = minetest.registered_nodes[minetest.get_node(p).name]
if (not nodedef) or nodedef.walkable then
self.v = 0
new_acce = {x = 0, y = 1, z = 0}
else
new_acce = {x = 0, y = -9.8, z = 0}
end
new_velo = get_velocity(self.v, self.object:get_yaw(),
self.object:get_velocity().y)
self.object:set_pos(self.object:get_pos())
else
p.y = p.y + 1
if is_water(p) then
local y = self.object:get_velocity().y
if y >= 5 then
y = 5
elseif y < 0 then
new_acce = {x = 0, y = 20, z = 0}
else
new_acce = {x = 0, y = 5, z = 0}
end
new_velo = get_velocity(self.v, self.object:get_yaw(), y)
self.object:set_pos(self.object:get_pos())
else
new_acce = {x = 0, y = 0, z = 0}
if math.abs(self.object:get_velocity().y) < 1 then
local pos = self.object:get_pos()
pos.y = math.floor(pos.y) + 0.5
self.object:set_pos(pos)
new_velo = get_velocity(self.v, self.object:get_yaw(), 0)
else
new_velo = get_velocity(self.v, self.object:get_yaw(),
self.object:get_velocity().y)
self.object:set_pos(self.object:get_pos())
end
end
end
self.object:set_velocity(new_velo)
self.object:set_acceleration(new_acce)
end
@ -237,58 +236,58 @@ minetest.register_entity("boats:boat", boat)
minetest.register_craftitem("boats:boat", {
description = S("Boat"),
inventory_image = "boats_inventory.png",
wield_image = "boats_wield.png",
wield_scale = {x = 2, y = 2, z = 1},
liquids_pointable = true,
groups = {flammable = 2},
description = S("Boat"),
inventory_image = "boats_inventory.png",
wield_image = "boats_wield.png",
wield_scale = {x = 2, y = 2, z = 1},
liquids_pointable = true,
groups = {flammable = 2},
on_place = function(itemstack, placer, pointed_thing)
local under = pointed_thing.under
local node = minetest.get_node(under)
local udef = minetest.registered_nodes[node.name]
if udef and udef.on_rightclick and
not (placer and placer:is_player() and
placer:get_player_control().sneak) then
return udef.on_rightclick(under, node, placer, itemstack,
pointed_thing) or itemstack
end
on_place = function(itemstack, placer, pointed_thing)
local under = pointed_thing.under
local node = minetest.get_node(under)
local udef = minetest.registered_nodes[node.name]
if udef and udef.on_rightclick and
not (placer and placer:is_player() and
placer:get_player_control().sneak) then
return udef.on_rightclick(under, node, placer, itemstack,
pointed_thing) or itemstack
end
if pointed_thing.type ~= "node" then
return itemstack
end
if not is_water(pointed_thing.under) then
return itemstack
end
pointed_thing.under.y = pointed_thing.under.y + 0.5
boat = minetest.add_entity(pointed_thing.under, "boats:boat")
if boat then
if placer then
boat:set_yaw(placer:get_look_horizontal())
end
local player_name = placer and placer:get_player_name() or ""
if not (creative and creative.is_enabled_for and
creative.is_enabled_for(player_name)) then
itemstack:take_item()
end
end
return itemstack
end,
if pointed_thing.type ~= "node" then
return itemstack
end
if not is_water(pointed_thing.under) then
return itemstack
end
pointed_thing.under.y = pointed_thing.under.y + 0.5
boat = minetest.add_entity(pointed_thing.under, "boats:boat")
if boat then
if placer then
boat:set_yaw(placer:get_look_horizontal())
end
local player_name = placer and placer:get_player_name() or ""
if not (creative and creative.is_enabled_for and
creative.is_enabled_for(player_name)) then
itemstack:take_item()
end
end
return itemstack
end,
})
minetest.register_craft({
output = "boats:boat",
recipe = {
{"", "", "" },
{"group:wood", "", "group:wood"},
{"group:wood", "group:wood", "group:wood"},
},
output = "boats:boat",
recipe = {
{"", "", "" },
{"group:wood", "", "group:wood"},
{"group:wood", "group:wood", "group:wood"},
},
})
minetest.register_craft({
type = "fuel",
recipe = "boats:boat",
burntime = 20,
type = "fuel",
recipe = "boats:boat",
burntime = 20,
})

View File

@ -27,6 +27,7 @@ function cart_entity:on_rightclick(clicker)
if not clicker or not clicker:is_player() then
return
end
self.object:set_hp(200)
local player_name = clicker:get_player_name()
if self.driver and player_name == self.driver then
self.driver = nil
@ -42,7 +43,7 @@ function cart_entity:on_rightclick(clicker)
end
function cart_entity:on_activate(staticdata, dtime_s)
self.object:set_armor_groups({immortal=1})
--self.object:set_armor_groups({immortal=1})
if string.sub(staticdata, 1, string.len("return")) ~= "return" then
return
end
@ -54,6 +55,7 @@ function cart_entity:on_activate(staticdata, dtime_s)
if data.old_dir then
self.old_dir = data.old_dir
end
self.object:set_hp(200)
end
function cart_entity:get_staticdata()
@ -71,7 +73,7 @@ function cart_entity:on_detach_child(child)
end
end
function cart_entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction)
function cart_entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction, damage)
local pos = self.object:get_pos()
local vel = self.object:get_velocity()
if not self.railtype or vector.equals(vel, {x=0, y=0, z=0}) then

View File

@ -1,18 +1,13 @@
-- mod support (moreblocks/technic_worldgen)
local slab_str = "stairs:slab_wood"
function applyModSupport()
local moreblocks_found = false
local technic_worldgen = false
local modnames = minetest.get_modnames()
for i, name in ipairs(modnames) do
-- minetest.log("[Mod] " .. name)
if name == "moreblocks" then
moreblocks_found = true
end
if name == "technic_worldgen" then
technic_worldgen = true
end
@ -24,11 +19,7 @@ function applyModSupport()
slab_str = "moreblocks:slab_wood"
end
end
--applyModSupport()
--Craft Recipes
-- added mod-support
minetest.register_craft({
output = 'drinks:juice_press',
recipe = {
@ -38,7 +29,6 @@ minetest.register_craft({
}
})
-- added mod-support
minetest.register_craft({
output = 'drinks:liquid_barrel',
recipe = {

View File

@ -11,7 +11,9 @@ doc.add_entry("epic_server", "armor", {
'Armor can\'t be crafted in the crafting grid, but will need to be created at either the anvil or the crystal workshop. You can find public anvils and crystal workshops at spawn.\n\n'..
'In addition to metal or crystals you\'ll also need some sort of fabric/leather. The metal armor can be crafted with burlap or leather, the diamond armor can be crafted with fabric or leather.'..
'Higher tier crystal armors require fabric to craft.\n'..
'You can check out your specific armor levels by looking at the 3d_armor tab in your inventory. Play around with different combinations to find what fits your playstyle best.')
'Some mobs will drop special rings, gloves, and amulets which can be equipped to give you extra armor buffs.'..
'You can check out your specific armor levels by looking at the 3d_armor tab in your inventory. Play around with different combinations to find what fits your playstyle best.\n'..
'Check out episode 26 of the Dev-blog for more information on armor and the combat system.')
}
})
@ -58,3 +60,12 @@ doc.add_entry("epic_server", "maxhp", {
'Some mobs will drop potions that will increase your Max HP by 5, with different caps.\n')
}
})
doc.add_entry("epic_server", "toolranks", {
name = ("Toolranks"),
data = { text = ('The Toolranks mod keeps track of how many times a tool has been used. As you use a tool, it will level up, increasing the tools power.'..
'Tools can be repaired by putting two of the same tool in the crafting grid. Be sure to check the output to make sure you\'re keeping your data.'..
'You can also repair tools in the tool repair station, using either ores, or another tool.\n\n'..
'You can still repair tools/armor at the smithy station, but please note, your toolrank data will be DESTROYED.'
)}
})

View File

@ -2,6 +2,7 @@ minetest.register_tool('epic:pick_titanium', {
_doc_items_crafting = 'This tool is crafted in the Smithy Station.',
description = 'Titanium Pickaxe',
inventory_image = 'epic_tool_titanium_pick.png',
_repair_material = 'epic:titanium_ingot',
tool_capabilities = {
full_punch_interval = 0.8,
max_drop_level=3,
@ -19,6 +20,7 @@ minetest.register_tool('epic:shovel_titanium', {
description = 'Titanium Shovel',
inventory_image = 'epic_tool_titanium_shovel.png',
wield_image = 'epic_tool_titanium_shovel.png^[transformR90',
_repair_material = 'epic:titanium_ingot',
tool_capabilities = {
full_punch_interval = 0.9,
max_drop_level=3,
@ -35,6 +37,7 @@ minetest.register_tool('epic:axe_titanium', {
_doc_items_crafting = 'This tool is crafted in the Smithy Station.',
description = 'Titanium Axe',
inventory_image = 'epic_tool_titanium_axe.png',
_repair_material = 'epic:titanium_ingot',
tool_capabilities = {
full_punch_interval = 0.8,
max_drop_level=3,
@ -51,6 +54,7 @@ minetest.register_tool('epic:sword_titanium', {
_doc_items_crafting = 'This tool is crafted in the Smithy Station.',
description = 'Titanium Sword',
inventory_image = 'epic_tool_titanium_sword.png',
_repair_material = 'epic:titanium_ingot',
tool_capabilities = {
full_punch_interval = 0.6,
max_drop_level=3,
@ -72,6 +76,7 @@ minetest.register_tool('epic:shovel_soft', {
inventory_image = 'epic_tool_shovel_soft.png',
wield_image = 'epic_tool_shovel_soft.png^[transformR90',
sound = {breaks = 'default_tool_breaks'},
_repair_material = 'epic:titanium_ingot',
groups = {shovel = 1, knockback=2},
on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type == "node" then
@ -98,6 +103,7 @@ minetest.register_tool('epic:pick_glowingdiamond', {
description = 'Glowingdiamond Pickaxe',
inventory_image = 'epic_tool_glowingdiamond_pick.png',
light_source = 13,
_repair_material = 'epic:glowingdiamond',
tool_capabilities = {
full_punch_interval = 1.0,
max_drop_level=2,
@ -116,6 +122,7 @@ minetest.register_tool('epic:shovel_glowingdiamond', {
inventory_image = 'epic_tool_glowingdiamond_shovel.png',
light_source = 13,
wield_image = 'epic_tool_glowingdiamond_shovel.png^[transformR90',
_repair_material = 'epic:glowingdiamond',
tool_capabilities = {
full_punch_interval = 1.1,
max_drop_level=1,
@ -133,6 +140,7 @@ minetest.register_tool('epic:axe_glowingdiamond', {
description = 'Glowingdiamond Axe',
inventory_image = 'epic_tool_glowingdiamond_axe.png',
light_source = 13,
_repair_material = 'epic:glowingdiamond',
tool_capabilities = {
full_punch_interval = 1.0,
max_drop_level=1,
@ -150,6 +158,7 @@ minetest.register_tool('epic:sword_glowingdiamond', {
description = 'Glowingdiamond Sword',
inventory_image = 'epic_tool_glowingdiamond_sword.png',
light_source = 13,
_repair_material = 'epic:glowingdiamond',
tool_capabilities = {
full_punch_interval = 0.8,
max_drop_level=1,
@ -205,6 +214,16 @@ minetest.register_tool('epic:reaver', {
groups = {not_in_creative_inventory=1}
})
toolranks.add_tool("epic:sword_titanium")
toolranks.add_tool("epic:sword_glowingdiamond")
toolranks.add_tool("epic:pick_titanium")
toolranks.add_tool("epic:pick_glowingdiamond")
toolranks.add_tool("epic:axe_titanium")
toolranks.add_tool("epic:axe_glowingdiamond")
toolranks.add_tool("epic:shovel_titanium")
toolranks.add_tool("epic:shovel_glowingdiamond")
toolranks.add_tool("epic:shovel_soft")
--[[
--------------------------
This code needs to be put into mobs_redo to handle the rare weapons wearing faster.

View File

@ -1,4 +1,8 @@
local news = {
'7/25/20',
'Added toolranks, and a way to repair tools to keep the rank informaion.',
'Check out the Toolranks information in Help > Server Specific Information > Toolranks for more information.',
'',
'7/23/20',
'Fixed a little issue in the drinks mod.',
'',

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 610 B

File diff suppressed because it is too large Load Diff

View File

@ -33,7 +33,7 @@ local anvil_multifurnace_def = { --on furnace
description = 'Smithy Station',
drawtype = 'mesh',
mesh = 'stations_anvil.obj',
tiles = {'stations_anvil_rust.png', 'stations_anvil_default.png', 'stations_anvil_fire.png'},
tiles = {'stations_anvil.png'},
sounds = default.node_sound_wood_defaults(),
paramtype2 = 'facedir',
paramtype = 'light',
@ -86,7 +86,7 @@ local anvil_locked_multifurnace_def = {
description = 'Smithy Station (locked)',
drawtype = 'mesh',
mesh = 'stations_anvil.obj',
tiles = {'stations_anvil_rust.png', 'stations_anvil_default.png', 'stations_anvil_fire.png'},
tiles = {'stations_anvil.png'},
sounds = default.node_sound_wood_defaults(),
paramtype2 = 'facedir',
paramtype = 'light',

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

27
mods/toolranks/README.md Normal file
View File

@ -0,0 +1,27 @@
# minetest-toolranks [toolranks]
Minetest tool ranks mod
Tools gain levels for digging nodes. Higher level tools dig faster and take longer to wear out.
## Are you a mod developer?
Does one of your mods add new tools?
If so, to support this mod, add this code to your mod, after your tool's code:
```lua
if minetest.get_modpath("toolranks") then
minetest.override_item("mymod:mytool", {
original_description = "My Tool",
description = toolranks.create_description("My Tool"),
after_use = toolranks.new_afteruse
})
end
end
```
Or alternatively, you can use the helper function:
```lua
toolranks.add_tool("mymod:mytool")
```

185
mods/toolranks/init.lua Normal file
View File

@ -0,0 +1,185 @@
local mod_storage = minetest.get_mod_storage()
local S = minetest.get_translator("toolranks")
toolranks = {}
toolranks.colors = {
grey = minetest.get_color_escape_sequence("#9d9d9d"),
green = minetest.get_color_escape_sequence("#1eff00"),
gold = minetest.get_color_escape_sequence("#ffdf00"),
white = minetest.get_color_escape_sequence("#ffffff")
}
local max_speed = tonumber(minetest.settings:get("toolranks_speed_multiplier")) or 2.0
local max_use = tonumber(minetest.settings:get("toolranks_use_multiplier")) or 2.0
local max_level = tonumber(minetest.settings:get("toolranks_levels")) or 10
local level_digs = tonumber(minetest.settings:get("toolranks_level_digs")) or 500
local level_multiplier = 1 / max_level
function toolranks.get_tool_type(description)
if not description then
return "tool"
else
local d = string.lower(description)
if string.find(d, "pickaxe") then
return "pickaxe"
elseif string.find(d, "axe") then
return "axe"
elseif string.find(d, "shovel") then
return "shovel"
elseif string.find(d, "hoe") then
return "hoe"
elseif string.find(d, "sword") then
return "sword"
else
return "tool"
end
end
end
function toolranks.get_level(uses)
if type(uses) == "number" and uses > 0 then
return math.min(max_level, math.floor(uses / level_digs))
end
return 0
end
function toolranks.create_description(name, uses)
local description = name
local tooltype = toolranks.get_tool_type(description)
local newdesc = S(
"@1@2\n@3Level @4 @5\n@6@Node dug: @7",
toolranks.colors.green,
description,
toolranks.colors.gold,
toolranks.get_level(uses),
S(tooltype),
toolranks.colors.grey,
(type(uses) == "number" and uses or 0)
)
return newdesc
end
function toolranks.new_afteruse(itemstack, user, node, digparams)
local itemmeta = itemstack:get_meta()
local itemdef = itemstack:get_definition()
local itemdesc = itemdef.original_description
local dugnodes = tonumber(itemmeta:get_string("dug")) or 0
local lastlevel = tonumber(itemmeta:get_string("lastlevel")) or 0
local most_digs = mod_storage:get_int("most_digs") or 0
local most_digs_user = mod_storage:get_string("most_digs_user") or 0
if digparams.wear > 0 then -- Only count nodes that spend the tool
dugnodes = dugnodes + 1
itemmeta:set_string("dug", dugnodes)
end
if dugnodes > most_digs then
if most_digs_user ~= user:get_player_name() then -- Avoid spam.
minetest.chat_send_all(S(
"Most used tool is now a @1@2@3 owned by @4 with @5 uses.",
toolranks.colors.green,
itemdesc,
toolranks.colors.white,
user:get_player_name(),
dugnodes
))
end
mod_storage:set_int("most_digs", dugnodes)
mod_storage:set_string("most_digs_user", user:get_player_name())
end
if itemstack:get_wear() > 60135 then
minetest.chat_send_player(user:get_player_name(), S("Your tool is about to break!"))
minetest.sound_play("default_tool_breaks", {
to_player = user:get_player_name(),
gain = 2.0,
})
end
local level = toolranks.get_level(dugnodes)
if lastlevel < level then
local levelup_text = S(
"Your @1@2@3 just leveled up!",
toolranks.colors.green,
itemdesc,
toolranks.colors.white
)
minetest.chat_send_player(user:get_player_name(), levelup_text)
minetest.sound_play("toolranks_levelup", {
to_player = user:get_player_name(),
gain = 2.0,
})
-- Make tool better by modifying tool_capabilities (if defined)
if itemdef.tool_capabilities then
local speed_multiplier = 1 + (level * level_multiplier * (max_speed - 1))
local use_multiplier = 1 + (level * level_multiplier * (max_use - 1))
local caps = table.copy(itemdef.tool_capabilities)
caps.full_punch_interval = caps.full_punch_interval and (caps.full_punch_interval / speed_multiplier)
caps.punch_attack_uses = caps.punch_attack_uses and (caps.punch_attack_uses * use_multiplier)
for _,c in pairs(caps.groupcaps) do
c.uses = c.uses * use_multiplier
for i,t in ipairs(c.times) do
c.times[i] = t / speed_multiplier
end
end
itemmeta:set_tool_capabilities(caps)
end
end
-- Old method for compatibility with tools without tool_capabilities defined
local wear = digparams.wear
if level > 0 and not itemdef.tool_capabilities then
local use_multiplier = 1 + (level * level_multiplier * (max_use - 1))
wear = wear / use_multiplier
end
itemmeta:set_string("lastlevel", level)
itemmeta:set_string("description", toolranks.create_description(itemdesc, dugnodes))
itemstack:add_wear(wear)
return itemstack
end
-- Helper function
function toolranks.add_tool(name)
local desc = ItemStack(name):get_definition().description
minetest.override_item(name, {
original_description = desc,
description = toolranks.create_description(desc),
after_use = toolranks.new_afteruse
})
end
-- Sword
toolranks.add_tool("default:sword_wood")
toolranks.add_tool("default:sword_stone")
toolranks.add_tool("default:sword_steel")
toolranks.add_tool("default:sword_bronze")
toolranks.add_tool("default:sword_mese")
toolranks.add_tool("default:sword_diamond")
-- Pickaxe
toolranks.add_tool("default:pick_wood")
toolranks.add_tool("default:pick_stone")
toolranks.add_tool("default:pick_steel")
toolranks.add_tool("default:pick_bronze")
toolranks.add_tool("default:pick_mese")
toolranks.add_tool("default:pick_diamond")
-- Axe
toolranks.add_tool("default:axe_wood")
toolranks.add_tool("default:axe_stone")
toolranks.add_tool("default:axe_steel")
toolranks.add_tool("default:axe_bronze")
toolranks.add_tool("default:axe_mese")
toolranks.add_tool("default:axe_diamond")
-- Shovel
toolranks.add_tool("default:shovel_wood")
toolranks.add_tool("default:shovel_stone")
toolranks.add_tool("default:shovel_steel")
toolranks.add_tool("default:shovel_bronze")
toolranks.add_tool("default:shovel_mese")
toolranks.add_tool("default:shovel_diamond")

View File

@ -0,0 +1,11 @@
# textdomain: toolranks
@1@2@n@3Level @4 @5@n@6Node dug: @7=@1@2@n@3Level @4 @5@n@6Node dug: @7
pickaxe=pickaxe
axe=axe
shovel=shovel
hoe=hoe
sword=sword
tool=tool
Most used tool is now a @1@2@3 owned by @4 with @5 uses.=Most used tool is now a @1@2@3 owned by @4 with @5 uses.
Your tool is about to break!=Your tool is about to break!
Your @1@2@3 just leveled up!=Your @1@2@3 just leveled up!

View File

@ -0,0 +1,11 @@
# textdomain: toolranks
@1@2@n@3Level @4 @5@n@6Node dug: @7=@1@2@n@3@5 niveau @4@n@6Blocks minés : @7
pickaxe=pioche
axe=hache
shovel=pelle
hoe=houe
sword=épée
tool=outil
Most used tool is now a @1@2@3 owned by @4 with @5 uses.=Loutil le plus utilisé est désormais @1@2@3 appartenant à @4 avec @5 utilisations.
Your tool is about to break!=Votre outil va se casser !
Your @1@2@3 just leveled up!=Votre @1@2@3 a gagné un niveau !

2
mods/toolranks/mod.conf Normal file
View File

@ -0,0 +1,2 @@
name = toolranks
depends = default

View File

@ -0,0 +1,8 @@
# Number of tool levels
toolranks_levels (Levels) int 10
# Number of nodes that need to be dug to reach the next tool level
toolranks_level_digs (Digs per level) int 500
# Dig speed multiplier at maximum tool level (1.0 to disable)
toolranks_speed_multiplier (Dig speed multiplier) float 2.0 1.0 10.0
# Durability multiplier at maximum tool level (1.0 to disable)
toolranks_use_multiplier (Durability multiplier) float 2.0 1.0 10.0

Binary file not shown.