update to multicraft
554
LICENSE.txt
|
@ -1,11 +1,10 @@
|
|||
|
||||
--------------------------------------
|
||||
BlockColor Game (2018-2019)
|
||||
|
||||
Blockcolor (Game)
|
||||
---
|
||||
|
||||
--------------------------------------
|
||||
Licenses : GNU LGPL 3.0 for code and Cc By SA 3.0 for medias (http://creativecommons.org/licenses/by-sa/3.0/)
|
||||
|
||||
Licenses : GNU LGPL 2.1 for code and Cc By SA 3.0 for medias.
|
||||
---
|
||||
|
||||
Game Creator : MrChiantos
|
||||
|
||||
|
@ -34,526 +33,67 @@ ComboBlock & ComboStair Model : Nathan (MinetestVideo)
|
|||
Header and Logo : LMD, azekill_DIABLO & MrChiantos
|
||||
Inventory Icons : Xenon (xenonca)
|
||||
|
||||
Minetest_Game and Others Mods : Minetest Team (Look readme or license in mod directory).
|
||||
Minetest : Copyright © 2010-2019 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
Multicraft : Copyright © 2014-2019 Maksim Gamarnik [MoNTE48] MoNTE48@mail.ua & MultiCraft Development Team.
|
||||
|
||||
--------------------------------------
|
||||
|
||||
Minetest (Engine)
|
||||
|
||||
--------------------------------------
|
||||
|
||||
License of media (textures and sounds)
|
||||
--------------------------------------
|
||||
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
See README.txt in each mod directory for information about other authors.
|
||||
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
||||
------
|
||||
|
||||
License of source code
|
||||
----------------------
|
||||
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
See README.txt in each mod directory for information about other authors.
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
========
|
||||
Version 3, 29 June 2007
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
|
||||
|
||||
Preamble
|
||||
0. Additional Definitions.
|
||||
As used herein, “this License” refers to version 3 of the GNU Lesser General Public License, and the “GNU GPL” refers to version 3 of the GNU General Public License.
|
||||
|
||||
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.
|
||||
“The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
|
||||
|
||||
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.
|
||||
An “Application” is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
A “Combined Work” is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the “Linked Version”.
|
||||
|
||||
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.
|
||||
The “Minimal Corresponding Source” for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
The “Corresponding Application Code” for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
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.
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
|
||||
|
||||
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.
|
||||
2. Conveying Modified Versions.
|
||||
If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
|
||||
|
||||
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.
|
||||
a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
|
||||
b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
|
||||
|
||||
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.
|
||||
a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license document.
|
||||
4. Combined Works.
|
||||
You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
|
||||
c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
|
||||
d) Do one of the following:
|
||||
0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
|
||||
1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
|
||||
e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
|
||||
5. Combined Libraries.
|
||||
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 that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
|
||||
b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
The Free Software Foundation may publish revised and/or new versions of the GNU 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.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.
|
|
@ -1,2 +1,2 @@
|
|||
# BlockColor
|
||||
BlockColor is a creative sandbox with only 8 colors. Only a limit : Your Imagination. (Made with Minetest Engine)
|
||||
BlockColor is a creative sandbox with only 8 colors. Only a limit : Your Imagination. (Made with Minetest Engine)
|
Before Width: | Height: | Size: 898 KiB |
Before Width: | Height: | Size: 514 KiB |
|
@ -1,7 +1,7 @@
|
|||
-- Minetest: builtin/client/chatcommands.lua
|
||||
|
||||
|
||||
core.register_on_sending_chat_message(function(message)
|
||||
core.register_on_sending_chat_messages(function(message)
|
||||
if message:sub(1,2) == ".." then
|
||||
return false
|
||||
end
|
||||
|
@ -40,13 +40,8 @@ end)
|
|||
core.register_chatcommand("list_players", {
|
||||
description = core.gettext("List online players"),
|
||||
func = function(param)
|
||||
local player_names = core.get_player_names()
|
||||
if not player_names then
|
||||
return false, core.gettext("This command is disabled by server.")
|
||||
end
|
||||
|
||||
local players = table.concat(player_names, ", ")
|
||||
return true, core.gettext("Online players: ") .. players
|
||||
local players = table.concat(core.get_player_names(), ", ")
|
||||
core.display_chat_message(core.gettext("Online players: ") .. players)
|
||||
end
|
||||
})
|
||||
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
-- CSM death formspec. Only used when clientside modding is enabled, otherwise
|
||||
-- handled by the engine.
|
||||
|
||||
core.register_on_death(function()
|
||||
core.display_chat_message("You died.")
|
||||
local formspec = "size[11,5.5]bgcolor[#320000b4;true]" ..
|
||||
"label[4.85,1.35;" .. fgettext("You died") ..
|
||||
"]button_exit[4,3;3,0.5;btn_respawn;".. fgettext("Respawn") .."]"
|
||||
core.show_formspec("bultin:death", formspec)
|
||||
end)
|
||||
|
||||
core.register_on_formspec_input(function(formname, fields)
|
||||
if formname == "bultin:death" then
|
||||
core.send_respawn()
|
||||
end
|
||||
end)
|
|
@ -1,5 +1,5 @@
|
|||
-- Minetest: builtin/client/init.lua
|
||||
local scriptpath = core.get_builtin_path()
|
||||
local scriptpath = core.get_builtin_path()..DIR_DELIM
|
||||
local clientpath = scriptpath.."client"..DIR_DELIM
|
||||
local commonpath = scriptpath.."common"..DIR_DELIM
|
||||
|
||||
|
@ -8,4 +8,16 @@ dofile(commonpath .. "after.lua")
|
|||
dofile(commonpath .. "chatcommands.lua")
|
||||
dofile(clientpath .. "chatcommands.lua")
|
||||
dofile(commonpath .. "vector.lua")
|
||||
dofile(clientpath .. "death_formspec.lua")
|
||||
|
||||
core.register_on_death(function()
|
||||
core.display_chat_message("You died.")
|
||||
local formspec = "size[11,5.5]bgcolor[#320000b4;true]" ..
|
||||
"label[5,2;" .. fgettext("You died.") .. "]button_exit[3.5,3;4,0.5;btn_respawn;".. fgettext("Respawn") .."]"
|
||||
core.show_formspec("bultin:death", formspec)
|
||||
end)
|
||||
|
||||
core.register_on_formspec_input(function(formname, fields)
|
||||
if formname == "bultin:death" then
|
||||
core.send_respawn()
|
||||
end
|
||||
end)
|
||||
|
|
|
@ -59,10 +59,10 @@ local function make_registration()
|
|||
end
|
||||
|
||||
core.registered_globalsteps, core.register_globalstep = make_registration()
|
||||
core.registered_on_mods_loaded, core.register_on_mods_loaded = make_registration()
|
||||
core.registered_on_shutdown, core.register_on_shutdown = make_registration()
|
||||
core.registered_on_receiving_chat_message, core.register_on_receiving_chat_message = make_registration()
|
||||
core.registered_on_sending_chat_message, core.register_on_sending_chat_message = make_registration()
|
||||
core.registered_on_connect, core.register_on_connect = make_registration()
|
||||
core.registered_on_receiving_chat_messages, core.register_on_receiving_chat_messages = make_registration()
|
||||
core.registered_on_sending_chat_messages, core.register_on_sending_chat_messages = make_registration()
|
||||
core.registered_on_death, core.register_on_death = make_registration()
|
||||
core.registered_on_hp_modification, core.register_on_hp_modification = make_registration()
|
||||
core.registered_on_damage_taken, core.register_on_damage_taken = make_registration()
|
||||
|
@ -71,6 +71,3 @@ core.registered_on_dignode, core.register_on_dignode = make_registration()
|
|||
core.registered_on_punchnode, core.register_on_punchnode = make_registration()
|
||||
core.registered_on_placenode, core.register_on_placenode = make_registration()
|
||||
core.registered_on_item_use, core.register_on_item_use = make_registration()
|
||||
core.registered_on_modchannel_message, core.register_on_modchannel_message = make_registration()
|
||||
core.registered_on_modchannel_signal, core.register_on_modchannel_signal = make_registration()
|
||||
core.registered_on_inventory_open, core.register_on_inventory_open = make_registration()
|
||||
|
|
|
@ -1,33 +1,41 @@
|
|||
local jobs = {}
|
||||
local time = 0.0
|
||||
local time_next = math.huge
|
||||
|
||||
core.register_globalstep(function(dtime)
|
||||
time = time + dtime
|
||||
|
||||
if #jobs < 1 then
|
||||
if time < time_next then
|
||||
return
|
||||
end
|
||||
|
||||
time_next = math.huge
|
||||
|
||||
-- Iterate backwards so that we miss any new timers added by
|
||||
-- a timer callback, and so that we don't skip the next timer
|
||||
-- in the list if we remove one.
|
||||
-- a timer callback.
|
||||
for i = #jobs, 1, -1 do
|
||||
local job = jobs[i]
|
||||
if time >= job.expire then
|
||||
core.set_last_run_mod(job.mod_origin)
|
||||
job.func(unpack(job.arg))
|
||||
table.remove(jobs, i)
|
||||
local jobs_l = #jobs
|
||||
jobs[i] = jobs[jobs_l]
|
||||
jobs[jobs_l] = nil
|
||||
elseif job.expire < time_next then
|
||||
time_next = job.expire
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
function core.after(after, func, ...)
|
||||
assert(tonumber(after) and type(func) == "function",
|
||||
"Invalid core.after invocation")
|
||||
"Invalid minetest.after invocation")
|
||||
local expire = time + after
|
||||
jobs[#jobs + 1] = {
|
||||
func = func,
|
||||
expire = time + after,
|
||||
expire = expire,
|
||||
arg = {...},
|
||||
mod_origin = core.get_last_run_mod()
|
||||
}
|
||||
end
|
||||
time_next = math.min(time_next, expire)
|
||||
end
|
|
@ -97,7 +97,7 @@ end
|
|||
|
||||
if INIT == "client" then
|
||||
core.register_chatcommand("help", {
|
||||
params = gettext("[all | <cmd>]"),
|
||||
params = gettext("[all/<cmd>]"),
|
||||
description = gettext("Get help for commands"),
|
||||
func = function(param)
|
||||
return do_help_cmd(nil, param)
|
||||
|
@ -105,7 +105,7 @@ if INIT == "client" then
|
|||
})
|
||||
else
|
||||
core.register_chatcommand("help", {
|
||||
params = "[all | privs | <cmd>]",
|
||||
params = "[all/privs/<cmd>]",
|
||||
description = "Get help for commands or list privileges",
|
||||
func = do_help_cmd,
|
||||
})
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
--
|
||||
--This program 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
|
||||
--the Free Software Foundation; either version 3.0 of the License, or
|
||||
--(at your option) any later version.
|
||||
--
|
||||
--This program is distributed in the hope that it will be useful,
|
||||
|
@ -47,17 +47,17 @@ function filterlist.create(raw_fct,compare_fct,uid_match_fct,filter_fct,fetch_pa
|
|||
|
||||
assert((raw_fct ~= nil) and (type(raw_fct) == "function"))
|
||||
assert((compare_fct ~= nil) and (type(compare_fct) == "function"))
|
||||
|
||||
|
||||
local self = {}
|
||||
|
||||
|
||||
self.m_raw_list_fct = raw_fct
|
||||
self.m_compare_fct = compare_fct
|
||||
self.m_filter_fct = filter_fct
|
||||
self.m_uid_match_fct = uid_match_fct
|
||||
|
||||
|
||||
self.m_filtercriteria = nil
|
||||
self.m_fetch_param = fetch_param
|
||||
|
||||
|
||||
self.m_sortmode = "none"
|
||||
self.m_sort_list = {}
|
||||
|
||||
|
@ -79,7 +79,7 @@ function filterlist.create(raw_fct,compare_fct,uid_match_fct,filter_fct,fetch_pa
|
|||
self.refresh = filterlist.refresh
|
||||
|
||||
filterlist.process(self)
|
||||
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
@ -128,49 +128,49 @@ function filterlist.get_raw_element(self,idx)
|
|||
if type(idx) ~= "number" then
|
||||
idx = tonumber(idx)
|
||||
end
|
||||
|
||||
|
||||
if idx ~= nil and idx > 0 and idx <= #self.m_raw_list then
|
||||
return self.m_raw_list[idx]
|
||||
end
|
||||
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
function filterlist.get_raw_index(self,listindex)
|
||||
assert(self.m_processed_list ~= nil)
|
||||
|
||||
|
||||
if listindex ~= nil and listindex > 0 and
|
||||
listindex <= #self.m_processed_list then
|
||||
local entry = self.m_processed_list[listindex]
|
||||
|
||||
|
||||
for i,v in ipairs(self.m_raw_list) do
|
||||
|
||||
|
||||
if self.m_compare_fct(v,entry) then
|
||||
return i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return 0
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
function filterlist.get_current_index(self,listindex)
|
||||
assert(self.m_processed_list ~= nil)
|
||||
|
||||
|
||||
if listindex ~= nil and listindex > 0 and
|
||||
listindex <= #self.m_raw_list then
|
||||
local entry = self.m_raw_list[listindex]
|
||||
|
||||
|
||||
for i,v in ipairs(self.m_processed_list) do
|
||||
|
||||
|
||||
if self.m_compare_fct(v,entry) then
|
||||
return i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return 0
|
||||
end
|
||||
|
||||
|
@ -183,23 +183,23 @@ function filterlist.process(self)
|
|||
self.m_processed_list = self.m_raw_list
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
self.m_processed_list = {}
|
||||
|
||||
|
||||
for k,v in pairs(self.m_raw_list) do
|
||||
if self.m_filtercriteria == nil or
|
||||
self.m_filter_fct(v,self.m_filtercriteria) then
|
||||
self.m_processed_list[#self.m_processed_list + 1] = v
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if self.m_sortmode == "none" then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if self.m_sort_list[self.m_sortmode] ~= nil and
|
||||
type(self.m_sort_list[self.m_sortmode]) == "function" then
|
||||
|
||||
|
||||
self.m_sort_list[self.m_sortmode](self)
|
||||
end
|
||||
end
|
||||
|
@ -209,7 +209,7 @@ function filterlist.size(self)
|
|||
if self.m_processed_list == nil then
|
||||
return 0
|
||||
end
|
||||
|
||||
|
||||
return #self.m_processed_list
|
||||
end
|
||||
|
||||
|
@ -233,8 +233,8 @@ function filterlist.raw_index_by_uid(self, uid)
|
|||
elementidx = i
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
-- If there are more elements than one with same name uid can't decide which
|
||||
-- one is meant. self shouldn't be possible but just for sure.
|
||||
if elementcount > 1 then
|
||||
|
@ -254,11 +254,11 @@ function compare_worlds(world1,world2)
|
|||
if world1.path ~= world2.path then
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
if world1.name ~= world2.name then
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
if world1.gameid ~= world2.gameid then
|
||||
return false
|
||||
end
|
||||
|
@ -288,11 +288,11 @@ function sort_mod_list(self)
|
|||
|
||||
table.sort(self.m_processed_list, function(a, b)
|
||||
-- Show game mods at bottom
|
||||
if a.type ~= b.type or a.loc ~= b.loc then
|
||||
if b.type == "game" then
|
||||
return a.loc ~= "game"
|
||||
if a.typ ~= b.typ then
|
||||
if b.typ == "game" then
|
||||
return a.typ ~= "game_mod"
|
||||
end
|
||||
return b.loc == "game"
|
||||
return b.typ == "game_mod"
|
||||
end
|
||||
-- If in same or no modpack, sort by name
|
||||
if a.modpack == b.modpack then
|
||||
|
@ -308,7 +308,7 @@ function sort_mod_list(self)
|
|||
elseif b.name == a.modpack then
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
local name_a = a.modpack or a.name
|
||||
local name_b = b.modpack or b.name
|
||||
if name_a:lower() == name_b:lower() then
|
||||
|
|
|
@ -166,9 +166,9 @@ end
|
|||
--------------------------------------------------------------------------------
|
||||
function string.split(str, delim, include_empty, max_splits, sep_is_pattern)
|
||||
delim = delim or ","
|
||||
max_splits = max_splits or -2
|
||||
max_splits = max_splits or -1
|
||||
local items = {}
|
||||
local pos, len = 1, #str
|
||||
local pos, len, seplen = 1, #str, #delim
|
||||
local plain = not sep_is_pattern
|
||||
max_splits = max_splits + 1
|
||||
repeat
|
||||
|
@ -382,7 +382,7 @@ if INIT == "game" then
|
|||
param2 = dirs1[fdir + 1]
|
||||
elseif isceiling then
|
||||
if orient_flags.force_facedir then
|
||||
param2 = 20
|
||||
cparam2 = 20
|
||||
else
|
||||
param2 = dirs2[fdir + 1]
|
||||
end
|
||||
|
@ -462,12 +462,6 @@ function core.explode_scrollbar_event(evt)
|
|||
return retval
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
function core.rgba(r, g, b, a)
|
||||
return a and string.format("#%02X%02X%02X%02X", r, g, b, a) or
|
||||
string.format("#%02X%02X%02X", r, g, b)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
function core.pos_to_string(pos, decimal_places)
|
||||
local x = pos.x
|
||||
|
@ -495,7 +489,7 @@ function core.string_to_pos(value)
|
|||
p.z = tonumber(p.z)
|
||||
return p
|
||||
end
|
||||
p = {}
|
||||
local p = {}
|
||||
p.x, p.y, p.z = string.match(value, "^%( *([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+) *%)$")
|
||||
if p.x and p.y and p.z then
|
||||
p.x = tonumber(p.x)
|
||||
|
@ -551,22 +545,12 @@ function table.copy(t, seen)
|
|||
end
|
||||
return n
|
||||
end
|
||||
|
||||
|
||||
function table.insert_all(t, other)
|
||||
for i=1, #other do
|
||||
t[#t + 1] = other[i]
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- mainmenu only functions
|
||||
--------------------------------------------------------------------------------
|
||||
if INIT == "mainmenu" then
|
||||
function core.get_game(index)
|
||||
local games = core.get_games()
|
||||
local games = game.get_games()
|
||||
|
||||
if index > 0 and index <= #games then
|
||||
return games[index]
|
||||
|
@ -641,57 +625,10 @@ function core.strip_colors(str)
|
|||
return (str:gsub(ESCAPE_CHAR .. "%([bc]@[^)]+%)", ""))
|
||||
end
|
||||
|
||||
function core.translate(textdomain, str, ...)
|
||||
local start_seq
|
||||
if textdomain == "" then
|
||||
start_seq = ESCAPE_CHAR .. "T"
|
||||
else
|
||||
start_seq = ESCAPE_CHAR .. "(T@" .. textdomain .. ")"
|
||||
end
|
||||
local arg = {n=select('#', ...), ...}
|
||||
local end_seq = ESCAPE_CHAR .. "E"
|
||||
local arg_index = 1
|
||||
local translated = str:gsub("@(.)", function(matched)
|
||||
local c = string.byte(matched)
|
||||
if string.byte("1") <= c and c <= string.byte("9") then
|
||||
local a = c - string.byte("0")
|
||||
if a ~= arg_index then
|
||||
error("Escape sequences in string given to core.translate " ..
|
||||
"are not in the correct order: got @" .. matched ..
|
||||
"but expected @" .. tostring(arg_index))
|
||||
end
|
||||
if a > arg.n then
|
||||
error("Not enough arguments provided to core.translate")
|
||||
end
|
||||
arg_index = arg_index + 1
|
||||
return ESCAPE_CHAR .. "F" .. arg[a] .. ESCAPE_CHAR .. "E"
|
||||
elseif matched == "n" then
|
||||
return "\n"
|
||||
else
|
||||
return matched
|
||||
end
|
||||
end)
|
||||
if arg_index < arg.n + 1 then
|
||||
error("Too many arguments provided to core.translate")
|
||||
end
|
||||
return start_seq .. translated .. end_seq
|
||||
end
|
||||
|
||||
function core.get_translator(textdomain)
|
||||
return function(str, ...) return core.translate(textdomain or "", str, ...) end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Returns the exact coordinate of a pointed surface
|
||||
--------------------------------------------------------------------------------
|
||||
function core.pointed_thing_to_face_pos(placer, pointed_thing)
|
||||
-- Avoid crash in some situations when player is inside a node, causing
|
||||
-- 'above' to equal 'under'.
|
||||
if vector.equals(pointed_thing.above, pointed_thing.under) then
|
||||
return pointed_thing.under
|
||||
end
|
||||
|
||||
local eye_height = placer:get_properties().eye_height
|
||||
local eye_offset_first = placer:get_eye_offset()
|
||||
local node_pos = pointed_thing.under
|
||||
local camera_pos = placer:get_pos()
|
||||
|
@ -711,7 +648,7 @@ function core.pointed_thing_to_face_pos(placer, pointed_thing)
|
|||
end
|
||||
|
||||
local fine_pos = {[nc] = node_pos[nc] + offset}
|
||||
camera_pos.y = camera_pos.y + eye_height + eye_offset_first.y / 10
|
||||
camera_pos.y = camera_pos.y + 1.625 + eye_offset_first.y / 10
|
||||
local f = (node_pos[nc] + offset - camera_pos[nc]) / look_dir[nc]
|
||||
|
||||
for i = 1, #oc do
|
||||
|
@ -719,28 +656,3 @@ function core.pointed_thing_to_face_pos(placer, pointed_thing)
|
|||
end
|
||||
return fine_pos
|
||||
end
|
||||
|
||||
function core.string_to_privs(str, delim)
|
||||
assert(type(str) == "string")
|
||||
delim = delim or ','
|
||||
local privs = {}
|
||||
for _, priv in pairs(string.split(str, delim)) do
|
||||
privs[priv:trim()] = true
|
||||
end
|
||||
return privs
|
||||
end
|
||||
|
||||
function core.privs_to_string(privs, delim)
|
||||
assert(type(privs) == "table")
|
||||
delim = delim or ','
|
||||
local list = {}
|
||||
for priv, bool in pairs(privs) do
|
||||
if bool then
|
||||
list[#list + 1] = priv
|
||||
end
|
||||
end
|
||||
return table.concat(list, delim)
|
||||
end
|
||||
|
||||
assert(core.string_to_privs("a,b").b == true)
|
||||
assert(core.privs_to_string({a=true,b=true}) == "a,b")
|
||||
|
|
|
@ -63,13 +63,34 @@ function vector.distance(a, b)
|
|||
end
|
||||
|
||||
function vector.direction(pos1, pos2)
|
||||
return vector.normalize({
|
||||
x = pos2.x - pos1.x,
|
||||
y = pos2.y - pos1.y,
|
||||
z = pos2.z - pos1.z
|
||||
})
|
||||
local x_raw = pos2.x - pos1.x
|
||||
local y_raw = pos2.y - pos1.y
|
||||
local z_raw = pos2.z - pos1.z
|
||||
local x_abs = math.abs(x_raw)
|
||||
local y_abs = math.abs(y_raw)
|
||||
local z_abs = math.abs(z_raw)
|
||||
if x_abs >= y_abs and
|
||||
x_abs >= z_abs then
|
||||
y_raw = y_raw * (1 / x_abs)
|
||||
z_raw = z_raw * (1 / x_abs)
|
||||
x_raw = x_raw / x_abs
|
||||
end
|
||||
if y_abs >= x_abs and
|
||||
y_abs >= z_abs then
|
||||
x_raw = x_raw * (1 / y_abs)
|
||||
z_raw = z_raw * (1 / y_abs)
|
||||
y_raw = y_raw / y_abs
|
||||
end
|
||||
if z_abs >= y_abs and
|
||||
z_abs >= x_abs then
|
||||
x_raw = x_raw * (1 / z_abs)
|
||||
y_raw = y_raw * (1 / z_abs)
|
||||
z_raw = z_raw / z_abs
|
||||
end
|
||||
return {x=x_raw, y=y_raw, z=z_raw}
|
||||
end
|
||||
|
||||
|
||||
function vector.add(a, b)
|
||||
if type(b) == "table" then
|
||||
return {x = a.x + b.x,
|
||||
|
|
|
@ -1,25 +1,99 @@
|
|||
-- Minetest: builtin/auth.lua
|
||||
|
||||
--
|
||||
-- Builtin authentication handler
|
||||
-- Authentication handler
|
||||
--
|
||||
|
||||
-- Make the auth object private, deny access to mods
|
||||
local core_auth = core.auth
|
||||
core.auth = nil
|
||||
function core.string_to_privs(str, delim)
|
||||
assert(type(str) == "string")
|
||||
delim = delim or ','
|
||||
local privs = {}
|
||||
for _, priv in pairs(string.split(str, delim)) do
|
||||
privs[priv:trim()] = true
|
||||
end
|
||||
return privs
|
||||
end
|
||||
|
||||
function core.privs_to_string(privs, delim)
|
||||
assert(type(privs) == "table")
|
||||
delim = delim or ','
|
||||
local list = {}
|
||||
for priv, bool in pairs(privs) do
|
||||
if bool then
|
||||
list[#list + 1] = priv
|
||||
end
|
||||
end
|
||||
return table.concat(list, delim)
|
||||
end
|
||||
|
||||
assert(core.string_to_privs("a,b").b == true)
|
||||
assert(core.privs_to_string({a=true,b=true}) == "a,b")
|
||||
|
||||
core.auth_file_path = core.get_worldpath().."/auth.txt"
|
||||
core.auth_table = {}
|
||||
|
||||
local function read_auth_file()
|
||||
local newtable = {}
|
||||
local file, errmsg = io.open(core.auth_file_path, 'rb')
|
||||
if not file then
|
||||
core.log("info", core.auth_file_path.." could not be opened for reading ("..errmsg.."); assuming new world")
|
||||
return
|
||||
end
|
||||
for line in file:lines() do
|
||||
if line ~= "" then
|
||||
local fields = line:split(":", true)
|
||||
local name, password, privilege_string, last_login = unpack(fields)
|
||||
last_login = tonumber(last_login)
|
||||
if not (name and password and privilege_string) then
|
||||
error("Invalid line in auth.txt: "..dump(line))
|
||||
end
|
||||
local privileges = core.string_to_privs(privilege_string)
|
||||
newtable[name] = {password=password, privileges=privileges, last_login=last_login}
|
||||
end
|
||||
end
|
||||
io.close(file)
|
||||
core.auth_table = newtable
|
||||
core.notify_authentication_modified()
|
||||
end
|
||||
|
||||
local function save_auth_file()
|
||||
local newtable = {}
|
||||
-- Check table for validness before attempting to save
|
||||
for name, stuff in pairs(core.auth_table) do
|
||||
assert(type(name) == "string")
|
||||
assert(name ~= "")
|
||||
assert(type(stuff) == "table")
|
||||
assert(type(stuff.password) == "string")
|
||||
assert(type(stuff.privileges) == "table")
|
||||
assert(stuff.last_login == nil or type(stuff.last_login) == "number")
|
||||
end
|
||||
local file, errmsg = io.open(core.auth_file_path, 'w+b')
|
||||
if not file then
|
||||
error(core.auth_file_path.." could not be opened for writing: "..errmsg)
|
||||
end
|
||||
for name, stuff in pairs(core.auth_table) do
|
||||
local priv_string = core.privs_to_string(stuff.privileges)
|
||||
local parts = {name, stuff.password, priv_string, stuff.last_login or ""}
|
||||
file:write(table.concat(parts, ":").."\n")
|
||||
end
|
||||
io.close(file)
|
||||
end
|
||||
|
||||
core.builtin_auth_handler = {
|
||||
get_auth = function(name)
|
||||
assert(type(name) == "string")
|
||||
local auth_entry = core_auth.read(name)
|
||||
-- If no such auth found, return nil
|
||||
if not auth_entry then
|
||||
-- Figure out what password to use for a new player (singleplayer
|
||||
-- always has an empty password, otherwise use default, which is
|
||||
-- usually empty too)
|
||||
local new_password_hash = ""
|
||||
-- If not in authentication table, return nil
|
||||
if not core.auth_table[name] then
|
||||
return nil
|
||||
end
|
||||
-- Figure out what privileges the player should have.
|
||||
-- Take a copy of the privilege table
|
||||
local privileges = {}
|
||||
for priv, _ in pairs(auth_entry.privileges) do
|
||||
for priv, _ in pairs(core.auth_table[name].privileges) do
|
||||
privileges[priv] = true
|
||||
end
|
||||
-- If singleplayer, give all privileges except those marked as give_to_singleplayer = false
|
||||
|
@ -32,125 +106,67 @@ core.builtin_auth_handler = {
|
|||
-- For the admin, give everything
|
||||
elseif name == core.settings:get("name") then
|
||||
for priv, def in pairs(core.registered_privileges) do
|
||||
if def.give_to_admin then
|
||||
privileges[priv] = true
|
||||
end
|
||||
privileges[priv] = true
|
||||
end
|
||||
end
|
||||
-- All done
|
||||
return {
|
||||
password = auth_entry.password,
|
||||
password = core.auth_table[name].password,
|
||||
privileges = privileges,
|
||||
-- Is set to nil if unknown
|
||||
last_login = auth_entry.last_login,
|
||||
last_login = core.auth_table[name].last_login,
|
||||
}
|
||||
end,
|
||||
create_auth = function(name, password)
|
||||
core.log("action", "[AUTH] Adding password entry for player " .. name)
|
||||
assert(type(name) == "string")
|
||||
assert(type(password) == "string")
|
||||
core.log('info', "Built-in authentication handler adding player '"..name.."'")
|
||||
return core_auth.create({
|
||||
name = name,
|
||||
core.auth_table[name] = {
|
||||
password = password,
|
||||
privileges = core.string_to_privs(core.settings:get("default_privs")),
|
||||
last_login = os.time(),
|
||||
})
|
||||
end,
|
||||
delete_auth = function(name)
|
||||
assert(type(name) == "string")
|
||||
local auth_entry = core_auth.read(name)
|
||||
if not auth_entry then
|
||||
return false
|
||||
end
|
||||
core.log('info', "Built-in authentication handler deleting player '"..name.."'")
|
||||
return core_auth.delete(name)
|
||||
}
|
||||
end,
|
||||
set_password = function(name, password)
|
||||
assert(type(name) == "string")
|
||||
assert(type(password) == "string")
|
||||
local auth_entry = core_auth.read(name)
|
||||
if not auth_entry then
|
||||
if not core.auth_table[name] then
|
||||
core.log("action", "[AUTH] Setting password for new player " .. name)
|
||||
core.builtin_auth_handler.create_auth(name, password)
|
||||
else
|
||||
core.log('info', "Built-in authentication handler setting password of player '"..name.."'")
|
||||
auth_entry.password = password
|
||||
core_auth.save(auth_entry)
|
||||
core.log("action", "[AUTH] Setting password for existing player " .. name)
|
||||
core.auth_table[name].password = password
|
||||
end
|
||||
return true
|
||||
end,
|
||||
set_privileges = function(name, privileges)
|
||||
core.log("action", "[AUTH] Setting privileges for player " .. name)
|
||||
assert(type(name) == "string")
|
||||
assert(type(privileges) == "table")
|
||||
local auth_entry = core_auth.read(name)
|
||||
if not auth_entry then
|
||||
auth_entry = core.builtin_auth_handler.create_auth(name,
|
||||
if not core.auth_table[name] then
|
||||
core.builtin_auth_handler.create_auth(name,
|
||||
core.get_password_hash(name,
|
||||
core.settings:get("default_password")))
|
||||
end
|
||||
|
||||
-- Run grant callbacks
|
||||
for priv, _ in pairs(privileges) do
|
||||
if not auth_entry.privileges[priv] then
|
||||
core.run_priv_callbacks(name, priv, nil, "grant")
|
||||
end
|
||||
end
|
||||
|
||||
-- Run revoke callbacks
|
||||
for priv, _ in pairs(auth_entry.privileges) do
|
||||
if not privileges[priv] then
|
||||
core.run_priv_callbacks(name, priv, nil, "revoke")
|
||||
end
|
||||
end
|
||||
|
||||
auth_entry.privileges = privileges
|
||||
core_auth.save(auth_entry)
|
||||
core.auth_table[name].privileges = privileges
|
||||
core.notify_authentication_modified(name)
|
||||
end,
|
||||
reload = function()
|
||||
core_auth.reload()
|
||||
core.log("action", "[AUTH] Reading authentication data from disk")
|
||||
read_auth_file()
|
||||
return true
|
||||
end,
|
||||
commit = function()
|
||||
core.log("action", "[AUTH] Writing authentication data to disk")
|
||||
save_auth_file()
|
||||
return true
|
||||
end,
|
||||
record_login = function(name)
|
||||
assert(type(name) == "string")
|
||||
local auth_entry = core_auth.read(name)
|
||||
assert(auth_entry)
|
||||
auth_entry.last_login = os.time()
|
||||
core_auth.save(auth_entry)
|
||||
end,
|
||||
iterate = function()
|
||||
local names = {}
|
||||
local nameslist = core_auth.list_names()
|
||||
for k,v in pairs(nameslist) do
|
||||
names[v] = true
|
||||
end
|
||||
return pairs(names)
|
||||
assert(core.auth_table[name]).last_login = os.time()
|
||||
end,
|
||||
}
|
||||
|
||||
core.register_on_prejoinplayer(function(name, ip)
|
||||
if core.registered_auth_handler ~= nil then
|
||||
return -- Don't do anything if custom auth handler registered
|
||||
end
|
||||
local auth_entry = core_auth.read(name)
|
||||
if auth_entry ~= nil then
|
||||
return
|
||||
end
|
||||
|
||||
local name_lower = name:lower()
|
||||
for k in core.builtin_auth_handler.iterate() do
|
||||
if k:lower() == name_lower then
|
||||
return string.format("\nCannot create new player called '%s'. "..
|
||||
"Another account called '%s' is already registered. "..
|
||||
"Please check the spelling if it's your account "..
|
||||
"or use a different nickname.", name, k)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
--
|
||||
-- Authentication API
|
||||
--
|
||||
|
||||
function core.register_authentication_handler(handler)
|
||||
if core.registered_auth_handler then
|
||||
error("Add-on authentication handler already registered by "..core.registered_auth_handler_modname)
|
||||
|
@ -176,10 +192,44 @@ end
|
|||
|
||||
core.set_player_password = auth_pass("set_password")
|
||||
core.set_player_privs = auth_pass("set_privileges")
|
||||
core.remove_player_auth = auth_pass("delete_auth")
|
||||
core.auth_reload = auth_pass("reload")
|
||||
core.auth_commit = auth_pass("commit")
|
||||
|
||||
core.auth_reload()
|
||||
|
||||
local record_login = auth_pass("record_login")
|
||||
|
||||
core.register_on_joinplayer(function(player)
|
||||
record_login(player:get_player_name())
|
||||
end)
|
||||
|
||||
core.register_on_shutdown(function()
|
||||
core.auth_commit()
|
||||
end)
|
||||
|
||||
core.register_on_prejoinplayer(function(name, ip)
|
||||
local auth = core.auth_table
|
||||
if auth[name] ~= nil then
|
||||
return
|
||||
end
|
||||
|
||||
local name_lower = name:lower()
|
||||
for k in pairs(auth) do
|
||||
if k:lower() == name_lower then
|
||||
return string.format("\nYou can not register as '%s'! "..
|
||||
"Another player called '%s' is already registered. "..
|
||||
"Please check the spelling if it's your account "..
|
||||
"or use a different name.", name, k)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
-- Autosave
|
||||
if not core.is_singleplayer() then
|
||||
local save_interval = 600
|
||||
local function auto_save()
|
||||
core.auth_commit()
|
||||
core.after(save_interval, auto_save)
|
||||
end
|
||||
core.after(save_interval, auto_save)
|
||||
end
|
||||
|
|
|
@ -41,7 +41,7 @@ end)
|
|||
|
||||
if core.settings:get_bool("profiler.load") then
|
||||
-- Run after register_chatcommand and its register_on_chat_message
|
||||
-- Before any chatcommands that should be profiled
|
||||
-- Before any chattcommands that should be profiled
|
||||
profiler.init_chatcommand()
|
||||
end
|
||||
|
||||
|
@ -71,7 +71,7 @@ end
|
|||
--
|
||||
core.register_chatcommand("me", {
|
||||
params = "<action>",
|
||||
description = "Show chat action (e.g., '/me orders a pizza' displays"
|
||||
description = "Display chat action (e.g., '/me orders a pizza' displays"
|
||||
.. " '<player name> orders a pizza')",
|
||||
privs = {shout=true},
|
||||
func = function(name, param)
|
||||
|
@ -84,7 +84,7 @@ core.register_chatcommand("admin", {
|
|||
func = function(name)
|
||||
local admin = core.settings:get("name")
|
||||
if admin then
|
||||
return true, "The administrator of this server is " .. admin .. "."
|
||||
return true, "The administrator of this server is "..admin.."."
|
||||
else
|
||||
return false, "There's no administrator named in the config file."
|
||||
end
|
||||
|
@ -93,44 +93,16 @@ core.register_chatcommand("admin", {
|
|||
|
||||
core.register_chatcommand("privs", {
|
||||
params = "[<name>]",
|
||||
description = "Show privileges of yourself or another player",
|
||||
description = "Print privileges of player",
|
||||
func = function(caller, param)
|
||||
param = param:trim()
|
||||
local name = (param ~= "" and param or caller)
|
||||
if not core.player_exists(name) then
|
||||
return false, "Player " .. name .. " does not exist."
|
||||
end
|
||||
return true, "Privileges of " .. name .. ": "
|
||||
.. core.privs_to_string(
|
||||
core.get_player_privs(name), ' ')
|
||||
end,
|
||||
})
|
||||
|
||||
core.register_chatcommand("haspriv", {
|
||||
params = "<privilege>",
|
||||
description = "Return list of all online players with privilege.",
|
||||
privs = {basic_privs = true},
|
||||
func = function(caller, param)
|
||||
param = param:trim()
|
||||
if param == "" then
|
||||
return false, "Invalid parameters (see /help haspriv)"
|
||||
end
|
||||
if not core.registered_privileges[param] then
|
||||
return false, "Unknown privilege!"
|
||||
end
|
||||
local privs = core.string_to_privs(param)
|
||||
local players_with_priv = {}
|
||||
for _, player in pairs(core.get_connected_players()) do
|
||||
local player_name = player:get_player_name()
|
||||
if core.check_player_privs(player_name, privs) then
|
||||
table.insert(players_with_priv, player_name)
|
||||
end
|
||||
end
|
||||
return true, "Players online with the \"" .. param .. "\" privilege: " ..
|
||||
table.concat(players_with_priv, ", ")
|
||||
end
|
||||
})
|
||||
|
||||
local function handle_grant_command(caller, grantname, grantprivstr)
|
||||
local caller_privs = core.get_player_privs(caller)
|
||||
if not (caller_privs.privs or caller_privs.basic_privs) then
|
||||
|
@ -160,9 +132,6 @@ local function handle_grant_command(caller, grantname, grantprivstr)
|
|||
if privs_unknown ~= "" then
|
||||
return false, privs_unknown
|
||||
end
|
||||
for priv, _ in pairs(grantprivs) do
|
||||
core.run_priv_callbacks(grantname, priv, caller, "grant")
|
||||
end
|
||||
core.set_player_privs(grantname, privs)
|
||||
core.log("action", caller..' granted ('..core.privs_to_string(grantprivs, ', ')..') privileges to '..grantname)
|
||||
if grantname ~= caller then
|
||||
|
@ -177,7 +146,7 @@ end
|
|||
|
||||
core.register_chatcommand("grant", {
|
||||
params = "<name> (<privilege> | all)",
|
||||
description = "Give privileges to player",
|
||||
description = "Give privilege to player",
|
||||
func = function(name, param)
|
||||
local grantname, grantprivstr = string.match(param, "([^ ]+) (.+)")
|
||||
if not grantname or not grantprivstr then
|
||||
|
@ -188,7 +157,7 @@ core.register_chatcommand("grant", {
|
|||
})
|
||||
|
||||
core.register_chatcommand("grantme", {
|
||||
params = "<privilege> | all",
|
||||
params = "<privilege>|all",
|
||||
description = "Grant privileges to yourself",
|
||||
func = function(name, param)
|
||||
if param == "" then
|
||||
|
@ -200,7 +169,7 @@ core.register_chatcommand("grantme", {
|
|||
|
||||
core.register_chatcommand("revoke", {
|
||||
params = "<name> (<privilege> | all)",
|
||||
description = "Remove privileges from player",
|
||||
description = "Remove privilege from player",
|
||||
privs = {},
|
||||
func = function(name, param)
|
||||
if not core.check_player_privs(name, {privs=true}) and
|
||||
|
@ -224,18 +193,12 @@ core.register_chatcommand("revoke", {
|
|||
end
|
||||
end
|
||||
if revoke_priv_str == "all" then
|
||||
revoke_privs = privs
|
||||
privs = {}
|
||||
else
|
||||
for priv, _ in pairs(revoke_privs) do
|
||||
privs[priv] = nil
|
||||
end
|
||||
end
|
||||
|
||||
for priv, _ in pairs(revoke_privs) do
|
||||
core.run_priv_callbacks(revoke_name, priv, name, "revoke")
|
||||
end
|
||||
|
||||
core.set_player_privs(revoke_name, privs)
|
||||
core.log("action", name..' revoked ('
|
||||
..core.privs_to_string(revoke_privs, ', ')
|
||||
|
@ -291,7 +254,7 @@ core.register_chatcommand("setpassword", {
|
|||
|
||||
core.register_chatcommand("clearpassword", {
|
||||
params = "<name>",
|
||||
description = "Set empty password for a player",
|
||||
description = "Set empty password",
|
||||
privs = {password=true},
|
||||
func = function(name, param)
|
||||
local toname = param
|
||||
|
@ -318,7 +281,7 @@ core.register_chatcommand("auth_reload", {
|
|||
|
||||
core.register_chatcommand("remove_player", {
|
||||
params = "<name>",
|
||||
description = "Remove a player's data",
|
||||
description = "Remove player data",
|
||||
privs = {server=true},
|
||||
func = function(name, param)
|
||||
local toname = param
|
||||
|
@ -341,9 +304,19 @@ core.register_chatcommand("remove_player", {
|
|||
end,
|
||||
})
|
||||
|
||||
core.register_chatcommand("auth_save", {
|
||||
params = "",
|
||||
description = "Write authentication data to disk",
|
||||
privs = {server=true},
|
||||
func = function(name, param)
|
||||
local done = core.auth_save()
|
||||
return done, (done and "Authentication data successfully saved to disk." or "Failed to write the auth.txt file.")
|
||||
end,
|
||||
})
|
||||
|
||||
core.register_chatcommand("teleport", {
|
||||
params = "<X>,<Y>,<Z> | <to_name> | (<name> <X>,<Y>,<Z>) | (<name> <to_name>)",
|
||||
description = "Teleport to position or player",
|
||||
description = "Teleport to player or position",
|
||||
privs = {teleport=true},
|
||||
func = function(name, param)
|
||||
-- Returns (pos, true) if found, otherwise (pos, false)
|
||||
|
@ -585,11 +558,8 @@ local function handle_give_command(cmd, giver, receiver, stackstring)
|
|||
local itemstack = ItemStack(stackstring)
|
||||
if itemstack:is_empty() then
|
||||
return false, "Cannot give an empty item"
|
||||
elseif (not itemstack:is_known()) or (itemstack:get_name() == "unknown") then
|
||||
elseif not itemstack:is_known() then
|
||||
return false, "Cannot give an unknown item"
|
||||
-- Forbid giving 'ignore' due to unwanted side effects
|
||||
elseif itemstack:get_name() == "ignore" then
|
||||
return false, "Giving 'ignore' is not allowed"
|
||||
end
|
||||
local receiverref = core.get_player_by_name(receiver)
|
||||
if receiverref == nil then
|
||||
|
@ -608,18 +578,18 @@ local function handle_give_command(cmd, giver, receiver, stackstring)
|
|||
-- entered (e.g. big numbers are always interpreted as 2^16-1).
|
||||
stackstring = itemstack:to_string()
|
||||
if giver == receiver then
|
||||
local msg = "%q %sadded to inventory."
|
||||
return true, msg:format(stackstring, partiality)
|
||||
return true, ("%q %sadded to inventory.")
|
||||
:format(stackstring, partiality)
|
||||
else
|
||||
core.chat_send_player(receiver, ("%q %sadded to inventory.")
|
||||
:format(stackstring, partiality))
|
||||
local msg = "%q %sadded to %s's inventory."
|
||||
return true, msg:format(stackstring, partiality, receiver)
|
||||
return true, ("%q %sadded to %s's inventory.")
|
||||
:format(stackstring, partiality, receiver)
|
||||
end
|
||||
end
|
||||
|
||||
core.register_chatcommand("give", {
|
||||
params = "<name> <ItemString> [<count> [<wear>]]",
|
||||
params = "<name> <ItemString>",
|
||||
description = "Give item to player",
|
||||
privs = {give=true},
|
||||
func = function(name, param)
|
||||
|
@ -632,7 +602,7 @@ core.register_chatcommand("give", {
|
|||
})
|
||||
|
||||
core.register_chatcommand("giveme", {
|
||||
params = "<ItemString> [<count> [<wear>]]",
|
||||
params = "<ItemString>",
|
||||
description = "Give item to yourself",
|
||||
privs = {give=true},
|
||||
func = function(name, param)
|
||||
|
@ -660,9 +630,6 @@ core.register_chatcommand("spawnentity", {
|
|||
core.log("error", "Unable to spawn entity, player is nil")
|
||||
return false, "Unable to spawn entity, player is nil"
|
||||
end
|
||||
if not core.registered_entities[entityname] then
|
||||
return false, "Cannot spawn an unknown entity"
|
||||
end
|
||||
if p == "" then
|
||||
p = player:get_pos()
|
||||
else
|
||||
|
@ -686,13 +653,10 @@ core.register_chatcommand("pulverize", {
|
|||
core.log("error", "Unable to pulverize, no player.")
|
||||
return false, "Unable to pulverize, no player."
|
||||
end
|
||||
local wielded_item = player:get_wielded_item()
|
||||
if wielded_item:is_empty() then
|
||||
if player:get_wielded_item():is_empty() then
|
||||
return false, "Unable to pulverize, no item in hand."
|
||||
end
|
||||
core.log("action", name .. " pulverized \"" ..
|
||||
wielded_item:get_name() .. " " .. wielded_item:get_count() .. "\"")
|
||||
player:set_wielded_item(nil)
|
||||
player:set_wielded_item(nil)
|
||||
return true, "An item was pulverized."
|
||||
end,
|
||||
})
|
||||
|
@ -701,8 +665,8 @@ core.register_chatcommand("pulverize", {
|
|||
core.rollback_punch_callbacks = {}
|
||||
|
||||
core.register_on_punchnode(function(pos, node, puncher)
|
||||
local name = puncher and puncher:get_player_name()
|
||||
if name and core.rollback_punch_callbacks[name] then
|
||||
local name = puncher:get_player_name()
|
||||
if core.rollback_punch_callbacks[name] then
|
||||
core.rollback_punch_callbacks[name](pos, node, puncher)
|
||||
core.rollback_punch_callbacks[name] = nil
|
||||
end
|
||||
|
@ -800,19 +764,16 @@ core.register_chatcommand("rollback", {
|
|||
})
|
||||
|
||||
core.register_chatcommand("status", {
|
||||
description = "Show server status",
|
||||
description = "Print server status",
|
||||
privs = {server=true},
|
||||
func = function(name, param)
|
||||
local status = core.get_server_status(name, false)
|
||||
if status and status ~= "" then
|
||||
return true, status
|
||||
end
|
||||
return false, "This command was disabled by a mod or game"
|
||||
return true, core.get_server_status()
|
||||
end,
|
||||
})
|
||||
|
||||
core.register_chatcommand("time", {
|
||||
params = "[<0..23>:<0..59> | <0..24000>]",
|
||||
description = "Show or set time of day",
|
||||
params = "<0..23>:<0..59> | <0..24000>",
|
||||
description = "Set time of day",
|
||||
privs = {},
|
||||
func = function(name, param)
|
||||
if param == "" then
|
||||
|
@ -851,7 +812,7 @@ core.register_chatcommand("time", {
|
|||
})
|
||||
|
||||
core.register_chatcommand("days", {
|
||||
description = "Show day count since world creation",
|
||||
description = "Display day count",
|
||||
func = function(name, param)
|
||||
return true, "Current day is " .. core.get_day_count()
|
||||
end
|
||||
|
@ -862,15 +823,13 @@ core.register_chatcommand("shutdown", {
|
|||
description = "Shutdown server (-1 cancels a delayed shutdown)",
|
||||
privs = {server=true},
|
||||
func = function(name, param)
|
||||
local delay, reconnect, message
|
||||
delay, param = param:match("^%s*(%S+)(.*)")
|
||||
if param then
|
||||
reconnect, param = param:match("^%s*(%S+)(.*)")
|
||||
end
|
||||
message = param and param:match("^%s*(.+)") or ""
|
||||
delay = tonumber(delay) or 0
|
||||
local delay, reconnect, message = param:match("([^ ][-]?[0-9]+)([^ ]+)(.*)")
|
||||
message = message or ""
|
||||
|
||||
if delay == 0 then
|
||||
if delay ~= "" then
|
||||
delay = tonumber(param) or 0
|
||||
else
|
||||
delay = 0
|
||||
core.log("action", name .. " shuts down server")
|
||||
core.chat_send_all("*** Server shutting down (operator request).")
|
||||
end
|
||||
|
@ -879,17 +838,12 @@ core.register_chatcommand("shutdown", {
|
|||
})
|
||||
|
||||
core.register_chatcommand("ban", {
|
||||
params = "[<name> | <IP_address>]",
|
||||
description = "Ban player or show ban list",
|
||||
params = "<name>",
|
||||
description = "Ban IP of player",
|
||||
privs = {ban=true},
|
||||
func = function(name, param)
|
||||
if param == "" then
|
||||
local ban_list = core.get_ban_list()
|
||||
if ban_list == "" then
|
||||
return true, "The ban list is empty."
|
||||
else
|
||||
return true, "Ban list: " .. ban_list
|
||||
end
|
||||
return true, "Ban list: " .. core.get_ban_list()
|
||||
end
|
||||
if not core.get_player_by_name(param) then
|
||||
return false, "No such player."
|
||||
|
@ -905,7 +859,7 @@ core.register_chatcommand("ban", {
|
|||
|
||||
core.register_chatcommand("unban", {
|
||||
params = "<name> | <IP_address>",
|
||||
description = "Remove player ban",
|
||||
description = "Remove IP ban",
|
||||
privs = {ban=true},
|
||||
func = function(name, param)
|
||||
if not core.unban_player_or_ip(param) then
|
||||
|
@ -936,7 +890,7 @@ core.register_chatcommand("kick", {
|
|||
})
|
||||
|
||||
core.register_chatcommand("clearobjects", {
|
||||
params = "[full | quick]",
|
||||
params = "[full|quick]",
|
||||
description = "Clear all objects in world",
|
||||
privs = {server=true},
|
||||
func = function(name, param)
|
||||
|
@ -983,7 +937,7 @@ core.register_chatcommand("msg", {
|
|||
|
||||
core.register_chatcommand("last-login", {
|
||||
params = "[<name>]",
|
||||
description = "Get the last login time of a player or yourself",
|
||||
description = "Get the last login time of a player",
|
||||
func = function(name, param)
|
||||
if param == "" then
|
||||
param = name
|
||||
|
@ -1006,7 +960,7 @@ core.register_chatcommand("clearinv", {
|
|||
if param and param ~= "" and param ~= name then
|
||||
if not core.check_player_privs(name, {server=true}) then
|
||||
return false, "You don't have permission"
|
||||
.. " to clear another player's inventory (missing privilege: server)"
|
||||
.. " to run this command (missing privilege: server)"
|
||||
end
|
||||
player = core.get_player_by_name(param)
|
||||
core.chat_send_player(param, name.." cleared your inventory.")
|
||||
|
@ -1056,3 +1010,40 @@ core.register_chatcommand("kill", {
|
|||
return handle_kill_command(name, param == "" and name or param)
|
||||
end,
|
||||
})
|
||||
|
||||
core.register_chatcommand("spawn", {
|
||||
params = "",
|
||||
description = "Teleport to the spawn point",
|
||||
func = function(name, param)
|
||||
local player = core.get_player_by_name(name)
|
||||
if not player then
|
||||
return false, "Command called by invalid player"
|
||||
end
|
||||
if core.setting_get_pos("static_spawnpoint") then
|
||||
player:set_pos(core.setting_get_pos("static_spawnpoint"))
|
||||
return true, "Teleporting to spawn..."
|
||||
else
|
||||
return false, "The spawn point is not set!"
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
core.register_chatcommand("setspawn", {
|
||||
params = "",
|
||||
description = "Sets the spawn point to your current position",
|
||||
privs = {server = true},
|
||||
func = function(name, param)
|
||||
local player = core.get_player_by_name(name)
|
||||
if not player then
|
||||
return false, "Command called by invalid player"
|
||||
end
|
||||
local pos = vector.round(player:get_pos())
|
||||
local x = pos.x
|
||||
local y = pos.y
|
||||
local z = pos.z
|
||||
local pos_to_string = x..","..y..","..z
|
||||
core.setting_set("static_spawnpoint", pos_to_string)
|
||||
core.setting_save()
|
||||
return true, "Setting spawn point to ("..x..", "..y..", "..z..")"
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -21,10 +21,6 @@ core.EMERGE_GENERATED = 4
|
|||
-- constants.h
|
||||
-- Size of mapblocks in nodes
|
||||
core.MAP_BLOCKSIZE = 16
|
||||
-- Default maximal HP of a player
|
||||
core.PLAYER_MAX_HP_DEFAULT = 20
|
||||
-- Default maximal breath of a player
|
||||
core.PLAYER_MAX_BREATH_DEFAULT = 11
|
||||
|
||||
-- light.h
|
||||
-- Maximum value for node 'light_source' parameter
|
||||
|
|
|
@ -18,7 +18,3 @@ function core.create_detached_inventory(name, callbacks, player_name)
|
|||
return core.create_detached_inventory_raw(name, player_name)
|
||||
end
|
||||
|
||||
function core.remove_detached_inventory(name)
|
||||
core.detached_inventories[name] = nil
|
||||
return core.remove_detached_inventory_raw(name)
|
||||
end
|
||||
|
|
|
@ -19,6 +19,7 @@ core.register_entity(":__builtin:falling_node", {
|
|||
|
||||
node = {},
|
||||
meta = {},
|
||||
timer = 0,
|
||||
|
||||
set_node = function(self, node, meta)
|
||||
self.node = node
|
||||
|
@ -53,8 +54,9 @@ core.register_entity(":__builtin:falling_node", {
|
|||
on_step = function(self, dtime)
|
||||
-- Set gravity
|
||||
local acceleration = self.object:get_acceleration()
|
||||
if not vector.equals(acceleration, {x = 0, y = -10, z = 0}) then
|
||||
self.object:set_acceleration({x = 0, y = -10, z = 0})
|
||||
local gravity = tonumber(core.settings:get("movement_gravity")) or 9.81
|
||||
if not vector.equals(acceleration, {x = 0, y = -gravity, z = 0}) then
|
||||
self.object:setacceleration({x = 0, y = -gravity, z = 0})
|
||||
end
|
||||
-- Turn to actual node when colliding with ground, or continue to move
|
||||
local pos = self.object:get_pos()
|
||||
|
@ -129,21 +131,20 @@ core.register_entity(":__builtin:falling_node", {
|
|||
local npos = self.object:get_pos()
|
||||
self.object:set_pos(vector.round(npos))
|
||||
end
|
||||
-- Drop node if does not fall within 5 seconds
|
||||
self.timer = self.timer + dtime
|
||||
if self.timer > 5 then
|
||||
core.add_item(pos, self.node)
|
||||
self.object:remove()
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
local function convert_to_falling_node(pos, node)
|
||||
local obj = core.add_entity(pos, "__builtin:falling_node")
|
||||
if not obj then
|
||||
return false
|
||||
local function spawn_falling_node(p, node, meta)
|
||||
local obj = core.add_entity(p, "__builtin:falling_node")
|
||||
if obj then
|
||||
obj:get_luaentity():set_node(node, meta)
|
||||
end
|
||||
node.level = core.get_node_level(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local metatable = meta and meta:to_table() or {}
|
||||
|
||||
obj:get_luaentity():set_node(node, metatable)
|
||||
core.remove_node(pos)
|
||||
return true
|
||||
end
|
||||
|
||||
function core.spawn_falling_node(pos)
|
||||
|
@ -151,27 +152,19 @@ function core.spawn_falling_node(pos)
|
|||
if node.name == "air" or node.name == "ignore" then
|
||||
return false
|
||||
end
|
||||
return convert_to_falling_node(pos, node)
|
||||
local obj = core.add_entity(pos, "__builtin:falling_node")
|
||||
if obj then
|
||||
obj:get_luaentity():set_node(node)
|
||||
core.remove_node(pos)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function drop_attached_node(p)
|
||||
local n = core.get_node(p)
|
||||
local drops = core.get_node_drops(n, "")
|
||||
local def = core.registered_items[n.name]
|
||||
if def and def.preserve_metadata then
|
||||
local oldmeta = core.get_meta(p):to_table().fields
|
||||
-- Copy pos and node because the callback can modify them.
|
||||
local pos_copy = {x=p.x, y=p.y, z=p.z}
|
||||
local node_copy = {name=n.name, param1=n.param1, param2=n.param2}
|
||||
local drop_stacks = {}
|
||||
for k, v in pairs(drops) do
|
||||
drop_stacks[k] = ItemStack(v)
|
||||
end
|
||||
drops = drop_stacks
|
||||
def.preserve_metadata(pos_copy, node_copy, oldmeta, drops)
|
||||
end
|
||||
core.remove_node(p)
|
||||
for _, item in pairs(drops) do
|
||||
for _, item in pairs(core.get_node_drops(n, "")) do
|
||||
local pos = {
|
||||
x = p.x + math.random()/2 - 0.25,
|
||||
y = p.y + math.random()/2 - 0.25,
|
||||
|
@ -209,7 +202,7 @@ end
|
|||
|
||||
function core.check_single_for_falling(p)
|
||||
local n = core.get_node(p)
|
||||
if core.get_item_group(n.name, "falling_node") ~= 0 then
|
||||
if core.get_item_group(n.name, "falling_node") ~= 0 and core.is_singleplayer() then
|
||||
local p_bottom = {x = p.x, y = p.y - 1, z = p.z}
|
||||
-- Only spawn falling node if node below is loaded
|
||||
local n_bottom = core.get_node_or_nil(p_bottom)
|
||||
|
@ -224,7 +217,21 @@ function core.check_single_for_falling(p)
|
|||
core.get_node_max_level(p_bottom))) and
|
||||
|
||||
(not d_bottom.walkable or d_bottom.buildable_to) then
|
||||
convert_to_falling_node(p, n)
|
||||
n.level = core.get_node_level(p)
|
||||
local meta = core.get_meta(p)
|
||||
local metatable = {}
|
||||
if meta ~= nil then
|
||||
metatable = meta:to_table()
|
||||
end
|
||||
core.remove_node(p)
|
||||
spawn_falling_node(p, n, metatable)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
if core.get_item_group(n.name, "falling_node") ~= 0 and not core.is_singleplayer() then
|
||||
if not builtin_shared.check_attached_node(p, n) then
|
||||
drop_attached_node(p)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
core.features = {
|
||||
glasslike_framed = true,
|
||||
nodebox_as_selectionbox = true,
|
||||
chat_send_player_param3 = true,
|
||||
get_all_craft_recipes_works = true,
|
||||
use_texture_alpha = true,
|
||||
no_legacy_abms = true,
|
||||
|
@ -10,8 +11,6 @@ core.features = {
|
|||
area_store_custom_ids = true,
|
||||
add_entity_with_staticdata = true,
|
||||
no_chat_message_prediction = true,
|
||||
object_use_texture_alpha = true,
|
||||
object_independent_selectionbox = true,
|
||||
}
|
||||
|
||||
function core.has_feature(arg)
|
||||
|
|
|
@ -0,0 +1,168 @@
|
|||
--From Better HUD mod
|
||||
--Copyright (C) BlockMen (2013-2016)
|
||||
|
||||
--This program 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 3.0 of the License, or
|
||||
--(at your option) any later version.
|
||||
--
|
||||
--This program is distributed in the hope that it will be useful,
|
||||
--but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
--GNU Lesser General Public License for more details.
|
||||
--
|
||||
--You should have received a copy of the GNU Lesser General Public License along
|
||||
--with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
hud, hud_id = {}, {}
|
||||
|
||||
-- keep id handling internal
|
||||
local sb_bg = {} -- statbar background ids
|
||||
|
||||
-- localize often used table
|
||||
local items = {}
|
||||
|
||||
local function throw_error(msg)
|
||||
core.log("error", "HUD[error]: " .. msg)
|
||||
end
|
||||
|
||||
--
|
||||
-- API
|
||||
--
|
||||
|
||||
function hud.register(name, def)
|
||||
if not name or not def then
|
||||
throw_error("not enough parameters given")
|
||||
return false
|
||||
end
|
||||
|
||||
if items[name] ~= nil then
|
||||
throw_error("A statbar with that name already exists")
|
||||
return false
|
||||
end
|
||||
|
||||
-- actually register
|
||||
-- add background first since draworder is based on id :\
|
||||
if --[[def.hud_elem_type == "statbar" and]] def.background ~= nil then
|
||||
sb_bg[name] = table.copy(def)
|
||||
sb_bg[name].text = def.background
|
||||
if not def.autohide_bg and def.max then
|
||||
sb_bg[name].number = def.max
|
||||
end
|
||||
end
|
||||
-- add item itself
|
||||
items[name] = def
|
||||
|
||||
-- no error so far, return success
|
||||
return true
|
||||
end
|
||||
|
||||
function hud.change_item(player, name, def)
|
||||
if not player or not player:is_player() or not name or not def then
|
||||
throw_error("Not enough parameters given to change HUD item")
|
||||
return false
|
||||
end
|
||||
local i_name = player:get_player_name().."_"..name
|
||||
local elem = hud_id[i_name]
|
||||
if not elem then
|
||||
throw_error("Given HUD element " .. dump(name) .. " does not exist")
|
||||
return false
|
||||
end
|
||||
|
||||
-- Only update if values supported and value actually changed
|
||||
-- update supported values (currently number and text only)
|
||||
if def.number and elem.number then
|
||||
if def.number ~= elem.number then
|
||||
if elem.max and def.number > elem.max and not def.max then
|
||||
def.number = elem.max
|
||||
end
|
||||
if def.max then
|
||||
elem.max = def.max
|
||||
end
|
||||
player:hud_change(elem.id, "number", def.number)
|
||||
elem.number = def.number
|
||||
-- hide background when set
|
||||
local bg = hud_id[i_name.."_bg"]
|
||||
if elem.autohide_bg then
|
||||
if def.number < 1 then
|
||||
player:hud_change(bg.id, "number", 0)
|
||||
else
|
||||
local num = bg.number
|
||||
if bg.max then
|
||||
num = bg.max
|
||||
end
|
||||
player:hud_change(bg.id, "number", num)
|
||||
end
|
||||
else
|
||||
if bg and bg.max and bg.max < 1 and def.max and def.max > bg.max then
|
||||
player:hud_change(bg.id, "number", def.max)
|
||||
bg.max = def.max
|
||||
bg.number = def.max
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if def.text and elem.text then
|
||||
if def.text ~= elem.text then
|
||||
player:hud_change(elem.id, "text", def.text)
|
||||
elem.text = def.text
|
||||
end
|
||||
end
|
||||
|
||||
if def.offset and elem.offset then
|
||||
if def.item_name and def.offset == "item" then
|
||||
-- for legacy reasons
|
||||
--[[if def.item_name then
|
||||
hud.swap_statbar(player, name, def.item_name)
|
||||
end]]
|
||||
else
|
||||
player:hud_change(elem.id, "offset", def.offset)
|
||||
elem.offset = def.offset
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function hud.remove_item(player, name)
|
||||
if not player or not name then
|
||||
throw_error("Not enough parameters given")
|
||||
return false
|
||||
end
|
||||
local i_name = player:get_player_name().."_"..name
|
||||
if hud_id[i_name] == nil then
|
||||
throw_error("Given HUD element " .. dump(name) .. " does not exist")
|
||||
return false
|
||||
end
|
||||
player:hud_remove(hud_id[i_name].id)
|
||||
hud_id[i_name] = nil
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
--
|
||||
-- Add registered HUD items to joining players
|
||||
--
|
||||
|
||||
-- Following code is placed here to keep HUD ids internal
|
||||
local function add_hud_item(player, name, def)
|
||||
if not player or not name or not def then
|
||||
throw_error("not enough parameters given")
|
||||
return false
|
||||
end
|
||||
local i_name = player:get_player_name().."_"..name
|
||||
hud_id[i_name] = def
|
||||
hud_id[i_name].id = player:hud_add(def)
|
||||
end
|
||||
|
||||
core.register_on_joinplayer(function(player)
|
||||
-- add the backgrounds for statbars
|
||||
for _,item in pairs(sb_bg) do
|
||||
add_hud_item(player, _.."_bg", item)
|
||||
end
|
||||
-- and finally the actual HUD items
|
||||
for _,item in pairs(items) do
|
||||
add_hud_item(player, _, item)
|
||||
end
|
||||
end)
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
local scriptpath = core.get_builtin_path()
|
||||
local scriptpath = core.get_builtin_path()..DIR_DELIM
|
||||
local commonpath = scriptpath.."common"..DIR_DELIM
|
||||
local gamepath = scriptpath.."game"..DIR_DELIM
|
||||
|
||||
|
@ -31,6 +31,7 @@ assert(loadfile(gamepath.."falling.lua"))(builtin_shared)
|
|||
dofile(gamepath.."features.lua")
|
||||
dofile(gamepath.."voxelarea.lua")
|
||||
dofile(gamepath.."forceloading.lua")
|
||||
dofile(gamepath.."hud.lua")
|
||||
dofile(gamepath.."statbars.lua")
|
||||
|
||||
profiler = nil
|
||||
|
|
|
@ -435,23 +435,123 @@ function core.item_secondary_use(itemstack, placer)
|
|||
return itemstack
|
||||
end
|
||||
|
||||
local function item_throw_step(entity, dtime)
|
||||
entity.throw_timer = entity.throw_timer + dtime
|
||||
if entity.throw_timer > 20 then
|
||||
entity.object:remove()
|
||||
return
|
||||
end
|
||||
if not entity.thrower then
|
||||
return
|
||||
end
|
||||
local pos = entity.object:get_pos()
|
||||
if not core.is_valid_pos(pos) then
|
||||
entity.object:remove()
|
||||
return
|
||||
end
|
||||
local hit_object = nil
|
||||
local dir = vector.normalize(entity.object:get_velocity())
|
||||
local pos2 = vector.add(pos, vector.multiply(dir, 3))
|
||||
local _, node_pos = minetest.line_of_sight(pos, pos2)
|
||||
if node_pos then
|
||||
local def = minetest.get_node(node_pos)
|
||||
if def then
|
||||
pos = vector.subtract(node_pos, vector.multiply(dir, 1.5))
|
||||
entity.object:move_to(pos)
|
||||
else
|
||||
node_pos = nil
|
||||
end
|
||||
end
|
||||
local objs = minetest.get_objects_inside_radius(pos, 1.5)
|
||||
for _, obj in pairs(objs) do
|
||||
if obj:is_player() then
|
||||
local name = obj:get_player_name()
|
||||
if name ~= entity.thrower then
|
||||
hit_object = obj
|
||||
end
|
||||
elseif obj:get_luaentity() ~= nil and
|
||||
obj:get_luaentity().name ~= entity.name then
|
||||
hit_object = obj
|
||||
end
|
||||
end
|
||||
if hit_object or node_pos then
|
||||
local player = core.get_player_by_name(entity.thrower)
|
||||
entity.on_impact(player, pos, entity.throw_direction, hit_object)
|
||||
entity.object:remove()
|
||||
end
|
||||
end
|
||||
|
||||
function core.item_throw(name, thrower, speed, accel, on_impact)
|
||||
if not thrower or not thrower:is_player() then
|
||||
return
|
||||
end
|
||||
local pos = thrower:get_pos()
|
||||
if not core.is_valid_pos(pos) then
|
||||
return
|
||||
end
|
||||
pos.y = pos.y + 1.5
|
||||
local obj = nil
|
||||
local properties = {is_visible=true}
|
||||
if core.registered_entities[name] then
|
||||
obj = core.add_entity(pos, name)
|
||||
elseif core.registered_items[name] then
|
||||
obj = core.add_entity(pos, "__builtin:throwing_item")
|
||||
properties.textures = {name}
|
||||
else
|
||||
return
|
||||
end
|
||||
if obj then
|
||||
local ent = obj:get_luaentity()
|
||||
if ent then
|
||||
local s = speed or 19 -- default speed
|
||||
local a = accel or -3 -- default acceleration
|
||||
local dir = thrower:get_look_dir()
|
||||
local gravity = tonumber(core.settings:get("movement_gravity")) or 9.81
|
||||
ent.thrower = thrower:get_player_name()
|
||||
ent.throw_timer = 0
|
||||
ent.throw_direction = dir
|
||||
ent.on_step = item_throw_step
|
||||
ent.on_impact = on_impact and on_impact or function() end
|
||||
obj:set_properties(properties)
|
||||
obj:set_velocity({x=dir.x * s, y=dir.y * s, z=dir.z * s})
|
||||
obj:set_acceleration({x=dir.x * a, y=-gravity, z=dir.z * a})
|
||||
return obj
|
||||
else
|
||||
obj:remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function core.item_drop(itemstack, dropper, pos)
|
||||
local dropper_is_player = dropper and dropper:is_player()
|
||||
local p = table.copy(pos)
|
||||
local cnt = itemstack:get_count()
|
||||
if not core.is_valid_pos(p) then
|
||||
return
|
||||
end
|
||||
if dropper_is_player then
|
||||
p.y = p.y + 1.2
|
||||
if not dropper:get_player_control().sneak then
|
||||
cnt = 1
|
||||
end
|
||||
end
|
||||
local item = itemstack:take_item(cnt)
|
||||
local obj = core.add_item(p, item)
|
||||
if obj then
|
||||
if dropper_is_player then
|
||||
local vel = dropper:get_player_velocity()
|
||||
local dir = dropper:get_look_dir()
|
||||
dir.x = dir.x * 2.9
|
||||
dir.y = dir.y * 2.9 + 2
|
||||
dir.z = dir.z * 2.9
|
||||
dir.x = vel.x + dir.x * 4
|
||||
dir.y = vel.y + dir.y * 4 + 2
|
||||
dir.z = vel.z + dir.z * 4
|
||||
obj:set_velocity(dir)
|
||||
obj:get_luaentity().dropped_by = dropper:get_player_name()
|
||||
else
|
||||
obj:set_velocity({
|
||||
x = math.random(-2, 2),
|
||||
y = math.random(2, 4),
|
||||
z = math.random(-2, 2)
|
||||
})
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
|
@ -469,11 +569,6 @@ function core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed
|
|||
if itemstack:take_item() ~= nil then
|
||||
user:set_hp(user:get_hp() + hp_change)
|
||||
|
||||
local def = itemstack:get_definition()
|
||||
if def and def.sound and def.sound.eat then
|
||||
minetest.sound_play(def.sound.eat, { pos = user:get_pos(), max_hear_distance = 16 })
|
||||
end
|
||||
|
||||
if replace_with_item then
|
||||
if itemstack:is_empty() then
|
||||
itemstack:add_item(replace_with_item)
|
||||
|
@ -496,6 +591,28 @@ end
|
|||
function core.item_eat(hp_change, replace_with_item)
|
||||
return function(itemstack, user, pointed_thing) -- closure
|
||||
if user then
|
||||
local pos = user:get_pos()
|
||||
pos.y = pos.y + 1.3
|
||||
local itemname = itemstack:get_name()
|
||||
local texture = core.registered_items[itemname].inventory_image
|
||||
local dir = user:get_look_dir()
|
||||
core.add_particlespawner({
|
||||
amount = 20,
|
||||
time = 0.1,
|
||||
minpos = pos,
|
||||
maxpos = pos,
|
||||
minvel = {x = dir.x - 1, y = 2, z = dir.z - 1},
|
||||
maxvel = {x = dir.x + 1, y = 2, z = dir.z + 1},
|
||||
minacc = {x = 0, y = -5, z = 0},
|
||||
maxacc = {x = 0, y = -9, z = 0},
|
||||
minexptime = 1,
|
||||
maxexptime = 1,
|
||||
minsize = 1,
|
||||
maxsize = 1,
|
||||
vertical = false,
|
||||
texture = texture,
|
||||
})
|
||||
core.sound_play("player_eat", {pos = pos, max_hear_distance = 10, gain = 0.3})
|
||||
return core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)
|
||||
end
|
||||
end
|
||||
|
@ -516,7 +633,7 @@ function core.handle_node_drops(pos, drops, digger)
|
|||
-- Add dropped items to object's inventory
|
||||
local inv = digger and digger:get_inventory()
|
||||
local give_item
|
||||
if inv then
|
||||
if inv and core.settings:get_bool("creative_mode") then
|
||||
give_item = function(item)
|
||||
return inv:add_item("main", item)
|
||||
end
|
||||
|
@ -530,12 +647,7 @@ function core.handle_node_drops(pos, drops, digger)
|
|||
for _, dropped_item in pairs(drops) do
|
||||
local left = give_item(dropped_item)
|
||||
if not left:is_empty() then
|
||||
local p = {
|
||||
x = pos.x + math.random()/2-0.25,
|
||||
y = pos.y + math.random()/2-0.25,
|
||||
z = pos.z + math.random()/2-0.25,
|
||||
}
|
||||
core.add_item(p, left)
|
||||
core.item_drop(left, nil, pos)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -585,20 +697,6 @@ function core.node_dig(pos, node, digger)
|
|||
digger:set_wielded_item(wielded)
|
||||
end
|
||||
|
||||
-- Check to see if metadata should be preserved.
|
||||
if def and def.preserve_metadata then
|
||||
local oldmeta = core.get_meta(pos):to_table().fields
|
||||
-- Copy pos and node because the callback can modify them.
|
||||
local pos_copy = {x=pos.x, y=pos.y, z=pos.z}
|
||||
local node_copy = {name=node.name, param1=node.param1, param2=node.param2}
|
||||
local drop_stacks = {}
|
||||
for k, v in pairs(drops) do
|
||||
drop_stacks[k] = ItemStack(v)
|
||||
end
|
||||
drops = drop_stacks
|
||||
def.preserve_metadata(pos_copy, node_copy, oldmeta, drops)
|
||||
end
|
||||
|
||||
-- Handle drops
|
||||
core.handle_node_drops(pos, drops, digger)
|
||||
|
||||
|
@ -637,18 +735,6 @@ function core.node_dig(pos, node, digger)
|
|||
end
|
||||
end
|
||||
|
||||
function core.itemstring_with_palette(item, palette_index)
|
||||
local stack = ItemStack(item) -- convert to ItemStack
|
||||
stack:get_meta():set_int("palette_index", palette_index)
|
||||
return stack:to_string()
|
||||
end
|
||||
|
||||
function core.itemstring_with_color(item, colorstring)
|
||||
local stack = ItemStack(item) -- convert to ItemStack
|
||||
stack:get_meta():set_string("color", colorstring)
|
||||
return stack:to_string()
|
||||
end
|
||||
|
||||
-- This is used to allow mods to redefine core.item_place and so on
|
||||
-- NOTE: This is not the preferred way. Preferred way is to provide enough
|
||||
-- callbacks to not require redefining global functions. -celeron55
|
||||
|
@ -671,7 +757,7 @@ core.nodedef_default = {
|
|||
inventory_image = "",
|
||||
wield_image = "",
|
||||
wield_scale = {x=1,y=1,z=1},
|
||||
stack_max = 99,
|
||||
stack_max = 64,
|
||||
usable = false,
|
||||
liquids_pointable = false,
|
||||
tool_capabilities = nil,
|
||||
|
@ -735,7 +821,7 @@ core.craftitemdef_default = {
|
|||
inventory_image = "",
|
||||
wield_image = "",
|
||||
wield_scale = {x=1,y=1,z=1},
|
||||
stack_max = 99,
|
||||
stack_max = 64,
|
||||
liquids_pointable = false,
|
||||
tool_capabilities = nil,
|
||||
|
||||
|
@ -773,7 +859,7 @@ core.noneitemdef_default = { -- This is used for the hand and unknown items
|
|||
inventory_image = "",
|
||||
wield_image = "",
|
||||
wield_scale = {x=1,y=1,z=1},
|
||||
stack_max = 99,
|
||||
stack_max = 64,
|
||||
liquids_pointable = false,
|
||||
tool_capabilities = nil,
|
||||
|
||||
|
|
|
@ -14,9 +14,82 @@ end
|
|||
-- If item_entity_ttl is not set, enity will have default life time
|
||||
-- Setting it to -1 disables the feature
|
||||
|
||||
local time_to_live = tonumber(core.settings:get("item_entity_ttl")) or 900
|
||||
local time_to_live = tonumber(core.settings:get("item_entity_ttl")) or 600
|
||||
local gravity = tonumber(core.settings:get("movement_gravity")) or 9.81
|
||||
|
||||
-- Water flow functions by QwertyMine3 (WTFPL), and TenPlus1 (MIT)
|
||||
local function to_unit_vector(dir_vector)
|
||||
local inv_roots = {
|
||||
[0] = 1,
|
||||
[1] = 1,
|
||||
[2] = 0.70710678118655,
|
||||
[4] = 0.5,
|
||||
[5] = 0.44721359549996,
|
||||
[8] = 0.35355339059327
|
||||
}
|
||||
local sum = dir_vector.x * dir_vector.x + dir_vector.z * dir_vector.z
|
||||
return {
|
||||
x = dir_vector.x * inv_roots[sum],
|
||||
y = dir_vector.y,
|
||||
z = dir_vector.z * inv_roots[sum]
|
||||
}
|
||||
end
|
||||
|
||||
local function quick_flow_logic(node, pos_testing, direction)
|
||||
local node_testing = core.get_node_or_nil(pos_testing)
|
||||
if not node_testing then
|
||||
node_testing = core.registered_nodes["default:dirt"]
|
||||
end
|
||||
if core.registered_nodes[node_testing.name].liquidtype ~= "flowing"
|
||||
and core.registered_nodes[node_testing.name].liquidtype ~= "source" then
|
||||
return 0
|
||||
end
|
||||
local param2_testing = node_testing.param2
|
||||
if param2_testing < node.param2 then
|
||||
if (node.param2 - param2_testing) > 6 then
|
||||
return -direction
|
||||
else
|
||||
return direction
|
||||
end
|
||||
elseif param2_testing > node.param2 then
|
||||
|
||||
if (param2_testing - node.param2) > 6 then
|
||||
return direction
|
||||
else
|
||||
return -direction
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
local function quick_flow(pos, node)
|
||||
if not core.registered_nodes[node.name].groups.liquid then
|
||||
return {x = 0, y = 0, z = 0}
|
||||
end
|
||||
local x, z = 0, 0
|
||||
x = x + quick_flow_logic(node, {x = pos.x - 1, y = pos.y, z = pos.z},-1)
|
||||
x = x + quick_flow_logic(node, {x = pos.x + 1, y = pos.y, z = pos.z}, 1)
|
||||
z = z + quick_flow_logic(node, {x = pos.x, y = pos.y, z = pos.z - 1},-1)
|
||||
z = z + quick_flow_logic(node, {x = pos.x, y = pos.y, z = pos.z + 1}, 1)
|
||||
return to_unit_vector({x = x, y = 0, z = z})
|
||||
end
|
||||
|
||||
core.register_entity(":__builtin:throwing_item", {
|
||||
physical = false,
|
||||
visual = "wielditem",
|
||||
collisionbox = {0,0,0, 0,0,0},
|
||||
textures = {""},
|
||||
visual_size = {x=0.4, y=0.4},
|
||||
is_visible = false,
|
||||
on_activate = function(self, staticdata)
|
||||
if staticdata == "expired" then
|
||||
self.object:remove()
|
||||
end
|
||||
end,
|
||||
get_staticdata = function()
|
||||
return "expired"
|
||||
end,
|
||||
})
|
||||
|
||||
core.register_entity(":__builtin:item", {
|
||||
initial_properties = {
|
||||
|
@ -62,7 +135,7 @@ core.register_entity(":__builtin:item", {
|
|||
collisionbox = {-size, -coll_height, -size,
|
||||
size, coll_height, size},
|
||||
selectionbox = {-size, -size, -size, size, size, size},
|
||||
automatic_rotate = math.pi * 0.5 * 0.2 / size,
|
||||
automatic_rotate = math.pi * 0.5 * 0.15 / size,
|
||||
wield_item = self.itemstring,
|
||||
})
|
||||
|
||||
|
@ -87,7 +160,7 @@ core.register_entity(":__builtin:item", {
|
|||
else
|
||||
self.itemstring = staticdata
|
||||
end
|
||||
self.object:set_armor_groups({immortal = 1})
|
||||
self.object:set_armor_groups({immortal = 1, silent = 1})
|
||||
self.object:set_velocity({x = 0, y = 2, z = 0})
|
||||
self.object:set_acceleration({x = 0, y = -gravity, z = 0})
|
||||
self:set_item()
|
||||
|
@ -140,11 +213,18 @@ core.register_entity(":__builtin:item", {
|
|||
end
|
||||
|
||||
local pos = self.object:get_pos()
|
||||
local node = core.get_node_or_nil({
|
||||
self.node_inside = core.get_node_or_nil(pos)
|
||||
self.def_inside = self.node_inside
|
||||
and core.registered_nodes[self.node_inside.name]
|
||||
self.node_under = core.get_node_or_nil({
|
||||
x = pos.x,
|
||||
y = pos.y + self.object:get_properties().collisionbox[2] - 0.05,
|
||||
z = pos.z
|
||||
})
|
||||
self.def_under = self.node_under
|
||||
and core.registered_nodes[self.node_under.name]
|
||||
|
||||
local node = self.node_inside
|
||||
-- Delete in 'ignore' nodes
|
||||
if node and node.name == "ignore" then
|
||||
self.itemstring = ""
|
||||
|
@ -153,11 +233,42 @@ core.register_entity(":__builtin:item", {
|
|||
end
|
||||
|
||||
local vel = self.object:get_velocity()
|
||||
local def = node and core.registered_nodes[node.name]
|
||||
local def = self.def_inside
|
||||
local is_moving = (def and not def.walkable) or
|
||||
vel.x ~= 0 or vel.y ~= 0 or vel.z ~= 0
|
||||
local is_slippery = false
|
||||
|
||||
-- Destroy item when dropped into lava
|
||||
if def and def.groups and def.groups.lava then
|
||||
core.sound_play("default_cool_lava", {pos = pos, max_hear_distance = 10})
|
||||
self.object:remove()
|
||||
core.add_particlespawner({
|
||||
amount = 3,
|
||||
time = 0.1,
|
||||
minpos = {x = pos.x - 0.1, y = pos.y + 0.1, z = pos.z - 0.1 },
|
||||
maxpos = {x = pos.x + 0.1, y = pos.y + 0.2, z = pos.z + 0.1 },
|
||||
minvel = {x = 0, y = 2.5, z = 0},
|
||||
maxvel = {x = 0, y = 2.5, z = 0},
|
||||
minacc = {x = -0.15, y = -0.02, z = -0.15},
|
||||
maxacc = {x = 0.15, y = -0.01, z = 0.15},
|
||||
minexptime = 4,
|
||||
maxexptime = 6,
|
||||
minsize = 2,
|
||||
maxsize = 4,
|
||||
texture = "item_smoke.png"
|
||||
})
|
||||
return
|
||||
end
|
||||
|
||||
-- Moving items in the water flow
|
||||
if def and def.liquidtype == "flowing" then
|
||||
local vec = quick_flow(pos, node)
|
||||
self.object:set_velocity({x = vec.x, y = vel.y, z = vec.z})
|
||||
return
|
||||
end
|
||||
|
||||
node = self.node_under
|
||||
def = self.def_under
|
||||
if def and def.walkable then
|
||||
local slippery = core.get_item_group(node.name, "slippery")
|
||||
is_slippery = slippery ~= 0
|
||||
|
@ -190,16 +301,17 @@ core.register_entity(":__builtin:item", {
|
|||
self.object:set_velocity({x = 0, y = 0, z = 0})
|
||||
end
|
||||
|
||||
--Only collect items if not moving
|
||||
-- Only collect items if not moving
|
||||
if is_moving then
|
||||
return
|
||||
end
|
||||
|
||||
-- Collect the items around to merge with
|
||||
local own_stack = ItemStack(self.itemstring)
|
||||
if own_stack:get_free_space() == 0 then
|
||||
return
|
||||
end
|
||||
local objects = core.get_objects_inside_radius(pos, 1.0)
|
||||
local objects = core.get_objects_inside_radius(pos, 0.25)
|
||||
for k, obj in pairs(objects) do
|
||||
local entity = obj:get_luaentity()
|
||||
if entity and entity.name == "__builtin:item" then
|
||||
|
|
|
@ -39,46 +39,26 @@ function core.check_player_privs(name, ...)
|
|||
return true, ""
|
||||
end
|
||||
|
||||
|
||||
local player_list = {}
|
||||
|
||||
|
||||
function core.send_join_message(player_name)
|
||||
if not core.is_singleplayer() then
|
||||
core.chat_send_all("*** " .. player_name .. " joined the game.")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function core.send_leave_message(player_name, timed_out)
|
||||
local announcement = "*** " .. player_name .. " left the game."
|
||||
if timed_out then
|
||||
announcement = announcement .. " (timed out)"
|
||||
end
|
||||
core.chat_send_all(announcement)
|
||||
end
|
||||
|
||||
|
||||
core.register_on_joinplayer(function(player)
|
||||
local player_name = player:get_player_name()
|
||||
player_list[player_name] = player
|
||||
if not minetest.is_singleplayer() then
|
||||
local status = core.get_server_status(player_name, true)
|
||||
if status and status ~= "" then
|
||||
core.chat_send_player(player_name, status)
|
||||
end
|
||||
if not core.is_singleplayer() then
|
||||
core.chat_send_all("=> " .. player_name .. " has joined the server")
|
||||
end
|
||||
core.send_join_message(player_name)
|
||||
end)
|
||||
|
||||
|
||||
core.register_on_leaveplayer(function(player, timed_out)
|
||||
local player_name = player:get_player_name()
|
||||
player_list[player_name] = nil
|
||||
core.send_leave_message(player_name, timed_out)
|
||||
local announcement = "<= " .. player_name .. " left the server"
|
||||
if timed_out then
|
||||
announcement = announcement .. " (timed out)"
|
||||
end
|
||||
core.chat_send_all(announcement)
|
||||
end)
|
||||
|
||||
|
||||
function core.get_connected_players()
|
||||
local temp_table = {}
|
||||
for index, value in pairs(player_list) do
|
||||
|
@ -103,10 +83,8 @@ function core.player_exists(name)
|
|||
return core.get_auth_handler().get_auth(name) ~= nil
|
||||
end
|
||||
|
||||
|
||||
-- Returns two position vectors representing a box of `radius` in each
|
||||
-- direction centered around the player corresponding to `player_name`
|
||||
|
||||
function core.get_player_radius_area(player_name, radius)
|
||||
local player = core.get_player_by_name(player_name)
|
||||
if player == nil then
|
||||
|
@ -124,25 +102,32 @@ function core.get_player_radius_area(player_name, radius)
|
|||
return p1, p2
|
||||
end
|
||||
|
||||
|
||||
function core.hash_node_position(pos)
|
||||
return (pos.z + 32768) * 65536 * 65536
|
||||
+ (pos.y + 32768) * 65536
|
||||
+ pos.x + 32768
|
||||
local mapgen_limit = tonumber(core.settings:get("mapgen_limit"))
|
||||
function core.is_valid_pos(pos)
|
||||
if pos then
|
||||
for _, v in pairs({"x", "y", "z"}) do
|
||||
if not pos[v] or pos[v] < -mapgen_limit or pos[v] > mapgen_limit then
|
||||
return
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
function core.hash_node_position(pos)
|
||||
return (pos.z+32768)*65536*65536 + (pos.y+32768)*65536 + pos.x+32768
|
||||
end
|
||||
|
||||
function core.get_position_from_hash(hash)
|
||||
local pos = {}
|
||||
pos.x = (hash % 65536) - 32768
|
||||
hash = math.floor(hash / 65536)
|
||||
pos.y = (hash % 65536) - 32768
|
||||
hash = math.floor(hash / 65536)
|
||||
pos.z = (hash % 65536) - 32768
|
||||
pos.x = (hash%65536) - 32768
|
||||
hash = math.floor(hash/65536)
|
||||
pos.y = (hash%65536) - 32768
|
||||
hash = math.floor(hash/65536)
|
||||
pos.z = (hash%65536) - 32768
|
||||
return pos
|
||||
end
|
||||
|
||||
|
||||
function core.get_item_group(name, group)
|
||||
if not core.registered_items[name] or not
|
||||
core.registered_items[name].groups[group] then
|
||||
|
@ -151,13 +136,11 @@ function core.get_item_group(name, group)
|
|||
return core.registered_items[name].groups[group]
|
||||
end
|
||||
|
||||
|
||||
function core.get_node_group(name, group)
|
||||
core.log("deprecated", "Deprecated usage of get_node_group, use get_item_group instead")
|
||||
return core.get_item_group(name, group)
|
||||
end
|
||||
|
||||
|
||||
function core.setting_get_pos(name)
|
||||
local value = core.settings:get(name)
|
||||
if not value then
|
||||
|
@ -166,22 +149,19 @@ function core.setting_get_pos(name)
|
|||
return core.string_to_pos(value)
|
||||
end
|
||||
|
||||
|
||||
-- To be overriden by protection mods
|
||||
|
||||
function core.is_protected(pos, name)
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
function core.record_protection_violation(pos, name)
|
||||
for _, func in pairs(core.registered_on_protection_violation) do
|
||||
func(pos, name)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Checks if specified volume intersects a protected volume
|
||||
-- Backport from Minetest 5.0
|
||||
|
||||
function core.is_area_protected(minp, maxp, player_name, interval)
|
||||
-- 'interval' is the largest allowed interval for the 3D lattice of checks.
|
||||
|
@ -227,7 +207,6 @@ function core.is_area_protected(minp, maxp, player_name, interval)
|
|||
return false
|
||||
end
|
||||
|
||||
|
||||
local raillike_ids = {}
|
||||
local raillike_cur_id = 0
|
||||
function core.raillike_group(name)
|
||||
|
@ -240,9 +219,7 @@ function core.raillike_group(name)
|
|||
return id
|
||||
end
|
||||
|
||||
|
||||
-- HTTP callback interface
|
||||
|
||||
function core.http_add_fetch(httpenv)
|
||||
httpenv.fetch = function(req, callback)
|
||||
local handle = httpenv.fetch_async(req)
|
||||
|
@ -261,12 +238,10 @@ function core.http_add_fetch(httpenv)
|
|||
return httpenv
|
||||
end
|
||||
|
||||
|
||||
function core.close_formspec(player_name, formname)
|
||||
return core.show_formspec(player_name, formname, "")
|
||||
end
|
||||
|
||||
|
||||
function core.cancel_shutdown_requests()
|
||||
core.request_shutdown("", false, -1)
|
||||
end
|
||||
|
|
|
@ -11,9 +11,6 @@ function core.register_privilege(name, param)
|
|||
if def.give_to_singleplayer == nil then
|
||||
def.give_to_singleplayer = true
|
||||
end
|
||||
if def.give_to_admin == nil then
|
||||
def.give_to_admin = def.give_to_singleplayer
|
||||
end
|
||||
if def.description == nil then
|
||||
def.description = "(no description)"
|
||||
end
|
||||
|
@ -34,7 +31,7 @@ core.register_privilege("basic_privs", "Can modify 'shout' and 'interact' privil
|
|||
core.register_privilege("privs", "Can modify privileges")
|
||||
|
||||
core.register_privilege("teleport", {
|
||||
description = "Can teleport self",
|
||||
description = "Can use /teleport command",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
core.register_privilege("bring", {
|
||||
|
@ -42,13 +39,12 @@ core.register_privilege("bring", {
|
|||
give_to_singleplayer = false,
|
||||
})
|
||||
core.register_privilege("settime", {
|
||||
description = "Can set the time of day using /time",
|
||||
description = "Can use /time",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
core.register_privilege("server", {
|
||||
description = "Can do server maintenance stuff",
|
||||
give_to_singleplayer = false,
|
||||
give_to_admin = true,
|
||||
})
|
||||
core.register_privilege("protection_bypass", {
|
||||
description = "Can bypass node protection in the world",
|
||||
|
@ -57,12 +53,10 @@ core.register_privilege("protection_bypass", {
|
|||
core.register_privilege("ban", {
|
||||
description = "Can ban and unban players",
|
||||
give_to_singleplayer = false,
|
||||
give_to_admin = true,
|
||||
})
|
||||
core.register_privilege("kick", {
|
||||
description = "Can kick players",
|
||||
give_to_singleplayer = false,
|
||||
give_to_admin = true,
|
||||
})
|
||||
core.register_privilege("give", {
|
||||
description = "Can use /give and /giveme",
|
||||
|
@ -71,31 +65,28 @@ core.register_privilege("give", {
|
|||
core.register_privilege("password", {
|
||||
description = "Can use /setpassword and /clearpassword",
|
||||
give_to_singleplayer = false,
|
||||
give_to_admin = true,
|
||||
})
|
||||
core.register_privilege("fly", {
|
||||
description = "Can use fly mode",
|
||||
description = "Can fly using the free_move mode",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
core.register_privilege("fast", {
|
||||
description = "Can use fast mode",
|
||||
description = "Can walk fast using the fast_move mode",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
core.register_privilege("noclip", {
|
||||
description = "Can fly through solid nodes using noclip mode",
|
||||
description = "Can fly through walls",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
core.register_privilege("rollback", {
|
||||
description = "Can use the rollback functionality",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
core.register_privilege("zoom", {
|
||||
description = "Can zoom the camera",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
core.register_privilege("debug", {
|
||||
description = "Allows enabling various debug options that may affect gameplay",
|
||||
give_to_singleplayer = false,
|
||||
give_to_admin = true,
|
||||
})
|
||||
|
||||
core.register_can_bypass_userlimit(function(name, ip)
|
||||
local privs = core.get_player_privs(name)
|
||||
return privs["server"] or privs["ban"] or privs["privs"] or privs["password"]
|
||||
end)
|
||||
|
|
|
@ -65,14 +65,14 @@ local function check_modname_prefix(name)
|
|||
error("Name " .. name .. " does not follow naming conventions: " ..
|
||||
"\"" .. expected_prefix .. "\" or \":\" prefix required")
|
||||
end
|
||||
|
||||
|
||||
-- Enforce that the name only contains letters, numbers and underscores.
|
||||
local subname = name:sub(#expected_prefix+1)
|
||||
if subname:find("[^%w_]") then
|
||||
error("Name " .. name .. " does not follow naming conventions: " ..
|
||||
"contains unallowed characters")
|
||||
end
|
||||
|
||||
|
||||
return name
|
||||
end
|
||||
end
|
||||
|
@ -177,7 +177,7 @@ function core.register_item(name, itemdef)
|
|||
--core.log("Registering item: " .. itemdef.name)
|
||||
core.registered_items[itemdef.name] = itemdef
|
||||
core.registered_aliases[itemdef.name] = nil
|
||||
register_item_raw(itemdef)
|
||||
register_item_raw(itemdef)
|
||||
end
|
||||
|
||||
function core.unregister_item(name)
|
||||
|
@ -331,8 +331,8 @@ core.register_item(":unknown", {
|
|||
|
||||
core.register_node(":air", {
|
||||
description = "Air",
|
||||
inventory_image = "air.png",
|
||||
wield_image = "air.png",
|
||||
inventory_image = "blank.png",
|
||||
wield_image = "blank.png",
|
||||
drawtype = "airlike",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
|
@ -343,11 +343,12 @@ core.register_node(":air", {
|
|||
floodable = true,
|
||||
air_equivalent = true,
|
||||
drop = "",
|
||||
drowning = 0,
|
||||
groups = {not_in_creative_inventory=1},
|
||||
})
|
||||
|
||||
core.register_node(":ignore", {
|
||||
description = "Ignore",
|
||||
description = "Ignore (you hacker you!)",
|
||||
inventory_image = "ignore.png",
|
||||
wield_image = "ignore.png",
|
||||
drawtype = "airlike",
|
||||
|
@ -359,14 +360,8 @@ core.register_node(":ignore", {
|
|||
buildable_to = true, -- A way to remove accidentally placed ignores
|
||||
air_equivalent = true,
|
||||
drop = "",
|
||||
drowning = 0,
|
||||
groups = {not_in_creative_inventory=1},
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
minetest.chat_send_player(
|
||||
placer:get_player_name(),
|
||||
minetest.colorize("#FF0000",
|
||||
"You can't place 'ignore' nodes!"))
|
||||
return ""
|
||||
end,
|
||||
})
|
||||
|
||||
-- The hand (bare definition)
|
||||
|
@ -394,6 +389,16 @@ function core.override_item(name, redefinition)
|
|||
end
|
||||
|
||||
|
||||
function core.add_group(name, adding)
|
||||
local addgroup = {}
|
||||
addgroup = table.copy(core.registered_items[name].groups)
|
||||
for k, v in pairs(adding) do
|
||||
addgroup[k] = v
|
||||
end
|
||||
core.override_item(name, {groups = addgroup})
|
||||
end
|
||||
|
||||
|
||||
core.callback_origins = {}
|
||||
|
||||
function core.run_callbacks(callbacks, mode, ...)
|
||||
|
@ -442,18 +447,6 @@ function core.run_callbacks(callbacks, mode, ...)
|
|||
return ret
|
||||
end
|
||||
|
||||
function core.run_priv_callbacks(name, priv, caller, method)
|
||||
local def = core.registered_privileges[priv]
|
||||
if not def or not def["on_" .. method] or
|
||||
not def["on_" .. method](name, caller) then
|
||||
for _, func in ipairs(core["registered_on_priv_" .. method]) do
|
||||
if not func(name, caller, priv) then
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
-- Callback registration
|
||||
--
|
||||
|
@ -513,26 +506,13 @@ local function make_registration_wrap(reg_fn_name, clear_fn_name)
|
|||
return list
|
||||
end
|
||||
|
||||
local function make_wrap_deregistration(reg_fn, clear_fn, list)
|
||||
local unregister = function (unregistered_key)
|
||||
local temporary_list = table.copy(list)
|
||||
clear_fn()
|
||||
for k,v in pairs(temporary_list) do
|
||||
if unregistered_key ~= k then
|
||||
reg_fn(v)
|
||||
end
|
||||
end
|
||||
end
|
||||
return unregister
|
||||
end
|
||||
|
||||
core.registered_on_player_hpchanges = { modifiers = { }, loggers = { } }
|
||||
|
||||
function core.registered_on_player_hpchange(player, hp_change, reason)
|
||||
function core.registered_on_player_hpchange(player, hp_change)
|
||||
local last = false
|
||||
for i = #core.registered_on_player_hpchanges.modifiers, 1, -1 do
|
||||
local func = core.registered_on_player_hpchanges.modifiers[i]
|
||||
hp_change, last = func(player, hp_change, reason)
|
||||
hp_change, last = func(player, hp_change)
|
||||
if type(hp_change) ~= "number" then
|
||||
local debuginfo = debug.getinfo(func)
|
||||
error("The register_on_hp_changes function has to return a number at " ..
|
||||
|
@ -543,7 +523,7 @@ function core.registered_on_player_hpchange(player, hp_change, reason)
|
|||
end
|
||||
end
|
||||
for i, func in ipairs(core.registered_on_player_hpchanges.loggers) do
|
||||
func(player, hp_change, reason)
|
||||
func(player, hp_change)
|
||||
end
|
||||
return hp_change
|
||||
end
|
||||
|
@ -564,12 +544,9 @@ core.registered_biomes = make_registration_wrap("register_biome", "cle
|
|||
core.registered_ores = make_registration_wrap("register_ore", "clear_registered_ores")
|
||||
core.registered_decorations = make_registration_wrap("register_decoration", "clear_registered_decorations")
|
||||
|
||||
core.unregister_biome = make_wrap_deregistration(core.register_biome, core.clear_registered_biomes, core.registered_biomes)
|
||||
|
||||
core.registered_on_chat_messages, core.register_on_chat_message = make_registration()
|
||||
core.registered_globalsteps, core.register_globalstep = make_registration()
|
||||
core.registered_playerevents, core.register_playerevent = make_registration()
|
||||
core.registered_on_mods_loaded, core.register_on_mods_loaded = make_registration()
|
||||
core.registered_on_shutdown, core.register_on_shutdown = make_registration()
|
||||
core.registered_on_punchnodes, core.register_on_punchnode = make_registration()
|
||||
core.registered_on_placenodes, core.register_on_placenode = make_registration()
|
||||
|
@ -588,16 +565,103 @@ core.registered_craft_predicts, core.register_craft_predict = make_registration(
|
|||
core.registered_on_protection_violation, core.register_on_protection_violation = make_registration()
|
||||
core.registered_on_item_eats, core.register_on_item_eat = make_registration()
|
||||
core.registered_on_punchplayers, core.register_on_punchplayer = make_registration()
|
||||
core.registered_on_priv_grant, core.register_on_priv_grant = make_registration()
|
||||
core.registered_on_priv_revoke, core.register_on_priv_revoke = make_registration()
|
||||
core.registered_can_bypass_userlimit, core.register_can_bypass_userlimit = make_registration()
|
||||
core.registered_on_modchannel_message, core.register_on_modchannel_message = make_registration()
|
||||
core.registered_on_auth_fail, core.register_on_auth_fail = make_registration()
|
||||
core.registered_on_player_inventory_actions, core.register_on_player_inventory_action = make_registration()
|
||||
core.registered_allow_player_inventory_actions, core.register_allow_player_inventory_action = make_registration()
|
||||
|
||||
-- Player step iteration
|
||||
|
||||
players_per_step = core.settings:get("players_per_globalstep")
|
||||
players_per_step = players_per_step and tonumber(players_per_step) or 20
|
||||
|
||||
local player_iter = nil
|
||||
local player_iter_forced = nil
|
||||
local playerstep_iter = nil
|
||||
local playerstep_funcs = {}
|
||||
local playerstep_funcs_forced = {}
|
||||
local playernames = {}
|
||||
local playernames_forced = {}
|
||||
|
||||
core.register_playerstep = function(func, force)
|
||||
local funcs = force and playerstep_funcs_forced or playerstep_funcs
|
||||
funcs[#funcs + 1] = func
|
||||
end
|
||||
|
||||
local function table_iter(t)
|
||||
local i = 0
|
||||
local n = table.getn(t)
|
||||
return function ()
|
||||
i = i + 1
|
||||
if i <= n then
|
||||
return t[i]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function core.get_player_iter()
|
||||
local names = {}
|
||||
for player in table_iter(core.get_connected_players()) do
|
||||
local name = player:get_player_name()
|
||||
if name then
|
||||
names[#names + 1] = name
|
||||
end
|
||||
end
|
||||
return table_iter(names)
|
||||
end
|
||||
|
||||
local function get_playerstep_func()
|
||||
if playerstep_iter == nil then
|
||||
playerstep_iter = table_iter(playerstep_funcs)
|
||||
playernames = {}
|
||||
for _ = 1, players_per_step do
|
||||
if player_iter == nil then
|
||||
player_iter = core.get_player_iter()
|
||||
end
|
||||
local name = player_iter()
|
||||
if not name then
|
||||
player_iter = nil
|
||||
break
|
||||
end
|
||||
playernames[#playernames + 1] = name
|
||||
end
|
||||
end
|
||||
local func = playerstep_iter()
|
||||
playerstep_iter = func and playerstep_iter
|
||||
return func or get_playerstep_func()
|
||||
end
|
||||
|
||||
-- Run playerstep callbacks
|
||||
|
||||
core.register_globalstep(function(dtime)
|
||||
-- Run forced callbacks
|
||||
if #playerstep_funcs_forced ~= 0 then
|
||||
playernames_forced = {}
|
||||
for _ = 1, players_per_step do
|
||||
if player_iter_forced == nil then
|
||||
player_iter_forced = core.get_player_iter()
|
||||
end
|
||||
local name = player_iter_forced()
|
||||
if not name then
|
||||
player_iter_forced = nil
|
||||
break
|
||||
end
|
||||
playernames_forced[#playernames_forced + 1] = name
|
||||
end
|
||||
for func in table_iter(playerstep_funcs_forced) do
|
||||
if type(func) == "function" then
|
||||
func(dtime, playernames_forced)
|
||||
end
|
||||
end
|
||||
end
|
||||
if #playerstep_funcs ~= 0 then
|
||||
-- Run single step callbacks
|
||||
local func = get_playerstep_func()
|
||||
if type(func) == "function" then
|
||||
func(dtime, playernames)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
--
|
||||
-- Compatibility for on_mapgen_init()
|
||||
--
|
||||
|
||||
core.register_on_mapgen_init = function(func) func(core.get_mapgen_params()) end
|
||||
|
||||
|
|
|
@ -1,87 +1,85 @@
|
|||
-- cache setting
|
||||
local enable_damage = core.settings:get_bool("enable_damage")
|
||||
|
||||
local health_bar_definition =
|
||||
{
|
||||
local health_bar_definition = {
|
||||
hud_elem_type = "statbar",
|
||||
position = { x=0.5, y=1 },
|
||||
text = "heart.png",
|
||||
number = core.PLAYER_MAX_HP_DEFAULT,
|
||||
direction = 0,
|
||||
size = { x=24, y=24 },
|
||||
offset = { x=(-10*24)-25, y=-(48+24+16)},
|
||||
position = {x = 0.5, y = 1},
|
||||
alignment = {x = -1, y = -1},
|
||||
offset = {x = -247, y = -108},
|
||||
size = {x = 24, y = 24},
|
||||
text = "heart.png",
|
||||
background = "heart_bg.png",
|
||||
number = 20
|
||||
}
|
||||
|
||||
local breath_bar_definition =
|
||||
{
|
||||
local breath_bar_definition = {
|
||||
hud_elem_type = "statbar",
|
||||
position = { x=0.5, y=1 },
|
||||
text = "bubble.png",
|
||||
number = core.PLAYER_MAX_BREATH_DEFAULT,
|
||||
direction = 0,
|
||||
size = { x=24, y=24 },
|
||||
offset = {x=25,y=-(48+24+16)},
|
||||
position = {x = 0.5, y = 1},
|
||||
alignment = {x = -1, y = -1},
|
||||
offset = {x = 8, y = -134},
|
||||
size = {x = 24, y = 24},
|
||||
text = "bubble.png",
|
||||
number = 20
|
||||
}
|
||||
|
||||
local hud_ids = {}
|
||||
|
||||
local function scaleToDefault(player, field)
|
||||
-- Scale "hp" or "breath" to the default dimensions
|
||||
local current = player["get_" .. field](player)
|
||||
local nominal = core["PLAYER_MAX_".. field:upper() .. "_DEFAULT"]
|
||||
local max_display = math.max(nominal,
|
||||
math.max(player:get_properties()[field .. "_max"], current))
|
||||
return current / max_display * nominal
|
||||
end
|
||||
local function initialize_builtin_statbars(player)
|
||||
|
||||
if not player:is_player() then
|
||||
return
|
||||
end
|
||||
|
||||
local function update_builtin_statbars(player)
|
||||
local name = player:get_player_name()
|
||||
|
||||
if name == "" then
|
||||
return
|
||||
end
|
||||
|
||||
local flags = player:hud_get_flags()
|
||||
if not hud_ids[name] then
|
||||
if (hud_ids[name] == nil) then
|
||||
hud_ids[name] = {}
|
||||
-- flags are not transmitted to client on connect, we need to make sure
|
||||
-- our current flags are transmitted by sending them actively
|
||||
player:hud_set_flags(flags)
|
||||
end
|
||||
local hud = hud_ids[name]
|
||||
|
||||
if flags.healthbar and enable_damage then
|
||||
local number = scaleToDefault(player, "hp")
|
||||
if hud.id_healthbar == nil then
|
||||
local hud_def = table.copy(health_bar_definition)
|
||||
hud_def.number = number
|
||||
hud.id_healthbar = player:hud_add(hud_def)
|
||||
else
|
||||
player:hud_change(hud.id_healthbar, "number", number)
|
||||
end
|
||||
elseif hud.id_healthbar then
|
||||
player:hud_remove(hud.id_healthbar)
|
||||
hud.id_healthbar = nil
|
||||
player:hud_set_flags(player:hud_get_flags())
|
||||
end
|
||||
|
||||
local breath_max = player:get_properties().breath_max
|
||||
if flags.breathbar and enable_damage and
|
||||
player:get_breath() < breath_max then
|
||||
local number = 2 * scaleToDefault(player, "breath")
|
||||
if hud.id_breathbar == nil then
|
||||
local hud_def = table.copy(breath_bar_definition)
|
||||
hud_def.number = number
|
||||
hud.id_breathbar = player:hud_add(hud_def)
|
||||
else
|
||||
player:hud_change(hud.id_breathbar, "number", number)
|
||||
if player:hud_get_flags().healthbar and enable_damage then
|
||||
if hud_ids[name].id_healthbar == nil then
|
||||
hud_ids[name].id_healthbar = hud.register("health", health_bar_definition)
|
||||
minetest.after(0, function()
|
||||
hud.change_item(player, "health", {number = player:get_hp()})
|
||||
end)
|
||||
end
|
||||
elseif hud.id_breathbar then
|
||||
player:hud_remove(hud.id_breathbar)
|
||||
hud.id_breathbar = nil
|
||||
else
|
||||
if hud_ids[name].id_healthbar ~= nil then
|
||||
player:hud_remove(hud_ids[name].id_healthbar)
|
||||
hud_ids[name].id_healthbar = nil
|
||||
end
|
||||
end
|
||||
|
||||
if (player:get_breath() < 11) then
|
||||
if player:hud_get_flags().breathbar and enable_damage then
|
||||
if hud_ids[name].id_breathbar == nil then
|
||||
hud_ids[name].id_breathbar = player:hud_add(breath_bar_definition)
|
||||
end
|
||||
else
|
||||
if hud_ids[name].id_breathbar ~= nil then
|
||||
player:hud_remove(hud_ids[name].id_breathbar)
|
||||
hud_ids[name].id_breathbar = nil
|
||||
end
|
||||
end
|
||||
elseif hud_ids[name].id_breathbar ~= nil then
|
||||
player:hud_remove(hud_ids[name].id_breathbar)
|
||||
hud_ids[name].id_breathbar = nil
|
||||
end
|
||||
end
|
||||
|
||||
local function cleanup_builtin_statbars(player)
|
||||
|
||||
if not player:is_player() then
|
||||
return
|
||||
end
|
||||
|
||||
local name = player:get_player_name()
|
||||
|
||||
if name == "" then
|
||||
|
@ -91,55 +89,57 @@ local function cleanup_builtin_statbars(player)
|
|||
hud_ids[name] = nil
|
||||
end
|
||||
|
||||
local function player_event_handler(player,eventname)
|
||||
local function player_event_handler(player, eventname)
|
||||
assert(player:is_player())
|
||||
|
||||
local name = player:get_player_name()
|
||||
|
||||
if name == "" or not hud_ids[name] then
|
||||
if name == "" then
|
||||
return
|
||||
end
|
||||
|
||||
if eventname == "health_changed" then
|
||||
update_builtin_statbars(player)
|
||||
initialize_builtin_statbars(player)
|
||||
|
||||
if hud_ids[name].id_healthbar then
|
||||
if hud_id[name.."_".."health"] ~= nil then
|
||||
hud.change_item(player, "health", {number = player:get_hp()})
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
if eventname == "breath_changed" then
|
||||
update_builtin_statbars(player)
|
||||
initialize_builtin_statbars(player)
|
||||
|
||||
if hud_ids[name].id_breathbar then
|
||||
if hud_ids[name].id_breathbar ~= nil then
|
||||
player:hud_change(hud_ids[name].id_breathbar,"number",player:get_breath()*2)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
if eventname == "hud_changed" then
|
||||
update_builtin_statbars(player)
|
||||
initialize_builtin_statbars(player)
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function core.hud_replace_builtin(name, definition)
|
||||
--[[function core.hud_replace_builtin(name, definition)
|
||||
|
||||
if type(definition) ~= "table" or
|
||||
definition.hud_elem_type ~= "statbar" then
|
||||
if definition == nil or
|
||||
type(definition) ~= "table" or
|
||||
definition.hud_elem_type ~= "statbar" then
|
||||
return false
|
||||
end
|
||||
|
||||
if name == "health" then
|
||||
health_bar_definition = definition
|
||||
|
||||
for name, ids in pairs(hud_ids) do
|
||||
for name,ids in pairs(hud_ids) do
|
||||
local player = core.get_player_by_name(name)
|
||||
if player and ids.id_healthbar then
|
||||
player:hud_remove(ids.id_healthbar)
|
||||
ids.id_healthbar = nil
|
||||
update_builtin_statbars(player)
|
||||
if player and hud_ids[name].id_healthbar then
|
||||
player:hud_remove(hud_ids[name].id_healthbar)
|
||||
initialize_builtin_statbars(player)
|
||||
end
|
||||
end
|
||||
return true
|
||||
|
@ -148,24 +148,68 @@ function core.hud_replace_builtin(name, definition)
|
|||
if name == "breath" then
|
||||
breath_bar_definition = definition
|
||||
|
||||
for name, ids in pairs(hud_ids) do
|
||||
for name,ids in pairs(hud_ids) do
|
||||
local player = core.get_player_by_name(name)
|
||||
if player and ids.id_breathbar then
|
||||
player:hud_remove(ids.id_breathbar)
|
||||
ids.id_breathbar = nil
|
||||
update_builtin_statbars(player)
|
||||
if player and hud_ids[name].id_breathbar then
|
||||
player:hud_remove(hud_ids[name].id_breathbar)
|
||||
initialize_builtin_statbars(player)
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
end]]
|
||||
|
||||
if enable_damage then
|
||||
core.register_on_joinplayer(initialize_builtin_statbars)
|
||||
core.register_on_leaveplayer(cleanup_builtin_statbars)
|
||||
core.register_playerevent(player_event_handler)
|
||||
end
|
||||
|
||||
-- Append "update_builtin_statbars" as late as possible
|
||||
-- This ensures that the HUD is hidden when the flags are updated in this callback
|
||||
core.register_on_mods_loaded(function()
|
||||
core.register_on_joinplayer(update_builtin_statbars)
|
||||
end)
|
||||
core.register_on_leaveplayer(cleanup_builtin_statbars)
|
||||
core.register_playerevent(player_event_handler)
|
||||
-- Hud Item name
|
||||
local timer, wield = {}, {}
|
||||
local timeout = 2
|
||||
|
||||
hud.register("itemname", {
|
||||
hud_elem_type = "text",
|
||||
position = {x = 0.5, y = 1},
|
||||
alignment = {x = 0, y = -10},
|
||||
offset = {x = 0, y = -25},
|
||||
number = 0xFFFFFF,
|
||||
text = ""
|
||||
})
|
||||
|
||||
minetest.register_playerstep(function(dtime, playernames)
|
||||
for _, name in pairs(playernames) do
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if player and player:is_player() then
|
||||
local wielded_item = player:get_wielded_item()
|
||||
local wielded_item_name = wielded_item:get_name()
|
||||
|
||||
timer[player] = timer[player] and timer[player] + dtime or 0
|
||||
wield[player] = wield[player] or ""
|
||||
|
||||
if timer[player] > timeout then
|
||||
hud.change_item(player, "itemname", {text = ""})
|
||||
timer[player] = 0
|
||||
return
|
||||
end
|
||||
|
||||
if player and wielded_item_name ~= wield[player] then
|
||||
wield[player] = wielded_item_name
|
||||
timer[player] = 0
|
||||
|
||||
local def = core.registered_items[wielded_item_name]
|
||||
local meta = wielded_item:get_meta()
|
||||
local meta_desc = meta:get_string("description")
|
||||
meta_desc = meta_desc:gsub("\27", ""):gsub("%(c@#%w%w%w%w%w%w%)", "")
|
||||
|
||||
local description = meta_desc ~= "" and meta_desc or
|
||||
(def and (def.description:match("(.-)\n") or def.description) or "")
|
||||
|
||||
hud.change_item(player, "itemname", {text = description})
|
||||
end
|
||||
end
|
||||
end
|
||||
end, minetest.is_singleplayer()) -- Force step in singlplayer mode only
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
-- Minetest: builtin/static_spawn.lua
|
||||
|
||||
local static_spawnpoint_string = core.settings:get("static_spawnpoint")
|
||||
if static_spawnpoint_string and
|
||||
if static_spawnpoint_string and
|
||||
static_spawnpoint_string ~= "" and
|
||||
not core.setting_get_pos("static_spawnpoint") then
|
||||
not core.setting_get_pos("static_spawnpoint") then
|
||||
error('The static_spawnpoint setting is invalid: "' ..
|
||||
static_spawnpoint_string .. '"')
|
||||
end
|
||||
end
|
||||
|
||||
local function put_player_in_spawn(player_obj)
|
||||
local static_spawnpoint = core.setting_get_pos("static_spawnpoint")
|
||||
|
|
|
@ -24,7 +24,7 @@ math.randomseed(os.time())
|
|||
minetest = core
|
||||
|
||||
-- Load other files
|
||||
local scriptdir = core.get_builtin_path()
|
||||
local scriptdir = core.get_builtin_path() .. DIR_DELIM
|
||||
local gamepath = scriptdir .. "game" .. DIR_DELIM
|
||||
local clientpath = scriptdir .. "client" .. DIR_DELIM
|
||||
local commonpath = scriptdir .. "common" .. DIR_DELIM
|
||||
|
|
|
@ -0,0 +1,200 @@
|
|||
--Minetest
|
||||
--Copyright (C) 2014 sapier
|
||||
--
|
||||
--This program 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 3.0 of the License, or
|
||||
--(at your option) any later version.
|
||||
--
|
||||
--This program is distributed in the hope that it will be useful,
|
||||
--but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
--GNU Lesser General Public License for more details.
|
||||
--
|
||||
--You should have received a copy of the GNU Lesser General Public License along
|
||||
--with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
local function get_formspec(tabview, name, tabdata)
|
||||
|
||||
local index = menudata.worldlist:get_current_index(
|
||||
tonumber(core.setting_get("mainmenu_last_selected_world"))
|
||||
)
|
||||
|
||||
local retval =
|
||||
"button[4,4.15;2.6,0.5;world_delete;" .. fgettext("Delete") .. "]" ..
|
||||
"button[6.5,4.15;2.8,0.5;world_create;" .. fgettext("New") .. "]" ..
|
||||
-- "button[9.2,4.15;2.55,0.5;world_configure;" .. fgettext("Configure") .. "]" ..
|
||||
"button[8.5,4.95;3.25,0.5;start_server;" .. fgettext("Start Game") .. "]" ..
|
||||
"label[4,-0.25;" .. fgettext("Select World:") .. "]" ..
|
||||
"checkbox[0.25,0.25;cb_creative_mode;" .. fgettext("Creative Inventory") .. ";" ..
|
||||
dump(core.setting_getbool("creative_mode")) .. "]" ..
|
||||
"checkbox[0.25,0.7;cb_enable_damage;" .. fgettext("Survival Mode") .. ";" ..
|
||||
dump(core.setting_getbool("enable_damage")) .. "]" ..
|
||||
dump(core.setting_getbool("server_announce")) .. "]" ..
|
||||
"label[0.25,2.2;" .. fgettext("Name/Password") .. "]" ..
|
||||
"field[0.55,3.2;3.5,0.5;te_playername;;" ..
|
||||
core.formspec_escape(core.setting_get("name")) .. "]" ..
|
||||
"pwdfield[0.55,4;3.5,0.5;te_passwd;]"
|
||||
|
||||
if PLATFORM ~= "Android" and PLATFORM ~= "iOS" then
|
||||
retval = retval ..
|
||||
"checkbox[0.25,1.15;cb_server_announce;" .. fgettext("Public") .. ";"
|
||||
return retval
|
||||
end
|
||||
|
||||
local bind_addr = core.setting_get("bind_address")
|
||||
if bind_addr ~= nil and bind_addr ~= "" then
|
||||
retval = retval ..
|
||||
"field[0.55,5.2;2.25,0.5;te_serveraddr;" .. fgettext("Bind Address") .. ";" ..
|
||||
core.formspec_escape(core.setting_get("bind_address")) .. "]" ..
|
||||
"field[2.8,5.2;1.25,0.5;te_serverport;" .. fgettext("Port") .. ";" ..
|
||||
core.formspec_escape(core.setting_get("port")) .. "]"
|
||||
else
|
||||
retval = retval ..
|
||||
"field[0.55,5.2;3.5,0.5;te_serverport;" .. fgettext("Server Port") .. ";" ..
|
||||
core.formspec_escape(core.setting_get("port")) .. "]"
|
||||
end
|
||||
|
||||
retval = retval ..
|
||||
"textlist[4,0.25;7.5,3.7;srv_worlds;" ..
|
||||
menu_render_worldlist() ..
|
||||
";" .. index .. ";true]"
|
||||
|
||||
return retval
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
local function main_button_handler(this, fields, name, tabdata)
|
||||
|
||||
local world_doubleclick = false
|
||||
|
||||
if fields["srv_worlds"] ~= nil then
|
||||
local event = core.explode_textlist_event(fields["srv_worlds"])
|
||||
local selected = core.get_textlist_index("srv_worlds")
|
||||
|
||||
menu_worldmt_legacy(selected)
|
||||
|
||||
if event.type == "DCL" then
|
||||
world_doubleclick = true
|
||||
end
|
||||
if event.type == "CHG" then
|
||||
core.settings:set("mainmenu_last_selected_world",
|
||||
menudata.worldlist:get_raw_index(core.get_textlist_index("srv_worlds")))
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
if menu_handle_key_up_down(fields,"srv_worlds","mainmenu_last_selected_world") then
|
||||
return true
|
||||
end
|
||||
|
||||
if fields["cb_creative_mode"] then
|
||||
core.settings:set("creative_mode", fields["cb_creative_mode"])
|
||||
local selected = core.get_textlist_index("srv_worlds")
|
||||
menu_worldmt(selected, "creative_mode", fields["cb_creative_mode"])
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
if fields["cb_enable_damage"] then
|
||||
core.settings:set("enable_damage", fields["cb_enable_damage"])
|
||||
local selected = core.get_textlist_index("srv_worlds")
|
||||
menu_worldmt(selected, "enable_damage", fields["cb_enable_damage"])
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
if fields["cb_server_announce"] then
|
||||
core.settings:set("server_announce", fields["cb_server_announce"])
|
||||
local selected = core.get_textlist_index("srv_worlds")
|
||||
menu_worldmt(selected, "server_announce", fields["cb_server_announce"])
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
if fields["start_server"] ~= nil or
|
||||
world_doubleclick or
|
||||
fields["key_enter"] then
|
||||
local selected = core.get_textlist_index("srv_worlds")
|
||||
gamedata.selected_world = menudata.worldlist:get_raw_index(selected)
|
||||
if selected ~= nil and gamedata.selected_world ~= 0 then
|
||||
gamedata.playername = fields["te_playername"]
|
||||
gamedata.password = fields["te_passwd"]
|
||||
gamedata.port = fields["te_serverport"]
|
||||
gamedata.address = ""
|
||||
|
||||
core.settings:set("port",gamedata.port)
|
||||
if fields["te_serveraddr"] ~= nil then
|
||||
core.settings:set("bind_address",fields["te_serveraddr"])
|
||||
end
|
||||
|
||||
--update last game
|
||||
local world = menudata.worldlist:get_raw_element(gamedata.selected_world)
|
||||
if world then
|
||||
local game, index = gamemgr.find_by_gameid(world.gameid)
|
||||
core.settings:set("menu_last_game", game.id)
|
||||
end
|
||||
|
||||
core.start()
|
||||
else
|
||||
gamedata.errormessage =
|
||||
fgettext("No world created or selected!")
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
if fields["world_create"] ~= nil then
|
||||
local create_world_dlg = create_create_world_dlg(true)
|
||||
create_world_dlg:set_parent(this)
|
||||
create_world_dlg:show()
|
||||
this:hide()
|
||||
return true
|
||||
end
|
||||
|
||||
if fields["world_delete"] ~= nil then
|
||||
local selected = core.get_textlist_index("srv_worlds")
|
||||
if selected ~= nil and
|
||||
selected <= menudata.worldlist:size() then
|
||||
local world = menudata.worldlist:get_list()[selected]
|
||||
if world ~= nil and
|
||||
world.name ~= nil and
|
||||
world.name ~= "" then
|
||||
local index = menudata.worldlist:get_raw_index(selected)
|
||||
local delete_world_dlg = create_delete_world_dlg(world.name,index)
|
||||
delete_world_dlg:set_parent(this)
|
||||
delete_world_dlg:show()
|
||||
this:hide()
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
if fields["world_configure"] ~= nil then
|
||||
local selected = core.get_textlist_index("srv_worlds")
|
||||
if selected ~= nil then
|
||||
local configdialog =
|
||||
create_configure_world_dlg(
|
||||
menudata.worldlist:get_raw_index(selected))
|
||||
|
||||
if (configdialog ~= nil) then
|
||||
configdialog:set_parent(this)
|
||||
configdialog:show()
|
||||
this:hide()
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
return {
|
||||
name = "server",
|
||||
caption = fgettext("Create Server"),
|
||||
cbf_formspec = get_formspec,
|
||||
cbf_button_handler = main_button_handler,
|
||||
on_change = nil
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
--
|
||||
--This program 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
|
||||
--the Free Software Foundation; either version 3.0 of the License, or
|
||||
--(at your option) any later version.
|
||||
--
|
||||
--This program is distributed in the hope that it will be useful,
|
||||
|
@ -23,7 +23,7 @@ local function get_bool_default(name, default)
|
|||
return val
|
||||
end
|
||||
|
||||
local profiler_path = core.get_builtin_path().."profiler"..DIR_DELIM
|
||||
local profiler_path = core.get_builtin_path()..DIR_DELIM.."profiler"..DIR_DELIM
|
||||
local profiler = {}
|
||||
local sampler = assert(loadfile(profiler_path .. "sampling.lua"))(profiler)
|
||||
local instrumentation = assert(loadfile(profiler_path .. "instrumentation.lua"))(profiler, sampler, get_bool_default)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
--
|
||||
--This program 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
|
||||
--the Free Software Foundation; either version 3.0 of the License, or
|
||||
--(at your option) any later version.
|
||||
--
|
||||
--This program is distributed in the hope that it will be useful,
|
||||
|
@ -88,7 +88,7 @@ local function instrument(def)
|
|||
if not def or not def.func then
|
||||
return
|
||||
end
|
||||
def.mod = def.mod or get_current_modname() or "??"
|
||||
def.mod = def.mod or get_current_modname()
|
||||
local modname = def.mod
|
||||
local instrument_name = generate_name(def)
|
||||
local func = def.func
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
--
|
||||
--This program 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
|
||||
--the Free Software Foundation; either version 3.0 of the License, or
|
||||
--(at your option) any later version.
|
||||
--
|
||||
--This program is distributed in the hope that it will be useful,
|
||||
|
@ -73,7 +73,7 @@ local Formatter = {
|
|||
end
|
||||
}
|
||||
|
||||
local widths = { 55, 9, 9, 9, 5, 5, 5 }
|
||||
local widths = { 50, 8, 8, 8, 5, 5, 5 }
|
||||
local txt_row_format = sprintf(" %%-%ds | %%%ds | %%%ds | %%%ds | %%%ds | %%%ds | %%%ds", unpack(widths))
|
||||
|
||||
local HR = {}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
--
|
||||
--This program 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
|
||||
--the Free Software Foundation; either version 3.0 of the License, or
|
||||
--(at your option) any later version.
|
||||
--
|
||||
--This program is distributed in the hope that it will be useful,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[server]
|
||||
BlockColor Server
|
||||
|
||||
blockcolor.net
|
||||
30000
|
||||
BlockColor is a creative sandbox with only 8 colors. Only a limit : Your Imagination - http://blockcolor.net/
|
||||
|
||||
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
uniform sampler2D baseTexture;
|
||||
uniform sampler2D normalTexture;
|
||||
uniform sampler2D textureFlags;
|
||||
|
||||
#define leftImage baseTexture
|
||||
#define rightImage normalTexture
|
||||
#define maskImage textureFlags
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 uv = gl_TexCoord[0].st;
|
||||
vec4 left = texture2D(leftImage, uv).rgba;
|
||||
vec4 right = texture2D(rightImage, uv).rgba;
|
||||
vec4 mask = texture2D(maskImage, uv).rgba;
|
||||
vec4 color;
|
||||
if (mask.r > 0.5)
|
||||
color = right;
|
||||
else
|
||||
color = left;
|
||||
gl_FragColor = color;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
void main(void)
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_Position = gl_Vertex;
|
||||
gl_FrontColor = gl_BackColor = gl_Color;
|
||||
}
|
|
@ -135,7 +135,7 @@ float disp_z;
|
|||
color.a = 1;
|
||||
|
||||
// Emphase blue a bit in darker places
|
||||
// See C++ implementation in mapblock_mesh.cpp final_color_blend()
|
||||
// See C++ implementation in mapblock_mesh.cpp finalColorBlend()
|
||||
float brightness = (color.r + color.g + color.b) / 3;
|
||||
color.b += max(0.0, 0.021 - abs(0.2 * brightness - 0.021) +
|
||||
0.07 * brightness);
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
print("Loaded example file!, loading more examples")
|
||||
dofile("preview:examples/first.lua")
|
|
@ -1 +0,0 @@
|
|||
print("loaded first.lua example file")
|
|
@ -1,57 +1,18 @@
|
|||
local modname = core.get_current_modname() or "??"
|
||||
local modstorage = core.get_mod_storage()
|
||||
local mod_channel
|
||||
|
||||
dofile("preview:example.lua")
|
||||
-- This is an example function to ensure it's working properly, should be removed before merge
|
||||
core.register_on_shutdown(function()
|
||||
print("[PREVIEW] shutdown client")
|
||||
end)
|
||||
local id = nil
|
||||
|
||||
local server_info = core.get_server_info()
|
||||
print("Server version: " .. server_info.protocol_version)
|
||||
print("Server ip: " .. server_info.ip)
|
||||
print("Server address: " .. server_info.address)
|
||||
print("Server port: " .. server_info.port)
|
||||
mod_channel = core.mod_channel_join("experimental_preview")
|
||||
|
||||
core.after(4, function()
|
||||
if mod_channel:is_writeable() then
|
||||
mod_channel:send_all("preview talk to experimental")
|
||||
end
|
||||
end)
|
||||
|
||||
core.after(1, function()
|
||||
id = core.localplayer:hud_add({
|
||||
hud_elem_type = "text",
|
||||
name = "example",
|
||||
number = 0xff0000,
|
||||
position = {x=0, y=1},
|
||||
offset = {x=8, y=-8},
|
||||
text = "You are using the preview mod",
|
||||
scale = {x=200, y=60},
|
||||
alignment = {x=1, y=-1},
|
||||
})
|
||||
end)
|
||||
|
||||
core.register_on_modchannel_message(function(channel, sender, message)
|
||||
print("[PREVIEW][modchannels] Received message `" .. message .. "` on channel `"
|
||||
.. channel .. "` from sender `" .. sender .. "`")
|
||||
core.after(1, function()
|
||||
mod_channel:send_all("CSM preview received " .. message)
|
||||
end)
|
||||
end)
|
||||
|
||||
core.register_on_modchannel_signal(function(channel, signal)
|
||||
print("[PREVIEW][modchannels] Received signal id `" .. signal .. "` on channel `"
|
||||
.. channel)
|
||||
end)
|
||||
|
||||
core.register_on_inventory_open(function(inventory)
|
||||
print("INVENTORY OPEN")
|
||||
print(dump(inventory))
|
||||
return false
|
||||
core.register_on_connect(function()
|
||||
print("[PREVIEW] Player connection completed")
|
||||
local server_info = core.get_server_info()
|
||||
print("Server version: " .. server_info.protocol_version)
|
||||
print("Server ip: " .. server_info.ip)
|
||||
print("Server address: " .. server_info.address)
|
||||
print("Server port: " .. server_info.port)
|
||||
end)
|
||||
|
||||
core.register_on_placenode(function(pointed_thing, node)
|
||||
|
@ -69,13 +30,13 @@ core.register_on_item_use(function(itemstack, pointed_thing)
|
|||
end)
|
||||
|
||||
-- This is an example function to ensure it's working properly, should be removed before merge
|
||||
core.register_on_receiving_chat_message(function(message)
|
||||
core.register_on_receiving_chat_messages(function(message)
|
||||
print("[PREVIEW] Received message " .. message)
|
||||
return false
|
||||
end)
|
||||
|
||||
-- This is an example function to ensure it's working properly, should be removed before merge
|
||||
core.register_on_sending_chat_message(function(message)
|
||||
core.register_on_sending_chat_messages(function(message)
|
||||
print("[PREVIEW] Sending message " .. message)
|
||||
return false
|
||||
end)
|
||||
|
@ -189,19 +150,3 @@ core.register_on_punchnode(function(pos, node)
|
|||
return false
|
||||
end)
|
||||
|
||||
core.register_chatcommand("privs", {
|
||||
func = function(param)
|
||||
return true, core.privs_to_string(minetest.get_privilege_list())
|
||||
end,
|
||||
})
|
||||
|
||||
core.register_chatcommand("text", {
|
||||
func = function(param)
|
||||
return core.localplayer:hud_change(id, "text", param)
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
core.register_on_mods_loaded(function()
|
||||
core.log("Yeah preview mod is loaded with other CSM mods.")
|
||||
end)
|
||||
|
|
523
doc/README.md
|
@ -1,500 +1,45 @@
|
|||
Minetest
|
||||
========
|
||||
Blockcolor Open Source Project
|
||||
==============================
|
||||
|
||||
[![Build Status](https://travis-ci.org/minetest/minetest.svg?branch=master)](https://travis-ci.org/minetest/minetest)
|
||||
[![Translation status](https://hosted.weblate.org/widgets/minetest/-/svg-badge.svg)](https://hosted.weblate.org/engage/minetest/?utm_source=widget)
|
||||
[![License](https://img.shields.io/badge/license-LGPLv2.1%2B-blue.svg)](https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html)
|
||||
Blockcolor is an Open Source sandbox creative game with 8 Colors. (https://blockcolor.net/).
|
||||
|
||||
Minetest is a free open-source voxel game engine with easy modding and game creation.
|
||||
Blockcolor is based on Multicraft/Minetest projects - Copyright © 2018-2019 - MrChiantos & BlockColor Community.
|
||||
|
||||
Copyright (C) 2010-2018 Perttu Ahola <celeron55@gmail.com>
|
||||
and contributors (see source file comments and the version control log)
|
||||
GNU LGPL 3.0 for code and Cc By SA 3.0 for medias (http://creativecommons.org/licenses/by-sa/3.0/)
|
||||
|
||||
In case you downloaded the source code:
|
||||
---------------------------------------
|
||||
If you downloaded the Minetest Engine source code in which this file is
|
||||
contained, you probably want to download the [Minetest Game](https://github.com/minetest/minetest_game/)
|
||||
project too. See its README.txt for more information.
|
||||
---
|
||||
|
||||
Table of Contents
|
||||
------------------
|
||||
__Game Creator__ : MrChiantos
|
||||
|
||||
1. [Further Documentation](#further-documentation)
|
||||
2. [Default Controls](#default-controls)
|
||||
3. [Paths](#paths)
|
||||
4. [Configuration File](#configuration-file)
|
||||
5. [Command-line Options](#command-line-options)
|
||||
6. [Compiling](#compiling)
|
||||
7. [Docker](#docker)
|
||||
8. [Version Scheme](#version-scheme)
|
||||
Helpers or others Creators :
|
||||
|
||||
__Animal Model :__ AspireMint
|
||||
__Ships Spawn Mod :__ SokoMine
|
||||
__Furnitures Mod :__ Gerold55
|
||||
__Slope Simple :__ Nigel
|
||||
__Awards :__ Ruben
|
||||
__SurfBoard :__ Archfan7411
|
||||
__Airboat :__ Paramat
|
||||
__DriftCar :__ Paramat
|
||||
__Spaceship :__ Paramat (Code) & SpaceShip'Model (Viktor Hahn )
|
||||
__Textures 16px :__ Peak (Since 1.46.4b)
|
||||
__Trampoline :__ hkzorman
|
||||
__Mobs mod :__ TenPlus1
|
||||
__Player Model :__ Quaternius (Human Low Poly / Since 1.53)
|
||||
__Player Model b3d :__ Kroukuk
|
||||
__Trees :__ Kenney.nl (Since 1.53)
|
||||
__Hdb Model (Homedecor) :__ Vanessa
|
||||
__Hovercraft :__ Stuart Jones
|
||||
__HotAirBallons :__ Me Me and Me // mbb (Flying Carpet - Wuzzy)
|
||||
__ComboBlock :__ Pithydon
|
||||
__ComboBlock & ComboStair Model :__ Nathan (MinetestVideo)
|
||||
__Header and Logo :__ LMD, azekill_DIABLO & MrChiantos
|
||||
__Inventory Icons :__ Xenon (xenonca)
|
||||
|
||||
Further documentation
|
||||
----------------------
|
||||
- Website: http://minetest.net/
|
||||
- Wiki: http://wiki.minetest.net/
|
||||
- Developer wiki: http://dev.minetest.net/
|
||||
- Forum: http://forum.minetest.net/
|
||||
- GitHub: https://github.com/minetest/minetest/
|
||||
- [doc/](doc/) directory of source distribution
|
||||
Minetest : Copyright © 2010-2019 celeron55, Perttu Ahola <celeron55@gmail.com> & Minetest Community and Devs.
|
||||
|
||||
Default controls
|
||||
----------------
|
||||
All controls are re-bindable using settings.
|
||||
Some can be changed in the key config dialog in the settings tab.
|
||||
Multicraft : Copyright © 2014-2019 Maksim Gamarnik [MoNTE48] MoNTE48@mail.ua & MultiCraft Development Team.
|
||||
|
||||
| Button | Action |
|
||||
|-------------------------------|----------------------------------------------------------------|
|
||||
| Move mouse | Look around |
|
||||
| W, A, S, D | Move |
|
||||
| Space | Jump/move up |
|
||||
| Shift | Sneak/move down |
|
||||
| Q | Drop itemstack |
|
||||
| Shift + Q | Drop single item |
|
||||
| Left mouse button | Dig/punch/take item |
|
||||
| Right mouse button | Place/use |
|
||||
| Shift + right mouse button | Build (without using) |
|
||||
| I | Inventory menu |
|
||||
| Mouse wheel | Select item |
|
||||
| 0-9 | Select item |
|
||||
| Z | Zoom (needs zoom privilege) |
|
||||
| T | Chat |
|
||||
| / | Command |
|
||||
| Esc | Pause menu/abort/exit (pauses only singleplayer game) |
|
||||
| R | Enable/disable full range view |
|
||||
| + | Increase view range |
|
||||
| - | Decrease view range |
|
||||
| K | Enable/disable fly mode (needs fly privilege) |
|
||||
| L | Enable/disable pitch move mode |
|
||||
| J | Enable/disable fast mode (needs fast privilege) |
|
||||
| H | Enable/disable noclip mode (needs noclip privilege) |
|
||||
| E | Move fast in fast mode |
|
||||
| F1 | Hide/show HUD |
|
||||
| F2 | Hide/show chat |
|
||||
| F3 | Disable/enable fog |
|
||||
| F4 | Disable/enable camera update (Mapblocks are not updated anymore when disabled, disabled in release builds) |
|
||||
| F5 | Cycle through debug information screens |
|
||||
| F6 | Cycle through profiler info screens |
|
||||
| F7 | Cycle through camera modes |
|
||||
| F9 | Cycle through minimap modes |
|
||||
| Shift + F9 | Change minimap orientation |
|
||||
| F10 | Show/hide console |
|
||||
| F12 | Take screenshot |
|
||||
---
|
||||
|
||||
Paths
|
||||
-----
|
||||
Locations:
|
||||
|
||||
* `bin` - Compiled binaries
|
||||
* `share` - Distributed read-only data
|
||||
* `user` - User-created modifiable data
|
||||
|
||||
Where each location is on each platform:
|
||||
|
||||
* Windows .zip / RUN_IN_PLACE source:
|
||||
* bin = `bin`
|
||||
* share = `.`
|
||||
* user = `.`
|
||||
* Windows installed:
|
||||
* $bin = `C:\Program Files\Minetest\bin (Depends on the install location)`
|
||||
* $share = `C:\Program Files\Minetest (Depends on the install location)`
|
||||
* $user = `%Appdata%\Minetest`
|
||||
* Linux installed:
|
||||
* `bin` = `/usr/bin`
|
||||
* `share` = `/usr/share/minetest`
|
||||
* `user` = `~/.minetest`
|
||||
* macOS:
|
||||
* `bin` = `Contents/MacOS`
|
||||
* `share` = `Contents/Resources`
|
||||
* `user` = `Contents/User OR ~/Library/Application Support/minetest`
|
||||
|
||||
Worlds can be found as separate folders in: `user/worlds/`
|
||||
|
||||
Configuration file:
|
||||
-------------------
|
||||
- Default location:
|
||||
`user/minetest.conf`
|
||||
- It is created by Minetest when it is ran the first time.
|
||||
- A specific file can be specified on the command line:
|
||||
`--config <path-to-file>`
|
||||
- A run-in-place build will look for the configuration file in
|
||||
`location_of_exe/../minetest.conf` and also `location_of_exe/../../minetest.conf`
|
||||
|
||||
Command-line options:
|
||||
---------------------
|
||||
- Use `--help`
|
||||
|
||||
Compiling
|
||||
---------
|
||||
### Compiling on GNU/Linux
|
||||
|
||||
#### Dependencies
|
||||
|
||||
| Dependency | Version | Commentary |
|
||||
|------------|---------|------------|
|
||||
| GCC | 4.9+ | Can be replaced with Clang 3.4+ |
|
||||
| CMake | 2.6+ | |
|
||||
| Irrlicht | 1.7.3+ | |
|
||||
| SQLite3 | 3.0+ | |
|
||||
| LuaJIT | 2.0+ | Bundled Lua 5.1 is used if not present |
|
||||
| GMP | 5.0.0+ | Bundled mini-GMP is used if not present |
|
||||
| JsonCPP | 1.0.0+ | Bundled JsonCPP is used if not present |
|
||||
|
||||
For Debian/Ubuntu:
|
||||
|
||||
sudo apt install build-essential libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev
|
||||
|
||||
For Fedora users:
|
||||
|
||||
sudo dnf install make automake gcc gcc-c++ kernel-devel cmake libcurl-devel openal-soft-devel libvorbis-devel libXxf86vm-devel libogg-devel freetype-devel mesa-libGL-devel zlib-devel jsoncpp-devel irrlicht-devel bzip2-libs gmp-devel sqlite-devel luajit-devel leveldb-devel ncurses-devel doxygen spatialindex-devel bzip2-devel
|
||||
|
||||
#### Download
|
||||
|
||||
You can install Git for easily keeping your copy up to date.
|
||||
If you don’t want Git, read below on how to get the source without Git.
|
||||
This is an example for installing Git on Debian/Ubuntu:
|
||||
|
||||
sudo apt install git
|
||||
|
||||
For Fedora users:
|
||||
|
||||
sudo dnf install git
|
||||
|
||||
Download source (this is the URL to the latest of source repository, which might not work at all times) using Git:
|
||||
|
||||
git clone --depth 1 https://github.com/minetest/minetest.git
|
||||
cd minetest
|
||||
|
||||
Download minetest_game (otherwise only the "Minimal development test" game is available) using Git:
|
||||
|
||||
git clone --depth 1 https://github.com/minetest/minetest_game.git games/minetest_game
|
||||
|
||||
Download source, without using Git:
|
||||
|
||||
wget https://github.com/minetest/minetest/archive/master.tar.gz
|
||||
tar xf master.tar.gz
|
||||
cd minetest-master
|
||||
|
||||
Download minetest_game, without using Git:
|
||||
|
||||
cd games/
|
||||
wget https://github.com/minetest/minetest_game/archive/master.tar.gz
|
||||
tar xf master.tar.gz
|
||||
mv minetest_game-master minetest_game
|
||||
cd ..
|
||||
|
||||
#### Build
|
||||
|
||||
Build a version that runs directly from the source directory:
|
||||
|
||||
cmake . -DRUN_IN_PLACE=TRUE
|
||||
make -j <number of processors>
|
||||
|
||||
Run it:
|
||||
|
||||
./bin/minetest
|
||||
|
||||
- Use `cmake . -LH` to see all CMake options and their current state
|
||||
- If you want to install it system-wide (or are making a distribution package),
|
||||
you will want to use `-DRUN_IN_PLACE=FALSE`
|
||||
- You can build a bare server by specifying `-DBUILD_SERVER=TRUE`
|
||||
- You can disable the client build by specifying `-DBUILD_CLIENT=FALSE`
|
||||
- You can select between Release and Debug build by `-DCMAKE_BUILD_TYPE=<Debug or Release>`
|
||||
- Debug build is slower, but gives much more useful output in a debugger
|
||||
- If you build a bare server, you don't need to have Irrlicht installed.
|
||||
- In that case use `-DIRRLICHT_SOURCE_DIR=/the/irrlicht/source`
|
||||
|
||||
### CMake options
|
||||
|
||||
General options and their default values:
|
||||
|
||||
BUILD_CLIENT=TRUE - Build Minetest client
|
||||
BUILD_SERVER=FALSE - Build Minetest server
|
||||
CMAKE_BUILD_TYPE=Release - Type of build (Release vs. Debug)
|
||||
Release - Release build
|
||||
Debug - Debug build
|
||||
SemiDebug - Partially optimized debug build
|
||||
RelWithDebInfo - Release build with debug information
|
||||
MinSizeRel - Release build with -Os passed to compiler to make executable as small as possible
|
||||
ENABLE_CURL=ON - Build with cURL; Enables use of online mod repo, public serverlist and remote media fetching via http
|
||||
ENABLE_CURSES=ON - Build with (n)curses; Enables a server side terminal (command line option: --terminal)
|
||||
ENABLE_FREETYPE=ON - Build with FreeType2; Allows using TTF fonts
|
||||
ENABLE_GETTEXT=ON - Build with Gettext; Allows using translations
|
||||
ENABLE_GLES=OFF - Search for Open GLES headers & libraries and use them
|
||||
ENABLE_LEVELDB=ON - Build with LevelDB; Enables use of LevelDB map backend
|
||||
ENABLE_POSTGRESQL=ON - Build with libpq; Enables use of PostgreSQL map backend (PostgreSQL 9.5 or greater recommended)
|
||||
ENABLE_REDIS=ON - Build with libhiredis; Enables use of Redis map backend
|
||||
ENABLE_SPATIAL=ON - Build with LibSpatial; Speeds up AreaStores
|
||||
ENABLE_SOUND=ON - Build with OpenAL, libogg & libvorbis; in-game sounds
|
||||
ENABLE_LUAJIT=ON - Build with LuaJIT (much faster than non-JIT Lua)
|
||||
ENABLE_SYSTEM_GMP=ON - Use GMP from system (much faster than bundled mini-gmp)
|
||||
ENABLE_SYSTEM_JSONCPP=OFF - Use JsonCPP from system
|
||||
OPENGL_GL_PREFERENCE=LEGACY - Linux client build only; See CMake Policy CMP0072 for reference
|
||||
RUN_IN_PLACE=FALSE - Create a portable install (worlds, settings etc. in current directory)
|
||||
USE_GPROF=FALSE - Enable profiling using GProf
|
||||
VERSION_EXTRA= - Text to append to version (e.g. VERSION_EXTRA=foobar -> Minetest 0.4.9-foobar)
|
||||
|
||||
Library specific options:
|
||||
|
||||
BZIP2_INCLUDE_DIR - Linux only; directory where bzlib.h is located
|
||||
BZIP2_LIBRARY - Linux only; path to libbz2.a/libbz2.so
|
||||
CURL_DLL - Only if building with cURL on Windows; path to libcurl.dll
|
||||
CURL_INCLUDE_DIR - Only if building with cURL; directory where curl.h is located
|
||||
CURL_LIBRARY - Only if building with cURL; path to libcurl.a/libcurl.so/libcurl.lib
|
||||
EGL_INCLUDE_DIR - Only if building with GLES; directory that contains egl.h
|
||||
EGL_LIBRARY - Only if building with GLES; path to libEGL.a/libEGL.so
|
||||
FREETYPE_INCLUDE_DIR_freetype2 - Only if building with FreeType 2; directory that contains an freetype directory with files such as ftimage.h in it
|
||||
FREETYPE_INCLUDE_DIR_ft2build - Only if building with FreeType 2; directory that contains ft2build.h
|
||||
FREETYPE_LIBRARY - Only if building with FreeType 2; path to libfreetype.a/libfreetype.so/freetype.lib
|
||||
FREETYPE_DLL - Only if building with FreeType 2 on Windows; path to libfreetype.dll
|
||||
GETTEXT_DLL - Only when building with gettext on Windows; path to libintl3.dll
|
||||
GETTEXT_ICONV_DLL - Only when building with gettext on Windows; path to libiconv2.dll
|
||||
GETTEXT_INCLUDE_DIR - Only when building with gettext; directory that contains iconv.h
|
||||
GETTEXT_LIBRARY - Only when building with gettext on Windows; path to libintl.dll.a
|
||||
GETTEXT_MSGFMT - Only when building with gettext; path to msgfmt/msgfmt.exe
|
||||
IRRLICHT_DLL - Only on Windows; path to Irrlicht.dll
|
||||
IRRLICHT_INCLUDE_DIR - Directory that contains IrrCompileConfig.h
|
||||
IRRLICHT_LIBRARY - Path to libIrrlicht.a/libIrrlicht.so/libIrrlicht.dll.a/Irrlicht.lib
|
||||
LEVELDB_INCLUDE_DIR - Only when building with LevelDB; directory that contains db.h
|
||||
LEVELDB_LIBRARY - Only when building with LevelDB; path to libleveldb.a/libleveldb.so/libleveldb.dll.a
|
||||
LEVELDB_DLL - Only when building with LevelDB on Windows; path to libleveldb.dll
|
||||
PostgreSQL_INCLUDE_DIR - Only when building with PostgreSQL; directory that contains libpq-fe.h
|
||||
POSTGRESQL_LIBRARY - Only when building with PostgreSQL; path to libpq.a/libpq.so
|
||||
REDIS_INCLUDE_DIR - Only when building with Redis; directory that contains hiredis.h
|
||||
REDIS_LIBRARY - Only when building with Redis; path to libhiredis.a/libhiredis.so
|
||||
SPATIAL_INCLUDE_DIR - Only when building with LibSpatial; directory that contains spatialindex/SpatialIndex.h
|
||||
SPATIAL_LIBRARY - Only when building with LibSpatial; path to libspatialindex_c.so/spatialindex-32.lib
|
||||
LUA_INCLUDE_DIR - Only if you want to use LuaJIT; directory where luajit.h is located
|
||||
LUA_LIBRARY - Only if you want to use LuaJIT; path to libluajit.a/libluajit.so
|
||||
MINGWM10_DLL - Only if compiling with MinGW; path to mingwm10.dll
|
||||
OGG_DLL - Only if building with sound on Windows; path to libogg.dll
|
||||
OGG_INCLUDE_DIR - Only if building with sound; directory that contains an ogg directory which contains ogg.h
|
||||
OGG_LIBRARY - Only if building with sound; path to libogg.a/libogg.so/libogg.dll.a
|
||||
OPENAL_DLL - Only if building with sound on Windows; path to OpenAL32.dll
|
||||
OPENAL_INCLUDE_DIR - Only if building with sound; directory where al.h is located
|
||||
OPENAL_LIBRARY - Only if building with sound; path to libopenal.a/libopenal.so/OpenAL32.lib
|
||||
OPENGLES2_INCLUDE_DIR - Only if building with GLES; directory that contains gl2.h
|
||||
OPENGLES2_LIBRARY - Only if building with GLES; path to libGLESv2.a/libGLESv2.so
|
||||
SQLITE3_INCLUDE_DIR - Directory that contains sqlite3.h
|
||||
SQLITE3_LIBRARY - Path to libsqlite3.a/libsqlite3.so/sqlite3.lib
|
||||
VORBISFILE_DLL - Only if building with sound on Windows; path to libvorbisfile-3.dll
|
||||
VORBISFILE_LIBRARY - Only if building with sound; path to libvorbisfile.a/libvorbisfile.so/libvorbisfile.dll.a
|
||||
VORBIS_DLL - Only if building with sound on Windows; path to libvorbis-0.dll
|
||||
VORBIS_INCLUDE_DIR - Only if building with sound; directory that contains a directory vorbis with vorbisenc.h inside
|
||||
VORBIS_LIBRARY - Only if building with sound; path to libvorbis.a/libvorbis.so/libvorbis.dll.a
|
||||
XXF86VM_LIBRARY - Only on Linux; path to libXXf86vm.a/libXXf86vm.so
|
||||
ZLIB_DLL - Only on Windows; path to zlib1.dll
|
||||
ZLIBWAPI_DLL - Only on Windows; path to zlibwapi.dll
|
||||
ZLIB_INCLUDE_DIR - Directory that contains zlib.h
|
||||
ZLIB_LIBRARY - Path to libz.a/libz.so/zlibwapi.lib
|
||||
|
||||
### Compiling on Windows
|
||||
|
||||
* This section is outdated. In addition to what is described here:
|
||||
* In addition to minetest, you need to download [minetest_game](https://github.com/minetest/minetest_game).
|
||||
* If you wish to have sound support, you need libogg, libvorbis and libopenal
|
||||
|
||||
* You need:
|
||||
* CMake:
|
||||
http://www.cmake.org/cmake/resources/software.html
|
||||
* A compiler
|
||||
* MinGW: http://www.mingw.org/
|
||||
* or Visual Studio: http://msdn.microsoft.com/en-us/vstudio/default
|
||||
* Irrlicht SDK 1.7:
|
||||
http://irrlicht.sourceforge.net/downloads.html
|
||||
* Zlib headers (zlib125.zip)
|
||||
http://www.winimage.com/zLibDll/index.html
|
||||
* Zlib library (zlibwapi.lib and zlibwapi.dll from zlib125dll.zip):
|
||||
http://www.winimage.com/zLibDll/index.html
|
||||
* SQLite3 headers and library
|
||||
https://www.sqlite.org/download.html
|
||||
* Optional: gettext library and tools:
|
||||
http://gnuwin32.sourceforge.net/downlinks/gettext.php
|
||||
* This is used for other UI languages. Feel free to leave it out.
|
||||
* And, of course, Minetest:
|
||||
http://minetest.net/download
|
||||
* Steps:
|
||||
* Select a directory called DIR hereafter in which you will operate.
|
||||
* Make sure you have CMake and a compiler installed.
|
||||
* Download all the other stuff to DIR and extract them into there.
|
||||
("extract here", not "extract to packagename/")
|
||||
* NOTE: zlib125dll.zip needs to be extracted into zlib125dll
|
||||
* NOTE: You need to extract sqlite3.h & sqlite3ext.h from the SQLite 3
|
||||
source and sqlite3.dll & sqlite3.def from the SQLite 3 precompiled
|
||||
binaries into "sqlite3" directory, and generate sqlite3.lib using
|
||||
command "LIB /DEF:sqlite3.def /OUT:sqlite3.lib"
|
||||
* All those packages contain a nice base directory in them, which
|
||||
should end up being the direct subdirectories of DIR.
|
||||
* You will end up with a directory structure like this (+=dir, -=file):
|
||||
-----------------
|
||||
+ DIR
|
||||
* zlib-1.2.5.tar.gz
|
||||
* zlib125dll.zip
|
||||
* irrlicht-1.8.3.zip
|
||||
* sqlite-amalgamation-3130000.zip (SQLite3 headers)
|
||||
* sqlite-dll-win32-x86-3130000.zip (SQLite3 library for 32bit system)
|
||||
* 110214175330.zip (or whatever, this is the minetest source)
|
||||
+ zlib-1.2.5
|
||||
* zlib.h
|
||||
+ win32
|
||||
...
|
||||
+ zlib125dll
|
||||
* readme.txt
|
||||
+ dll32
|
||||
...
|
||||
+ irrlicht-1.8.3
|
||||
+ lib
|
||||
+ include
|
||||
...
|
||||
+ sqlite3
|
||||
sqlite3.h
|
||||
sqlite3ext.h
|
||||
sqlite3.lib
|
||||
sqlite3.dll
|
||||
+ gettext (optional)
|
||||
+bin
|
||||
+include
|
||||
+lib
|
||||
+ minetest
|
||||
+ src
|
||||
+ doc
|
||||
* CMakeLists.txt
|
||||
...
|
||||
-----------------
|
||||
* Start up the CMake GUI
|
||||
* Select "Browse Source..." and select DIR/minetest
|
||||
* Now, if using MSVC:
|
||||
* Select "Browse Build..." and select DIR/minetest-build
|
||||
* Else if using MinGW:
|
||||
* Select "Browse Build..." and select DIR/minetest
|
||||
* Select "Configure"
|
||||
* Select your compiler
|
||||
* It will warn about missing stuff, ignore that at this point. (later don't)
|
||||
* Make sure the configuration is as follows
|
||||
(note that the versions may differ for you):
|
||||
|
||||
BUILD_CLIENT [X]
|
||||
BUILD_SERVER [ ]
|
||||
CMAKE_BUILD_TYPE Release
|
||||
CMAKE_INSTALL_PREFIX DIR/minetest-install
|
||||
IRRLICHT_SOURCE_DIR DIR/irrlicht-1.8.3
|
||||
RUN_IN_PLACE [X]
|
||||
WARN_ALL [ ]
|
||||
ZLIB_DLL DIR/zlib125dll/dll32/zlibwapi.dll
|
||||
ZLIB_INCLUDE_DIR DIR/zlib-1.2.5
|
||||
ZLIB_LIBRARIES DIR/zlib125dll/dll32/zlibwapi.lib
|
||||
GETTEXT_BIN_DIR DIR/gettext/bin
|
||||
GETTEXT_INCLUDE_DIR DIR/gettext/include
|
||||
GETTEXT_LIBRARIES DIR/gettext/lib/intl.lib
|
||||
GETTEXT_MSGFMT DIR/gettext/bin/msgfmt
|
||||
|
||||
* If CMake complains it couldn't find SQLITE3, choose "Advanced" box on the
|
||||
right top corner, then specify the location of SQLITE3_INCLUDE_DIR and
|
||||
SQLITE3_LIBRARY manually.
|
||||
* If you want to build 64-bit minetest, you will need to build 64-bit version
|
||||
of irrlicht engine manually, as only 32-bit pre-built library is provided.
|
||||
* Hit "Configure"
|
||||
* Hit "Configure" once again 8)
|
||||
* If something is still coloured red, you have a problem.
|
||||
* Hit "Generate"
|
||||
If using MSVC:
|
||||
* Open the generated minetest.sln
|
||||
* The project defaults to the "Debug" configuration. Make very sure to
|
||||
select "Release", unless you want to debug some stuff (it's slower
|
||||
and might not even work at all)
|
||||
* Build the ALL_BUILD project
|
||||
* Build the INSTALL project
|
||||
* You should now have a working game with the executable in
|
||||
DIR/minetest-install/bin/minetest.exe
|
||||
* Additionally you may create a zip package by building the PACKAGE
|
||||
project.
|
||||
If using MinGW:
|
||||
* Using the command line, browse to the build directory and run 'make'
|
||||
(or mingw32-make or whatever it happens to be)
|
||||
* You may need to copy some of the downloaded DLLs into bin/, see what
|
||||
running the produced executable tells you it doesn't have.
|
||||
* You should now have a working game with the executable in
|
||||
DIR/minetest/bin/minetest.exe
|
||||
|
||||
### Bat script to build Windows releases of Minetest
|
||||
|
||||
This is how we build Windows releases.
|
||||
|
||||
set sourcedir=%CD%
|
||||
set installpath="C:\tmp\minetest_install"
|
||||
set irrlichtpath="C:\tmp\irrlicht-1.7.2"
|
||||
|
||||
set builddir=%sourcedir%\bvc10
|
||||
mkdir %builddir%
|
||||
pushd %builddir%
|
||||
cmake %sourcedir% -G "Visual Studio 10" -DIRRLICHT_SOURCE_DIR=%irrlichtpath% -DRUN_IN_PLACE=TRUE -DCMAKE_INSTALL_PREFIX=%installpath%
|
||||
if %errorlevel% neq 0 goto fail
|
||||
"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" ALL_BUILD.vcxproj /p:Configuration=Release
|
||||
if %errorlevel% neq 0 goto fail
|
||||
"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" INSTALL.vcxproj /p:Configuration=Release
|
||||
if %errorlevel% neq 0 goto fail
|
||||
"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" PACKAGE.vcxproj /p:Configuration=Release
|
||||
if %errorlevel% neq 0 goto fail
|
||||
popd
|
||||
echo Finished.
|
||||
exit /b 0
|
||||
|
||||
:fail
|
||||
popd
|
||||
echo Failed.
|
||||
exit /b 1
|
||||
|
||||
### Windows Installer using WIX Toolset
|
||||
|
||||
Requirements:
|
||||
* Visual Studio 2017
|
||||
* Wix Toolset
|
||||
|
||||
In Visual Studio 2017 Installer select "Optional Features" -> "Wix Toolset"
|
||||
|
||||
Build the binaries like described above, but make sure you unselect "RUN_IN_PLACE".
|
||||
|
||||
Open the generated Project file with VS. Right click "PACKAGE" and choose "Generate".
|
||||
It may take some minutes to generate the installer.
|
||||
|
||||
|
||||
Docker
|
||||
------
|
||||
We provide Minetest server docker images using the Gitlab mirror registry.
|
||||
|
||||
Images are built on each commit and available using the following tag scheme:
|
||||
|
||||
* `registry.gitlab.com/minetest/minetest/server:latest` (latest build)
|
||||
* `registry.gitlab.com/minetest/minetest/server:<branch/tag>` (current branch or current tag)
|
||||
* `registry.gitlab.com/minetest/minetest/server:<commit-id>` (current commit id)
|
||||
|
||||
If you want to test it on a docker server, you can easily run:
|
||||
|
||||
sudo docker run registry.gitlab.com/minetest/minetest/server:<docker tag>
|
||||
|
||||
If you want to use it in a production environment you should use volumes bound to the docker host
|
||||
to persist data and modify the configuration:
|
||||
|
||||
sudo docker create -v /home/minetest/data/:/var/lib/minetest/ -v /home/minetest/conf/:/etc/minetest/ registry.gitlab.com/minetest/minetest/server:master
|
||||
|
||||
Data will be written to `/home/minetest/data` on the host, and configuration will be read from `/home/minetest/conf/minetest.conf`.
|
||||
|
||||
Note: If you don't understand the previous commands, please read the official Docker documentation before use.
|
||||
|
||||
You can also host your minetest server inside a Kubernetes cluster. See our example implementation in `misc/kubernetes.yml`.
|
||||
|
||||
|
||||
Version scheme
|
||||
--------------
|
||||
We use `major.minor.patch` since 5.0.0-dev. Prior to that we used `0.major.minor`.
|
||||
|
||||
- Major is incremented when the release contains breaking changes, all other
|
||||
numbers are set to 0.
|
||||
- Minor is incremented when the release contains new non-breaking features,
|
||||
patch is set to 0.
|
||||
- Patch is incremented when the release only contains bugfixes and very
|
||||
minor/trivial features considered necessary.
|
||||
|
||||
Since 5.0.0-dev and 0.4.17-dev, the dev notation refers to the next release,
|
||||
i.e.: 5.0.0-dev is the development version leading to 5.0.0.
|
||||
Prior to that we used `previous_version-dev`.
|
||||
If I forgot you, thank you to contact me via the forum of minetest, I could add you to the list of names.
|
||||
|
|
7045
doc/lua_api.txt
|
@ -1,5 +1,5 @@
|
|||
Minetest Lua Mainmenu API Reference 5.0.1
|
||||
=========================================
|
||||
Minetest Lua Mainmenu API Reference 0.4.17
|
||||
========================================
|
||||
|
||||
Introduction
|
||||
-------------
|
||||
|
@ -33,6 +33,32 @@ core.close()
|
|||
Filesystem:
|
||||
core.get_builtin_path()
|
||||
^ returns path to builtin root
|
||||
core.get_modpath() (possible in async calls)
|
||||
^ returns path to global modpath
|
||||
core.get_modstore_details(modid) (possible in async calls)
|
||||
^ modid numeric id of mod in modstore
|
||||
^ returns {
|
||||
id = <numeric id of mod in modstore>,
|
||||
title = <human readable title>,
|
||||
basename = <basename for mod>,
|
||||
description = <description of mod>,
|
||||
author = <author of mod>,
|
||||
download_url= <best match download url>,
|
||||
license = <short description of license>,
|
||||
rating = <float value of current rating>
|
||||
}
|
||||
core.get_modstore_list() (possible in async calls)
|
||||
^ returns {
|
||||
[1] = {
|
||||
id = <numeric id of mod in modstore>,
|
||||
title = <human readable title>,
|
||||
basename = <basename for mod>
|
||||
}
|
||||
}
|
||||
core.get_gamepath() (possible in async calls)
|
||||
^ returns path to global gamepath
|
||||
core.get_texturepath() (possible in async calls)
|
||||
^ returns path to default textures
|
||||
core.create_dir(absolute_path) (possible in async calls)
|
||||
^ absolute_path to directory to create (needs to be absolute)
|
||||
^ returns true/false
|
||||
|
@ -63,9 +89,6 @@ core.get_video_drivers()
|
|||
^ returns list of available video drivers' settings name and 'friendly' display name
|
||||
^ e.g. { {name="opengl", friendly_name="OpenGL"}, {name="software", friendly_name="Software Renderer"} }
|
||||
^ first element of returned list is guaranteed to be the NULL driver
|
||||
core.get_mapgen_names([include_hidden=false]) -> table of map generator algorithms
|
||||
registered in the core (possible in async calls)
|
||||
core.get_cache_path() -> path of cache
|
||||
|
||||
Formspec:
|
||||
core.update_formspec(formspec)
|
||||
|
@ -106,47 +129,20 @@ core.get_screen_info()
|
|||
window_height = <current window height>
|
||||
}
|
||||
|
||||
### Content and Packages
|
||||
|
||||
Content - an installed mod, modpack, game, or texture pack (txt)
|
||||
Package - content which is downloadable from the content db, may or may not be installed.
|
||||
|
||||
* core.get_modpath() (possible in async calls)
|
||||
* returns path to global modpath
|
||||
* core.get_clientmodpath() (possible in async calls)
|
||||
* returns path to global client-side modpath
|
||||
* core.get_gamepath() (possible in async calls)
|
||||
* returns path to global gamepath
|
||||
* core.get_texturepath() (possible in async calls)
|
||||
* returns path to default textures
|
||||
* core.get_game(index)
|
||||
* returns:
|
||||
|
||||
{
|
||||
id = <id>,
|
||||
path = <full path to game>,
|
||||
gamemods_path = <path>,
|
||||
name = <name of game>,
|
||||
menuicon_path = <full path to menuicon>,
|
||||
author = "author",
|
||||
DEPRECATED:
|
||||
addon_mods_paths = {[1] = <path>,},
|
||||
}
|
||||
|
||||
* core.get_games() -> table of all games in upper format (possible in async calls)
|
||||
* core.get_content_info(path)
|
||||
* returns
|
||||
|
||||
{
|
||||
name = "name of content",
|
||||
type = "mod" or "modpack" or "game" or "txp",
|
||||
description = "description",
|
||||
author = "author",
|
||||
path = "path/to/content",
|
||||
depends = {"mod", "names"}, -- mods only
|
||||
optional_depends = {"mod", "names"}, -- mods only
|
||||
}
|
||||
|
||||
Games:
|
||||
core.get_game(index)
|
||||
^ returns {
|
||||
id = <id>,
|
||||
path = <full path to game>,
|
||||
gamemods_path = <path>,
|
||||
name = <name of game>,
|
||||
menuicon_path = <full path to menuicon>,
|
||||
DEPRECATED:
|
||||
addon_mods_paths = {[1] = <path>,},
|
||||
}
|
||||
core.get_games() -> table of all games in upper format (possible in async calls)
|
||||
core.get_mapgen_names([include_hidden=false]) -> table of map generator algorithms
|
||||
registered in the core (possible in async calls)
|
||||
|
||||
Favorites:
|
||||
core.get_favorites(location) -> list of favorites (possible in async calls)
|
||||
|
@ -176,14 +172,11 @@ core.log(loglevel, line) (possible in async calls)
|
|||
^ loglevel one of "error", "action", "info", "verbose"
|
||||
|
||||
Settings:
|
||||
core.settings:set(name, value)
|
||||
core.settings:get(name) -> string or nil (possible in async calls)
|
||||
core.settings:set_bool(name, value)
|
||||
core.settings:get_bool(name) -> bool or nil (possible in async calls)
|
||||
core.settings:save() -> nil, save all settings to config file
|
||||
|
||||
For a complete list of methods of the Settings object see
|
||||
[lua_api.txt](https://github.com/minetest/minetest/blob/master/doc/lua_api.txt)
|
||||
core.setting_set(name, value)
|
||||
core.setting_get(name) -> string or nil (possible in async calls)
|
||||
core.setting_setbool(name, value)
|
||||
core.setting_getbool(name) -> bool or nil (possible in async calls)
|
||||
core.setting_save() -> nil, save all settings to config file
|
||||
|
||||
Worlds:
|
||||
core.get_worlds() -> list of worlds (possible in async calls)
|
||||
|
@ -241,3 +234,8 @@ Limitations of Async operations
|
|||
-Limited set of available functions
|
||||
e.g. No access to functions modifying menu like core.start,core.close,
|
||||
core.file_open_dialog
|
||||
|
||||
|
||||
Class reference
|
||||
----------------
|
||||
Settings: see lua_api.txt
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Minetest Texture Pack Reference
|
||||
BlockColor Texture Pack Reference
|
||||
===============================
|
||||
|
||||
Texture packs allow you to replace textures provided by a mod with your own
|
||||
|
@ -9,7 +9,6 @@ Texture pack directory structure
|
|||
|
||||
textures
|
||||
|-- Texture Pack
|
||||
| |-- texture_pack.conf
|
||||
| |-- screenshot.png
|
||||
| |-- description.txt
|
||||
| |-- override.txt
|
||||
|
@ -22,17 +21,9 @@ This is a directory containing the entire contents of a single texture pack.
|
|||
It can be chosen more or less freely and will also become the name of the
|
||||
texture pack. The name must not be “base”.
|
||||
|
||||
### `texture_pack.conf`
|
||||
A key-value config file with the following keys:
|
||||
|
||||
* `title` - human readable title
|
||||
* `description` - short description, shown in the content tab
|
||||
|
||||
### `description.txt`
|
||||
**Deprecated**, you should use texture_pack.conf instead.
|
||||
|
||||
A file containing a short description of the texture pack to be shown in the
|
||||
content tab.
|
||||
texture packs tab.
|
||||
|
||||
### `screenshot.png`
|
||||
A preview image showing an in-game screenshot of this texture pack; it will be
|
||||
|
@ -42,7 +33,7 @@ minimum size of 300×200 pixels.
|
|||
### `your_texture_1.png`, `your_texture_2.png`, etc.
|
||||
Any other PNG files will be interpreted as textures. They must have the same
|
||||
names as the textures they are supposed to override. For example, to override
|
||||
the apple texture of Minetest Game, add a PNG file named `default_apple.png`.
|
||||
the apple texture of MutliCraft Game, add a PNG file named `default_apple.png`.
|
||||
|
||||
The custom textures do not necceessarily require the same size as their
|
||||
originals, but this might be required for a few particular textures. When
|
||||
|
@ -88,9 +79,9 @@ by texture packs. All existing fallback textures can be found in the directory
|
|||
* `progress_bar.png`: foreground texture of the loading screen's progress bar
|
||||
* `progress_bar_bg.png`: background texture of the loading screen's progress bar
|
||||
|
||||
* `moon.png`: texture of the moon. Default texture is generated by Minetest
|
||||
* `moon.png`: texture of the moon. Default texture is generated by engine
|
||||
* `moon_tonemap.png`: tonemap to be used when `moon.png` was found
|
||||
* `sun.png`: texture of the sun. Default texture is generated by Minetest
|
||||
* `sun.png`: texture of the sun. Default texture is generated by engine
|
||||
* `sun_tonemap.png`: tonemap to be used when `sun.png` was found
|
||||
* `sunrisebg.png`: shown sky texture when the sun rises
|
||||
|
||||
|
@ -168,44 +159,3 @@ Here are face selectors you can choose from:
|
|||
| bottom | y- |
|
||||
| sides | x-, x+, z-, z+ |
|
||||
| all | All faces. You can also use '*' instead of 'all'. |
|
||||
|
||||
Designing leaves textures for the leaves rendering options
|
||||
----------------------------------------------------------
|
||||
|
||||
Minetest has three modes for rendering leaves nodes if the node has the
|
||||
`allfaces_optional` drawtype.
|
||||
|
||||
### Fancy
|
||||
|
||||
Uses the texture specified in the `tiles` nodedef field.
|
||||
The texture should have some transparent pixels and be in the RGBA format so
|
||||
that the transparent pixels can have color information.
|
||||
Faces of every leaves node are rendered even if they are inside a solid volume
|
||||
of leaves; this gives a dense appearance.
|
||||
|
||||
### Opaque
|
||||
|
||||
Uses the texture specified in `tiles` but makes it opaque by converting each
|
||||
transparent pixel into an opaque pixel that uses the color information of that
|
||||
transparent pixel.
|
||||
Due to this the `tiles` texture format must be RGBA not 'indexed alpha' to allow
|
||||
each transparent pixel to have color information.
|
||||
|
||||
The colors of the transparent pixels should be set for a good appearance in
|
||||
`opaque` mode. This can be done by painting the pixels the desired colors then
|
||||
erasing them. Then when saving the texture, use the 'save color information from
|
||||
transparent pixels' option (or equivalent).
|
||||
|
||||
### Simple
|
||||
|
||||
Uses the texture specified in the `special_tiles` nodedef field if it exists, if
|
||||
not, the `tiles` texture.
|
||||
The `special_tiles` texture should have fewer transparent pixels than the
|
||||
`tiles` texture and be in the 'indexed alpha' format.
|
||||
|
||||
This mode is between the other two in terms of appearance and rendering load.
|
||||
The nodes are rendered using the `glasslike` drawtype, only showing the surface
|
||||
faces for any solid volume of leaves, not the internal faces.
|
||||
Due to this the `tiles` texture might appear lacking in density, so optionally a
|
||||
`special_tiles` texture can be used to provide a texture with fewer transparent
|
||||
pixels for a denser appearance.
|
||||
|
|
|
@ -29,7 +29,6 @@ It can be copied over from an old world to a newly created world.
|
|||
|
||||
World
|
||||
|-- auth.txt ----- Authentication data
|
||||
|-- auth.sqlite -- Authentication data (SQLite alternative)
|
||||
|-- env_meta.txt - Environment metadata
|
||||
|-- ipban.txt ---- Banned ips/users
|
||||
|-- map_meta.txt - Map metadata
|
||||
|
@ -63,34 +62,6 @@ Example lines:
|
|||
- Player "bar", no password, no privileges:
|
||||
bar::
|
||||
|
||||
auth.sqlite
|
||||
------------
|
||||
Contains authentification data as an SQLite database. This replaces auth.txt
|
||||
above when auth_backend is set to "sqlite3" in world.mt .
|
||||
|
||||
This database contains two tables "auth" and "user_privileges":
|
||||
|
||||
CREATE TABLE `auth` (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`name` VARCHAR(32) UNIQUE,
|
||||
`password` VARCHAR(512),
|
||||
`last_login` INTEGER
|
||||
);
|
||||
CREATE TABLE `user_privileges` (
|
||||
`id` INTEGER,
|
||||
`privilege` VARCHAR(32),
|
||||
PRIMARY KEY (id, privilege)
|
||||
CONSTRAINT fk_id FOREIGN KEY (id) REFERENCES auth (id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
The "name" and "password" fields of the auth table are the same as the auth.txt
|
||||
fields (with modern password hash). The "last_login" field is the last login
|
||||
time as a unix time stamp.
|
||||
|
||||
The "user_privileges" table contains one entry per privilege and player.
|
||||
A player with "interact" and "shout" privileges will have two entries, one
|
||||
with privilege="interact" and the second with privilege="shout".
|
||||
|
||||
env_meta.txt
|
||||
-------------
|
||||
Simple global environment variables.
|
||||
|
@ -127,16 +98,8 @@ See Player File Format below.
|
|||
world.mt
|
||||
---------
|
||||
World metadata.
|
||||
Example content (added indentation and - explanations):
|
||||
gameid = mesetint - name of the game
|
||||
enable_damage = true - whether damage is enabled or not
|
||||
creative_mode = false - whether creative mode is enabled or not
|
||||
backend = sqlite3 - which DB backend to use for blocks (sqlite3, dummy, leveldb, redis, postgresql)
|
||||
player_backend = sqlite3 - which DB backend to use for player data
|
||||
readonly_backend = sqlite3 - optionally readonly seed DB (DB file _must_ be located in "readonly" subfolder)
|
||||
server_announce = false - whether the server is publicly announced or not
|
||||
load_mod_<mod> = false - whether <mod> is to be loaded in this world
|
||||
auth_backend = files - which DB backend to use for authentication data
|
||||
Example content (added indentation):
|
||||
gameid = mesetint
|
||||
|
||||
Player File Format
|
||||
===================
|
||||
|
|
Before Width: | Height: | Size: 127 B After Width: | Height: | Size: 127 B |
Before Width: | Height: | Size: 114 B After Width: | Height: | Size: 114 B |
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 131 B |
Before Width: | Height: | Size: 127 B After Width: | Height: | Size: 127 B |
Before Width: | Height: | Size: 126 B After Width: | Height: | Size: 126 B |
Before Width: | Height: | Size: 100 B After Width: | Height: | Size: 100 B |
Before Width: | Height: | Size: 160 B After Width: | Height: | Size: 160 B |
Before Width: | Height: | Size: 209 B After Width: | Height: | Size: 209 B |
Before Width: | Height: | Size: 216 B After Width: | Height: | Size: 216 B |
Before Width: | Height: | Size: 244 B After Width: | Height: | Size: 244 B |
Before Width: | Height: | Size: 158 B After Width: | Height: | Size: 158 B |
Before Width: | Height: | Size: 208 B After Width: | Height: | Size: 208 B |
Before Width: | Height: | Size: 146 B After Width: | Height: | Size: 146 B |
Before Width: | Height: | Size: 204 B After Width: | Height: | Size: 204 B |
Before Width: | Height: | Size: 202 B After Width: | Height: | Size: 202 B |
Before Width: | Height: | Size: 96 B After Width: | Height: | Size: 96 B |
Before Width: | Height: | Size: 102 B After Width: | Height: | Size: 102 B |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |