Replaces spaces with tabs
parent
faa80348fb
commit
d084b00f33
252
LICENSE.txt
252
LICENSE.txt
|
@ -15,8 +15,8 @@ License of source code
|
|||
Copyright (C) 2017 XtremeHacker
|
||||
See README.txt in each mod directory for information about other authors.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
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
|
||||
|
@ -27,21 +27,21 @@ See README.txt in each mod directory for information about other authors.
|
|||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
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
|
||||
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,
|
||||
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
|
||||
|
@ -49,12 +49,12 @@ 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
|
||||
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
|
||||
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
|
||||
|
@ -62,32 +62,32 @@ 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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
|
@ -95,7 +95,7 @@ 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
|
||||
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
|
||||
|
@ -103,7 +103,7 @@ 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
|
||||
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
|
||||
|
@ -111,38 +111,38 @@ 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
|
||||
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
|
||||
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
|
||||
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
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
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
|
||||
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
|
||||
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
|
||||
|
@ -150,13 +150,13 @@ 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
|
||||
"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
|
||||
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
|
||||
|
@ -164,7 +164,7 @@ 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
|
||||
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
|
||||
|
@ -172,37 +172,37 @@ 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,
|
||||
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
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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.)
|
||||
(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,
|
||||
|
@ -225,7 +225,7 @@ 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
|
||||
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,
|
||||
|
@ -234,65 +234,65 @@ 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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
|
@ -300,39 +300,39 @@ 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.)
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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
|
||||
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
|
||||
|
@ -341,29 +341,29 @@ 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
|
||||
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
|
||||
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.
|
||||
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.
|
||||
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
|
||||
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
|
||||
|
@ -371,7 +371,7 @@ 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
|
||||
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
|
||||
|
@ -380,7 +380,7 @@ 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
|
||||
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
|
||||
|
@ -388,7 +388,7 @@ 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
|
||||
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
|
||||
|
@ -419,7 +419,7 @@ 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
|
||||
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,
|
||||
|
@ -427,7 +427,7 @@ 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
|
||||
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.
|
||||
|
@ -440,7 +440,7 @@ 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
|
||||
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
|
||||
|
@ -449,9 +449,9 @@ 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
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
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
|
||||
|
@ -461,7 +461,7 @@ 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
|
||||
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
|
||||
|
@ -472,37 +472,37 @@ 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
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
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
|
||||
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>
|
||||
<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 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.
|
||||
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
|
||||
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.
|
||||
|
||||
|
@ -510,10 +510,10 @@ 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.
|
||||
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
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
|
150
game_api.md
150
game_api.md
|
@ -54,35 +54,35 @@ The gamemode API allows registering new gamemodes to be used in-game.
|
|||
#### Gamemode definition
|
||||
```lua
|
||||
{
|
||||
tab_group = "creative", -- Group of tabs to be shown in inventory
|
||||
aliases = {"c", "1"}, -- Aliases that refer to the gamemode
|
||||
tab_group = "creative", -- Group of tabs to be shown in inventory
|
||||
aliases = {"c", "1"}, -- Aliases that refer to the gamemode
|
||||
|
||||
-- Gamemode-specific hand definition
|
||||
hand = {
|
||||
range = 10 -- Custom range
|
||||
on_use = function() ... end, -- Custom on_use
|
||||
full_punch_interval = 1.0,
|
||||
-- Gamemode-specific hand definition
|
||||
hand = {
|
||||
range = 10 -- Custom range
|
||||
on_use = function() ... end, -- Custom on_use
|
||||
full_punch_interval = 1.0,
|
||||
max_drop_level = 0,
|
||||
groupcaps = {
|
||||
fleshy = {times={[2]=2.00, [3]=1.00}, uses=0, maxlevel=1},
|
||||
crumbly = {times={[2]=3.00, [3]=0.70}, uses=0, maxlevel=1},
|
||||
snappy = {times={[3]=0.40}, uses=0, maxlevel=1},
|
||||
oddly_breakable_by_hand = {times={[1]=7.00,[2]=4.00,[3]=1.40},
|
||||
uses=0, maxlevel=3},
|
||||
},
|
||||
damage_groups = {fleshy=1},
|
||||
},
|
||||
uses=0, maxlevel=3},
|
||||
},
|
||||
damage_groups = {fleshy=1},
|
||||
},
|
||||
|
||||
stack_unlimited = true, -- Whether the player can place an infinite amount of blocks from a single itemstack
|
||||
item_drops = "auto", -- Automatically pick up item if not in inventory (used by creative), else drop item
|
||||
hud_flags = { hotbar = false }, -- Change HUD flags for gamemode
|
||||
privileges = { interact = false }, -- Enable/disable privileges for gamemode
|
||||
on_enable = function(player)
|
||||
-- Called when the gamemode is enabled for a player
|
||||
end,
|
||||
on_disable = function(player)
|
||||
-- Called when the player changes to another gamemode
|
||||
end,
|
||||
stack_unlimited = true, -- Whether the player can place an infinite amount of blocks from a single itemstack
|
||||
item_drops = "auto", -- Automatically pick up item if not in inventory (used by creative), else drop item
|
||||
hud_flags = { hotbar = false }, -- Change HUD flags for gamemode
|
||||
privileges = { interact = false }, -- Enable/disable privileges for gamemode
|
||||
on_enable = function(player)
|
||||
-- Called when the gamemode is enabled for a player
|
||||
end,
|
||||
on_disable = function(player)
|
||||
-- Called when the player changes to another gamemode
|
||||
end,
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -173,23 +173,23 @@ The GUI API easily generates formstrings for custom elements and allows you to r
|
|||
#### Tab definition
|
||||
```lua
|
||||
{
|
||||
style = "vertical" or "horizontal",
|
||||
-- ^ "vertical" causes the tab to be displayed as part of a
|
||||
-- vertical list (default), while horizontal causes the tab
|
||||
-- to be displayed as part of a horizontal list at the top
|
||||
-- of the formspec.
|
||||
icon = "tab_inventory.png",
|
||||
tooltip = "Inventory",
|
||||
default = true, -- Set tab to default
|
||||
groups = { survival = true, creative = false}, -- Tab groups allow grouping multiple tabs together
|
||||
get = function(name) -- Get formspec string (must return a formstring)
|
||||
return [[
|
||||
label[0,0;Hello world!]
|
||||
]]
|
||||
end,
|
||||
handle = function(name, fields)
|
||||
-- Handle submitted data
|
||||
end,
|
||||
style = "vertical" or "horizontal",
|
||||
-- ^ "vertical" causes the tab to be displayed as part of a
|
||||
-- vertical list (default), while horizontal causes the tab
|
||||
-- to be displayed as part of a horizontal list at the top
|
||||
-- of the formspec.
|
||||
icon = "tab_inventory.png",
|
||||
tooltip = "Inventory",
|
||||
default = true, -- Set tab to default
|
||||
groups = { survival = true, creative = false}, -- Tab groups allow grouping multiple tabs together
|
||||
get = function(name) -- Get formspec string (must return a formstring)
|
||||
return [[
|
||||
label[0,0;Hello world!]
|
||||
]]
|
||||
end,
|
||||
handle = function(name, fields)
|
||||
-- Handle submitted data
|
||||
end,
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -237,13 +237,13 @@ The players API allows getting or setting specifics related to the player includ
|
|||
#### Model definition
|
||||
```lua
|
||||
{
|
||||
animation_speed = 30, -- Animation speed
|
||||
textures = {"character.png"}, -- Textures file
|
||||
animations = {
|
||||
-- Standard animations
|
||||
stand = { x= 0, y= 79, },
|
||||
...
|
||||
}
|
||||
animation_speed = 30, -- Animation speed
|
||||
textures = {"character.png"}, -- Textures file
|
||||
animations = {
|
||||
-- Standard animations
|
||||
stand = { x= 0, y= 79, },
|
||||
...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -255,8 +255,8 @@ The soil API allows registering soils nodes (e.g grass/dirt).
|
|||
|
||||
* `name`: Name of soil (without modname)
|
||||
* `def`: See [Node definition (`register_node`)]
|
||||
* Unless overriden in definition, groups `crumbly` and `soil`,
|
||||
* `is_ground_content`, and `drops` are automatically set.
|
||||
* Unless overriden in definition, groups `crumbly` and `soil`,
|
||||
* `is_ground_content`, and `drops` are automatically set.
|
||||
|
||||
Trees API
|
||||
---------
|
||||
|
@ -301,22 +301,22 @@ The trees API allows registering, checking, placing, and growing trees.
|
|||
#### Tree definition
|
||||
```lua
|
||||
{
|
||||
basename = "Oak", -- Name to be concatenated for other nodes
|
||||
center = "trees_oak_log.png", -- Center (top/bottom) texture
|
||||
sides = "trees_oak_log_sides.png", -- Side texture
|
||||
plank = "trees_oak_plank.png", -- Plank texture
|
||||
sapling = "trees_oak_sapling.png", -- Sapling texture
|
||||
leaf = "trees_oak_leaf.png", -- Leaf texture
|
||||
offset = { x = -3, y = -1, z = -3}, -- Placement offset (x and z typically half the width and depth of the tree, y typically -1)
|
||||
schematic = "oak_tree.mts", -- Tree schematic file
|
||||
-- Mapgen definitions (minus those mentioned above - i.e. schematic)
|
||||
mapgen = {
|
||||
place_on = {"soil:dirt_with_grass"},
|
||||
fill_ratio = 0.05,
|
||||
biomes = {"eden:grassland"},
|
||||
y_min = 1,
|
||||
y_max = 200,
|
||||
},
|
||||
basename = "Oak", -- Name to be concatenated for other nodes
|
||||
center = "trees_oak_log.png", -- Center (top/bottom) texture
|
||||
sides = "trees_oak_log_sides.png", -- Side texture
|
||||
plank = "trees_oak_plank.png", -- Plank texture
|
||||
sapling = "trees_oak_sapling.png", -- Sapling texture
|
||||
leaf = "trees_oak_leaf.png", -- Leaf texture
|
||||
offset = { x = -3, y = -1, z = -3}, -- Placement offset (x and z typically half the width and depth of the tree, y typically -1)
|
||||
schematic = "oak_tree.mts", -- Tree schematic file
|
||||
-- Mapgen definitions (minus those mentioned above - i.e. schematic)
|
||||
mapgen = {
|
||||
place_on = {"soil:dirt_with_grass"},
|
||||
fill_ratio = 0.05,
|
||||
biomes = {"eden:grassland"},
|
||||
y_min = 1,
|
||||
y_max = 200,
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -334,7 +334,7 @@ The tools API easily registers entire sets of tools.
|
|||
#### Tool Definition
|
||||
```lua
|
||||
tools.register("Diamond", "diamond", {
|
||||
material = "ores:diamond",
|
||||
material = "ores:diamond",
|
||||
pick = {"tools_diamond_pick.png", {
|
||||
-- Capabilities
|
||||
}},
|
||||
|
@ -366,15 +366,15 @@ The flora API is meant to allow registration of plants and their characteristics
|
|||
#### Plant definition
|
||||
```lua
|
||||
flora.register("cactus", {
|
||||
node = {
|
||||
description = "Cactus",
|
||||
tiles = {"flora_cactus.png"},
|
||||
...
|
||||
},
|
||||
decoration = {
|
||||
deco_type = "simple",
|
||||
place_on = "soil:sand",
|
||||
...
|
||||
},
|
||||
node = {
|
||||
description = "Cactus",
|
||||
tiles = {"flora_cactus.png"},
|
||||
...
|
||||
},
|
||||
decoration = {
|
||||
deco_type = "simple",
|
||||
place_on = "soil:sand",
|
||||
...
|
||||
},
|
||||
})
|
||||
```
|
||||
```
|
||||
|
|
|
@ -14,13 +14,13 @@ Everything not listed in here:
|
|||
XtremeHacker (CC BY-SA 3.0)
|
||||
|
||||
celeron55, Perttu Ahola <celeron55@gmail.com> (CC BY-SA 3.0):
|
||||
character.b3d
|
||||
character.b3d
|
||||
|
||||
Jordach (CC BY-SA 3.0):
|
||||
character.png
|
||||
character.png
|
||||
|
||||
octacian (CC BY-SA 3.0):
|
||||
crosshair.png
|
||||
crosshair.png
|
||||
|
||||
Jordan4ibanez (CC BY-SA 3.0):
|
||||
eden_item_pickup.1.ogg
|
||||
|
|
|
@ -6,19 +6,19 @@ minetest.register_privilege("heal", "Ability to use /heal")
|
|||
-- [command] Heal - /heal param
|
||||
minetest.register_chatcommand("heal", {
|
||||
description = "Heal yourself or another player",
|
||||
params = "<player>",
|
||||
params = "<player>",
|
||||
privs = {heal=true},
|
||||
func = function(name, param)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if param and minetest.get_player_by_name(param) then
|
||||
player = minetest.get_player_by_name(param)
|
||||
elseif param ~= "" then
|
||||
return true, "Player \""..param.."\" doesn't exist"
|
||||
end
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if param and minetest.get_player_by_name(param) then
|
||||
player = minetest.get_player_by_name(param)
|
||||
elseif param ~= "" then
|
||||
return true, "Player \""..param.."\" doesn't exist"
|
||||
end
|
||||
|
||||
-- Set HP
|
||||
player:set_hp(20)
|
||||
-- Return message
|
||||
return true, player:get_player_name().." had been healed"
|
||||
end,
|
||||
-- Set HP
|
||||
player:set_hp(20)
|
||||
-- Return message
|
||||
return true, player:get_player_name().." had been healed"
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -6,20 +6,20 @@ local modpath = minetest.get_modpath("eden")
|
|||
|
||||
-- [function] Get subgame version information
|
||||
function eden.get_version()
|
||||
return {
|
||||
version = "0.1",
|
||||
type = "dev",
|
||||
core = "0.4.15",
|
||||
core_type = "dev",
|
||||
}
|
||||
return {
|
||||
version = "0.1",
|
||||
type = "dev",
|
||||
core = "0.4.15",
|
||||
core_type = "dev",
|
||||
}
|
||||
end
|
||||
|
||||
-- [register] On join send message
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
minetest.after(0, function()
|
||||
minetest.chat_send_player(player:get_player_name(), "This is Eden, a highly"
|
||||
.." work-in-progress Minetest subgame.")
|
||||
end)
|
||||
minetest.after(0, function()
|
||||
minetest.chat_send_player(player:get_player_name(), "This is Eden, a highly"
|
||||
.." work-in-progress Minetest subgame.")
|
||||
end)
|
||||
end)
|
||||
|
||||
-- Load item entity
|
||||
|
|
|
@ -71,7 +71,7 @@ minetest.register_entity("eden:wield_entity", {
|
|||
|
||||
-- [register] Globalstep
|
||||
minetest.register_globalstep(function(dtime)
|
||||
-- Add/update wielditem entity
|
||||
-- Add/update wielditem entity
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
local name = player:get_player_name()
|
||||
local wield = player_wielding[name] or {}
|
||||
|
|
|
@ -12,12 +12,12 @@ local creative = minetest.setting_getbool("creative_mode")
|
|||
|
||||
-- [register] On join set gamemode
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
gamemode.set(player, gamemode.get(player))
|
||||
gamemode.set(player, gamemode.get(player))
|
||||
end)
|
||||
|
||||
-- [register] On place node
|
||||
minetest.register_on_placenode(function(pos, newnode, player, oldnode, itemstack)
|
||||
local mode = gamemode.def(gamemode.get(player))
|
||||
local mode = gamemode.def(gamemode.get(player))
|
||||
local name = player:get_player_name()
|
||||
|
||||
if not gamemode.can_interact(player) then
|
||||
|
@ -27,7 +27,7 @@ minetest.register_on_placenode(function(pos, newnode, player, oldnode, itemstack
|
|||
return true
|
||||
end
|
||||
|
||||
return mode.stack_unlimited
|
||||
return mode.stack_unlimited
|
||||
end)
|
||||
|
||||
-- [register] On dig node
|
||||
|
@ -44,12 +44,12 @@ end)
|
|||
|
||||
-- [register] On hp change
|
||||
minetest.register_on_player_hpchange(function(player, hp_change)
|
||||
local def = gamemode.def(gamemode.get(player))
|
||||
if def.damage == false then
|
||||
return 0
|
||||
else
|
||||
return hp_change
|
||||
end
|
||||
local def = gamemode.def(gamemode.get(player))
|
||||
if def.damage == false then
|
||||
return 0
|
||||
else
|
||||
return hp_change
|
||||
end
|
||||
end, true)
|
||||
|
||||
---
|
||||
|
@ -58,14 +58,14 @@ end, true)
|
|||
|
||||
local rotate_node = minetest.rotate_node
|
||||
function minetest.rotate_node(itemstack, placer, pointed_thing)
|
||||
itemstack = rotate_node(itemstack, placer, pointed_thing)
|
||||
itemstack = rotate_node(itemstack, placer, pointed_thing)
|
||||
|
||||
local mode = gamemode.def(gamemode.get(placer))
|
||||
if not mode.stack_unlimited then
|
||||
itemstack:take_item(1)
|
||||
end
|
||||
local mode = gamemode.def(gamemode.get(placer))
|
||||
if not mode.stack_unlimited then
|
||||
itemstack:take_item(1)
|
||||
end
|
||||
|
||||
return itemstack
|
||||
return itemstack
|
||||
end
|
||||
|
||||
---
|
||||
|
@ -74,19 +74,19 @@ end
|
|||
|
||||
-- [function] Register gamemode
|
||||
function gamemode.register(name, def)
|
||||
-- Register hand
|
||||
if def.hand then
|
||||
minetest.register_item("gamemode:"..name, {
|
||||
type = "none",
|
||||
wield_image = def.hand.wield_image or "wieldhand.png",
|
||||
wield_scale = {x = 1, y = 1, z = 2.5},
|
||||
range = def.hand.range,
|
||||
tool_capabilities = def.hand,
|
||||
-- Register hand
|
||||
if def.hand then
|
||||
minetest.register_item("gamemode:"..name, {
|
||||
type = "none",
|
||||
wield_image = def.hand.wield_image or "wieldhand.png",
|
||||
wield_scale = {x = 1, y = 1, z = 2.5},
|
||||
range = def.hand.range,
|
||||
tool_capabilities = def.hand,
|
||||
on_use = def.hand.on_use,
|
||||
})
|
||||
})
|
||||
|
||||
def.hand = "gamemode:"..name
|
||||
end
|
||||
end
|
||||
|
||||
-- Save aliases
|
||||
if def.aliases then
|
||||
|
@ -101,92 +101,92 @@ end
|
|||
|
||||
-- [function] Get gamemode definition
|
||||
function gamemode.def(name)
|
||||
if gamemodes[name] then
|
||||
return gamemodes[name]
|
||||
if gamemodes[name] then
|
||||
return gamemodes[name]
|
||||
else
|
||||
if aliases[name] then
|
||||
return gamemodes[aliases[name]]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- [function] Set player gamemode
|
||||
function gamemode.set(player, gm_name)
|
||||
local gm = gamemode.def(gm_name)
|
||||
if gm then
|
||||
local name = player:get_player_name()
|
||||
if gm then
|
||||
local name = player:get_player_name()
|
||||
local privs = minetest.get_player_privs(name)
|
||||
|
||||
local old_gm = gamemode.def(gamemode.get(player))
|
||||
-- Revert HUD flags
|
||||
if old_gm.hud_flags then
|
||||
local flags = table.copy(old_gm.hud_flags)
|
||||
for _, f in pairs(flags) do
|
||||
flags[_] = not f
|
||||
end
|
||||
player:hud_set_flags(flags)
|
||||
end
|
||||
local old_gm = gamemode.def(gamemode.get(player))
|
||||
-- Revert HUD flags
|
||||
if old_gm.hud_flags then
|
||||
local flags = table.copy(old_gm.hud_flags)
|
||||
for _, f in pairs(flags) do
|
||||
flags[_] = not f
|
||||
end
|
||||
player:hud_set_flags(flags)
|
||||
end
|
||||
-- Revert privileges
|
||||
if old_gm.privileges then
|
||||
for _, i in pairs(old_gm.privileges) do
|
||||
privs[_] = not old_gm.privileges[_] or nil
|
||||
end
|
||||
end
|
||||
-- Check for on disable
|
||||
if old_gm.on_disable then
|
||||
old_gm.on_disable(player)
|
||||
end
|
||||
if old_gm.privileges then
|
||||
for _, i in pairs(old_gm.privileges) do
|
||||
privs[_] = not old_gm.privileges[_] or nil
|
||||
end
|
||||
end
|
||||
-- Check for on disable
|
||||
if old_gm.on_disable then
|
||||
old_gm.on_disable(player)
|
||||
end
|
||||
|
||||
-- Update cache
|
||||
player:set_attribute("gamemode", gm_name)
|
||||
-- Update formspec
|
||||
if gm.tab_group then
|
||||
gui.set_tab_group(player, gm.tab_group)
|
||||
end
|
||||
-- Update HUD flags
|
||||
if gm.hud_flags then
|
||||
player:hud_set_flags(gm.hud_flags)
|
||||
end
|
||||
-- Check for on enable
|
||||
if gm.on_enable then
|
||||
gm.on_enable(player)
|
||||
end
|
||||
-- Update privileges
|
||||
if gm.privileges then
|
||||
for _, i in pairs(gm.privileges) do
|
||||
privs[_] = gm.privileges[_] or nil
|
||||
end
|
||||
end
|
||||
-- Update hand
|
||||
if gm.hand then
|
||||
player:get_inventory():set_stack("hand", 1, gm.hand)
|
||||
-- Update cache
|
||||
player:set_attribute("gamemode", gm_name)
|
||||
-- Update formspec
|
||||
if gm.tab_group then
|
||||
gui.set_tab_group(player, gm.tab_group)
|
||||
end
|
||||
-- Update HUD flags
|
||||
if gm.hud_flags then
|
||||
player:hud_set_flags(gm.hud_flags)
|
||||
end
|
||||
-- Check for on enable
|
||||
if gm.on_enable then
|
||||
gm.on_enable(player)
|
||||
end
|
||||
-- Update privileges
|
||||
if gm.privileges then
|
||||
for _, i in pairs(gm.privileges) do
|
||||
privs[_] = gm.privileges[_] or nil
|
||||
end
|
||||
end
|
||||
-- Update hand
|
||||
if gm.hand then
|
||||
player:get_inventory():set_stack("hand", 1, gm.hand)
|
||||
else -- else, Reset hand
|
||||
player:get_inventory():set_stack("hand", 1, "")
|
||||
end
|
||||
end
|
||||
|
||||
minetest.set_player_privs(name, privs)
|
||||
|
||||
return true
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
-- [function] Get player gamemode
|
||||
function gamemode.get(player)
|
||||
if type(player) == "string" then
|
||||
player = minetest.get_player_by_name(player)
|
||||
end
|
||||
if type(player) == "string" then
|
||||
player = minetest.get_player_by_name(player)
|
||||
end
|
||||
|
||||
local gm = player:get_attribute("gamemode")
|
||||
if not gm or gm == "" then
|
||||
if creative then gm = "creative"
|
||||
else gm = "survival" end
|
||||
end
|
||||
local gm = player:get_attribute("gamemode")
|
||||
if not gm or gm == "" then
|
||||
if creative then gm = "creative"
|
||||
else gm = "survival" end
|
||||
end
|
||||
|
||||
if not gamemode.def(gm) then
|
||||
return "survival"
|
||||
end
|
||||
|
||||
return gm
|
||||
return gm
|
||||
end
|
||||
|
||||
-- [function] Can interact
|
||||
|
@ -208,10 +208,10 @@ minetest.register_privilege("gamemode", "Ability to use /gamemode")
|
|||
|
||||
-- [command] Gamemode - /gamemode <mode>
|
||||
minetest.register_chatcommand("gamemode", {
|
||||
description = "Change gamemode",
|
||||
params = "<gamemode> / <name> <gamemode>",
|
||||
privs = {gamemode=true},
|
||||
func = function(name, param)
|
||||
description = "Change gamemode",
|
||||
params = "<gamemode> / <name> <gamemode>",
|
||||
privs = {gamemode=true},
|
||||
func = function(name, param)
|
||||
local params = param:split(" ")
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local newgm
|
||||
|
@ -232,11 +232,11 @@ minetest.register_chatcommand("gamemode", {
|
|||
-- Set gamemode
|
||||
if newgm and gamemode.set(player, newgm) then
|
||||
local gm_name = gamemode.def(newgm).name
|
||||
return true, "Set "..player:get_player_name().."'s gamemode to "..gm_name
|
||||
return true, "Set "..player:get_player_name().."'s gamemode to "..gm_name
|
||||
else -- else, Return invalid gamemode
|
||||
return false, "Invalid gamemode "..dump(newgm)
|
||||
end
|
||||
end,
|
||||
end,
|
||||
})
|
||||
|
||||
---
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
-- [gamemode] Survival
|
||||
gamemode.register("survival", {
|
||||
aliases = {"s", "0"},
|
||||
tab_group = "survival",
|
||||
hand = {
|
||||
tab_group = "survival",
|
||||
hand = {
|
||||
full_punch_interval = 1.0,
|
||||
max_drop_level = 0,
|
||||
groupcaps = {
|
||||
|
@ -20,8 +20,8 @@ gamemode.register("survival", {
|
|||
damage_groups = {fleshy=1},
|
||||
},
|
||||
privileges = {
|
||||
interact = true,
|
||||
},
|
||||
interact = true,
|
||||
},
|
||||
})
|
||||
|
||||
local digtime = 25
|
||||
|
@ -29,12 +29,12 @@ local caps = {times = {digtime, digtime, digtime}, uses = 0, maxlevel = 256}
|
|||
-- [gamemode] Creative
|
||||
gamemode.register("creative", {
|
||||
aliases = {"c", "1"},
|
||||
tab_group = "creative",
|
||||
stack_unlimited = true,
|
||||
item_drops = "auto",
|
||||
damage = false,
|
||||
breath = false,
|
||||
hand = {
|
||||
tab_group = "creative",
|
||||
stack_unlimited = true,
|
||||
item_drops = "auto",
|
||||
damage = false,
|
||||
breath = false,
|
||||
hand = {
|
||||
range = 10,
|
||||
full_punch_interval = 0.5,
|
||||
max_drop_level = 3,
|
||||
|
@ -48,43 +48,43 @@ gamemode.register("creative", {
|
|||
damage_groups = {fleshy = 10},
|
||||
},
|
||||
privileges = {
|
||||
fly = true, fast = true,
|
||||
},
|
||||
fly = true, fast = true,
|
||||
},
|
||||
})
|
||||
|
||||
-- [gamemode] Spectator
|
||||
gamemode.register("spectator", {
|
||||
aliases = {"o", "2"},
|
||||
tab_group = "spectator",
|
||||
damage = false,
|
||||
breath = false,
|
||||
tab_group = "spectator",
|
||||
damage = false,
|
||||
breath = false,
|
||||
hand = {
|
||||
range = 0,
|
||||
on_use = function() return end,
|
||||
},
|
||||
hud_flags = {
|
||||
hotbar = false,
|
||||
crosshair = false,
|
||||
wielditem = false,
|
||||
minimap = false,
|
||||
},
|
||||
privileges = {
|
||||
fly = true, noclip = true, fast = true, interact = false,
|
||||
},
|
||||
on_enable = function(player)
|
||||
player:set_properties({
|
||||
hud_flags = {
|
||||
hotbar = false,
|
||||
crosshair = false,
|
||||
wielditem = false,
|
||||
minimap = false,
|
||||
},
|
||||
privileges = {
|
||||
fly = true, noclip = true, fast = true, interact = false,
|
||||
},
|
||||
on_enable = function(player)
|
||||
player:set_properties({
|
||||
visual_size = {x = 0, y = 0},
|
||||
makes_footstep_sound = false,
|
||||
collisionbox = {0},
|
||||
})
|
||||
player:set_nametag_attributes({color = {a = 0}})
|
||||
end,
|
||||
on_disable = function(player)
|
||||
player:set_properties({
|
||||
player:set_nametag_attributes({color = {a = 0}})
|
||||
end,
|
||||
on_disable = function(player)
|
||||
player:set_properties({
|
||||
visual_size = {x = 1, y = 1},
|
||||
makes_footstep_sound = true,
|
||||
collisionbox = {-0.3, -1, -0.3, 0.3, 1, 0.3}
|
||||
})
|
||||
player:set_nametag_attributes({color = {a = 255, r = 255, g = 255, b = 255}})
|
||||
end,
|
||||
player:set_nametag_attributes({color = {a = 255, r = 255, g = 255, b = 255}})
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -11,23 +11,23 @@ Everything not listed in here:
|
|||
XtremeHacker (CC BY-SA 3.0)
|
||||
|
||||
kaadmy (CC BY-SA 4.0):
|
||||
gui_hotbar_bg.png
|
||||
gui_hotbar_selected.png
|
||||
heart.png
|
||||
bubble.png
|
||||
gui_formspec_bg.png
|
||||
gui_tab_active.png
|
||||
gui_tab_inactive.png
|
||||
gui_itemslot.png
|
||||
gui_itemslot_dark.png
|
||||
gui_button_2w_inactive.png
|
||||
gui_button_2w_active.png
|
||||
gui_button_3w_inactive.png
|
||||
gui_button_3w_active.png
|
||||
gui_arrow_bg.png
|
||||
gui_hotbar_bg.png
|
||||
gui_hotbar_selected.png
|
||||
heart.png
|
||||
bubble.png
|
||||
gui_formspec_bg.png
|
||||
gui_tab_active.png
|
||||
gui_tab_inactive.png
|
||||
gui_itemslot.png
|
||||
gui_itemslot_dark.png
|
||||
gui_button_2w_inactive.png
|
||||
gui_button_2w_active.png
|
||||
gui_button_3w_inactive.png
|
||||
gui_button_3w_active.png
|
||||
gui_arrow_bg.png
|
||||
|
||||
octacian (CC BY-SA 3.0):
|
||||
heart_bg.png
|
||||
bubble_bg.png
|
||||
gui_formspec_title.png
|
||||
gui_icon_inventory.png
|
||||
heart_bg.png
|
||||
bubble_bg.png
|
||||
gui_formspec_title.png
|
||||
gui_icon_inventory.png
|
||||
|
|
232
mods/gui/api.lua
232
mods/gui/api.lua
|
@ -11,23 +11,23 @@ local forms = {}
|
|||
|
||||
-- [local function] Preprocess
|
||||
local function pre(player, name, form, group)
|
||||
form = "size[9.5,9]"..form..gui.colors..gui.bg.."background[0,0;9.5,9;gui_formspec_bg.png]"
|
||||
form = "size[9.5,9]"..form..gui.colors..gui.bg.."background[0,0;9.5,9;gui_formspec_bg.png]"
|
||||
|
||||
local tab = gui.get_tab(name)
|
||||
local tabs = forms
|
||||
local group = group or gui.get_inv_group(player)
|
||||
if group then
|
||||
tabs = gui.get_tabs_by_group(group)
|
||||
end
|
||||
local tab = gui.get_tab(name)
|
||||
local tabs = forms
|
||||
local group = group or gui.get_inv_group(player)
|
||||
if group then
|
||||
tabs = gui.get_tabs_by_group(group)
|
||||
end
|
||||
|
||||
local vx, vy = -0.91, 0.5
|
||||
local vx, vy = -0.91, 0.5
|
||||
local hx, hy = 0.5, -0.96
|
||||
-- Generate tabs
|
||||
for _, f in pairs(tabs) do
|
||||
-- Generate tabs
|
||||
for _, f in pairs(tabs) do
|
||||
local x, y, r = vx, vy, ""
|
||||
local style = f.style or "vertical"
|
||||
local icon = f.icon or "gui_null.png"
|
||||
local tooltip = f.tooltip or ""
|
||||
local icon = f.icon or "gui_null.png"
|
||||
local tooltip = f.tooltip or ""
|
||||
local tab = {
|
||||
active = "gui_tab_active.png",
|
||||
inactive = "gui_tab_inactive.png",
|
||||
|
@ -49,21 +49,21 @@ local function pre(player, name, form, group)
|
|||
}
|
||||
end
|
||||
|
||||
local shifted_icon = "[combine:16x16:0,0="..tab.active..":"..shift.active.x..","..shift.active.y.."="..icon
|
||||
local shifted_icon = "[combine:16x16:0,0="..tab.active..":"..shift.active.x..","..shift.active.y.."="..icon
|
||||
icon = "[combine:16x16:0,0="..tab.inactive..":"..shift.inactive.x..","..shift.inactive.y.."="..icon
|
||||
|
||||
form = form .. "image_button["..x..","..y..";1,1;"..minetest.formspec_escape(icon)
|
||||
form = form .. "image_button["..x..","..y..";1,1;"..minetest.formspec_escape(icon)
|
||||
..";".."tab_"..f.name..";;true;false;"..minetest.formspec_escape(shifted_icon).."]"
|
||||
.."tooltip[tab_"..f.name..";"..tooltip.."]"
|
||||
.."tooltip[tab_"..f.name..";"..tooltip.."]"
|
||||
|
||||
if style == "horizontal" then
|
||||
hx = x + 0.82
|
||||
elseif style == "vertical" then
|
||||
vy = y + 0.82
|
||||
vy = y + 0.82
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return form
|
||||
return form
|
||||
end
|
||||
|
||||
---
|
||||
|
@ -72,34 +72,34 @@ end
|
|||
|
||||
-- [register] On join
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
-- Set inventory size
|
||||
player:get_inventory():set_size("main", 9 * 3)
|
||||
-- Set inventory size
|
||||
player:get_inventory():set_size("main", 9 * 3)
|
||||
-- Initialize creative inventory
|
||||
gui.init_creative_inv(player)
|
||||
end)
|
||||
|
||||
-- [register] On receive fields
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname == "" then
|
||||
formname = player:get_attribute("inv_form") or "gui:inventory"
|
||||
end
|
||||
if formname == "" then
|
||||
formname = player:get_attribute("inv_form") or "gui:inventory"
|
||||
end
|
||||
|
||||
formname = formname:split(":")
|
||||
formname = formname:split(":")
|
||||
|
||||
if formname[1] == "gui" and gui.get_tab(formname[2]) then
|
||||
-- Check for tab clicks
|
||||
for _, f in pairs(forms) do
|
||||
if fields["tab_"..f.name] then
|
||||
gui.set_current_tab(player, f.name)
|
||||
return
|
||||
end
|
||||
end
|
||||
if formname[1] == "gui" and gui.get_tab(formname[2]) then
|
||||
-- Check for tab clicks
|
||||
for _, f in pairs(forms) do
|
||||
if fields["tab_"..f.name] then
|
||||
gui.set_current_tab(player, f.name)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local handle = gui.get_tab(formname[2]).handle
|
||||
if handle then
|
||||
handle(player:get_player_name(), fields)
|
||||
end
|
||||
end
|
||||
local handle = gui.get_tab(formname[2]).handle
|
||||
if handle then
|
||||
handle(player:get_player_name(), fields)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
---
|
||||
|
@ -108,84 +108,84 @@ end)
|
|||
|
||||
-- [function] Register tab
|
||||
function gui.register_tab(name, def)
|
||||
def.name = name
|
||||
forms[#forms + 1] = def
|
||||
def.name = name
|
||||
forms[#forms + 1] = def
|
||||
end
|
||||
|
||||
-- [function] Get tab
|
||||
function gui.get_tab(name)
|
||||
for _, f in pairs(forms) do
|
||||
if f.name == name then
|
||||
return f
|
||||
end
|
||||
end
|
||||
for _, f in pairs(forms) do
|
||||
if f.name == name then
|
||||
return f
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- [function] Get tabs by group
|
||||
function gui.get_tabs_by_group(group)
|
||||
local tabs = {}
|
||||
for _, f in pairs(forms) do
|
||||
if f.groups[group] then
|
||||
tabs[#tabs + 1] = f
|
||||
end
|
||||
end
|
||||
return tabs
|
||||
local tabs = {}
|
||||
for _, f in pairs(forms) do
|
||||
if f.groups[group] then
|
||||
tabs[#tabs + 1] = f
|
||||
end
|
||||
end
|
||||
return tabs
|
||||
end
|
||||
|
||||
-- [function] Get group default tab
|
||||
function gui.get_group_default(group)
|
||||
local tabs = gui.get_tabs_by_group(group)
|
||||
if tabs then
|
||||
for _, f in pairs(tabs) do
|
||||
if f.default then
|
||||
return f
|
||||
end
|
||||
end
|
||||
end
|
||||
local tabs = gui.get_tabs_by_group(group)
|
||||
if tabs then
|
||||
for _, f in pairs(tabs) do
|
||||
if f.default then
|
||||
return f
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- [function] Set current tab
|
||||
function gui.set_current_tab(player, formname)
|
||||
if type(player) == "string" then
|
||||
player = minetest.get_player_by_name(player)
|
||||
end
|
||||
local name = player:get_player_name()
|
||||
if type(player) == "string" then
|
||||
player = minetest.get_player_by_name(player)
|
||||
end
|
||||
local name = player:get_player_name()
|
||||
|
||||
if gui.get_tab(formname) then
|
||||
local f = gui.get_tab(formname)
|
||||
if gui.get_tab(formname) then
|
||||
local f = gui.get_tab(formname)
|
||||
|
||||
player:set_inventory_formspec(pre(player, f.name, f.get(name)))
|
||||
player:set_attribute("inv_form", "gui:"..f.name)
|
||||
end
|
||||
player:set_inventory_formspec(pre(player, f.name, f.get(name)))
|
||||
player:set_attribute("inv_form", "gui:"..f.name)
|
||||
end
|
||||
end
|
||||
|
||||
-- [function] Get player inventory group
|
||||
function gui.get_inv_group(player)
|
||||
if type(player) == "string" then
|
||||
player = minetest.get_player_by_name(player)
|
||||
end
|
||||
if type(player) == "string" then
|
||||
player = minetest.get_player_by_name(player)
|
||||
end
|
||||
|
||||
local attr = player:get_attribute("inv_tab_group")
|
||||
if attr and attr ~= "" then
|
||||
return attr
|
||||
end
|
||||
local attr = player:get_attribute("inv_tab_group")
|
||||
if attr and attr ~= "" then
|
||||
return attr
|
||||
end
|
||||
end
|
||||
|
||||
-- [function] Set tab group
|
||||
function gui.set_tab_group(player, group)
|
||||
if type(player) == "string" then
|
||||
player = minetest.get_player_by_name(player)
|
||||
end
|
||||
local name = player:get_player_name()
|
||||
if type(player) == "string" then
|
||||
player = minetest.get_player_by_name(player)
|
||||
end
|
||||
local name = player:get_player_name()
|
||||
|
||||
-- Set attribute
|
||||
player:set_attribute("inv_tab_group", group)
|
||||
-- Set attribute
|
||||
player:set_attribute("inv_tab_group", group)
|
||||
|
||||
local default = gui.get_group_default(group)
|
||||
if default then
|
||||
player:set_inventory_formspec(pre(player, default.name, default.get(name), group))
|
||||
player:set_attribute("inv_form", "gui:"..default.name)
|
||||
end
|
||||
local default = gui.get_group_default(group)
|
||||
if default then
|
||||
player:set_inventory_formspec(pre(player, default.name, default.get(name), group))
|
||||
player:set_attribute("inv_form", "gui:"..default.name)
|
||||
end
|
||||
end
|
||||
|
||||
-- [function] Get itemslot background
|
||||
|
@ -208,24 +208,24 @@ end
|
|||
|
||||
-- [function] Get hotbar itemslot background
|
||||
function gui.get_hotbar_itemslot_bg(x, y, w, h)
|
||||
local out = ""
|
||||
for i = 0, w - 1, 1 do
|
||||
for j = 0, h - 1, 1 do
|
||||
out = out .."image["..x+i..","..y+j..";1,1;gui_itemslot.png^gui_itemslot_dark.png]"
|
||||
end
|
||||
end
|
||||
return out
|
||||
local out = ""
|
||||
for i = 0, w - 1, 1 do
|
||||
for j = 0, h - 1, 1 do
|
||||
out = out .."image["..x+i..","..y+j..";1,1;gui_itemslot.png^gui_itemslot_dark.png]"
|
||||
end
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
-- [function] Make inventory
|
||||
function gui.make_inv(x, y, w, h, location, name, hotbar, start, strict_count)
|
||||
start = start or ""
|
||||
start = start or ""
|
||||
|
||||
if hotbar ~= false then
|
||||
hotbar = gui.get_hotbar_itemslot_bg(x, y, w, 1)
|
||||
else
|
||||
hotbar = ""
|
||||
end
|
||||
if hotbar ~= false then
|
||||
hotbar = gui.get_hotbar_itemslot_bg(x, y, w, 1)
|
||||
else
|
||||
hotbar = ""
|
||||
end
|
||||
|
||||
local count
|
||||
if strict_count then
|
||||
|
@ -265,29 +265,29 @@ function gui.make_inv(x, y, w, h, location, name, hotbar, start, strict_count)
|
|||
end
|
||||
end
|
||||
|
||||
return "list["..location..";"..name..";"..x..","..y..";"..w..","..h..";"..start.."]"
|
||||
..hotbar..gui.get_itemslot_bg(x, y, w, h, (count or nil))
|
||||
return "list["..location..";"..name..";"..x..","..y..";"..w..","..h..";"..start.."]"
|
||||
..hotbar..gui.get_itemslot_bg(x, y, w, h, (count or nil))
|
||||
end
|
||||
|
||||
-- [function] Make button
|
||||
function gui.make_button(x, y, w, h, name, label, noclip, exit)
|
||||
local nc = tostring(noclip) or "false"
|
||||
local nc = tostring(noclip) or "false"
|
||||
|
||||
local type = "image_button"
|
||||
if exit == true then
|
||||
type = "image_button_exit"
|
||||
end
|
||||
local type = "image_button"
|
||||
if exit == true then
|
||||
type = "image_button_exit"
|
||||
end
|
||||
|
||||
if w == 1 then
|
||||
return type.."["..x..","..y..";"..w..","..h..";gui_button_1w_inactive.png;"
|
||||
..name..";"..label..";"..nc..";false;gui_button_1w_active.png]"
|
||||
elseif w == 2 then
|
||||
return type.."["..x..","..y..";"..w..","..h..";gui_button_2w_inactive.png;"
|
||||
..name..";"..label..";"..nc..";false;gui_button_2w_active.png]"
|
||||
else
|
||||
return type.."["..x..","..y..";"..w..","..h..";gui_button_3w_inactive.png;"
|
||||
..name..";"..label..";"..nc..";false;gui_button_3w_active.png]"
|
||||
end
|
||||
if w == 1 then
|
||||
return type.."["..x..","..y..";"..w..","..h..";gui_button_1w_inactive.png;"
|
||||
..name..";"..label..";"..nc..";false;gui_button_1w_active.png]"
|
||||
elseif w == 2 then
|
||||
return type.."["..x..","..y..";"..w..","..h..";gui_button_2w_inactive.png;"
|
||||
..name..";"..label..";"..nc..";false;gui_button_2w_active.png]"
|
||||
else
|
||||
return type.."["..x..","..y..";"..w..","..h..";gui_button_3w_inactive.png;"
|
||||
..name..";"..label..";"..nc..";false;gui_button_3w_active.png]"
|
||||
end
|
||||
end
|
||||
|
||||
---
|
||||
|
|
|
@ -6,19 +6,19 @@
|
|||
|
||||
-- [register] Inventory tab
|
||||
gui.register_tab("inventory", {
|
||||
icon = "gui_icon_inventory.png",
|
||||
tooltip = "Inventory",
|
||||
default = true,
|
||||
groups = {survival = true, creative = true},
|
||||
get = function(name)
|
||||
return
|
||||
gui.make_inv(2.3, 1, 3, 3, "current_player", "craft", false) ..
|
||||
"image[5.25,2;1,1;gui_arrow_bg.png^[transformR270]" ..
|
||||
icon = "gui_icon_inventory.png",
|
||||
tooltip = "Inventory",
|
||||
default = true,
|
||||
groups = {survival = true, creative = true},
|
||||
get = function(name)
|
||||
return
|
||||
gui.make_inv(2.3, 1, 3, 3, "current_player", "craft", false) ..
|
||||
"image[5.25,2;1,1;gui_arrow_bg.png^[transformR270]" ..
|
||||
"listring[current_player;main]" ..
|
||||
"listring[current_player;craft]" ..
|
||||
gui.make_inv(6.25, 2, 1, 1, "current_player", "craftpreview", false) ..
|
||||
gui.make_inv(0.25, 4.7, 9, 4, "current_player", "main")
|
||||
end,
|
||||
gui.make_inv(6.25, 2, 1, 1, "current_player", "craftpreview", false) ..
|
||||
gui.make_inv(0.25, 4.7, 9, 4, "current_player", "main")
|
||||
end,
|
||||
handle = function(name, fields)
|
||||
if fields.quit then
|
||||
local player = minetest.get_player_by_name(name)
|
||||
|
@ -42,69 +42,69 @@ local items = minetest.registered_items
|
|||
-- [register] Creative inventory tab
|
||||
gui.register_tab("creative", {
|
||||
icon = "gui_icon_creative.png",
|
||||
tooltip = "Creative inventory",
|
||||
groups = {creative = true},
|
||||
get = function(name)
|
||||
gui.update_creative_inv(name, items)
|
||||
local inv = gui.creative_inventory[name]
|
||||
local start_i = inv.start_i or 0
|
||||
local pagenum = math.floor(start_i / (6*9) + 1)
|
||||
local pagemax = math.ceil(inv.size / (6*9))
|
||||
return
|
||||
"label[7.48,6.7;" .. minetest.colorize("#FFFF00", tostring(pagenum)) .. " / " .. tostring(pagemax) .. "]" ..
|
||||
gui.make_inv(0.25, 7.7, 9, 1, "current_player", "main") ..
|
||||
gui.make_inv(5.25, 6.5, 1, 1, "detached:trash", "main", false) ..
|
||||
"listring[]" ..
|
||||
"listring[current_player;main]" ..
|
||||
"listring[detached:creative_" .. name .. ";main]" ..
|
||||
gui.make_inv(0.25, 0.25, 9, 6, "detached:creative_" .. name, "main", false, tostring(start_i), true) ..
|
||||
"field[0.55,6.89;3.2,1;creative_filter;;" .. minetest.formspec_escape(inv.filter) .. "]" ..
|
||||
gui.make_button(6.65, 6.55, 1, 1, "creative_prev", "<") ..
|
||||
gui.make_button(8.34, 6.55, 1, 1, "creative_next", ">") ..
|
||||
gui.make_button(3.35, 6.55, 1, 1, "creative_search", "?") ..
|
||||
gui.make_button(4, 6.55, 1, 1, "creative_clear", "X") ..
|
||||
[[
|
||||
image[5.33,6.6;0.8,0.8;gui_icon_trash.png]
|
||||
tooltip[creative_search;Search]
|
||||
tooltip[creative_clear;Reset]
|
||||
listring[current_player;main]
|
||||
listring[current_player;main]
|
||||
field_close_on_enter[creative_filter;false]
|
||||
]]
|
||||
end,
|
||||
handle = function(name, fields)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local inv = gui.creative_inventory[name]
|
||||
assert(inv)
|
||||
tooltip = "Creative inventory",
|
||||
groups = {creative = true},
|
||||
get = function(name)
|
||||
gui.update_creative_inv(name, items)
|
||||
local inv = gui.creative_inventory[name]
|
||||
local start_i = inv.start_i or 0
|
||||
local pagenum = math.floor(start_i / (6*9) + 1)
|
||||
local pagemax = math.ceil(inv.size / (6*9))
|
||||
return
|
||||
"label[7.48,6.7;" .. minetest.colorize("#FFFF00", tostring(pagenum)) .. " / " .. tostring(pagemax) .. "]" ..
|
||||
gui.make_inv(0.25, 7.7, 9, 1, "current_player", "main") ..
|
||||
gui.make_inv(5.25, 6.5, 1, 1, "detached:trash", "main", false) ..
|
||||
"listring[]" ..
|
||||
"listring[current_player;main]" ..
|
||||
"listring[detached:creative_" .. name .. ";main]" ..
|
||||
gui.make_inv(0.25, 0.25, 9, 6, "detached:creative_" .. name, "main", false, tostring(start_i), true) ..
|
||||
"field[0.55,6.89;3.2,1;creative_filter;;" .. minetest.formspec_escape(inv.filter) .. "]" ..
|
||||
gui.make_button(6.65, 6.55, 1, 1, "creative_prev", "<") ..
|
||||
gui.make_button(8.34, 6.55, 1, 1, "creative_next", ">") ..
|
||||
gui.make_button(3.35, 6.55, 1, 1, "creative_search", "?") ..
|
||||
gui.make_button(4, 6.55, 1, 1, "creative_clear", "X") ..
|
||||
[[
|
||||
image[5.33,6.6;0.8,0.8;gui_icon_trash.png]
|
||||
tooltip[creative_search;Search]
|
||||
tooltip[creative_clear;Reset]
|
||||
listring[current_player;main]
|
||||
listring[current_player;main]
|
||||
field_close_on_enter[creative_filter;false]
|
||||
]]
|
||||
end,
|
||||
handle = function(name, fields)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local inv = gui.creative_inventory[name]
|
||||
assert(inv)
|
||||
|
||||
if fields.creative_clear then
|
||||
inv.start_i = 0
|
||||
inv.filter = ""
|
||||
gui.update_creative_inv(name, items)
|
||||
elseif fields.creative_search or
|
||||
fields.key_enter_field == "creative_filter" then
|
||||
inv.start_i = 0
|
||||
inv.filter = fields.creative_filter:lower()
|
||||
gui.update_creative_inv(name, items)
|
||||
elseif not fields.quit then
|
||||
local start_i = inv.start_i or 0
|
||||
if fields.creative_clear then
|
||||
inv.start_i = 0
|
||||
inv.filter = ""
|
||||
gui.update_creative_inv(name, items)
|
||||
elseif fields.creative_search or
|
||||
fields.key_enter_field == "creative_filter" then
|
||||
inv.start_i = 0
|
||||
inv.filter = fields.creative_filter:lower()
|
||||
gui.update_creative_inv(name, items)
|
||||
elseif not fields.quit then
|
||||
local start_i = inv.start_i or 0
|
||||
|
||||
if fields.creative_prev then
|
||||
start_i = start_i - 6*9
|
||||
if start_i < 0 then
|
||||
start_i = inv.size - (inv.size % (6*9))
|
||||
if inv.size == start_i then
|
||||
start_i = math.max(0, inv.size - (6*9))
|
||||
end
|
||||
end
|
||||
elseif fields.creative_next then
|
||||
start_i = start_i + 6*9
|
||||
if start_i >= inv.size then
|
||||
start_i = 0
|
||||
end
|
||||
end
|
||||
if fields.creative_prev then
|
||||
start_i = start_i - 6*9
|
||||
if start_i < 0 then
|
||||
start_i = inv.size - (inv.size % (6*9))
|
||||
if inv.size == start_i then
|
||||
start_i = math.max(0, inv.size - (6*9))
|
||||
end
|
||||
end
|
||||
elseif fields.creative_next then
|
||||
start_i = start_i + 6*9
|
||||
if start_i >= inv.size then
|
||||
start_i = 0
|
||||
end
|
||||
end
|
||||
|
||||
inv.start_i = start_i
|
||||
end
|
||||
end,
|
||||
inv.start_i = start_i
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
|
110
mods/gui/hud.lua
110
mods/gui/hud.lua
|
@ -2,68 +2,68 @@
|
|||
|
||||
-- [statbar] Health
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
local name = player:get_player_name()
|
||||
|
||||
hudlib.add_statbar(name, "health", {
|
||||
replace = "health",
|
||||
position = { x = 0.5, y = 1 },
|
||||
size = { x = 24, y = 24 },
|
||||
offset = { x = (-10*24)-20, y = -(48+24+16)},
|
||||
texture = "heart.png",
|
||||
background = "heart_bg.png",
|
||||
min = 0,
|
||||
max = 20,
|
||||
start = player:get_hp(),
|
||||
events = {
|
||||
damage = function(self, player)
|
||||
self:set_status(player:get_hp())
|
||||
end,
|
||||
},
|
||||
on_step = function(self, player)
|
||||
local def = gamemode.def(gamemode.get(player))
|
||||
if def.damage == false then
|
||||
self:hide()
|
||||
else
|
||||
self:show()
|
||||
end
|
||||
end,
|
||||
})
|
||||
hudlib.add_statbar(name, "health", {
|
||||
replace = "health",
|
||||
position = { x = 0.5, y = 1 },
|
||||
size = { x = 24, y = 24 },
|
||||
offset = { x = (-10*24)-20, y = -(48+24+16)},
|
||||
texture = "heart.png",
|
||||
background = "heart_bg.png",
|
||||
min = 0,
|
||||
max = 20,
|
||||
start = player:get_hp(),
|
||||
events = {
|
||||
damage = function(self, player)
|
||||
self:set_status(player:get_hp())
|
||||
end,
|
||||
},
|
||||
on_step = function(self, player)
|
||||
local def = gamemode.def(gamemode.get(player))
|
||||
if def.damage == false then
|
||||
self:hide()
|
||||
else
|
||||
self:show()
|
||||
end
|
||||
end,
|
||||
})
|
||||
end)
|
||||
|
||||
-- [statbar] Breath
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
local name = player:get_player_name()
|
||||
|
||||
hudlib.add_statbar(name, "breath", {
|
||||
show = false,
|
||||
replace = "breath",
|
||||
position = { x = 0.5, y = 1 },
|
||||
size = { x = 24, y = 24 },
|
||||
offset = { x = 20, y = -(48+24+17)},
|
||||
texture = "bubble.png",
|
||||
background = "bubble_bg.png",
|
||||
min = 0,
|
||||
max = 20,
|
||||
events = {
|
||||
breath = function(self, player)
|
||||
local bg = hudlib.get_statbar(name, "breath_background")
|
||||
local air = player:get_breath()
|
||||
local def = gamemode.def(gamemode.get(player))
|
||||
hudlib.add_statbar(name, "breath", {
|
||||
show = false,
|
||||
replace = "breath",
|
||||
position = { x = 0.5, y = 1 },
|
||||
size = { x = 24, y = 24 },
|
||||
offset = { x = 20, y = -(48+24+17)},
|
||||
texture = "bubble.png",
|
||||
background = "bubble_bg.png",
|
||||
min = 0,
|
||||
max = 20,
|
||||
events = {
|
||||
breath = function(self, player)
|
||||
local bg = hudlib.get_statbar(name, "breath_background")
|
||||
local air = player:get_breath()
|
||||
local def = gamemode.def(gamemode.get(player))
|
||||
|
||||
if air < 11 and def.breath == false then
|
||||
self:hide()
|
||||
player:set_breath(11)
|
||||
return
|
||||
end
|
||||
if air < 11 and def.breath == false then
|
||||
self:hide()
|
||||
player:set_breath(11)
|
||||
return
|
||||
end
|
||||
|
||||
if air > 10 then
|
||||
self:hide()
|
||||
else
|
||||
self:show()
|
||||
end
|
||||
if air > 10 then
|
||||
self:hide()
|
||||
else
|
||||
self:show()
|
||||
end
|
||||
|
||||
self:set_status(air * 2)
|
||||
end,
|
||||
},
|
||||
})
|
||||
self:set_status(air * 2)
|
||||
end,
|
||||
},
|
||||
})
|
||||
end)
|
||||
|
|
|
@ -6,9 +6,9 @@ local modpath = minetest.get_modpath("gui")
|
|||
|
||||
-- [on join] Configure hotbar
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
player:hud_set_hotbar_itemcount(9)
|
||||
player:hud_set_hotbar_image("gui_hotbar_bg.png")
|
||||
player:hud_set_hotbar_selected_image("gui_hotbar_selected.png")
|
||||
player:hud_set_hotbar_itemcount(9)
|
||||
player:hud_set_hotbar_image("gui_hotbar_bg.png")
|
||||
player:hud_set_hotbar_selected_image("gui_hotbar_selected.png")
|
||||
end)
|
||||
|
||||
-- Load API
|
||||
|
|
|
@ -8,35 +8,35 @@ ores = {}
|
|||
|
||||
-- [local function] Register oredef
|
||||
local function register_oredef(ore, def)
|
||||
local ores = def.ore
|
||||
local ores = def.ore
|
||||
|
||||
local function register(_)
|
||||
local oredef = ores[_]
|
||||
oredef.ore = ore
|
||||
oredef.ore_type = oredef.ore_type or def.ore_type
|
||||
oredef.wherein = oredef.wherein or def.ore_wherein
|
||||
-- Register ore definition
|
||||
minetest.register_ore(oredef)
|
||||
end
|
||||
local function register(_)
|
||||
local oredef = ores[_]
|
||||
oredef.ore = ore
|
||||
oredef.ore_type = oredef.ore_type or def.ore_type
|
||||
oredef.wherein = oredef.wherein or def.ore_wherein
|
||||
-- Register ore definition
|
||||
minetest.register_ore(oredef)
|
||||
end
|
||||
|
||||
for _, i in ipairs(ores) do
|
||||
register(_)
|
||||
end
|
||||
for _, i in ipairs(ores) do
|
||||
register(_)
|
||||
end
|
||||
end
|
||||
|
||||
-- [function] Register ore
|
||||
function ores.register(name, def)
|
||||
-- Check and register ore definition
|
||||
if def.ore then
|
||||
register_oredef("ores:"..name, def)
|
||||
end
|
||||
-- Check and register ore definition
|
||||
if def.ore then
|
||||
register_oredef("ores:"..name, def)
|
||||
end
|
||||
|
||||
-- Ore node
|
||||
minetest.register_node("ores:"..name, {
|
||||
description = def.basename.." Ore",
|
||||
tiles = {"eden_stone.png^"..def.texture},
|
||||
groups = def.groups
|
||||
})
|
||||
-- Ore node
|
||||
minetest.register_node("ores:"..name, {
|
||||
description = def.basename.." Ore",
|
||||
tiles = {"eden_stone.png^"..def.texture},
|
||||
groups = def.groups
|
||||
})
|
||||
end
|
||||
|
||||
---
|
||||
|
@ -45,100 +45,100 @@ end
|
|||
|
||||
-- [ore] Coal
|
||||
ores.register("coal", {
|
||||
basename = "Coal",
|
||||
texture = "ores_coal_ore.png",
|
||||
groups = {cracky = 3},
|
||||
ore_type = "scatter",
|
||||
ore_wherein = "eden:stone",
|
||||
ore = {
|
||||
{
|
||||
clust_scarcity = 8 * 8 * 8,
|
||||
clust_num_ores = 8,
|
||||
clust_size = 3,
|
||||
y_min = -31000,
|
||||
y_max = 64,
|
||||
},
|
||||
{
|
||||
clust_scarcity = 24 * 24 * 24,
|
||||
clust_num_ores = 27,
|
||||
clust_size = 6,
|
||||
y_min = -31000,
|
||||
y_max = 0,
|
||||
},
|
||||
},
|
||||
basename = "Coal",
|
||||
texture = "ores_coal_ore.png",
|
||||
groups = {cracky = 3},
|
||||
ore_type = "scatter",
|
||||
ore_wherein = "eden:stone",
|
||||
ore = {
|
||||
{
|
||||
clust_scarcity = 8 * 8 * 8,
|
||||
clust_num_ores = 8,
|
||||
clust_size = 3,
|
||||
y_min = -31000,
|
||||
y_max = 64,
|
||||
},
|
||||
{
|
||||
clust_scarcity = 24 * 24 * 24,
|
||||
clust_num_ores = 27,
|
||||
clust_size = 6,
|
||||
y_min = -31000,
|
||||
y_max = 0,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- [ore] Iron
|
||||
ores.register("iron", {
|
||||
basename = "Iron",
|
||||
texture = "ores_iron_ore.png",
|
||||
groups = {cracky = 2},
|
||||
ore_type = "scatter",
|
||||
ore_wherein = "eden:stone",
|
||||
ore = {
|
||||
{
|
||||
clust_scarcity = 7 * 7 * 7,
|
||||
clust_num_ores = 5,
|
||||
clust_size = 3,
|
||||
y_min = -31000,
|
||||
y_max = 0,
|
||||
},
|
||||
{
|
||||
clust_scarcity = 24 * 24 * 24,
|
||||
clust_num_ores = 27,
|
||||
clust_size = 6,
|
||||
y_min = -31000,
|
||||
y_max = -64,
|
||||
},
|
||||
},
|
||||
basename = "Iron",
|
||||
texture = "ores_iron_ore.png",
|
||||
groups = {cracky = 2},
|
||||
ore_type = "scatter",
|
||||
ore_wherein = "eden:stone",
|
||||
ore = {
|
||||
{
|
||||
clust_scarcity = 7 * 7 * 7,
|
||||
clust_num_ores = 5,
|
||||
clust_size = 3,
|
||||
y_min = -31000,
|
||||
y_max = 0,
|
||||
},
|
||||
{
|
||||
clust_scarcity = 24 * 24 * 24,
|
||||
clust_num_ores = 27,
|
||||
clust_size = 6,
|
||||
y_min = -31000,
|
||||
y_max = -64,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- [ore] Gold
|
||||
ores.register("gold", {
|
||||
basename = "Gold",
|
||||
texture = "ores_gold_ore.png",
|
||||
groups = {cracky = 2},
|
||||
ore_type = "scatter",
|
||||
ore_wherein = "eden:stone",
|
||||
ore = {
|
||||
{
|
||||
clust_scarcity = 15 * 15 * 15,
|
||||
clust_num_ores = 3,
|
||||
clust_size = 2,
|
||||
y_min = -255,
|
||||
y_max = -64,
|
||||
},
|
||||
{
|
||||
clust_scarcity = 13 * 13 * 13,
|
||||
clust_num_ores = 5,
|
||||
clust_size = 3,
|
||||
y_min = -31000,
|
||||
y_max = -256,
|
||||
},
|
||||
},
|
||||
basename = "Gold",
|
||||
texture = "ores_gold_ore.png",
|
||||
groups = {cracky = 2},
|
||||
ore_type = "scatter",
|
||||
ore_wherein = "eden:stone",
|
||||
ore = {
|
||||
{
|
||||
clust_scarcity = 15 * 15 * 15,
|
||||
clust_num_ores = 3,
|
||||
clust_size = 2,
|
||||
y_min = -255,
|
||||
y_max = -64,
|
||||
},
|
||||
{
|
||||
clust_scarcity = 13 * 13 * 13,
|
||||
clust_num_ores = 5,
|
||||
clust_size = 3,
|
||||
y_min = -31000,
|
||||
y_max = -256,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- [ore] Diamond
|
||||
ores.register("diamond", {
|
||||
basename = "Diamond",
|
||||
texture = "ores_diamond_ore.png",
|
||||
groups = {cracky = 1, level = 3},
|
||||
ore_type = "scatter",
|
||||
ore_wherein = "eden:stone",
|
||||
ore = {
|
||||
{
|
||||
clust_scarcity = 17 * 17 * 17,
|
||||
clust_num_ores = 4,
|
||||
clust_size = 3,
|
||||
y_min = -255,
|
||||
y_max = -128,
|
||||
},
|
||||
{
|
||||
clust_scarcity = 15 * 15 * 15,
|
||||
clust_num_ores = 4,
|
||||
clust_size = 3,
|
||||
y_min = -31000,
|
||||
y_max = -256,
|
||||
},
|
||||
},
|
||||
basename = "Diamond",
|
||||
texture = "ores_diamond_ore.png",
|
||||
groups = {cracky = 1, level = 3},
|
||||
ore_type = "scatter",
|
||||
ore_wherein = "eden:stone",
|
||||
ore = {
|
||||
{
|
||||
clust_scarcity = 17 * 17 * 17,
|
||||
clust_num_ores = 4,
|
||||
clust_size = 3,
|
||||
y_min = -255,
|
||||
y_max = -128,
|
||||
},
|
||||
{
|
||||
clust_scarcity = 15 * 15 * 15,
|
||||
clust_num_ores = 4,
|
||||
clust_size = 3,
|
||||
y_min = -31000,
|
||||
y_max = -256,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
|
@ -11,7 +11,7 @@ Everything not listed in here:
|
|||
XtremeHacker (CC BY-SA 3.0)
|
||||
|
||||
celeron55, Perttu Ahola <celeron55@gmail.com> (CC BY-SA 3.0):
|
||||
character.b3d
|
||||
character.b3d
|
||||
|
||||
Jordach (CC BY-SA 3.0):
|
||||
character.png
|
||||
character.png
|
||||
|
|
|
@ -15,9 +15,9 @@ local models = players.registered_models
|
|||
function players.register_model(name, def)
|
||||
models[name] = def
|
||||
|
||||
if def.default_model then
|
||||
players.default_model = name
|
||||
end
|
||||
if def.default_model then
|
||||
players.default_model = name
|
||||
end
|
||||
end
|
||||
|
||||
-- Player stats and animations
|
||||
|
@ -96,9 +96,9 @@ end
|
|||
|
||||
-- [on joinplayer] Update appearance/physics
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
if not players.default_model then
|
||||
return
|
||||
end
|
||||
if not players.default_model then
|
||||
return
|
||||
end
|
||||
|
||||
players.attached[player:get_player_name()] = false
|
||||
players.set_model(player, players.default_model)
|
||||
|
|
|
@ -42,7 +42,7 @@ minetest.register_globalstep(function(dtime)
|
|||
if ctrl[PRIMARY] and ctrl.up and not spr.is then
|
||||
start_sprint(player, name, "primary")
|
||||
elseif ((not ctrl[PRIMARY] and spr.is) or
|
||||
(ctrl[PRIMARY] and not ctrl.up and spr.is))
|
||||
(ctrl[PRIMARY] and not ctrl.up and spr.is))
|
||||
and spr.trigger == "primary" then
|
||||
stop_sprint(player, name)
|
||||
end
|
||||
|
@ -55,7 +55,7 @@ minetest.register_globalstep(function(dtime)
|
|||
|
||||
if ctrl[SECOND] ~= secondary[name].last then
|
||||
if secondary[name].time > 0.3 and not spr.is and
|
||||
secondary[name].count > 0 and secondary[name].count < 3 then
|
||||
secondary[name].count > 0 and secondary[name].count < 3 then
|
||||
secondary[name] = {count = 0, time = 0, last = false}
|
||||
return
|
||||
end
|
||||
|
|
|
@ -8,13 +8,13 @@ soil = {}
|
|||
|
||||
-- [function] Register soil
|
||||
function soil.register(name, def)
|
||||
if not def.groups then def.groups = {} end
|
||||
def.groups.crumbly = def.groups.crumbly or 3
|
||||
def.groups.soil = def.groups.soil or 1
|
||||
def.is_ground_content = true
|
||||
def.drop = def.drop or "soil:"..name
|
||||
if not def.groups then def.groups = {} end
|
||||
def.groups.crumbly = def.groups.crumbly or 3
|
||||
def.groups.soil = def.groups.soil or 1
|
||||
def.is_ground_content = true
|
||||
def.drop = def.drop or "soil:"..name
|
||||
|
||||
minetest.register_node("soil:"..name, def)
|
||||
minetest.register_node("soil:"..name, def)
|
||||
end
|
||||
|
||||
---
|
||||
|
|
|
@ -13,4 +13,4 @@ Everything not listed in here:
|
|||
XtremeHacker (CC BY-SA 3.0)
|
||||
|
||||
octacian (CC BY-SA 3.0):
|
||||
trees_oak_sapling.png (please replace)
|
||||
trees_oak_sapling.png (please replace)
|
||||
|
|
|
@ -40,84 +40,84 @@ function trees.register(name, def)
|
|||
}
|
||||
local items = def.items
|
||||
|
||||
-- Sapling
|
||||
minetest.register_node(items.sapling, {
|
||||
-- Sapling
|
||||
minetest.register_node(items.sapling, {
|
||||
tree_type = name,
|
||||
description = def.basename.." Sapling",
|
||||
drawtype = "plantlike",
|
||||
inventory_image = def.sapling,
|
||||
wield_image = def.sapling,
|
||||
tiles = {def.sapling},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
on_timer = trees.grow,
|
||||
on_construct = function(pos)
|
||||
minetest.get_node_timer(pos):start(math.random(def.time.start_min, def.time.start_max))
|
||||
end,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
|
||||
},
|
||||
groups = {dig_immediate = 3, flammable = 2, sapling = 1},
|
||||
})
|
||||
|
||||
-- Normal (large)
|
||||
minetest.register_node(items.large, {
|
||||
tree_type = name,
|
||||
description = "Large "..def.basename.." Log",
|
||||
tiles = {def.center, def.sides},
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = false,
|
||||
groups = {choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, log = 1},
|
||||
on_place = minetest.rotate_node,
|
||||
})
|
||||
|
||||
-- Trunk
|
||||
minetest.register_node(items.trunk, {
|
||||
tree_type = name,
|
||||
description = def.basename.." Trunk",
|
||||
tiles = {def.center, def.sides},
|
||||
description = def.basename.." Sapling",
|
||||
drawtype = "plantlike",
|
||||
inventory_image = def.sapling,
|
||||
wield_image = def.sapling,
|
||||
tiles = {def.sapling},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = false,
|
||||
groups = {choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, log = 1, not_in_creative_inventory = 1},
|
||||
drop = "trees:"..name.."_large",
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.25, -0.5, -0.25, 0.25, 0.5, 0.25}, -- Base
|
||||
{-0.1875, -0.5, -0.375, 0.25, 0.375, -0.25}, -- NodeBox3
|
||||
{0.25, -0.5, -0.1875, 0.375, 0.1875, 0.1875}, -- NodeBox4
|
||||
{-0.375, -0.5, -0.25, -0.25, 0.25, 0.1875}, -- NodeBox5
|
||||
{-0.1875, -0.5, 0.25, 0.1875, 0.4375, 0.375}, -- NodeBox6
|
||||
{-0.0625, -0.5, 0.375, 0.125, 0, 0.4375}, -- NodeBox7
|
||||
},
|
||||
},
|
||||
})
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
on_timer = trees.grow,
|
||||
on_construct = function(pos)
|
||||
minetest.get_node_timer(pos):start(math.random(def.time.start_min, def.time.start_max))
|
||||
end,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
|
||||
},
|
||||
groups = {dig_immediate = 3, flammable = 2, sapling = 1},
|
||||
})
|
||||
|
||||
-- Log
|
||||
minetest.register_node(items.log, {
|
||||
-- Normal (large)
|
||||
minetest.register_node(items.large, {
|
||||
tree_type = name,
|
||||
description = def.basename.." Log",
|
||||
tiles = {def.center, def.sides},
|
||||
description = "Large "..def.basename.." Log",
|
||||
tiles = {def.center, def.sides},
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = false,
|
||||
groups = {choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, log = 1},
|
||||
on_place = minetest.rotate_node,
|
||||
})
|
||||
|
||||
-- Trunk
|
||||
minetest.register_node(items.trunk, {
|
||||
tree_type = name,
|
||||
description = def.basename.." Trunk",
|
||||
tiles = {def.center, def.sides},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = false,
|
||||
groups = {choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, log = 1, not_in_creative_inventory = 1},
|
||||
drop = "trees:"..name.."_large",
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "connected",
|
||||
fixed = {-0.25, -0.5, -0.25, 0.25, 0.5, 0.25},
|
||||
connect_front = {-0.125, -0.125, -0.5, 0.1875, 0.1875, -0.25},
|
||||
connect_back = {-0.1875, -0.125, 0.1875, 0.1875, 0.1875, 0.5},
|
||||
connect_left = {-0.5, -0.125, -0.125, -0.25, 0.1875, 0.125},
|
||||
connect_right = {0.25, -0.125, -0.125, 0.5, 0.1875, 0.1875},
|
||||
},
|
||||
connects_to = {"trees:"..name.."_leaf"},
|
||||
})
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = false,
|
||||
groups = {choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, log = 1, not_in_creative_inventory = 1},
|
||||
drop = "trees:"..name.."_large",
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.25, -0.5, -0.25, 0.25, 0.5, 0.25}, -- Base
|
||||
{-0.1875, -0.5, -0.375, 0.25, 0.375, -0.25}, -- NodeBox3
|
||||
{0.25, -0.5, -0.1875, 0.375, 0.1875, 0.1875}, -- NodeBox4
|
||||
{-0.375, -0.5, -0.25, -0.25, 0.25, 0.1875}, -- NodeBox5
|
||||
{-0.1875, -0.5, 0.25, 0.1875, 0.4375, 0.375}, -- NodeBox6
|
||||
{-0.0625, -0.5, 0.375, 0.125, 0, 0.4375}, -- NodeBox7
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- Log
|
||||
minetest.register_node(items.log, {
|
||||
tree_type = name,
|
||||
description = def.basename.." Log",
|
||||
tiles = {def.center, def.sides},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = false,
|
||||
groups = {choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, log = 1, not_in_creative_inventory = 1},
|
||||
drop = "trees:"..name.."_large",
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "connected",
|
||||
fixed = {-0.25, -0.5, -0.25, 0.25, 0.5, 0.25},
|
||||
connect_front = {-0.125, -0.125, -0.5, 0.1875, 0.1875, -0.25},
|
||||
connect_back = {-0.1875, -0.125, 0.1875, 0.1875, 0.1875, 0.5},
|
||||
connect_left = {-0.5, -0.125, -0.125, -0.25, 0.1875, 0.125},
|
||||
connect_right = {0.25, -0.125, -0.125, 0.5, 0.1875, 0.1875},
|
||||
},
|
||||
connects_to = {"trees:"..name.."_leaf"},
|
||||
})
|
||||
|
||||
-- Plank
|
||||
minetest.register_node(items.plank, {
|
||||
|
@ -135,18 +135,18 @@ function trees.register(name, def)
|
|||
recipe = {"trees:"..name.."_large"},
|
||||
})
|
||||
|
||||
-- Leaf
|
||||
minetest.register_node(items.leaf, {
|
||||
-- Leaf
|
||||
minetest.register_node(items.leaf, {
|
||||
tree_type = name,
|
||||
description = def.basename.." Leaf",
|
||||
tiles = {def.leaf},
|
||||
drawtype = "allfaces_optional",
|
||||
waving = 1,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = false,
|
||||
groups = {snappy = 3, flammable = 2, leaves = 1},
|
||||
})
|
||||
description = def.basename.." Leaf",
|
||||
tiles = {def.leaf},
|
||||
drawtype = "allfaces_optional",
|
||||
waving = 1,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = false,
|
||||
groups = {snappy = 3, flammable = 2, leaves = 1},
|
||||
})
|
||||
|
||||
-- Wall Node
|
||||
minetest.register_node(items.wall, {
|
||||
|
@ -224,29 +224,29 @@ function trees.register(name, def)
|
|||
},
|
||||
})
|
||||
|
||||
-- Decoration
|
||||
-- Decoration
|
||||
if def.mapgen and def.schematic then
|
||||
local mapgen = def.mapgen
|
||||
mapgen.deco_type = "schematic"
|
||||
mapgen.sidelen = mapgen.sidelen or 16
|
||||
mapgen.flags = "place_center_x, place_center_z"
|
||||
mapgen.rotation = "random"
|
||||
mapgen.schematic = path.."/"..def.schematic
|
||||
minetest.register_decoration(mapgen)
|
||||
local mapgen = def.mapgen
|
||||
mapgen.deco_type = "schematic"
|
||||
mapgen.sidelen = mapgen.sidelen or 16
|
||||
mapgen.flags = "place_center_x, place_center_z"
|
||||
mapgen.rotation = "random"
|
||||
mapgen.schematic = path.."/"..def.schematic
|
||||
minetest.register_decoration(mapgen)
|
||||
end
|
||||
|
||||
-- General
|
||||
def.name = name
|
||||
def.min_light = def.min_light or 13
|
||||
def.time = def.time or {
|
||||
start_min = 2400,
|
||||
start_max = 4800,
|
||||
retry_min = 240,
|
||||
retry_max = 600,
|
||||
}
|
||||
-- General
|
||||
def.name = name
|
||||
def.min_light = def.min_light or 13
|
||||
def.time = def.time or {
|
||||
start_min = 2400,
|
||||
start_max = 4800,
|
||||
retry_min = 240,
|
||||
retry_max = 600,
|
||||
}
|
||||
|
||||
-- Add to table
|
||||
trees.registered[name] = def
|
||||
-- Add to table
|
||||
trees.registered[name] = def
|
||||
end
|
||||
|
||||
-- [function] Get name
|
||||
|
@ -273,62 +273,62 @@ end
|
|||
|
||||
-- [function] Can grow
|
||||
function trees.can_grow(pos)
|
||||
local def = trees.get_def(pos)
|
||||
local def = trees.get_def(pos)
|
||||
if not def then return end
|
||||
|
||||
local light = def.min_light
|
||||
local light = def.min_light
|
||||
|
||||
local node_under = minetest.get_node_or_nil({x = pos.x, y = pos.y - 1, z = pos.z})
|
||||
-- Check for node under
|
||||
if not node_under then
|
||||
return
|
||||
end
|
||||
local node_under = minetest.get_node_or_nil({x = pos.x, y = pos.y - 1, z = pos.z})
|
||||
-- Check for node under
|
||||
if not node_under then
|
||||
return
|
||||
end
|
||||
|
||||
local name_under = node_under.name
|
||||
-- Check if soil group
|
||||
if minetest.get_item_group(name_under, "soil") == 0 then
|
||||
return
|
||||
end
|
||||
local name_under = node_under.name
|
||||
-- Check if soil group
|
||||
if minetest.get_item_group(name_under, "soil") == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local light_level = minetest.get_node_light(pos)
|
||||
if light and not light_level or light_level < light then
|
||||
return
|
||||
end
|
||||
local light_level = minetest.get_node_light(pos)
|
||||
if light and not light_level or light_level < light then
|
||||
return
|
||||
end
|
||||
|
||||
return true
|
||||
return true
|
||||
end
|
||||
|
||||
-- [function] Place tree
|
||||
function trees.place(name, pos)
|
||||
if trees.registered[name] then
|
||||
local tree = trees.registered[name]
|
||||
if tree.schematic then
|
||||
if tree.offset then
|
||||
pos = vector.add(tree.offset, pos)
|
||||
end
|
||||
if trees.registered[name] then
|
||||
local tree = trees.registered[name]
|
||||
if tree.schematic then
|
||||
if tree.offset then
|
||||
pos = vector.add(tree.offset, pos)
|
||||
end
|
||||
|
||||
return minetest.place_schematic(pos, path.."/"..tree.schematic, "random",
|
||||
nil, false)
|
||||
end
|
||||
end
|
||||
return minetest.place_schematic(pos, path.."/"..tree.schematic, "random",
|
||||
nil, false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- [function] Grow tree
|
||||
function trees.grow(pos)
|
||||
if trees.can_grow(pos) then
|
||||
if trees.can_grow(pos) then
|
||||
local name = trees.get_name(pos)
|
||||
local basename = trees.get_def(pos).basename
|
||||
-- Log message
|
||||
minetest.log("action", "A "..basename.." sapling grows into a tree at "..
|
||||
minetest.pos_to_string(pos))
|
||||
-- Place tree
|
||||
trees.place(name, pos)
|
||||
else
|
||||
-- Log message
|
||||
minetest.log("action", "A "..basename.." sapling grows into a tree at "..
|
||||
minetest.pos_to_string(pos))
|
||||
-- Place tree
|
||||
trees.place(name, pos)
|
||||
else
|
||||
local def = trees.get_def(pos)
|
||||
if def then
|
||||
minetest.get_node_timer(pos):start(math.random(def.time.retry_min, def.time.retry_max))
|
||||
minetest.get_node_timer(pos):start(math.random(def.time.retry_min, def.time.retry_max))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---
|
||||
|
@ -337,19 +337,19 @@ end
|
|||
|
||||
-- [register chatcommand] Place tree
|
||||
minetest.register_chatcommand("place_tree", {
|
||||
description = "[DEBUG] Place tree",
|
||||
params = "<tree name> <pos (x y z)>",
|
||||
privs = {debug=true},
|
||||
func = function(name, param)
|
||||
local tname, p = string.match(param, "^([^ ]+) *(.*)$")
|
||||
description = "[DEBUG] Place tree",
|
||||
params = "<tree name> <pos (x y z)>",
|
||||
privs = {debug=true},
|
||||
func = function(name, param)
|
||||
local tname, p = string.match(param, "^([^ ]+) *(.*)$")
|
||||
local pos = minetest.string_to_pos(p)
|
||||
|
||||
if not pos then
|
||||
pos = minetest.get_player_by_name(name):getpos()
|
||||
end
|
||||
if not pos then
|
||||
pos = minetest.get_player_by_name(name):getpos()
|
||||
end
|
||||
|
||||
return true, "Success: "..dump(trees.place(tname, pos))
|
||||
end
|
||||
return true, "Success: "..dump(trees.place(tname, pos))
|
||||
end
|
||||
})
|
||||
|
||||
---
|
||||
|
|
Loading…
Reference in New Issue