Add "moremesecons" modpack.
@ -79,6 +79,7 @@ The following mods are also included:
|
||||
* animal_rat ([animals_modpack][]) ([CC-BY-SA / CC0](mods/mobs_passive/animal_rat/License.txt))
|
||||
* chicken ([Creatures MOB-Engine][cme])
|
||||
* sheep ([Creatures MOB-Engine][cme])
|
||||
* [moremesecons][] ([GPL](mods/moremesecons/LICENSE.txt))
|
||||
* [pipeworks][] ([WTFPL](mods/pipeworks/LICENSE))
|
||||
* plantlife/
|
||||
* player/
|
||||
@ -158,6 +159,7 @@ The following mods are also included:
|
||||
[mobf]: https://github.com/sapier/mobf_core
|
||||
[mobs_goblins]: https://forum.minetest.net/viewtopic.php?t=13004
|
||||
[moreblocks]: https://forum.minetest.net/viewtopic.php?t=509
|
||||
[moremesecons]: https://forum.minetest.net/viewtopic.php?t=13150
|
||||
[moreores]: https://forum.minetest.net/viewtopic.php?t=549
|
||||
[moretrees]: https://forum.minetest.net/viewtopic.php?t=4394
|
||||
[mydoors]: https://forum.minetest.net/viewtopic.php?t=10626
|
||||
|
674
mods/moremesecons/LICENSE.txt
Normal file
@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, 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
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If 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 convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU 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
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "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 PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state 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 program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
34
mods/moremesecons/README.md
Normal file
@ -0,0 +1,34 @@
|
||||
# MoreMesecons
|
||||
|
||||
Based on Mesecons by Jeija
|
||||
By @paly2 and @HybridDog
|
||||
With the participation of @LeMagnesium (bugfix), @Ataron (textures), @JAPP (texture).
|
||||
|
||||
Dependencies: [Mesecons](https://github.com/Jeija/minetest-mod-mesecons/), [vector_extras](https://github.com/HybridDog/vector_extras/), [digilines](https://github.com/minetest-mods/digilines) (optionnal).
|
||||
|
||||
This mod is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License v3.0 as published by the Free Software Foundation. You should have received a copy of the GNU General Public License along with this mod.
|
||||
|
||||
MoreMesecons is a mod for minetest wich adds some mesecons items.
|
||||
|
||||
[Here](http://github.com/minetest-mods/MoreMesecons/wiki)'s the wiki !
|
||||
|
||||
### New items
|
||||
|
||||
* `Adjustable Blinky plant` : Like a mesecons blinky plant, but... adjustable. Right-click to change the interval.
|
||||
* `Adjustable Player Detector` : Like a mesecons player detector, but you can change its detection radius by right-click.
|
||||
* `Craftable Command Block` : A command block with just some commands accepted. The admin can change the accepted command (first line of the init.lua), default "tell". Only "@nearest" can be used in the commands, and the admin can change the maximum distance of "@nearest" (default 8 blocks).
|
||||
* `Conductor Signal Changer` : Like a diode which can be activated by sending a signal on its pin "F", and deactivated by sending a signal on its pin "O".
|
||||
* `Dual Delayer` : If it receives a mesecons signal, port 1 turns on immediatly and port 2 turns on 0.4 seconds later. At the end of the signal, port 2 turns off immediatly and port 1 turns off 0.4 secondes later. For example, this is useful for double extenders.
|
||||
* `Entity Detector` : You can use it to detect an entity. You can choose the entity to detect by right-click (use itemstring, for example "mobs:rat". To detect a dropped item, write "__builtin:item". To detect a specific dropped item, write its itemstring (for example "default:cobble")).
|
||||
* `Igniter` : This node is a lighter that ignites ajacent flammable nodes (including TNT).
|
||||
* `Injector Controller` : This node is useful to activate/deactivate a pipeworks filter injector : it sends a blinky signal.
|
||||
* `Jammer` : If turned on, this node stops mesecons in a radius of 10 nodes.
|
||||
* `Luacontroller Template Tool` : This tool is very useful to manipulate templates with luacontrollers. Just click with it on a luacontroller, then you'll see a formspec.
|
||||
* `Player Killer` : This block kills the nearest player (with a maximal distance of 8 blocks by default) (if this player isn't its owner) when it receives a mesecons signal.
|
||||
* `Sayer` : This node sends a message to every players inside a radius of 8 nodes.
|
||||
* `Signal Changer` : If it receives a signal on its pin "F", it turns on. If it receives a signal on its pin "O", it turns off. Note : an inverted signal is sended at the other end of the arrow.
|
||||
* `Switch Torch` : It connects just like Mesecons Torch. If it receives a signal, it turns on, and if it receives a second signal, it turns off.
|
||||
* `Teleporter` : If you place one teleporter, if it receives a mesecons, it teleports the nearest player on itself. If you place two teleporters on the same axis, if one receives a mesecons signal, it teleports the nearest player on the second (with a maximal distance of 50 nodes by default). The player teleporter must be inside a radius of 25 nodes.
|
||||
* `Temporary Gate` : If it receives a mesecons signal, whatever its duration, a mesecons signal is send with a fixed duration. You can change it by right-click (in seconds) (you can write for example 0.2 to send a pulse, or 20 to send long signals).
|
||||
* `Wireless` : Place 2 (or more) wireless somewhere. Change their channel by right-click. If you send a signal to a wireless, every wireless wich have the same channel will send the signal. Compatible with digiline mod.
|
||||
* `Wireless Jammer` : If it receives a mesecons signal, it deactivates all wireless (receptors) in a radius of 15 nodes.
|
1
mods/moremesecons/modpack.txt
Normal file
@ -0,0 +1 @@
|
||||
The presence of this file indicates that the current folder is a modpack.
|
@ -0,0 +1 @@
|
||||
mesecons
|
@ -0,0 +1,60 @@
|
||||
local toggle_timer = function (pos, restart)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
if timer:is_started()
|
||||
and not restart then
|
||||
timer:stop()
|
||||
else
|
||||
timer:start(tonumber(minetest.get_meta(pos):get_string("interval")) or 0)
|
||||
end
|
||||
end
|
||||
|
||||
local on_timer = function(pos)
|
||||
if mesecon.flipstate(pos, minetest.get_node(pos)) == "on" then
|
||||
mesecon.receptor_on(pos)
|
||||
else
|
||||
mesecon.receptor_off(pos)
|
||||
end
|
||||
toggle_timer(pos, false)
|
||||
end
|
||||
|
||||
mesecon.register_node("moremesecons_adjustable_blinkyplant:adjustable_blinky_plant", {
|
||||
description="Adjustable Blinky Plant",
|
||||
drawtype = "plantlike",
|
||||
inventory_image = "moremesecons_blinky_plant_off.png",
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.3, -0.5, -0.3, 0.3, -0.5+0.7, 0.3},
|
||||
},
|
||||
on_timer = on_timer,
|
||||
on_construct = function(pos)
|
||||
minetest.get_meta(pos):set_string("formspec", "field[interval;interval;${interval}]")
|
||||
toggle_timer(pos, true)
|
||||
end,
|
||||
on_receive_fields = function(pos, _, fields, player)
|
||||
local interval = tonumber(fields.interval)
|
||||
if interval
|
||||
and not minetest.is_protected(pos, player:get_player_name()) then
|
||||
minetest.get_meta(pos):set_string("interval", interval)
|
||||
toggle_timer(pos, true)
|
||||
end
|
||||
end,
|
||||
},{
|
||||
tiles = {"moremesecons_blinky_plant_off.png"},
|
||||
groups = {dig_immediate=3},
|
||||
mesecons = {receptor = { state = mesecon.state.off }}
|
||||
},{
|
||||
tiles = {"moremesecons_blinky_plant_off.png^moremesecons_blinky_plant_on.png"},
|
||||
groups = {dig_immediate=3, not_in_creative_inventory=1},
|
||||
sunlight_propagates = true,
|
||||
mesecons = {receptor = { state = mesecon.state.on }},
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moremesecons_adjustable_blinkyplant:adjustable_blinky_plant_off 1",
|
||||
recipe = { {"mesecons_blinkyplant:blinky_plant_off"},
|
||||
{"default:mese_crystal_fragment"},}
|
||||
})
|
After Width: | Height: | Size: 361 B |
After Width: | Height: | Size: 237 B |
@ -0,0 +1 @@
|
||||
mesecons
|
@ -0,0 +1,131 @@
|
||||
-- Adjustable Player Detector
|
||||
-- Detects players in a certain radius
|
||||
-- The radius can be changes by right-click (by default 6)
|
||||
|
||||
local function make_formspec(meta)
|
||||
meta:set_string("formspec", "size[9,5]" ..
|
||||
"field[0.3, 0;9,2;scanname;Name of player to scan for (empty for any):;${scanname}]"..
|
||||
"field[0.3,1.5;4,2;digiline_channel;Digiline Channel (optional):;${digiline_channel}]"..
|
||||
"field[0.3,3;2,2;radius;Detection radius:;${radius}]"..
|
||||
"button_exit[3.5,3.5;2,3;;Save]")
|
||||
end
|
||||
|
||||
local function object_detector_make_formspec(pos)
|
||||
make_formspec(minetest.get_meta(pos))
|
||||
end
|
||||
|
||||
local function object_detector_on_receive_fields(pos, _, fields, player)
|
||||
if not fields.scanname
|
||||
or not fields.digiline_channel
|
||||
or minetest.is_protected(pos, player:get_player_name()) then
|
||||
return
|
||||
end
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("scanname", fields.scanname)
|
||||
meta:set_string("digiline_channel", fields.digiline_channel)
|
||||
local r = tonumber(fields.radius)
|
||||
if r then
|
||||
meta:set_int("radius", r)
|
||||
end
|
||||
end
|
||||
|
||||
-- returns true if player was found, false if not
|
||||
local object_detector_scan = function (pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local scanname = meta:get_string("scanname")
|
||||
local scan_all = scanname == ""
|
||||
local radius = meta:get_int("radius")
|
||||
if radius == 0 then
|
||||
radius = 6
|
||||
end
|
||||
for _,obj in pairs(minetest.get_objects_inside_radius(pos, radius)) do
|
||||
local isname = obj:get_player_name() -- "" is returned if it is not a player; "" ~= nil!
|
||||
if isname ~= ""
|
||||
and (scan_all or isname == scanname) then -- player with scanname found or not scanname specified
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- set player name when receiving a digiline signal on a specific channel
|
||||
local object_detector_digiline = {
|
||||
effector = {
|
||||
action = function (pos, node, channel, msg)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local active_channel = meta:get_string("digiline_channel")
|
||||
if channel ~= active_channel then
|
||||
return
|
||||
end
|
||||
meta:set_string("scanname", msg)
|
||||
if meta:get_string("formspec") ~= "" then
|
||||
make_formspec(meta)
|
||||
end
|
||||
end,
|
||||
}
|
||||
}
|
||||
|
||||
minetest.register_node("moremesecons_adjustable_player_detector:player_detector_off", {
|
||||
tiles = {"default_steel_block.png", "default_steel_block.png", "moremesecons_player_detector_off.png"},
|
||||
paramtype = "light",
|
||||
walkable = true,
|
||||
groups = {cracky=3},
|
||||
description="Adjustable Player Detector",
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.off,
|
||||
rules = mesecon.rules.pplate
|
||||
}},
|
||||
on_construct = object_detector_make_formspec,
|
||||
on_receive_fields = object_detector_on_receive_fields,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
digiline = object_detector_digiline
|
||||
})
|
||||
|
||||
minetest.register_node("moremesecons_adjustable_player_detector:player_detector_on", {
|
||||
tiles = {"default_steel_block.png", "default_steel_block.png", "moremesecons_player_detector_on.png"},
|
||||
paramtype = "light",
|
||||
walkable = true,
|
||||
groups = {cracky=3,not_in_creative_inventory=1},
|
||||
drop = 'moremesecons_adjustable_player_detector:player_detector_off',
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.on,
|
||||
rules = mesecon.rules.pplate
|
||||
}},
|
||||
on_construct = object_detector_make_formspec,
|
||||
on_receive_fields = object_detector_on_receive_fields,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
digiline = object_detector_digiline
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'moremesecons_adjustable_player_detector:player_detector_off',
|
||||
recipe = {
|
||||
{"mesecons_detector:object_detector_off"},
|
||||
{"default:mese_crystal_fragment"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"moremesecons_adjustable_player_detector:player_detector_off"},
|
||||
interval = 1.0,
|
||||
chance = 1,
|
||||
action = function(pos)
|
||||
if object_detector_scan(pos) then
|
||||
minetest.swap_node(pos, {name = "moremesecons_adjustable_player_detector:player_detector_on"})
|
||||
mesecon.receptor_on(pos, mesecon.rules.pplate)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"moremesecons_adjustable_player_detector:player_detector_on"},
|
||||
interval = 1.0,
|
||||
chance = 1,
|
||||
action = function(pos)
|
||||
if not object_detector_scan(pos) then
|
||||
minetest.swap_node(pos, {name = "moremesecons_adjustable_player_detector:player_detector_off"})
|
||||
mesecon.receptor_off(pos, mesecon.rules.pplate)
|
||||
end
|
||||
end,
|
||||
})
|
After Width: | Height: | Size: 624 B |
After Width: | Height: | Size: 709 B |
1
mods/moremesecons/moremesecons_commandblock/depends.txt
Normal file
@ -0,0 +1 @@
|
||||
mesecons
|
172
mods/moremesecons/moremesecons_commandblock/init.lua
Normal file
@ -0,0 +1,172 @@
|
||||
local accepted_commands = {"tell"} -- Authorized commands. Any to accept all.
|
||||
local NEAREST_MAX_DISTANCE = 8
|
||||
|
||||
local function initialize_data(meta)
|
||||
local commands = meta:get_string("commands")
|
||||
meta:set_string("formspec",
|
||||
"invsize[9,5;]" ..
|
||||
"textarea[0.5,0.5;8.5,4;commands;Commands;"..commands.."]" ..
|
||||
"label[1,3.8;@nearest is replaced by the nearest player name ("..tostring(NEAREST_MAX_DISTANCE).." nodes max for the nearest distance)".."]" ..
|
||||
"button_exit[3.3,4.5;2,1;submit;Submit]")
|
||||
local owner = meta:get_string("owner")
|
||||
if owner == "" then
|
||||
owner = "not owned"
|
||||
else
|
||||
owner = "owned by " .. owner
|
||||
end
|
||||
meta:set_string("infotext", "Command Block\n" ..
|
||||
"(" .. owner .. ")\n" ..
|
||||
"Commands: "..commands)
|
||||
end
|
||||
|
||||
local function construct(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
meta:set_string("commands", "tell @nearest Commandblock unconfigured")
|
||||
|
||||
meta:set_string("owner", "")
|
||||
|
||||
initialize_data(meta)
|
||||
end
|
||||
|
||||
local function after_place(pos, placer)
|
||||
if placer then
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("owner", placer:get_player_name())
|
||||
initialize_data(meta)
|
||||
end
|
||||
end
|
||||
|
||||
local function receive_fields(pos, _, fields, player)
|
||||
if not fields.submit then
|
||||
return
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
local owner = meta:get_string("owner")
|
||||
if owner ~= ""
|
||||
and player:get_player_name() ~= owner then
|
||||
return
|
||||
end
|
||||
meta:set_string("commands", fields.commands)
|
||||
|
||||
initialize_data(meta)
|
||||
end
|
||||
|
||||
local function resolve_commands(commands, pos)
|
||||
local nearest = nil
|
||||
local min_distance = math.huge
|
||||
local players = minetest.get_connected_players()
|
||||
for index, player in pairs(players) do
|
||||
local distance = vector.distance(pos, player:getpos())
|
||||
if distance < min_distance then
|
||||
min_distance = distance
|
||||
nearest = player:get_player_name()
|
||||
end
|
||||
end
|
||||
new_commands = commands:gsub("@nearest", nearest)
|
||||
return new_commands, min_distance, new_commands ~= commands
|
||||
end
|
||||
|
||||
local function commandblock_action_on(pos, node)
|
||||
if node.name ~= "moremesecons_commandblock:commandblock_off" then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.swap_node(pos, {name = "moremesecons_commandblock:commandblock_on"})
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local owner = meta:get_string("owner")
|
||||
if owner == "" then
|
||||
return
|
||||
end
|
||||
|
||||
local commands, distance, nearest_in_commands = resolve_commands(meta:get_string("commands"), pos)
|
||||
if distance > NEAREST_MAX_DISTANCE and nearest_in_commands then
|
||||
minetest.chat_send_player(owner, "The nearest player is too far to use his name in the commands of a craftable command block.")
|
||||
return
|
||||
end
|
||||
for _, command in pairs(commands:split("\n")) do
|
||||
local pos = command:find(" ")
|
||||
local cmd, param = command, ""
|
||||
if pos then
|
||||
cmd = command:sub(1, pos - 1)
|
||||
param = command:sub(pos + 1)
|
||||
end
|
||||
local cmddef = minetest.chatcommands[cmd]
|
||||
local is_an_authorized_command = false
|
||||
for i = 1, #accepted_commands do
|
||||
if cmd == accepted_commands[i] then
|
||||
is_an_authorized_command = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if not is_an_authorized_command and #accepted_commands ~= 0 then
|
||||
minetest.chat_send_player(owner, "You can not execute the command "..cmd.." with a craftable command block ! This event will be reported.")
|
||||
minetest.log("action", "Player "..owner.." tryed to execute an unauthorized command with a craftable command block.")
|
||||
return
|
||||
end
|
||||
if not cmddef then
|
||||
minetest.chat_send_player(owner, "The command "..cmd.." does not exist")
|
||||
return
|
||||
end
|
||||
local has_privs, missing_privs = minetest.check_player_privs(owner, cmddef.privs)
|
||||
if not has_privs then
|
||||
minetest.chat_send_player(owner, "You don't have permission "
|
||||
.."to run "..cmd
|
||||
.." (missing privileges: "
|
||||
..table.concat(missing_privs, ", ")..")")
|
||||
return
|
||||
end
|
||||
cmddef.func(owner, param)
|
||||
end
|
||||
end
|
||||
|
||||
local function commandblock_action_off(pos, node)
|
||||
if node.name == "moremesecons_commandblock:commandblock_on" then
|
||||
minetest.swap_node(pos, {name = "moremesecons_commandblock:commandblock_off"})
|
||||
end
|
||||
end
|
||||
|
||||
local function can_dig(pos, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local owner = meta:get_string("owner")
|
||||
return owner == "" or owner == player:get_player_name()
|
||||
end
|
||||
|
||||
minetest.register_node("moremesecons_commandblock:commandblock_off", {
|
||||
description = "Craftable Command Block",
|
||||
tiles = {"moremesecons_commandblock_off.png"},
|
||||
groups = {cracky=2, mesecon_effector_off=1},
|
||||
on_construct = construct,
|
||||
after_place_node = after_place,
|
||||
on_receive_fields = receive_fields,
|
||||
can_dig = can_dig,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = {effector = {
|
||||
action_on = commandblock_action_on
|
||||
}}
|
||||
})
|
||||
|
||||
minetest.register_node("moremesecons_commandblock:commandblock_on", {
|
||||
tiles = {"moremesecons_commandblock_on.png"},
|
||||
groups = {cracky=2, mesecon_effector_on=1, not_in_creative_inventory=1},
|
||||
light_source = 10,
|
||||
drop = "moremesecons_commandblock:commandblock_off",
|
||||
on_construct = construct,
|
||||
after_place_node = after_place,
|
||||
on_receive_fields = receive_fields,
|
||||
can_dig = can_dig,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = {effector = {
|
||||
action_off = commandblock_action_off
|
||||
}}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moremesecons_commandblock:commandblock_off",
|
||||
recipe = {
|
||||
{"group:mesecon_conductor_craftable","default:mese_crystal","group:mesecon_conductor_craftable"},
|
||||
{"default:mese_crystal","group:mesecon_conductor_craftable","default:mese_crystal"},
|
||||
{"group:mesecon_conductor_craftable","default:mese_crystal","group:mesecon_conductor_craftable"}
|
||||
}
|
||||
})
|
After Width: | Height: | Size: 150 B |
After Width: | Height: | Size: 150 B |
@ -0,0 +1 @@
|
||||
mesecons
|
@ -0,0 +1,81 @@
|
||||
local nodebox = {
|
||||
type = "fixed",
|
||||
fixed = {{-8/16, -8/16, -8/16, 8/16, -7/16, 8/16 }},
|
||||
}
|
||||
|
||||
local function signalchanger_get_output_rules(node)
|
||||
local rules = {{x=1, y=0, z=0}}
|
||||
for i = 0, node.param2 do
|
||||
rules = mesecon.rotate_rules_left(rules)
|
||||
end
|
||||
return rules
|
||||
end
|
||||
|
||||
local function signalchanger_get_input_rules(node)
|
||||
local rules = {{x=0, y=0, z=1, name="input_on"}, {x=0, y=0, z=-1, name="input_off"}, {x=-1, y=0, z=0, name="input_signal"}}
|
||||
for i = 0, node.param2 do
|
||||
rules = mesecon.rotate_rules_left(rules)
|
||||
end
|
||||
return rules
|
||||
end
|
||||
|
||||
local update = function(pos, node, link, newstate)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int(link.name, newstate == "on" and 1 or 0)
|
||||
local input_on = meta:get_int("input_on") == 1
|
||||
local input_off = meta:get_int("input_off") == 1
|
||||
local input_signal = meta:get_int("input_signal") == 1
|
||||
|
||||
if input_on then
|
||||
minetest.swap_node(pos, {name = "moremesecons_conductor_signalchanger:conductor_signalchanger_on", param2 = node.param2})
|
||||
elseif input_off then
|
||||
mesecon.receptor_off(pos, signalchanger_get_output_rules(node))
|
||||
minetest.swap_node(pos, {name = "moremesecons_conductor_signalchanger:conductor_signalchanger_off", param2 = node.param2})
|
||||
end
|
||||
|
||||
if input_signal and minetest.get_node(pos).name == "moremesecons_conductor_signalchanger:conductor_signalchanger_on" then -- Note : we must use "minetest.get_node(pos)" and not "node" because the node may have been changed
|
||||
mesecon.receptor_on(pos, signalchanger_get_output_rules(node))
|
||||
else
|
||||
mesecon.receptor_off(pos, signalchanger_get_output_rules(node))
|
||||
end
|
||||
end
|
||||
|
||||
mesecon.register_node("moremesecons_conductor_signalchanger:conductor_signalchanger", {
|
||||
description = "Conductor Signal Changer",
|
||||
inventory_image = "moremesecons_conductor_signalchanger_off.png",
|
||||
groups = {dig_immediate = 2},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
drawtype = "nodebox",
|
||||
selection_box = nodebox,
|
||||
node_box = nodebox,
|
||||
},{
|
||||
groups = {dig_immediate = 2},
|
||||
mesecons = {
|
||||
receptor = {
|
||||
rules = signalchanger_get_output_rules
|
||||
},
|
||||
effector = {
|
||||
rules = signalchanger_get_input_rules,
|
||||
action_change = update
|
||||
},
|
||||
},
|
||||
tiles = {"moremesecons_conductor_signalchanger_off.png"},
|
||||
},{
|
||||
groups = {dig_immediate = 2, not_in_creative_inventory = 1},
|
||||
mesecons = {
|
||||
receptor = {
|
||||
rules = signalchanger_get_output_rules,
|
||||
},
|
||||
effector = {
|
||||
rules = signalchanger_get_input_rules,
|
||||
action_change = update,
|
||||
},
|
||||
},
|
||||
tiles = {"moremesecons_conductor_signalchanger_on.png"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moremesecons_conductor_signalchanger:conductor_signalchanger_off",
|
||||
recipe = {{"group:mesecon_conductor_craftable","moremesecons_signalchanger:signalchanger_off"}}
|
||||
})
|
After Width: | Height: | Size: 109 B |
After Width: | Height: | Size: 109 B |
1
mods/moremesecons/moremesecons_dual_delayer/depends.txt
Normal file
@ -0,0 +1 @@
|
||||
mesecons
|
95
mods/moremesecons/moremesecons_dual_delayer/init.lua
Normal file
@ -0,0 +1,95 @@
|
||||
local function dual_delayer_get_input_rules(node)
|
||||
local rules = {{x=-1, y=0, z=0}}
|
||||
for i = 0, node.param2 do
|
||||
rules = mesecon.rotate_rules_left(rules)
|
||||
end
|
||||
return rules
|
||||
end
|
||||
|
||||
local function dual_delayer_get_output_rules(node)
|
||||
local rules = {{x=0, y=0, z=-1}, {x=0, y=0, z=1}}
|
||||
for i = 0, node.param2 do
|
||||
rules = mesecon.rotate_rules_left(rules)
|
||||
end
|
||||
return rules
|
||||
end
|
||||
|
||||
local dual_delayer_activate = function(pos, node)
|
||||
mesecon.receptor_on(pos, {dual_delayer_get_output_rules(node)[1]}) -- Turn on the port 1
|
||||
minetest.swap_node(pos, {name = "moremesecons_dual_delayer:dual_delayer_10", param2 = node.param2})
|
||||
minetest.after(0.4, function(pos, node)
|
||||
mesecon.receptor_on(pos, {dual_delayer_get_output_rules(node)[2]}) -- Turn on the port 2
|
||||
minetest.swap_node(pos, {name = "moremesecons_dual_delayer:dual_delayer_11", param2 = node.param2})
|
||||
end, pos, node)
|
||||
end
|
||||
|
||||
local dual_delayer_deactivate = function(pos, node, link)
|
||||
mesecon.receptor_off(pos, {dual_delayer_get_output_rules(node)[2]}) -- Turn off the port 2
|
||||
minetest.swap_node(pos, {name = "moremesecons_dual_delayer:dual_delayer_10", param2 = node.param2})
|
||||
minetest.after(0.4, function(pos, node)
|
||||
mesecon.receptor_off(pos, {dual_delayer_get_output_rules(node)[1]}) -- Turn off the port 1
|
||||
minetest.swap_node(pos, {name = "moremesecons_dual_delayer:dual_delayer_00", param2 = node.param2})
|
||||
end, pos, node)
|
||||
end
|
||||
|
||||
|
||||
for n,i in pairs({{0,0},{1,0},{1,1}}) do
|
||||
local i1,i2 = unpack(i)
|
||||
|
||||
local groups = {dig_immediate = 2}
|
||||
if n ~= 1 then
|
||||
groups.not_in_creative_inventory = 1
|
||||
end
|
||||
|
||||
local top_texture = "^moremesecons_dual_delayer_overlay.png^[makealpha:255,126,126"
|
||||
if i1 == i2 then
|
||||
if i1 == 0 then
|
||||
top_texture = "mesecons_wire_off.png"..top_texture
|
||||
else
|
||||
top_texture = "mesecons_wire_on.png"..top_texture
|
||||
end
|
||||
else
|
||||
local pre = "mesecons_wire_off.png^[lowpart:50:mesecons_wire_on.png^[transformR"
|
||||
if i1 == 0 then
|
||||
pre = pre.. 90
|
||||
else
|
||||
pre = pre.. 270
|
||||
end
|
||||
top_texture = pre..top_texture
|
||||
end
|
||||
|
||||
minetest.register_node("moremesecons_dual_delayer:dual_delayer_"..i1 ..i2, {
|
||||
description = "Dual Delayer",
|
||||
drop = "moremesecons_dual_delayer:dual_delayer_00",
|
||||
inventory_image = top_texture,
|
||||
wield_image = top_texture,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {{-6/16, -8/16, -1/16, 6/16, -7/16, 8/16 },
|
||||
{-8/16, -8/16, 1/16, -6/16, -7/16, -1/16},
|
||||
{8/16, -8/16, -1/16, 6/16, -7/16, 1/16}}
|
||||
},
|
||||
groups = groups,
|
||||
tiles = {top_texture, "moremesecons_dual_delayer_bottom.png", "moremesecons_dual_delayer_side_left.png", "moremesecons_dual_delayer_side_right.png", "moremesecons_dual_delayer_ends.png", "moremesecons_dual_delayer_ends.png"},
|
||||
mesecons = {
|
||||
receptor = {
|
||||
state = mesecon.state.off,
|
||||
rules = dual_delayer_get_output_rules
|
||||
},
|
||||
effector = {
|
||||
rules = dual_delayer_get_input_rules,
|
||||
action_on = dual_delayer_activate,
|
||||
action_off = dual_delayer_deactivate
|
||||
}
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "moremesecons_dual_delayer:dual_delayer_00 2",
|
||||
recipe = {"mesecons_delayer:delayer_off_1", "mesecons_delayer:delayer_off_1"}
|
||||
})
|
After Width: | Height: | Size: 99 B |
After Width: | Height: | Size: 91 B |
After Width: | Height: | Size: 154 B |
After Width: | Height: | Size: 78 B |
After Width: | Height: | Size: 77 B |
@ -0,0 +1 @@
|
||||
mesecons
|
134
mods/moremesecons/moremesecons_entity_detector/init.lua
Normal file
@ -0,0 +1,134 @@
|
||||
-- Entity detector
|
||||
-- Detects entitys in a certain radius
|
||||
-- The radius can be changes by right-click (by default 6)
|
||||
|
||||
local function make_formspec(meta)
|
||||
meta:set_string("formspec", "size[9,5]" ..
|
||||
"field[0.3, 0;9,2;scanname;Name (itemstring) of entity to scan for (empty for any):;${scanname}]"..
|
||||
"field[0.3,1.5;4,2;digiline_channel;Digiline Channel (optional):;${digiline_channel}]"..
|
||||
"field[0.3,3;2,2;radius;Detection radius:;${radius}]"..
|
||||
"button_exit[3.5,3.5;2,3;;Save]")
|
||||
end
|
||||
|
||||
local function object_detector_make_formspec(pos)
|
||||
make_formspec(minetest.get_meta(pos))
|
||||
end
|
||||
|
||||
local function object_detector_on_receive_fields(pos, _, fields, player)
|
||||
if not fields.scanname
|
||||
or not fields.digiline_channel
|
||||
or minetest.is_protected(pos, player:get_player_name()) then
|
||||
return
|
||||
end
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("scanname", fields.scanname)
|
||||
meta:set_string("digiline_channel", fields.digiline_channel)
|
||||
local r = tonumber(fields.radius)
|
||||
if r then
|
||||
meta:set_int("radius", r)
|
||||
end
|
||||
end
|
||||
|
||||
-- returns true if entity was found, false if not
|
||||
local object_detector_scan = function (pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local scanname = meta:get_string("scanname")
|
||||
local scan_all = scanname == ""
|
||||
local radius = meta:get_int("radius")
|
||||
if radius == 0 then
|
||||
radius = 6
|
||||
end
|
||||
for _,obj in pairs(minetest.get_objects_inside_radius(pos, radius)) do
|
||||
if not obj:is_player() then
|
||||
local luaentity = obj:get_luaentity()
|
||||
local isname = luaentity.name
|
||||
if isname
|
||||
and (scan_all or isname == scanname or (isname == "__builtin:item" and luaentity.itemstring == scanname)) then -- entity with scanname found or not scanname specified
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- set entity name when receiving a digiline signal on a specific channel
|
||||
local object_detector_digiline = {
|
||||
effector = {
|
||||
action = function (pos, node, channel, msg)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local active_channel = meta:get_string("digiline_channel")
|
||||
if channel ~= active_channel then
|
||||
return
|
||||
end
|
||||
meta:set_string("scanname", msg)
|
||||
if meta:get_string("formspec") ~= "" then
|
||||
make_formspec(meta)
|
||||
end
|
||||
end,
|
||||
}
|
||||
}
|
||||
|
||||
minetest.register_node("moremesecons_entity_detector:entity_detector_off", {
|
||||
tiles = {"default_steel_block.png", "default_steel_block.png", "moremesecons_entity_detector_off.png"},
|
||||
paramtype = "light",
|
||||
walkable = true,
|
||||
groups = {cracky=3},
|
||||
description="Entity Detector",
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.off,
|
||||
rules = mesecon.rules.pplate
|
||||
}},
|
||||
on_construct = object_detector_make_formspec,
|
||||
on_receive_fields = object_detector_on_receive_fields,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
digiline = object_detector_digiline
|
||||
})
|
||||
|
||||
minetest.register_node("moremesecons_entity_detector:entity_detector_on", {
|
||||
tiles = {"default_steel_block.png", "default_steel_block.png", "moremesecons_entity_detector_on.png"},
|
||||
paramtype = "light",
|
||||
walkable = true,
|
||||
groups = {cracky=3,not_in_creative_inventory=1},
|
||||
drop = 'moremesecons_entity_detector:entity_detector_off',
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.on,
|
||||
rules = mesecon.rules.pplate
|
||||
}},
|
||||
on_construct = object_detector_make_formspec,
|
||||
on_receive_fields = object_detector_on_receive_fields,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
digiline = object_detector_digiline
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'moremesecons_entity_detector:entity_detector_off',
|
||||
recipe = {
|
||||
{"default:mese_crystal_fragment"},
|
||||
{"mesecons_detector:object_detector_off"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"moremesecons_entity_detector:entity_detector_off"},
|
||||
interval = 1.0,
|
||||
chance = 1,
|
||||
action = function(pos)
|
||||
if object_detector_scan(pos) then
|
||||
minetest.swap_node(pos, {name = "moremesecons_entity_detector:entity_detector_on"})
|
||||
mesecon.receptor_on(pos, mesecon.rules.pplate)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"moremesecons_entity_detector:entity_detector_on"},
|
||||
interval = 1.0,
|
||||
chance = 1,
|
||||
action = function(pos)
|
||||
if not object_detector_scan(pos) then
|
||||
minetest.swap_node(pos, {name = "moremesecons_entity_detector:entity_detector_off"})
|
||||
mesecon.receptor_off(pos, mesecon.rules.pplate)
|
||||
end
|
||||
end,
|
||||
})
|
After Width: | Height: | Size: 554 B |
After Width: | Height: | Size: 549 B |
2
mods/moremesecons/moremesecons_igniter/depends.txt
Normal file
@ -0,0 +1,2 @@
|
||||
mesecons
|
||||
fire
|
48
mods/moremesecons/moremesecons_igniter/init.lua
Normal file
@ -0,0 +1,48 @@
|
||||
local function add_back_igniter(pos)
|
||||
local name = minetest.get_node(pos).name
|
||||
|
||||
if name == "moremesecons_igniter:igniter" then
|
||||
-- this should not happen
|
||||
minetest.log("error", "[moremesecons_igniter] igniter is already back")
|
||||
return
|
||||
end
|
||||
|
||||
if name == "ignore" then
|
||||
-- in case of unloaded chunk
|
||||
minetest.get_voxel_manip():read_from_map(pos, pos)
|
||||
name = minetest.get_node(pos).name
|
||||
end
|
||||
|
||||
if name == "air"
|
||||
or name == "fire:basic_flame" then
|
||||
minetest.set_node(pos, {name="moremesecons_igniter:igniter"})
|
||||
else
|
||||
-- drop it as item if something took place there in the 0.8 seconds
|
||||
pos.y = pos.y+1
|
||||
minetest.add_item(pos, "moremesecons_igniter:igniter")
|
||||
pos.y = pos.y-1
|
||||
end
|
||||
end
|
||||
|
||||
local function igniter_on(pos)
|
||||
minetest.set_node(pos, {name="fire:basic_flame"})
|
||||
minetest.after(0.8, add_back_igniter, pos)
|
||||
end
|
||||
|
||||
minetest.register_node("moremesecons_igniter:igniter", {
|
||||
description = "Igniter",
|
||||
paramtype = "light",
|
||||
tiles = {"moremesecons_igniter.png"},
|
||||
groups = {cracky=3},
|
||||
mesecons = {
|
||||
effector = {
|
||||
action_on = igniter_on
|
||||
}}
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moremesecons_igniter:igniter",
|
||||
recipe = { {"default:torch"},
|
||||
{"default:mese_crystal_fragment"},}
|
||||
})
|
After Width: | Height: | Size: 696 B |
@ -0,0 +1 @@
|
||||
mesecons
|
84
mods/moremesecons/moremesecons_injector_controller/init.lua
Normal file
@ -0,0 +1,84 @@
|
||||
local injector_controller_get_output_rules = function(node)
|
||||
local rules = {{x = 0, y = 0, z = 1}}
|
||||
for i = 0, node.param2 do
|
||||
rules = mesecon.rotate_rules_left(rules)
|
||||
end
|
||||
return rules
|
||||
end
|
||||
|
||||
local injector_controller_get_input_rules = function(node)
|
||||
local rules = {{x = 0, y = 0, z = -1},
|
||||
{x = 1, y = 0, z = 0},
|
||||
{x = -1, y = 0, z = 0}}
|
||||
for i = 0, node.param2 do
|
||||
rules = mesecon.rotate_rules_left(rules)
|
||||
end
|
||||
return rules
|
||||
end
|
||||
|
||||
local start_timer = function(pos)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
timer:start(1)
|
||||
end
|
||||
local stop_timer = function(pos, node)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
timer:stop()
|
||||
mesecon.receptor_off(pos, injector_controller_get_output_rules(node))
|
||||
minetest.swap_node(pos, {name="moremesecons_injector_controller:injector_controller_off", param2=node.param2})
|
||||
end
|
||||
|
||||
local on_timer = function(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
if(mesecon.flipstate(pos, node) == "on") then
|
||||
mesecon.receptor_on(pos, injector_controller_get_output_rules(node))
|
||||
else
|
||||
mesecon.receptor_off(pos, injector_controller_get_output_rules(node))
|
||||
end
|
||||
start_timer(pos)
|
||||
end
|
||||
|
||||
mesecon.register_node("moremesecons_injector_controller:injector_controller", {
|
||||
description="Injector Controller",
|
||||
drawtype = "nodebox",
|
||||
inventory_image = "moremesecons_injector_controller_off.png",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {{-8/16, -8/16, -8/16, 8/16, -7/16, 8/16 }},
|
||||
},
|
||||
on_timer = on_timer,
|
||||
},{
|
||||
tiles = {"moremesecons_injector_controller_off.png", "moremesecons_injector_controller_side.png", "moremesecons_injector_controller_side.png"},
|
||||
groups = {dig_immediate=2},
|
||||
mesecons = {
|
||||
receptor = {
|
||||
state = mesecon.state.off,
|
||||
rules = injector_controller_get_output_rules
|
||||
},
|
||||
effector = {
|
||||
rules = injector_controller_get_input_rules,
|
||||
action_on = start_timer,
|
||||
action_off = stop_timer,
|
||||
}
|
||||
}
|
||||
},{
|
||||
tiles = {"moremesecons_injector_controller_on.png", "moremesecons_injector_controller_side.png", "moremesecons_injector_controller_side.png"},
|
||||
groups = {dig_immediate=2, not_in_creative_inventory=1},
|
||||
mesecons = {
|
||||
receptor = {
|
||||
state = mesecon.state.on,
|
||||
rules = injector_controller_get_output_rules
|
||||
},
|
||||
effector = {
|
||||
rules = injector_controller_get_input_rules,
|
||||
action_off = stop_timer,
|
||||
action_on = start_timer,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moremesecons_injector_controller:injector_controller_off",
|
||||
recipe = {{"mesecons_blinkyplant:blinky_plant_off","mesecons_gates:and_off"}}
|
||||
})
|
After Width: | Height: | Size: 127 B |
After Width: | Height: | Size: 127 B |
After Width: | Height: | Size: 114 B |
2
mods/moremesecons/moremesecons_jammer/depends.txt
Normal file
@ -0,0 +1,2 @@
|
||||
mesecons
|
||||
vector_extras
|
131
mods/moremesecons/moremesecons_jammer/init.lua
Normal file
@ -0,0 +1,131 @@
|
||||
local JAMMER_MAX_DISTANCE = 10
|
||||
|
||||
-- see wireless jammer
|
||||
local get = vector.get_data_from_pos
|
||||
local set = vector.set_data_to_pos
|
||||
local remove = vector.remove_data_from_pos
|
||||
|
||||
local jammers = {}
|
||||
local function add_jammer(pos)
|
||||
if get(jammers, pos.z,pos.y,pos.x) then
|
||||
return
|
||||
end
|
||||
set(jammers, pos.z,pos.y,pos.x, true)
|
||||
end
|
||||
|
||||
local function remove_jammer(pos)
|
||||
remove(jammers, pos.z,pos.y,pos.x)
|
||||
end
|
||||
|
||||
local function is_jammed(pos)
|
||||
local pz,py,px = vector.unpack(pos)
|
||||
for z,yxs in pairs(jammers) do
|
||||
if math.abs(pz-z) <= JAMMER_MAX_DISTANCE then
|
||||
for y,xs in pairs(yxs) do
|
||||
if math.abs(py-y) <= JAMMER_MAX_DISTANCE then
|
||||
for x in pairs(xs) do
|
||||
if math.abs(px-x) <= JAMMER_MAX_DISTANCE
|
||||
and (px-x)^2+(py-y)^2+(pz-z)^2 <= JAMMER_MAX_DISTANCE^2 then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
minetest.after(0, function() -- After loading all mods, override some functions
|
||||
local jammed
|
||||
|
||||
local actual_node_get = minetest.get_node_or_nil
|
||||
local function temp_node_get(pos, ...)
|
||||
local node = actual_node_get(pos, ...)
|
||||
if jammed == nil
|
||||
and node then
|
||||
jammed = is_jammed(pos)
|
||||
end
|
||||
return node
|
||||
end
|
||||
|
||||
local actual_is_conductor_off = mesecon.is_conductor_off
|
||||
local function temp_is_conductor_off(...)
|
||||
if jammed then
|
||||
-- go to the next elseif, there's is_effector
|
||||
return
|
||||
end
|
||||
local v = actual_is_conductor_off(...)
|
||||
if v then
|
||||
-- it continues to the next frontier
|
||||
jammed = nil
|
||||
end
|
||||
return v
|
||||
end
|
||||
|
||||
local actual_is_effector = mesecon.is_effector
|
||||
local function temp_is_effector(...)
|
||||
local abort_here = jammed
|
||||
-- the last elseif before continuing, jammed needs to be nil then
|
||||
jammed = nil
|
||||
if abort_here then
|
||||
return
|
||||
end
|
||||
return actual_is_effector(...)
|
||||
end
|
||||
|
||||
local actual_turnon = mesecon.turnon
|
||||
function mesecon.turnon(...)
|
||||
--set those to the temporary functions
|
||||
minetest.get_node_or_nil = temp_node_get
|
||||
mesecon.is_conductor_off = temp_is_conductor_off
|
||||
mesecon.is_effector = temp_is_effector
|
||||
|
||||
actual_turnon(...)
|
||||
|
||||
minetest.get_node_or_nil = actual_node_get
|
||||
mesecon.is_conductor_off = actual_is_conductor_off
|
||||
mesecon.is_effector = actual_is_effector
|
||||
|
||||
-- safety
|
||||
jammed = nil
|
||||
end
|
||||
end)
|
||||
|
||||
mesecon.register_node("moremesecons_jammer:jammer", {
|
||||
description = "Mesecons Jammer",
|
||||
paramtype = "light",
|
||||
},{
|
||||
tiles = {"moremesecons_jammer_off.png"},
|
||||
groups = {dig_immediate=2},
|
||||
mesecons = {effector = {
|
||||
action_on = function(pos)
|
||||
add_jammer(pos)
|
||||
minetest.swap_node(pos, {name="moremesecons_jammer:jammer_on"})
|
||||
end
|
||||
}},
|
||||
},{
|
||||
tiles = {"moremesecons_jammer_on.png"},
|
||||
groups = {dig_immediate=2, not_in_creative_inventory=1},
|
||||
mesecons = {effector = {
|
||||
action_off = function(pos)
|
||||
remove_jammer(pos)
|
||||
minetest.swap_node(pos, {name="moremesecons_jammer:jammer_off"})
|
||||
end
|
||||
}},
|
||||
on_destruct = remove_jammer,
|
||||
on_construct = add_jammer,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moremesecons_jammer:jammer_off",
|
||||
recipe = {{"group:mesecon_conductor_craftable", "default:mese", "group:mesecon_conductor_craftable"},
|
||||
{"", "moremesecons_wireless:jammer_off", ""}}
|
||||
})
|
||||
|
||||
minetest.register_lbm({
|
||||
name = "moremesecons_jammer:add_jammer",
|
||||
nodenames = {"moremesecons_jammer:jammer_on"},
|
||||
run_at_every_load = true,
|
||||
action = add_jammer
|
||||
})
|
After Width: | Height: | Size: 100 B |
After Width: | Height: | Size: 112 B |
@ -0,0 +1,2 @@
|
||||
mesecons
|
||||
vector_extras
|
303
mods/moremesecons/moremesecons_luacontroller_tool/init.lua
Normal file
@ -0,0 +1,303 @@
|
||||
--[[
|
||||
vector_extras there: https://github.com/HybridDog/vector_extras
|
||||
]]
|
||||
|
||||
local templates = {MoreMesecons = {
|
||||
logic = [[-- AND
|
||||
port.a = pin.b and pin.c
|
||||
-- OR
|
||||
port.a = pin.b or pin.c
|
||||
-- NOT
|
||||
port.a = not pin.b
|
||||
-- NAND
|
||||
port.a = not (pin.b and pin.c)
|
||||
-- NOR
|
||||
port.a = not (pin.b or pin.c)
|
||||
-- XOR
|
||||
port.a = pin.b ~= pin.c
|
||||
-- XNOR / NXOR
|
||||
port.a = pin.b == pin.c]],
|
||||
digilinesth = [[digiline_send(channel, msg)
|
||||
if event.type == "digiline" then
|
||||
print(event.channel)
|
||||
print(event.msg)
|
||||
end]],
|
||||
}}
|
||||
|
||||
|
||||
local file_path = minetest.get_worldpath().."/MoreMesecons_lctt"
|
||||
|
||||
-- load templates from a compressed file
|
||||
local templates_file = io.open(file_path, "rb")
|
||||
if templates_file then
|
||||
local templates_raw = templates_file:read("*all")
|
||||
io.close(templates_file)
|
||||
if templates_raw
|
||||
and templates_raw ~= "" then
|
||||
for name,t in pairs(minetest.deserialize(minetest.decompress(templates_raw))) do
|
||||
templates[name] = t
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- the save function
|
||||
local function save_to_file()
|
||||
local templates_file = io.open(file_path, "w")
|
||||
if not templates_file then
|
||||
minetest.log("error", "[MoreMesecons] Could not open file for saving!")
|
||||
return
|
||||
end
|
||||
local player_templates = table.copy(templates)
|
||||
player_templates.MoreMesecons = nil
|
||||
templates_file:write(minetest.compress(minetest.serialize(player_templates)))
|
||||
io.close(templates_file)
|
||||
end
|
||||
|
||||
-- save doesn't save more than every 10s to disallow spamming
|
||||
local saving
|
||||
local function save()
|
||||
if saving then
|
||||
return
|
||||
end
|
||||
saving = true
|
||||
minetest.after(16, function()
|
||||
save_to_file()
|
||||
saving = false
|
||||
end)
|
||||
end
|
||||
|
||||
minetest.register_on_shutdown(function()
|
||||
if saving then
|
||||
save_to_file()
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
-- used for the dropdown formspec element
|
||||
local function fill_formspec_dropdown_list(t, selected)
|
||||
local it,num = {},1
|
||||
for i in pairs(t) do
|
||||
it[num] = i
|
||||
num = num+1
|
||||
end
|
||||
num = num-1
|
||||
table.sort(it)
|
||||
local txt = ""
|
||||
local selected_id
|
||||
for i = 1,num do
|
||||
local t = it[i]
|
||||
if not selected_id
|
||||
and t == selected then
|
||||
selected_id = i
|
||||
end
|
||||
txt = txt..t -- add available indices
|
||||
if i ~= num then
|
||||
txt = txt..","
|
||||
end
|
||||
end
|
||||
return txt..";"..(selected_id or 1).."]"
|
||||
--spec = string.sub(spec, 1, -2)
|
||||
end
|
||||
|
||||
local pdata = {}
|
||||
|
||||
local function get_selection_formspec(pname, selected_template)
|
||||
-- templates might be removed by someone while changing sth in formspec
|
||||
local pl_templates = templates[pname]
|
||||
if not pl_templates then
|
||||
pname = next(templates)
|
||||
pl_templates = templates[pname]
|
||||
end
|
||||
|
||||
local template_code = pl_templates[selected_template]
|
||||
if not template_code then
|
||||
selected_template = next(pl_templates)
|
||||
template_code = pl_templates[selected_template]
|
||||
end
|
||||
|
||||
local spec = "size[10,10]"..
|
||||
|
||||
-- show available players, field player_name, current player name is the selected one
|
||||
"dropdown[0,0;5;player_name;"..
|
||||
fill_formspec_dropdown_list(templates, pname)..
|
||||
|
||||
-- show templates of pname
|
||||
"dropdown[5,0;5;template_name;"..
|
||||
fill_formspec_dropdown_list(pl_templates, selected_template)..
|
||||
|
||||
-- show selected template
|
||||
"textarea[0,1;10.5,8.5;template_code;template code:;"..template_code.."]"..
|
||||
|
||||
-- save name
|
||||
"field[5,9.5;5,0;save_name;savename;"..selected_template.."]"..
|
||||
|
||||
"button[0,10;2,0;button;set]"..
|
||||
|
||||
"button[2,10;2,0;button;add]"..
|
||||
|
||||
"button[5,10;2,0;button;save]"
|
||||
|
||||
return spec
|
||||
end
|
||||
|
||||
-- tests if the node is a luacontroller
|
||||
local function is_luacontroller(pos)
|
||||
return string.match(minetest.get_node(pos).name, "mesecons_luacontroller:luacontroller%d%d%d%d")
|
||||
end
|
||||
|
||||
-- do not localize the function directly here to support possible overwritten luacontrollers
|
||||
local luac_def = minetest.registered_nodes["mesecons_luacontroller:luacontroller0000"]
|
||||
local function set_luacontroller_code(pos, code)
|
||||
luac_def.on_receive_fields(pos, nil, {code=code, program=""})
|
||||
end
|
||||
|
||||
minetest.register_tool("moremesecons_luacontroller_tool:lctt", {
|
||||
description = "luacontroller template tool",
|
||||
inventory_image = "moremesecons_luacontroller_tool.png",
|
||||
|
||||
on_use = function(_, player, pt)
|
||||
if not player
|
||||
or not pt then
|
||||
return
|
||||
end
|
||||
|
||||
local pname = player:get_player_name()
|
||||
local pos = pt.under
|
||||
if not is_luacontroller(pos) then
|
||||
minetest.chat_send_player(pname, "You can use the luacontroller template tool only on luacontroller nodes.")
|
||||
return
|
||||
end
|
||||
|
||||
pdata[pname] = pdata[pname] or {
|
||||
pos = pos,
|
||||
player_name = pname,
|
||||
template_name = next(templates[pname] or templates[next(templates)]),
|
||||
}
|
||||
minetest.show_formspec(pname, "moremesecons:luacontroller_tool", get_selection_formspec(pdata[pname].player_name, pdata[pname].template_name))
|
||||
end,
|
||||
})
|
||||
|
||||
--[[ Luacontroller reset_meta function, by Jeija
|
||||
local function reset_meta(pos, code, errmsg)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("code", code)
|
||||
code = minetest.formspec_escape(code or "")
|
||||
errmsg = minetest.formspec_escape(errmsg or "")
|
||||
meta:set_string("formspec", "size[10,8]"..
|
||||
"background[-0.2,-0.25;10.4,8.75;jeija_luac_background.png]"..
|
||||
"textarea[0.2,0.6;10.2,5;code;;"..code.."]"..
|
||||
"image_button[3.75,6;2.5,1;jeija_luac_runbutton.png;program;]"..
|
||||
"image_button_exit[9.72,-0.25;0.425,0.4;jeija_close_window.png;exit;]"..
|
||||
"label[0.1,5;"..errmsg.."]")
|
||||
meta:set_int("heat", 0)
|
||||
meta:set_int("luac_id", math.random(1, 65535))
|
||||
end--]]
|
||||
|
||||
-- used to avoid possibly crashes
|
||||
local function get_code_or_nil(pname, player_name, template_name)
|
||||
local player_templates = templates[player_name]
|
||||
if not player_templates then
|
||||
minetest.chat_send_player(pname, "error: "..player_name.." doesn't have templates now")
|
||||
return
|
||||
end
|
||||
local code = player_templates[template_name]
|
||||
if not code then
|
||||
minetest.chat_send_player(pname, "error: "..template_name.." doesn't exist now")
|
||||
return
|
||||
end
|
||||
return code
|
||||
end
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname ~= "moremesecons:luacontroller_tool"
|
||||
or fields.quit
|
||||
or not player then
|
||||
return
|
||||
end
|
||||
|
||||
--minetest.chat_send_all(dump(fields))
|
||||
|
||||
local pname = player:get_player_name()
|
||||
|
||||
if fields.player_name
|
||||
and fields.player_name ~= pdata[pname].player_name then
|
||||
-- show available templates of that player
|
||||
minetest.show_formspec(pname, "moremesecons:luacontroller_tool",
|
||||
get_selection_formspec(fields.player_name, pdata[pname].template_name)
|
||||
)
|
||||
pdata[pname].player_name = fields.player_name
|
||||
return
|
||||
end
|
||||
|
||||
if fields.template_name
|
||||
and fields.template_name ~= pdata[pname].template_name then
|
||||
-- show selected template of that player
|
||||
minetest.show_formspec(pname, "moremesecons:luacontroller_tool",
|
||||
get_selection_formspec(pdata[pname].player_name, fields.template_name)
|
||||
)
|
||||
pdata[pname].template_name = fields.template_name
|
||||
return
|
||||
end
|
||||
|
||||
local pos = pdata[pname].pos
|
||||
if not is_luacontroller(pos) then
|
||||
-- this can happen
|
||||
return
|
||||
end
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
if fields.button == "set" then
|
||||
-- replace the code of the luacontroller with the template
|
||||
local code = get_code_or_nil(pname, fields.player_name, fields.template_name)
|
||||
if code then
|
||||
set_luacontroller_code(pos, code)
|
||||
minetest.chat_send_player(pname, "code set to template at "..vector.pos_to_string(pos))
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if fields.button == "add" then
|
||||
-- add the template to the end of the code of the luacontroller
|
||||
local code = get_code_or_nil(pname, fields.player_name, fields.template_name)
|
||||
if code then
|
||||
set_luacontroller_code(pos, meta:get_string("code").."\r"..code)
|
||||
minetest.chat_send_player(pname, "code added to luacontroller at "..vector.pos_to_string(pos))
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if fields.button == "save" then
|
||||
-- save the template, when you try to change others' templates, yours become changed
|
||||
local savename = fields.template_name
|
||||
if fields.save_name
|
||||
and fields.save_name ~= ""
|
||||
and fields.save_name ~= savename then
|
||||
savename = minetest.formspec_escape(fields.save_name)
|
||||
end
|
||||
local code = fields.template_code
|
||||
if not code then
|
||||
minetest.chat_send_player(pname, "error: template code missing")
|
||||
return
|
||||
end
|
||||
templates[pname] = templates[pname] or {}
|
||||
if code == "" then
|
||||
templates[pname][savename] = nil
|
||||
if not next(templates[pname]) then
|
||||
templates[pname] = nil
|
||||
end
|
||||
minetest.chat_send_player(pname, "template removed")
|
||||
save()
|
||||
return
|
||||
end
|
||||
code = minetest.formspec_escape(code)
|
||||
if templates[pname][savename] == code then
|
||||
minetest.chat_send_player(pname, "template not saved because it didn't change")
|
||||
return
|
||||
end
|
||||
templates[pname][savename] = code
|
||||
save()
|
||||
minetest.chat_send_player(pname, "template "..pname.."/"..savename.." saved")
|
||||
return
|
||||
end
|
||||
end)
|
After Width: | Height: | Size: 290 B |
2
mods/moremesecons/moremesecons_playerkiller/depends.txt
Normal file
@ -0,0 +1,2 @@
|
||||
mesecons
|
||||
mesecons_materials
|
62
mods/moremesecons/moremesecons_playerkiller/init.lua
Normal file
@ -0,0 +1,62 @@
|
||||
local kill_nearest_player = function(pos)
|
||||
local MAX_DISTANCE = 8 -- Use this number to set maximal distance to kill
|
||||
|
||||
-- Search the nearest player
|
||||
local nearest
|
||||
local min_distance = MAX_DISTANCE
|
||||
for index, player in pairs(minetest.get_connected_players()) do
|
||||
local distance = vector.distance(pos, player:getpos())
|
||||
if distance < min_distance then
|
||||
min_distance = distance
|
||||
nearest = player
|
||||
end
|
||||
end
|
||||
|
||||
if not nearest then
|
||||
-- no nearby player
|
||||
return
|
||||
end
|
||||
|
||||
local owner = minetest.get_meta(pos):get_string("owner")
|
||||
if not owner then
|
||||
-- maybe some mod placed it
|
||||
return
|
||||
end
|
||||
|
||||
if owner == nearest:get_player_name() then
|
||||
-- don't kill the owner !
|
||||
return
|
||||
end
|
||||
|
||||
-- And kill him
|
||||
nearest:set_hp(0)
|
||||
minetest.log("action", "Player "..owner.." kills player "..nearest.." using a MoreMesecons Player Killer.")
|
||||
end
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moremesecons_playerkiller:playerkiller",
|
||||
recipe = { {"","default:mese",""},
|
||||
{"default:apple","mesecons_detector:object_detector_off","default:apple"},
|
||||
{"","default:apple",""}}
|
||||
})
|
||||
|
||||
minetest.register_node("moremesecons_playerkiller:playerkiller", {
|
||||
description = "Player Killer",
|
||||
tiles = {"moremesecons_playerkiller_top.png", "moremesecons_playerkiller_top.png", "moremesecons_playerkiller_side.png"},
|
||||
paramtype = "light",
|
||||
walkable = true,
|
||||
groups = {cracky=3},
|
||||
mesecons = {effector = {
|
||||
state = mesecon.state.off,
|
||||
action_on = kill_nearest_player
|
||||
}},
|
||||
after_place_node = function(pos, placer)
|
||||
if not placer then
|
||||
return
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("owner", placer:get_player_name())
|
||||
meta:set_string("infotext", "PlayerKiller owned by " .. meta:get_string("owner"))
|
||||
end,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 3.1 KiB |
3
mods/moremesecons/moremesecons_sayer/depends.txt
Normal file
@ -0,0 +1,3 @@
|
||||
mesecons
|
||||
mesecons_noteblock
|
||||
default
|
95
mods/moremesecons/moremesecons_sayer/init.lua
Normal file
@ -0,0 +1,95 @@
|
||||
local MAX_DISTANCE = 8
|
||||
local use_speech_dispatcher = true
|
||||
|
||||
local sayer_activate
|
||||
if use_speech_dispatcher
|
||||
and minetest.is_singleplayer() -- must! executing commands with it and crashes may be possible
|
||||
and io.popen("if hash spd-say 2>/dev/null; then printf yes; fi"):read("*all") == "yes" then
|
||||
minetest.log("info", "[moremesecons_sayer] using speech dispatcher")
|
||||
local tab = {
|
||||
"spd-say",
|
||||
nil,
|
||||
""
|
||||
}
|
||||
local language = minetest.setting_get("language") or "en"
|
||||
if language ~= "en" then
|
||||
tab[3] = "-l "..language
|
||||
end
|
||||
MAX_DISTANCE = MAX_DISTANCE^2
|
||||
function sayer_activate(pos)
|
||||
local text = minetest.get_meta(pos):get_string("text")
|
||||
if text == "" then
|
||||
-- nothing to say
|
||||
return
|
||||
end
|
||||
if string.find(text, '"') then
|
||||
text = "So, singleplayer, you want to use me to execute commands? Writing quotes is not allowed!"
|
||||
end
|
||||
tab[2] = '"'..text..'"'
|
||||
local ppos = minetest.get_player_by_name("singleplayer"):getpos()
|
||||
ppos.y = ppos.y+1.625 -- camera position (without bobbing)
|
||||
-- that here's just 1 volume means that it's mono
|
||||
local volume = math.floor(-100*(
|
||||
1-MAX_DISTANCE/vector.distance(pos, ppos)^2
|
||||
+0.5))
|
||||
if volume <= -100 then
|
||||
-- nothing to hear
|
||||
return
|
||||
end
|
||||
if volume > 0 then
|
||||
--volume = "+"..math.min(100, volume)
|
||||
-- volume bigger 0 somehow isn't louder, it rather tries to scream
|
||||
volume = "+"..math.min(100, math.floor(volume/(MAX_DISTANCE-1)+0.5))
|
||||
end
|
||||
if volume == 0 then
|
||||
tab[4] = nil
|
||||
else
|
||||
tab[4] = "-i "..volume
|
||||
end
|
||||
os.execute(table.concat(tab, " "))
|
||||
end
|
||||
else
|
||||
function sayer_activate(pos)
|
||||
local tab = {
|
||||
"Sayer at pos",
|
||||
nil,
|
||||
"says : "..minetest.get_meta(pos):get_string("text")
|
||||
}
|
||||
for _,player in pairs(minetest.get_connected_players()) do
|
||||
if vector.distance(pos, player:getpos()) <= MAX_DISTANCE then
|
||||
tab[2] = minetest.pos_to_string(pos)
|
||||
minetest.chat_send_player(player:get_player_name(), table.concat(tab, " "))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("moremesecons_sayer:sayer", {
|
||||
description = "sayer",
|
||||
tiles = {"mesecons_noteblock.png", "default_wood.png"},
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
|
||||
},
|
||||
groups = {dig_immediate = 2},
|
||||
on_construct = function(pos)
|
||||
minetest.get_meta(pos):set_string("formspec", "field[text;text;${text}]")
|
||||
end,
|
||||
on_receive_fields = function(pos, _, fields, player)
|
||||
if fields.text
|
||||
and not minetest.is_protected(pos, player:get_player_name()) then
|
||||
minetest.get_meta(pos):set_string("text", fields.text)
|
||||
end
|
||||
end,
|
||||
mesecons = {effector = {
|
||||
action_on = sayer_activate
|
||||
}}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moremesecons_sayer:sayer 2",
|
||||
recipe = {{"mesecons_luacontroller:luacontroller0000", "mesecons_noteblock:noteblock"},
|
||||
{"group:wood", "group:wood"}}
|
||||
})
|
1
mods/moremesecons/moremesecons_signalchanger/depends.txt
Normal file
@ -0,0 +1 @@
|
||||
mesecons
|
81
mods/moremesecons/moremesecons_signalchanger/init.lua
Normal file
@ -0,0 +1,81 @@
|
||||
local nodebox = {
|
||||
type = "fixed",
|
||||
fixed = {{-8/16, -8/16, -8/16, 8/16, -7/16, 8/16 }},
|
||||
}
|
||||
|
||||
local function signalchanger_get_output_rules(node)
|
||||
local rules = {{x=1, y=0, z=0},
|
||||
{x=-1, y=0, z=0}}
|
||||
for i = 0, node.param2 do
|
||||
rules = mesecon.rotate_rules_left(rules)
|
||||
end
|
||||
return rules
|
||||
end
|
||||
|
||||
local function signalchanger_get_input_rules(node)
|
||||
local rules = {{x=0, y=0, z=1, name="input_on"}, {x=0, y=0, z=-1, name="input_off"}}
|
||||
for i = 0, node.param2 do
|
||||
rules = mesecon.rotate_rules_left(rules)
|
||||
end
|
||||
return rules
|
||||
end
|
||||
|
||||
local update = function(pos, node, link, newstate)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int(link.name, newstate == "on" and 1 or 0)
|
||||
local input_on = meta:get_int("input_on") == 1
|
||||
local input_off = meta:get_int("input_off") == 1
|
||||
if input_on then
|
||||
mesecon.receptor_on(pos, {signalchanger_get_output_rules(node)[1]})
|
||||
mesecon.receptor_off(pos, {signalchanger_get_output_rules(node)[2]})
|
||||
minetest.swap_node(pos, {name = "moremesecons_signalchanger:signalchanger_on", param2 = node.param2})
|
||||
elseif input_off then
|
||||
mesecon.receptor_off(pos, {signalchanger_get_output_rules(node)[1]})
|
||||
mesecon.receptor_on(pos, {signalchanger_get_output_rules(node)[2]})
|
||||
minetest.swap_node(pos, {name = "moremesecons_signalchanger:signalchanger_off", param2 = node.param2})
|
||||
end
|
||||
end
|
||||
|
||||
mesecon.register_node("moremesecons_signalchanger:signalchanger", {
|
||||
description = "Signal Changer",
|
||||
inventory_image = "moremesecons_signalchanger_off.png",
|
||||
groups = {dig_immediate = 2},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
drawtype = "nodebox",
|
||||
selection_box = nodebox,
|
||||
node_box = nodebox,
|
||||
},{
|
||||
groups = {dig_immediate = 2},
|
||||
mesecons = {
|
||||
receptor = {
|
||||
rules = signalchanger_get_output_rules
|
||||
},
|
||||
effector = {
|
||||
rules = signalchanger_get_input_rules,
|
||||
action_change = update
|
||||
},
|
||||
},
|
||||
tiles = {"moremesecons_signalchanger_off.png"},
|
||||
on_construct = function(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
mesecon.receptor_on(pos, {signalchanger_get_output_rules(node)[2]})
|
||||
end
|
||||
},{
|
||||
groups = {dig_immediate = 2, not_in_creative_inventory = 1},
|
||||
mesecons = {
|
||||
receptor = {
|
||||
rules = signalchanger_get_output_rules,
|
||||
},
|
||||
effector = {
|
||||
rules = signalchanger_get_input_rules,
|
||||
action_change = update,
|
||||
},
|
||||
},
|
||||
tiles = {"moremesecons_signalchanger_on.png"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moremesecons_signalchanger:signalchanger_off",
|
||||
recipe = {{"group:mesecon_conductor_craftable","moremesecons_switchtorch:switchtorch_on","group:mesecon_conductor_craftable"}}
|
||||
})
|
After Width: | Height: | Size: 109 B |
After Width: | Height: | Size: 109 B |
1
mods/moremesecons/moremesecons_switchtorch/depends.txt
Normal file
@ -0,0 +1 @@
|
||||
mesecons
|
129
mods/moremesecons/moremesecons_switchtorch/init.lua
Normal file
@ -0,0 +1,129 @@
|
||||
local rotate_torch_rules = function (rules, param2)
|
||||
if param2 == 5 then
|
||||
return mesecon.rotate_rules_right(rules)
|
||||
elseif param2 == 2 then
|
||||
return mesecon.rotate_rules_right(mesecon.rotate_rules_right(rules)) --180 degrees
|
||||
elseif param2 == 4 then
|
||||
return mesecon.rotate_rules_left(rules)
|
||||
elseif param2 == 1 then
|
||||
return mesecon.rotate_rules_down(rules)
|
||||
elseif param2 == 0 then
|
||||
return mesecon.rotate_rules_up(rules)
|
||||
else
|
||||
return rules
|
||||
end
|
||||
end
|
||||
|
||||
local output_rules = {
|
||||
{x = 1, y = 0, z = 0},
|
||||
{x = 0, y = 0, z = 1},
|
||||
{x = 0, y = 0, z =-1},
|
||||
{x = 0, y = 1, z = 0},
|
||||
{x = 0, y =-1, z = 0}
|
||||
}
|
||||
local torch_get_output_rules = function(node)
|
||||
return rotate_torch_rules(output_rules, node.param2)
|
||||
end
|
||||
|
||||
local input_rules = {
|
||||
{x = -2, y = 0, z = 0},
|
||||
{x = -1, y = 1, z = 0}
|
||||
}
|
||||
local torch_get_input_rules = function(node)
|
||||
return rotate_torch_rules(input_rules, node.param2)
|
||||
end
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moremesecons_switchtorch:switchtorch_on 4",
|
||||
recipe = {
|
||||
{"default:stick"},
|
||||
{"group:mesecon_conductor_craftable"},
|
||||
}
|
||||
})
|
||||
|
||||
local torch_selectionbox =
|
||||
{
|
||||
type = "wallmounted",
|
||||
wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1},
|
||||
wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
|
||||
wall_side = {-0.5, -0.1, -0.1, -0.5+0.6, 0.1, 0.1},
|
||||
}
|
||||
|
||||
minetest.register_node("moremesecons_switchtorch:switchtorch_off", {
|
||||
description = "Switch Torch",
|
||||
inventory_image = "moremesecons_switchtorch_on.png",
|
||||
wield_image = "moremesecons_switchtorch_on.png",
|
||||
drawtype = "torchlike",
|
||||
tiles = {"moremesecons_switchtorch_off.png", "moremesecons_switchtorch_off_ceiling.png", "moremesecons_switchtorch_off_side.png"},
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
paramtype2 = "wallmounted",
|
||||
selection_box = torch_selectionbox,
|
||||
groups = {dig_immediate = 3},
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.off,
|
||||
rules = torch_get_output_rules
|
||||
}},
|
||||
|
||||
on_construct = function(pos)-- For EndPower
|
||||
minetest.get_meta(pos):set_int("EndPower", 1) -- 1 for true, 0 for false
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("moremesecons_switchtorch:switchtorch_on", {
|
||||
drawtype = "torchlike",
|
||||
tiles = {"moremesecons_switchtorch_on.png", "moremesecons_switchtorch_on_ceiling.png", "moremesecons_switchtorch_on_side.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
paramtype2 = "wallmounted",
|
||||
selection_box = torch_selectionbox,
|
||||
groups = {dig_immediate=3, not_in_creative_inventory = 1},
|
||||
drop = "moremesecons_switchtorch:switchtorch_off",
|
||||
light_source = LIGHT_MAX-5,
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.on,
|
||||
rules = torch_get_output_rules
|
||||
}},
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"moremesecons_switchtorch:switchtorch_off","moremesecons_switchtorch:switchtorch_on"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node)
|
||||
local is_powered = false
|
||||
for _, rule in ipairs(torch_get_input_rules(node)) do
|
||||
local src = vector.add(pos, rule)
|
||||
if mesecon.is_power_on(src) then
|
||||
is_powered = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_int("EndPower") == 0 == is_powered then
|
||||
return
|
||||
end
|
||||
if not is_powered then
|
||||
meta:set_int("EndPower", 1)
|
||||
return
|
||||
end
|
||||
if node.name == "moremesecons_switchtorch:switchtorch_on" then
|
||||
minetest.swap_node(pos, {name = "moremesecons_switchtorch:switchtorch_off", param2 = node.param2})
|
||||
mesecon.receptor_off(pos, torch_get_output_rules(node))
|
||||
elseif node.name == "moremesecons_switchtorch:switchtorch_off" then
|
||||
minetest.swap_node(pos, {name = "moremesecons_switchtorch:switchtorch_on", param2 = node.param2})
|
||||
mesecon.receptor_on(pos, torch_get_output_rules(node))
|
||||
end
|
||||
meta:set_int("EndPower", 0)
|
||||
end
|
||||
})
|
||||
|
||||
-- Param2 Table (Block Attached To)
|
||||
-- 5 = z-1
|
||||
-- 3 = x-1
|
||||
-- 4 = z+1
|
||||
-- 2 = x+1
|
||||
-- 0 = y+1
|
||||
-- 1 = y-1
|
After Width: | Height: | Size: 119 B |
After Width: | Height: | Size: 111 B |
After Width: | Height: | Size: 110 B |
After Width: | Height: | Size: 116 B |
After Width: | Height: | Size: 118 B |
After Width: | Height: | Size: 114 B |
2
mods/moremesecons/moremesecons_teleporter/depends.txt
Normal file
@ -0,0 +1,2 @@
|
||||
mesecons
|
||||
vector_extras
|
92
mods/moremesecons/moremesecons_teleporter/init.lua
Normal file
@ -0,0 +1,92 @@
|
||||
local teleporters = {}
|
||||
local teleporters_rids = {}
|
||||
|
||||
|
||||
local register = function(pos)
|
||||
if not vector.get_data_from_pos(teleporters_rids, pos.z,pos.y,pos.x) then
|
||||
table.insert(teleporters, pos)
|
||||
vector.set_data_to_pos(teleporters_rids, pos.z,pos.y,pos.x, #teleporters)
|
||||
end
|
||||
end
|
||||
|
||||
local teleport_nearest = function(pos)
|
||||
local MAX_TELEPORTATION_DISTANCE = 50
|
||||
local MAX_PLAYER_DISTANCE = 25
|
||||
|
||||
-- Search the nearest player
|
||||
local nearest = nil
|
||||
local min_distance = MAX_PLAYER_DISTANCE
|
||||
local players = minetest.get_connected_players()
|
||||
for index, player in pairs(players) do
|
||||
local distance = vector.distance(pos, player:getpos())
|
||||
if distance < min_distance then
|
||||
min_distance = distance
|
||||
nearest = player
|
||||
end
|
||||
end
|
||||
|
||||
if not nearest then
|
||||
-- If there is no nearest player (maybe too far...)
|
||||
return
|
||||
end
|
||||
|
||||
-- Search other teleporter and teleport
|
||||
if not minetest.registered_nodes["moremesecons_teleporter:teleporter"] then return end
|
||||
|
||||
local newpos = {}
|
||||
for i = 1, #teleporters do
|
||||
if minetest.get_node(teleporters[i]).name == "moremesecons_teleporter:teleporter" then
|
||||
if teleporters[i].y == pos.y and teleporters[i].x == pos.x and teleporters[i].z ~= pos.z then
|
||||
newpos = {x=teleporters[i].x, y=teleporters[i].y+1, z=teleporters[i].z}
|
||||
elseif teleporters[i].z == pos.z and teleporters[i].x == pos.x and teleporters[i].y ~= pos.y then
|
||||
newpos = {x=teleporters[i].x, y=teleporters[i].y+1, z=teleporters[i].z}
|
||||
elseif teleporters[i].z == pos.z and teleporters[i].y == pos.y and teleporters[i].x ~= pos.x then
|
||||
newpos = {x=teleporters[i].x, y=teleporters[i].y+1, z=teleporters[i].z}
|
||||
end
|
||||
end
|
||||
end
|
||||
if newpos.x then
|
||||
-- If there is another teleporter BUT too far, delete newpos.
|
||||
if vector.distance(newpos, pos) > MAX_TELEPORTATION_DISTANCE then
|
||||
newpos = {}
|
||||
end
|
||||
end
|
||||
if not newpos.x then
|
||||
newpos = {x=pos.x, y=pos.y+1, z=pos.z} -- If newpos doesn't exist, teleport on the actual teleporter.
|
||||
end
|
||||
nearest:moveto(newpos)
|
||||
minetest.log("action", "Player "..nearest:get_player_name().." was teleport with a MoreMesecons Teleporter.")
|
||||
end
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moremesecons_teleporter:teleporter 2",
|
||||
recipe = {{"default:diamond","default:stick","default:mese"}}
|
||||
})
|
||||
minetest.register_node("moremesecons_teleporter:teleporter", {
|
||||
tiles = {"moremesecons_teleporter.png"},
|
||||
paramtype = "light",
|
||||
walkable = true,
|
||||
groups = {cracky=3},
|
||||
description="Teleporter",
|
||||
mesecons = {effector = {
|
||||
state = mesecon.state.off,
|
||||
action_on = teleport_nearest
|
||||
}},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
on_construct = register,
|
||||
on_destruct = function(pos)
|
||||
local RID = vector.get_data_from_pos(teleporters_rids, pos.z,pos.y,pos.x)
|
||||
if RID then
|
||||
table.remove(teleporters, RID)
|
||||
vector.remove_data_from_pos(teleporters_rids, pos.z,pos.y,pos.x)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
minetest.register_lbm({
|
||||
name = "moremesecons_teleporter:add_teleporter",
|
||||
nodenames = {"moremesecons_teleporter:teleporter"},
|
||||
run_at_every_load = true,
|
||||
action = register
|
||||
})
|
After Width: | Height: | Size: 513 B |
1
mods/moremesecons/moremesecons_temporarygate/depends.txt
Normal file
@ -0,0 +1 @@
|
||||
mesecons
|
124
mods/moremesecons/moremesecons_temporarygate/init.lua
Normal file
@ -0,0 +1,124 @@
|
||||
local temporarygate_get_output_rules = function(node)
|
||||
local rules = {{x = 0, y = 0, z = 1}}
|
||||
for i = 0, node.param2 do
|
||||
rules = mesecon.rotate_rules_left(rules)
|
||||
end
|
||||
return rules
|
||||
end
|
||||
|
||||
local temporarygate_get_input_rules = function(node)
|
||||
local rules = {{x = 0, y = 0, z = -1}}
|
||||
for i = 0, node.param2 do
|
||||
rules = mesecon.rotate_rules_left(rules)
|
||||
end
|
||||
return rules
|
||||
end
|
||||
|
||||
-- Functions that are called after the delay time
|
||||
|
||||
local function temporarygate_activate(pos, node)
|
||||
-- using a meta string allows writing the time in hexadecimals
|
||||
local time = tonumber(minetest.get_meta(pos):get_string("time"))
|
||||
if not time then
|
||||
return
|
||||
end
|
||||
node.name = "moremesecons_temporarygate:temporarygate_on"
|
||||
minetest.swap_node(pos, node)
|
||||
mesecon.receptor_on(pos)
|
||||
minetest.after(time, function(pos, node)
|
||||
mesecon.receptor_off(pos)
|
||||
node.name = "moremesecons_temporarygate:temporarygate_off"
|
||||
minetest.swap_node(pos, node)
|
||||
end, pos, node)
|
||||
end
|
||||
|
||||
boxes = {{ -6/16, -8/16, -6/16, 6/16, -7/16, 6/16 }, -- the main slab
|
||||
|
||||
{ -2/16, -7/16, -4/16, 2/16, -26/64, -3/16 }, -- the jeweled "on" indicator
|
||||
{ -3/16, -7/16, -3/16, 3/16, -26/64, -2/16 },
|
||||
{ -4/16, -7/16, -2/16, 4/16, -26/64, 2/16 },
|
||||
{ -3/16, -7/16, 2/16, 3/16, -26/64, 3/16 },
|
||||
{ -2/16, -7/16, 3/16, 2/16, -26/64, 4/16 },
|
||||
|
||||
{ -6/16, -7/16, -6/16, -4/16, -27/64, -4/16 }, -- the timer indicator
|
||||
{ -8/16, -8/16, -1/16, -6/16, -7/16, 1/16 }, -- the two wire stubs
|
||||
{ 6/16, -8/16, -1/16, 8/16, -7/16, 1/16 }}
|
||||
|
||||
mesecon.register_node("moremesecons_temporarygate:temporarygate", {
|
||||
description = "Temporary Gate",
|
||||
drawtype = "nodebox",
|
||||
inventory_image = "moremesecons_temporarygate_off.png",
|
||||
wield_image = "moremesecons_temporarygate_off.png",
|
||||
walkable = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 },
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = boxes
|
||||
},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
on_construct = function(pos)
|
||||
minetest.get_meta(pos):set_string("formspec", "field[time;time;${time}]")
|
||||
end,
|
||||
on_receive_fields = function(pos, _, fields, player)
|
||||
if fields.time
|
||||
and not minetest.is_protected(pos, player:get_player_name()) then
|
||||
minetest.get_meta(pos):set_string("time", fields.time)
|
||||
end
|
||||
end
|
||||
},{
|
||||
tiles = {
|
||||
"moremesecons_temporarygate_off.png",
|
||||
"moremesecons_temporarygate_bottom.png",
|
||||
"moremesecons_temporarygate_ends_off.png",
|
||||
"moremesecons_temporarygate_ends_off.png",
|
||||
"moremesecons_temporarygate_sides_off.png",
|
||||
"moremesecons_temporarygate_sides_off.png"
|
||||
},
|
||||
groups = {bendy=2,snappy=1,dig_immediate=2},
|
||||
mesecons = {
|
||||
receptor =
|
||||
{
|
||||
state = mesecon.state.off,
|
||||
rules = temporarygate_get_output_rules
|
||||
},
|
||||
effector =
|
||||
{
|
||||
rules = temporarygate_get_input_rules,
|
||||
action_on = temporarygate_activate
|
||||
}
|
||||
},
|
||||
},{
|
||||
tiles = {
|
||||
"moremesecons_temporarygate_on.png",
|
||||
"moremesecons_temporarygate_bottom.png",
|
||||
"moremesecons_temporarygate_ends_on.png",
|
||||
"moremesecons_temporarygate_ends_on.png",
|
||||
"moremesecons_temporarygate_sides_on.png",
|
||||
"moremesecons_temporarygate_sides_on.png"
|
||||
},
|
||||
groups = {bendy=2,snappy=1,dig_immediate=2, not_in_creative_inventory=1},
|
||||
mesecons = {
|
||||
receptor = {
|
||||
state = mesecon.state.on,
|
||||
rules = temporarygate_get_output_rules
|
||||
},
|
||||
effector = {
|
||||
rules = temporarygate_get_input_rules,
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moremesecons_temporarygate:temporarygate_off 2",
|
||||
recipe = {
|
||||
{"group:mesecon_conductor_craftable", "mesecons_delayer:delayer_off_1", "group:mesecon_conductor_craftable"},
|
||||
{"default:wood","default:wood", "default:wood"},
|
||||
}
|
||||
})
|
After Width: | Height: | Size: 261 B |
After Width: | Height: | Size: 170 B |
After Width: | Height: | Size: 171 B |
After Width: | Height: | Size: 361 B |
After Width: | Height: | Size: 364 B |
After Width: | Height: | Size: 164 B |
After Width: | Height: | Size: 169 B |
3
mods/moremesecons/moremesecons_wireless/depends.txt
Normal file
@ -0,0 +1,3 @@
|
||||
mesecons
|
||||
vector_extras
|
||||
digilines?
|
227
mods/moremesecons/moremesecons_wireless/init.lua
Normal file
@ -0,0 +1,227 @@
|
||||
local JAMMER_MAX_DISTANCE = 15
|
||||
|
||||
local wireless = {}
|
||||
local wireless_rids = {}
|
||||
|
||||
-- localize these functions with small names because they work fairly fast
|
||||
local get = vector.get_data_from_pos
|
||||
local set = vector.set_data_to_pos
|
||||
local remove = vector.remove_data_from_pos
|
||||
|
||||
-- if the wireless at pos isn't stored yet, put it into the tables
|
||||
local function register_RID(pos)
|
||||
if get(wireless_rids, pos.z,pos.y,pos.x) then
|
||||
return
|
||||
end
|
||||
local RID = #wireless+1
|
||||
wireless[RID] = pos
|
||||
set(wireless_rids, pos.z,pos.y,pos.x, RID)
|
||||
end
|
||||
|
||||
local is_jammed
|
||||
local function wireless_activate(pos)
|
||||
if is_jammed(pos) then
|
||||
-- jamming doesn't disallow receiving signals, only sending them
|
||||
return
|
||||
end
|
||||
|
||||
local channel_first_wireless = minetest.get_meta(pos):get_string("channel")
|
||||
if channel_first_wireless == "" then
|
||||
return
|
||||
end
|
||||
|
||||
for i = 1, #wireless do
|
||||
if not vector.equals(wireless[i], pos)
|
||||
and minetest.get_meta(wireless[i]):get_string("channel") == channel_first_wireless then
|
||||
mesecon.receptor_on(wireless[i])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function wireless_deactivate(pos)
|
||||
if is_jammed(pos) then
|
||||
return
|
||||
end
|
||||
local channel_first_wireless = minetest.get_meta(pos):get_string("channel")
|
||||
for i = 1, #wireless do
|
||||
if not vector.equals(wireless[i], pos)
|
||||
and minetest.get_meta(wireless[i]):get_string("channel") == channel_first_wireless then
|
||||
mesecon.receptor_off(wireless[i])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function on_digiline_receive(pos, node, channel, msg)
|
||||
local setchan = minetest.get_meta(pos):get_string("channel") -- Note : the digiline channel is the same as the wireless channel. TODO: Making two different channels and a more complex formspec ?
|
||||
if channel ~= setchan or is_jammed(pos) or setchan == "" then
|
||||
return
|
||||
end
|
||||
for i = 1, #wireless do
|
||||
if not vector.equals(wireless[i], pos)
|
||||
and minetest.get_meta(wireless[i]):get_string("channel") == channel then
|
||||
digiline:receptor_send(wireless[i], digiline.rules.default, channel, msg)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("moremesecons_wireless:wireless", {
|
||||
tiles = {"moremesecons_wireless.png"},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
description = "Wireless",
|
||||
walkable = true,
|
||||
groups = {cracky=3},
|
||||
mesecons = {effector = {
|
||||
action_on = wireless_activate,
|
||||
action_off = wireless_deactivate
|
||||
}},
|
||||
digiline = {
|
||||
receptor = {},
|
||||
effector = {
|
||||
action = on_digiline_receive
|
||||
},
|
||||
},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
on_construct = function(pos)
|
||||
minetest.get_meta(pos):set_string("formspec", "field[channel;channel;${channel}]")
|
||||
register_RID(pos)
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
local RID = get(wireless_rids, pos.z,pos.y,pos.x)
|
||||
if RID then
|
||||
table.remove(wireless, RID)
|
||||
vector.remove_data_from_pos(wireless_rids, pos.z,pos.y,pos.x)
|
||||
end
|
||||
mesecon.receptor_off(pos)
|
||||
end,
|
||||
on_receive_fields = function(pos, _, fields, player)
|
||||
if fields.channel
|
||||
and not minetest.is_protected(pos, player:get_player_name()) then
|
||||
minetest.get_meta(pos):set_string("channel", fields.channel)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
local jammers = {}
|
||||
local function add_jammer(pos)
|
||||
if get(jammers, pos.z,pos.y,pos.x) then
|
||||
return
|
||||
end
|
||||
set(jammers, pos.z,pos.y,pos.x, true)
|
||||
end
|
||||
|
||||
local function remove_jammer(pos)
|
||||
remove(jammers, pos.z,pos.y,pos.x)
|
||||
end
|
||||
|
||||
-- looks big, but should work fast
|
||||
function is_jammed(pos)
|
||||
local pz,py,px = vector.unpack(pos)
|
||||
for z,yxs in pairs(jammers) do
|
||||
if math.abs(pz-z) <= JAMMER_MAX_DISTANCE then
|
||||
for y,xs in pairs(yxs) do
|
||||
if math.abs(py-y) <= JAMMER_MAX_DISTANCE then
|
||||
for x in pairs(xs) do
|
||||
if math.abs(px-x) <= JAMMER_MAX_DISTANCE
|
||||
and (px-x)^2+(py-y)^2+(pz-z)^2 <= JAMMER_MAX_DISTANCE^2 then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
mesecon.register_node("moremesecons_wireless:jammer", {
|
||||
description = "Wireless Jammer",
|
||||
paramtype = "light",
|
||||
drawtype = "nodebox",
|
||||
},{
|
||||
tiles = {"mesecons_wire_off.png^moremesecons_jammer_top.png", "moremesecons_jammer_bottom.png", "mesecons_wire_off.png^moremesecons_jammer_side_off.png"},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
-- connection
|
||||
{-1/16, -0.5, -0.5, 1/16, -7/16, 0.5},
|
||||
{-0.5, -0.5, -1/16, 0.5, -7/16, 1/16},
|
||||
|
||||
--stabilization
|
||||
{-1/16, -7/16, -1/16, 1/16, -6/16, 1/16},
|
||||
|
||||
-- fields
|
||||
{-7/16, -6/16, -7/16, 7/16, -4/16, 7/16},
|
||||
{-5/16, -4/16, -5/16, 5/16, -3/16, 5/16},
|
||||
{-3/16, -3/16, -3/16, 3/16, -2/16, 3/16},
|
||||
{-1/16, -2/16, -1/16, 1/16, -1/16, 1/16},
|
||||
},
|
||||
},
|
||||
groups = {dig_immediate=2},
|
||||
mesecons = {effector = {
|
||||
rules = mesecon.rules.flat,
|
||||
action_on = function(pos)
|
||||
add_jammer(pos)
|
||||
minetest.swap_node(pos, {name="moremesecons_wireless:jammer_on"})
|
||||
end
|
||||
}}
|
||||
},{
|
||||
tiles = {"mesecons_wire_on.png^moremesecons_jammer_top.png", "moremesecons_jammer_bottom.png", "mesecons_wire_on.png^moremesecons_jammer_side_on.png"},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
-- connection
|
||||
{-1/16, -0.5, -0.5, 1/16, -7/16, 0.5},
|
||||
{-0.5, -0.5, -1/16, 0.5, -7/16, 1/16},
|
||||
|
||||
--stabilization
|
||||
{-1/16, -7/16, -1/16, 1/16, 5/16, 1/16},
|
||||
|
||||
-- fields
|
||||
{-7/16, -6/16, -7/16, 7/16, -4/16, 7/16},
|
||||
{-5/16, -3/16, -5/16, 5/16, -1/16, 5/16},
|
||||
{-3/16, 0, -3/16, 3/16, 2/16, 3/16},
|
||||
{-1/16, 3/16, -1/16, 1/16, 5/16, 1/16},
|
||||
},
|
||||
},
|
||||
groups = {dig_immediate=2, not_in_creative_inventory=1},
|
||||
mesecons = {effector = {
|
||||
rules = mesecon.rules.flat,
|
||||
action_off = function(pos)
|
||||
remove_jammer(pos)
|
||||
minetest.swap_node(pos, {name="moremesecons_wireless:jammer_off"})
|
||||
end
|
||||
}},
|
||||
on_destruct = remove_jammer,
|
||||
on_construct = add_jammer,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moremesecons_wireless:jammer_off",
|
||||
recipe = {
|
||||
{"moremesecons_wireless:wireless", "mesecons_torch:mesecon_torch_on", "moremesecons_wireless:wireless"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moremesecons_wireless:wireless 2",
|
||||
recipe = {
|
||||
{"group:mesecon_conductor_craftable", "", "group:mesecon_conductor_craftable"},
|
||||
{"", "mesecons_torch:mesecon_torch_on", ""},
|
||||
{"group:mesecon_conductor_craftable", "", "group:mesecon_conductor_craftable"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_lbm({
|
||||
name = "moremesecons_wireless:add_jammer",
|
||||
nodenames = {"moremesecons_wireless:jammer_on"},
|
||||
run_at_every_load = true,
|
||||
action = add_jammer
|
||||
})
|
||||
|
||||
minetest.register_lbm({
|
||||
name = "moremesecons_wireless:add_wireless",
|
||||
nodenames = {"moremesecons_wireless:wireless"},
|
||||
run_at_every_load = true,
|
||||
action = register_RID
|
||||
})
|
After Width: | Height: | Size: 170 B |
After Width: | Height: | Size: 138 B |
After Width: | Height: | Size: 163 B |
After Width: | Height: | Size: 160 B |
After Width: | Height: | Size: 3.4 KiB |