Compare commits
40 Commits
server_ste
...
patch_#135
Author | SHA1 | Date | |
---|---|---|---|
7d8fd7a8df | |||
39361fb719 | |||
9c2a5c313c | |||
fb417d45a7 | |||
b3f3692622 | |||
ae557d1cd4 | |||
d5b39951a4 | |||
b0f81a8c62 | |||
d9cc1d5aa1 | |||
e8d31c3e5a | |||
85f2f3f742 | |||
711c73a197 | |||
16b4b79c51 | |||
b4654cedb7 | |||
3105ae7084 | |||
f12206acc6 | |||
f479dd27d5 | |||
f46bc329de | |||
669e3d0880 | |||
2d0ff5e2ac | |||
33de6fad55 | |||
9ab0d9deb2 | |||
c3082f6601 | |||
09be8af517 | |||
75ca00f51e | |||
d0fdefb5a6 | |||
5516ca58e9 | |||
913e355a71 | |||
96011bc718 | |||
ec63bd3abf | |||
d15e3eedb0 | |||
885899cbaf | |||
6efe579f68 | |||
4f2604e01b | |||
c87bc60635 | |||
8ea71a9036 | |||
367a41416b | |||
afad592783 | |||
9a9df6cabf | |||
edc10dac47 |
532
LICENSE.txt
Normal file
@ -0,0 +1,532 @@
|
||||
The LGPLv3 applies to all code in this project.
|
||||
The CC-BY-SA-3.0 license applies to textures and any other content in this project which is not source code.
|
||||
|
||||
=================================================================
|
||||
|
||||
GNU LESSER 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.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
|
||||
=================================================================
|
||||
|
||||
Creative Commons Legal Code
|
||||
|
||||
Attribution-ShareAlike 3.0 Unported
|
||||
|
||||
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
||||
LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN
|
||||
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
||||
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
||||
REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR
|
||||
DAMAGES RESULTING FROM ITS USE.
|
||||
|
||||
License
|
||||
|
||||
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE
|
||||
COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY
|
||||
COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS
|
||||
AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
|
||||
|
||||
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE
|
||||
TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY
|
||||
BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS
|
||||
CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND
|
||||
CONDITIONS.
|
||||
|
||||
1. Definitions
|
||||
|
||||
a. "Adaptation" means a work based upon the Work, or upon the Work and
|
||||
other pre-existing works, such as a translation, adaptation,
|
||||
derivative work, arrangement of music or other alterations of a
|
||||
literary or artistic work, or phonogram or performance and includes
|
||||
cinematographic adaptations or any other form in which the Work may be
|
||||
recast, transformed, or adapted including in any form recognizably
|
||||
derived from the original, except that a work that constitutes a
|
||||
Collection will not be considered an Adaptation for the purpose of
|
||||
this License. For the avoidance of doubt, where the Work is a musical
|
||||
work, performance or phonogram, the synchronization of the Work in
|
||||
timed-relation with a moving image ("synching") will be considered an
|
||||
Adaptation for the purpose of this License.
|
||||
b. "Collection" means a collection of literary or artistic works, such as
|
||||
encyclopedias and anthologies, or performances, phonograms or
|
||||
broadcasts, or other works or subject matter other than works listed
|
||||
in Section 1(f) below, which, by reason of the selection and
|
||||
arrangement of their contents, constitute intellectual creations, in
|
||||
which the Work is included in its entirety in unmodified form along
|
||||
with one or more other contributions, each constituting separate and
|
||||
independent works in themselves, which together are assembled into a
|
||||
collective whole. A work that constitutes a Collection will not be
|
||||
considered an Adaptation (as defined below) for the purposes of this
|
||||
License.
|
||||
c. "Creative Commons Compatible License" means a license that is listed
|
||||
at http://creativecommons.org/compatiblelicenses that has been
|
||||
approved by Creative Commons as being essentially equivalent to this
|
||||
License, including, at a minimum, because that license: (i) contains
|
||||
terms that have the same purpose, meaning and effect as the License
|
||||
Elements of this License; and, (ii) explicitly permits the relicensing
|
||||
of adaptations of works made available under that license under this
|
||||
License or a Creative Commons jurisdiction license with the same
|
||||
License Elements as this License.
|
||||
d. "Distribute" means to make available to the public the original and
|
||||
copies of the Work or Adaptation, as appropriate, through sale or
|
||||
other transfer of ownership.
|
||||
e. "License Elements" means the following high-level license attributes
|
||||
as selected by Licensor and indicated in the title of this License:
|
||||
Attribution, ShareAlike.
|
||||
f. "Licensor" means the individual, individuals, entity or entities that
|
||||
offer(s) the Work under the terms of this License.
|
||||
g. "Original Author" means, in the case of a literary or artistic work,
|
||||
the individual, individuals, entity or entities who created the Work
|
||||
or if no individual or entity can be identified, the publisher; and in
|
||||
addition (i) in the case of a performance the actors, singers,
|
||||
musicians, dancers, and other persons who act, sing, deliver, declaim,
|
||||
play in, interpret or otherwise perform literary or artistic works or
|
||||
expressions of folklore; (ii) in the case of a phonogram the producer
|
||||
being the person or legal entity who first fixes the sounds of a
|
||||
performance or other sounds; and, (iii) in the case of broadcasts, the
|
||||
organization that transmits the broadcast.
|
||||
h. "Work" means the literary and/or artistic work offered under the terms
|
||||
of this License including without limitation any production in the
|
||||
literary, scientific and artistic domain, whatever may be the mode or
|
||||
form of its expression including digital form, such as a book,
|
||||
pamphlet and other writing; a lecture, address, sermon or other work
|
||||
of the same nature; a dramatic or dramatico-musical work; a
|
||||
choreographic work or entertainment in dumb show; a musical
|
||||
composition with or without words; a cinematographic work to which are
|
||||
assimilated works expressed by a process analogous to cinematography;
|
||||
a work of drawing, painting, architecture, sculpture, engraving or
|
||||
lithography; a photographic work to which are assimilated works
|
||||
expressed by a process analogous to photography; a work of applied
|
||||
art; an illustration, map, plan, sketch or three-dimensional work
|
||||
relative to geography, topography, architecture or science; a
|
||||
performance; a broadcast; a phonogram; a compilation of data to the
|
||||
extent it is protected as a copyrightable work; or a work performed by
|
||||
a variety or circus performer to the extent it is not otherwise
|
||||
considered a literary or artistic work.
|
||||
i. "You" means an individual or entity exercising rights under this
|
||||
License who has not previously violated the terms of this License with
|
||||
respect to the Work, or who has received express permission from the
|
||||
Licensor to exercise rights under this License despite a previous
|
||||
violation.
|
||||
j. "Publicly Perform" means to perform public recitations of the Work and
|
||||
to communicate to the public those public recitations, by any means or
|
||||
process, including by wire or wireless means or public digital
|
||||
performances; to make available to the public Works in such a way that
|
||||
members of the public may access these Works from a place and at a
|
||||
place individually chosen by them; to perform the Work to the public
|
||||
by any means or process and the communication to the public of the
|
||||
performances of the Work, including by public digital performance; to
|
||||
broadcast and rebroadcast the Work by any means including signs,
|
||||
sounds or images.
|
||||
k. "Reproduce" means to make copies of the Work by any means including
|
||||
without limitation by sound or visual recordings and the right of
|
||||
fixation and reproducing fixations of the Work, including storage of a
|
||||
protected performance or phonogram in digital form or other electronic
|
||||
medium.
|
||||
|
||||
2. Fair Dealing Rights. Nothing in this License is intended to reduce,
|
||||
limit, or restrict any uses free from copyright or rights arising from
|
||||
limitations or exceptions that are provided for in connection with the
|
||||
copyright protection under copyright law or other applicable laws.
|
||||
|
||||
3. License Grant. Subject to the terms and conditions of this License,
|
||||
Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
|
||||
perpetual (for the duration of the applicable copyright) license to
|
||||
exercise the rights in the Work as stated below:
|
||||
|
||||
a. to Reproduce the Work, to incorporate the Work into one or more
|
||||
Collections, and to Reproduce the Work as incorporated in the
|
||||
Collections;
|
||||
b. to create and Reproduce Adaptations provided that any such Adaptation,
|
||||
including any translation in any medium, takes reasonable steps to
|
||||
clearly label, demarcate or otherwise identify that changes were made
|
||||
to the original Work. For example, a translation could be marked "The
|
||||
original work was translated from English to Spanish," or a
|
||||
modification could indicate "The original work has been modified.";
|
||||
c. to Distribute and Publicly Perform the Work including as incorporated
|
||||
in Collections; and,
|
||||
d. to Distribute and Publicly Perform Adaptations.
|
||||
e. For the avoidance of doubt:
|
||||
|
||||
i. Non-waivable Compulsory License Schemes. In those jurisdictions in
|
||||
which the right to collect royalties through any statutory or
|
||||
compulsory licensing scheme cannot be waived, the Licensor
|
||||
reserves the exclusive right to collect such royalties for any
|
||||
exercise by You of the rights granted under this License;
|
||||
ii. Waivable Compulsory License Schemes. In those jurisdictions in
|
||||
which the right to collect royalties through any statutory or
|
||||
compulsory licensing scheme can be waived, the Licensor waives the
|
||||
exclusive right to collect such royalties for any exercise by You
|
||||
of the rights granted under this License; and,
|
||||
iii. Voluntary License Schemes. The Licensor waives the right to
|
||||
collect royalties, whether individually or, in the event that the
|
||||
Licensor is a member of a collecting society that administers
|
||||
voluntary licensing schemes, via that society, from any exercise
|
||||
by You of the rights granted under this License.
|
||||
|
||||
The above rights may be exercised in all media and formats whether now
|
||||
known or hereafter devised. The above rights include the right to make
|
||||
such modifications as are technically necessary to exercise the rights in
|
||||
other media and formats. Subject to Section 8(f), all rights not expressly
|
||||
granted by Licensor are hereby reserved.
|
||||
|
||||
4. Restrictions. The license granted in Section 3 above is expressly made
|
||||
subject to and limited by the following restrictions:
|
||||
|
||||
a. You may Distribute or Publicly Perform the Work only under the terms
|
||||
of this License. You must include a copy of, or the Uniform Resource
|
||||
Identifier (URI) for, this License with every copy of the Work You
|
||||
Distribute or Publicly Perform. You may not offer or impose any terms
|
||||
on the Work that restrict the terms of this License or the ability of
|
||||
the recipient of the Work to exercise the rights granted to that
|
||||
recipient under the terms of the License. You may not sublicense the
|
||||
Work. You must keep intact all notices that refer to this License and
|
||||
to the disclaimer of warranties with every copy of the Work You
|
||||
Distribute or Publicly Perform. When You Distribute or Publicly
|
||||
Perform the Work, You may not impose any effective technological
|
||||
measures on the Work that restrict the ability of a recipient of the
|
||||
Work from You to exercise the rights granted to that recipient under
|
||||
the terms of the License. This Section 4(a) applies to the Work as
|
||||
incorporated in a Collection, but this does not require the Collection
|
||||
apart from the Work itself to be made subject to the terms of this
|
||||
License. If You create a Collection, upon notice from any Licensor You
|
||||
must, to the extent practicable, remove from the Collection any credit
|
||||
as required by Section 4(c), as requested. If You create an
|
||||
Adaptation, upon notice from any Licensor You must, to the extent
|
||||
practicable, remove from the Adaptation any credit as required by
|
||||
Section 4(c), as requested.
|
||||
b. You may Distribute or Publicly Perform an Adaptation only under the
|
||||
terms of: (i) this License; (ii) a later version of this License with
|
||||
the same License Elements as this License; (iii) a Creative Commons
|
||||
jurisdiction license (either this or a later license version) that
|
||||
contains the same License Elements as this License (e.g.,
|
||||
Attribution-ShareAlike 3.0 US)); (iv) a Creative Commons Compatible
|
||||
License. If you license the Adaptation under one of the licenses
|
||||
mentioned in (iv), you must comply with the terms of that license. If
|
||||
you license the Adaptation under the terms of any of the licenses
|
||||
mentioned in (i), (ii) or (iii) (the "Applicable License"), you must
|
||||
comply with the terms of the Applicable License generally and the
|
||||
following provisions: (I) You must include a copy of, or the URI for,
|
||||
the Applicable License with every copy of each Adaptation You
|
||||
Distribute or Publicly Perform; (II) You may not offer or impose any
|
||||
terms on the Adaptation that restrict the terms of the Applicable
|
||||
License or the ability of the recipient of the Adaptation to exercise
|
||||
the rights granted to that recipient under the terms of the Applicable
|
||||
License; (III) You must keep intact all notices that refer to the
|
||||
Applicable License and to the disclaimer of warranties with every copy
|
||||
of the Work as included in the Adaptation You Distribute or Publicly
|
||||
Perform; (IV) when You Distribute or Publicly Perform the Adaptation,
|
||||
You may not impose any effective technological measures on the
|
||||
Adaptation that restrict the ability of a recipient of the Adaptation
|
||||
from You to exercise the rights granted to that recipient under the
|
||||
terms of the Applicable License. This Section 4(b) applies to the
|
||||
Adaptation as incorporated in a Collection, but this does not require
|
||||
the Collection apart from the Adaptation itself to be made subject to
|
||||
the terms of the Applicable License.
|
||||
c. If You Distribute, or Publicly Perform the Work or any Adaptations or
|
||||
Collections, You must, unless a request has been made pursuant to
|
||||
Section 4(a), keep intact all copyright notices for the Work and
|
||||
provide, reasonable to the medium or means You are utilizing: (i) the
|
||||
name of the Original Author (or pseudonym, if applicable) if supplied,
|
||||
and/or if the Original Author and/or Licensor designate another party
|
||||
or parties (e.g., a sponsor institute, publishing entity, journal) for
|
||||
attribution ("Attribution Parties") in Licensor's copyright notice,
|
||||
terms of service or by other reasonable means, the name of such party
|
||||
or parties; (ii) the title of the Work if supplied; (iii) to the
|
||||
extent reasonably practicable, the URI, if any, that Licensor
|
||||
specifies to be associated with the Work, unless such URI does not
|
||||
refer to the copyright notice or licensing information for the Work;
|
||||
and (iv) , consistent with Ssection 3(b), in the case of an
|
||||
Adaptation, a credit identifying the use of the Work in the Adaptation
|
||||
(e.g., "French translation of the Work by Original Author," or
|
||||
"Screenplay based on original Work by Original Author"). The credit
|
||||
required by this Section 4(c) may be implemented in any reasonable
|
||||
manner; provided, however, that in the case of a Adaptation or
|
||||
Collection, at a minimum such credit will appear, if a credit for all
|
||||
contributing authors of the Adaptation or Collection appears, then as
|
||||
part of these credits and in a manner at least as prominent as the
|
||||
credits for the other contributing authors. For the avoidance of
|
||||
doubt, You may only use the credit required by this Section for the
|
||||
purpose of attribution in the manner set out above and, by exercising
|
||||
Your rights under this License, You may not implicitly or explicitly
|
||||
assert or imply any connection with, sponsorship or endorsement by the
|
||||
Original Author, Licensor and/or Attribution Parties, as appropriate,
|
||||
of You or Your use of the Work, without the separate, express prior
|
||||
written permission of the Original Author, Licensor and/or Attribution
|
||||
Parties.
|
||||
d. Except as otherwise agreed in writing by the Licensor or as may be
|
||||
otherwise permitted by applicable law, if You Reproduce, Distribute or
|
||||
Publicly Perform the Work either by itself or as part of any
|
||||
Adaptations or Collections, You must not distort, mutilate, modify or
|
||||
take other derogatory action in relation to the Work which would be
|
||||
prejudicial to the Original Author's honor or reputation. Licensor
|
||||
agrees that in those jurisdictions (e.g. Japan), in which any exercise
|
||||
of the right granted in Section 3(b) of this License (the right to
|
||||
make Adaptations) would be deemed to be a distortion, mutilation,
|
||||
modification or other derogatory action prejudicial to the Original
|
||||
Author's honor and reputation, the Licensor will waive or not assert,
|
||||
as appropriate, this Section, to the fullest extent permitted by the
|
||||
applicable national law, to enable You to reasonably exercise Your
|
||||
right under Section 3(b) of this License (right to make Adaptations)
|
||||
but not otherwise.
|
||||
|
||||
5. Representations, Warranties and Disclaimer
|
||||
|
||||
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR
|
||||
OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY
|
||||
KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE,
|
||||
INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF
|
||||
LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS,
|
||||
WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION
|
||||
OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
|
||||
|
||||
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE
|
||||
LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR
|
||||
ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES
|
||||
ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS
|
||||
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
7. Termination
|
||||
|
||||
a. This License and the rights granted hereunder will terminate
|
||||
automatically upon any breach by You of the terms of this License.
|
||||
Individuals or entities who have received Adaptations or Collections
|
||||
from You under this License, however, will not have their licenses
|
||||
terminated provided such individuals or entities remain in full
|
||||
compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will
|
||||
survive any termination of this License.
|
||||
b. Subject to the above terms and conditions, the license granted here is
|
||||
perpetual (for the duration of the applicable copyright in the Work).
|
||||
Notwithstanding the above, Licensor reserves the right to release the
|
||||
Work under different license terms or to stop distributing the Work at
|
||||
any time; provided, however that any such election will not serve to
|
||||
withdraw this License (or any other license that has been, or is
|
||||
required to be, granted under the terms of this License), and this
|
||||
License will continue in full force and effect unless terminated as
|
||||
stated above.
|
||||
|
||||
8. Miscellaneous
|
||||
|
||||
a. Each time You Distribute or Publicly Perform the Work or a Collection,
|
||||
the Licensor offers to the recipient a license to the Work on the same
|
||||
terms and conditions as the license granted to You under this License.
|
||||
b. Each time You Distribute or Publicly Perform an Adaptation, Licensor
|
||||
offers to the recipient a license to the original Work on the same
|
||||
terms and conditions as the license granted to You under this License.
|
||||
c. If any provision of this License is invalid or unenforceable under
|
||||
applicable law, it shall not affect the validity or enforceability of
|
||||
the remainder of the terms of this License, and without further action
|
||||
by the parties to this agreement, such provision shall be reformed to
|
||||
the minimum extent necessary to make such provision valid and
|
||||
enforceable.
|
||||
d. No term or provision of this License shall be deemed waived and no
|
||||
breach consented to unless such waiver or consent shall be in writing
|
||||
and signed by the party to be charged with such waiver or consent.
|
||||
e. This License constitutes the entire agreement between the parties with
|
||||
respect to the Work licensed here. There are no understandings,
|
||||
agreements or representations with respect to the Work not specified
|
||||
here. Licensor shall not be bound by any additional provisions that
|
||||
may appear in any communication from You. This License may not be
|
||||
modified without the mutual written agreement of the Licensor and You.
|
||||
f. The rights granted under, and the subject matter referenced, in this
|
||||
License were drafted utilizing the terminology of the Berne Convention
|
||||
for the Protection of Literary and Artistic Works (as amended on
|
||||
September 28, 1979), the Rome Convention of 1961, the WIPO Copyright
|
||||
Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996
|
||||
and the Universal Copyright Convention (as revised on July 24, 1971).
|
||||
These rights and subject matter take effect in the relevant
|
||||
jurisdiction in which the License terms are sought to be enforced
|
||||
according to the corresponding provisions of the implementation of
|
||||
those treaty provisions in the applicable national law. If the
|
||||
standard suite of rights granted under applicable copyright law
|
||||
includes additional rights not granted under this License, such
|
||||
additional rights are deemed to be included in the License; this
|
||||
License is not intended to restrict the license of any rights under
|
||||
applicable law.
|
||||
|
||||
|
||||
Creative Commons Notice
|
||||
|
||||
Creative Commons is not a party to this License, and makes no warranty
|
||||
whatsoever in connection with the Work. Creative Commons will not be
|
||||
liable to You or any party on any legal theory for any damages
|
||||
whatsoever, including without limitation any general, special,
|
||||
incidental or consequential damages arising in connection to this
|
||||
license. Notwithstanding the foregoing two (2) sentences, if Creative
|
||||
Commons has expressly identified itself as the Licensor hereunder, it
|
||||
shall have all rights and obligations of Licensor.
|
||||
|
||||
Except for the limited purpose of indicating to the public that the
|
||||
Work is licensed under the CCPL, Creative Commons does not authorize
|
||||
the use by either party of the trademark "Creative Commons" or any
|
||||
related trademark or logo of Creative Commons without the prior
|
||||
written consent of Creative Commons. Any permitted use will be in
|
||||
compliance with Creative Commons' then-current trademark usage
|
||||
guidelines, as may be published on its website or otherwise made
|
||||
available upon request from time to time. For the avoidance of doubt,
|
||||
this trademark restriction does not form part of the License.
|
||||
|
||||
Creative Commons may be contacted at http://creativecommons.org/.
|
14
README.md
@ -52,24 +52,26 @@ Who wrote it anyways?
|
||||
These awesome people made Mesecons possible!
|
||||
|
||||
| Contributor | Contribution |
|
||||
| --------------- | ---------------------------------- |
|
||||
| --------------- | -------------------------------- |
|
||||
| Jat15 | Various tweaks. |
|
||||
| Jeija | **Main developer! Everything.** |
|
||||
| Jordach | Noteblock sounds. |
|
||||
| khonkhortistan | Coding, recipes, textures. |
|
||||
| khonkhortistan | Code, recipes, textures. |
|
||||
| Kotolegokot | Nodeboxes for items. |
|
||||
| minerd247 | Textures. |
|
||||
| Nore/Novatux | Code. |
|
||||
| RealBadAngel | Fixes, improvements. |
|
||||
| sfan5 | Coding, recipes, textures. |
|
||||
| Uberi/Temperest | Coding, textures, documentation. |
|
||||
| VanessaE | Coding, recipes, textures, design. |
|
||||
| sfan5 | Code, recipes, textures. |
|
||||
| suzenako | Piston sounds. |
|
||||
| Uberi/Temperest | Code, textures, documentation. |
|
||||
| VanessaE | Code, recipes, textures, design. |
|
||||
| Whiskers75 | Logic gates implementation. |
|
||||
|
||||
There are also a whole bunch of other people helping with everything from code to testing and feedback. Mesecons would also not be possible without their help!
|
||||
|
||||
Alright, how can I use it?
|
||||
--------------------------
|
||||
All textures in this project are licensed under the CC-BY-SA 2.0 (Creative Commons Attribution-ShareAlike 2.0 Generic). That means you can distribute and remix them as much as you want to, under the condition that you give credit to the authors and the project, and that if you remix and release them, they must be under the same or similar license to this one.
|
||||
All textures in this project are licensed under the CC-BY-SA 3.0 (Creative Commons Attribution-ShareAlike 3.0 Generic). That means you can distribute and remix them as much as you want to, under the condition that you give credit to the authors and the project, and that if you remix and release them, they must be under the same or similar license to this one.
|
||||
|
||||
All code in this project is licensed under the LGPL version 3 or later. That means you have unlimited freedom to distribute and modify the work however you see fit, provided that if you decide to distribute it or any modified versions of it, you must also use the same license. The LGPL also grants the additional freedom to write extensions for the software and distribute them without the extensions being subject to the terms of the LGPL, although the software itself retains its license.
|
||||
|
||||
|
@ -49,6 +49,31 @@ mesecon.receptors={} -- saves all information about receptors | DEPRECATED
|
||||
mesecon.effectors={} -- saves all information about effectors | DEPRECATED
|
||||
mesecon.conductors={} -- saves all information about conductors | DEPRECATED
|
||||
|
||||
|
||||
local wpath = minetest.get_worldpath()
|
||||
local function read_file(fn)
|
||||
local f = io.open(fn, "r")
|
||||
if f==nil then return {} end
|
||||
local t = f:read("*all")
|
||||
f:close()
|
||||
if t=="" or t==nil then return {} end
|
||||
return minetest.deserialize(t)
|
||||
end
|
||||
|
||||
local function write_file(fn, tbl)
|
||||
local f = io.open(fn, "w")
|
||||
f:write(minetest.serialize(tbl))
|
||||
f:close()
|
||||
end
|
||||
|
||||
mesecon.to_update = read_file(wpath.."/mesecon_to_update")
|
||||
mesecon.r_to_update = read_file(wpath.."/mesecon_r_to_update")
|
||||
|
||||
minetest.register_on_shutdown(function()
|
||||
write_file(wpath.."/mesecon_to_update",mesecon.to_update)
|
||||
write_file(wpath.."/mesecon_r_to_update",mesecon.r_to_update)
|
||||
end)
|
||||
|
||||
-- Settings
|
||||
dofile(minetest.get_modpath("mesecons").."/settings.lua")
|
||||
|
||||
@ -76,34 +101,51 @@ dofile(minetest.get_modpath("mesecons").."/legacy.lua");
|
||||
-- API
|
||||
-- these are the only functions you need to remember
|
||||
|
||||
function mesecon:receptor_on(pos, rules)
|
||||
function mesecon:receptor_on_i(pos, rules)
|
||||
rules = rules or mesecon.rules.default
|
||||
|
||||
for _, rule in ipairs(rules) do
|
||||
for _, rule in ipairs(mesecon:flattenrules(rules)) do
|
||||
local np = mesecon:addPosRule(pos, rule)
|
||||
local link, rulename = mesecon:rules_link(pos, np, rules)
|
||||
if link then
|
||||
local rulenames = mesecon:rules_link_rule_all(pos, rule)
|
||||
for _, rulename in ipairs(rulenames) do
|
||||
mesecon:turnon(np, rulename)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mesecon:receptor_off(pos, rules)
|
||||
function mesecon:receptor_on(pos, rules)
|
||||
if MESECONS_GLOBALSTEP then
|
||||
rules = rules or mesecon.rules.default
|
||||
mesecon.r_to_update[#mesecon.r_to_update+1]={pos=pos, rules=rules, action="on"}
|
||||
else
|
||||
mesecon:receptor_on_i(pos, rules)
|
||||
end
|
||||
end
|
||||
|
||||
for _, rule in ipairs(rules) do
|
||||
function mesecon:receptor_off_i(pos, rules)
|
||||
rules = rules or mesecon.rules.default
|
||||
for _, rule in ipairs(mesecon:flattenrules(rules)) do
|
||||
local np = mesecon:addPosRule(pos, rule)
|
||||
local link, rulename = mesecon:rules_link(pos, np, rules)
|
||||
if link then
|
||||
if not mesecon:connected_to_receptor(np) then
|
||||
local rulenames = mesecon:rules_link_rule_all(pos, rule)
|
||||
for _, rulename in ipairs(rulenames) do
|
||||
if not mesecon:connected_to_receptor(np, mesecon:invertRule(rule)) then
|
||||
mesecon:turnoff(np, rulename)
|
||||
else
|
||||
mesecon:changesignal(np, minetest.env:get_node(np), rulename, mesecon.state.off)
|
||||
mesecon:changesignal(np, minetest.get_node(np), rulename, mesecon.state.off)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mesecon:receptor_off(pos, rules)
|
||||
if MESECONS_GLOBALSTEP then
|
||||
rules = rules or mesecon.rules.default
|
||||
mesecon.r_to_update[#mesecon.r_to_update+1]={pos=pos, rules=rules, action="off"}
|
||||
else
|
||||
mesecon:receptor_off_i(pos, rules)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
print("[OK] Mesecons")
|
||||
|
||||
|
@ -32,10 +32,10 @@
|
||||
|
||||
-- CONDUCTORS
|
||||
-- mesecon:is_conductor(nodename) --> Returns true if nodename is a conductor
|
||||
-- mesecon:is_conductor_on(nodename) --> Returns true if nodename is a conductor with state = mesecon.state.on
|
||||
-- mesecon:is_conductor_off(nodename) --> Returns true if nodename is a conductor with state = mesecon.state.off
|
||||
-- mesecon:get_conductor_on(offstate) --> Returns the onstate nodename of the conductor with the name offstate
|
||||
-- mesecon:get_conductor_off(onstate) --> Returns the offstate nodename of the conductor with the name onstate
|
||||
-- mesecon:is_conductor_on(node) --> Returns true if node is a conductor with state = mesecon.state.on
|
||||
-- mesecon:is_conductor_off(node) --> Returns true if node is a conductor with state = mesecon.state.off
|
||||
-- mesecon:get_conductor_on(node_off) --> Returns the onstate nodename of the conductor
|
||||
-- mesecon:get_conductor_off(node_on) --> Returns the offstate nodename of the conductor
|
||||
-- mesecon:conductor_get_rules(node) --> Returns the input+output rules of a conductor (mesecon.rules.default if none specified)
|
||||
|
||||
-- HIGH-LEVEL Internals
|
||||
@ -180,25 +180,111 @@ end
|
||||
--Signals
|
||||
|
||||
function mesecon:activate(pos, node, rulename)
|
||||
if MESECONS_GLOBALSTEP then
|
||||
if rulename == nil then
|
||||
for _,rule in ipairs(mesecon:effector_get_rules(node)) do
|
||||
mesecon:activate(pos, node, rule)
|
||||
end
|
||||
return
|
||||
end
|
||||
add_action(pos, "on", rulename)
|
||||
else
|
||||
local effector = mesecon:get_effector(node.name)
|
||||
if effector and effector.action_on then
|
||||
effector.action_on (pos, node, rulename)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mesecon:deactivate(pos, node, rulename)
|
||||
if MESECONS_GLOBALSTEP then
|
||||
if rulename == nil then
|
||||
for _,rule in ipairs(mesecon:effector_get_rules(node)) do
|
||||
mesecon:deactivate(pos, node, rule)
|
||||
end
|
||||
return
|
||||
end
|
||||
add_action(pos, "off", rulename)
|
||||
else
|
||||
local effector = mesecon:get_effector(node.name)
|
||||
if effector and effector.action_off then
|
||||
effector.action_off (pos, node, rulename)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mesecon:changesignal(pos, node, rulename, newstate)
|
||||
|
||||
newstate = newstate or "on"
|
||||
--rulename = rulename or mesecon.rules.default
|
||||
if MESECONS_GLOBALSTEP then
|
||||
if rulename == nil then
|
||||
for _,rule in ipairs(mesecon:effector_get_rules(node)) do
|
||||
mesecon:changesignal(pos, node, rule, newstate)
|
||||
end
|
||||
return
|
||||
end
|
||||
add_action(pos, "c"..newstate, rulename)
|
||||
else
|
||||
local effector = mesecon:get_effector(node.name)
|
||||
if effector and effector.action_change then
|
||||
effector.action_change (pos, node, rulename, newstate)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function execute_actions(dtime)
|
||||
local nactions = mesecon.to_update
|
||||
mesecon.to_update = {}
|
||||
for _,i in ipairs(nactions) do
|
||||
node = minetest.get_node(i.pos)
|
||||
if node.name=="ignore" then
|
||||
add_action(i.pos, i.action, i.rname)
|
||||
else
|
||||
effector = mesecon:get_effector(node.name)
|
||||
if i.action == "on" then
|
||||
if effector and effector.action_on then
|
||||
effector.action_on(i.pos, node, i.rname)
|
||||
end
|
||||
elseif i.action == "off" then
|
||||
if effector and effector.action_off then
|
||||
effector.action_off(i.pos, node, i.rname)
|
||||
end
|
||||
elseif i.action == "con" then
|
||||
if effector and effector.action_change then
|
||||
effector.action_change(i.pos, node, i.rname, "on")
|
||||
end
|
||||
elseif i.action == "coff" then
|
||||
if effector and effector.action_change then
|
||||
effector.action_change(i.pos, node, i.rname, "off")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local nactions = mesecon.r_to_update
|
||||
mesecon.r_to_update = {}
|
||||
for _,i in ipairs(nactions) do
|
||||
if i.action == "on" then
|
||||
mesecon:receptor_on_i(i.pos, i.rules)
|
||||
else
|
||||
mesecon:receptor_off_i(i.pos,i.rules)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_globalstep(execute_actions)
|
||||
|
||||
function add_action(pos, action, rname)
|
||||
for i, update in ipairs(mesecon.to_update) do
|
||||
-- check if action for this node already exist, if so correct it:
|
||||
if mesecon:cmpPos(pos, update.pos) and mesecon:cmpPos(update.rname, rname) then
|
||||
mesecon.to_update[i].action = action
|
||||
return -- action added (as correction), so return now
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(mesecon.to_update, {pos = pos, action = action, rname = rname})
|
||||
end
|
||||
|
||||
--Rules
|
||||
|
||||
@ -212,18 +298,38 @@ end
|
||||
|
||||
-- Conductors
|
||||
|
||||
function mesecon:is_conductor_on(nodename)
|
||||
local conductor = mesecon:get_conductor(nodename)
|
||||
if conductor and conductor.state == mesecon.state.on then
|
||||
return true
|
||||
function mesecon:is_conductor_on(node, rulename)
|
||||
local conductor = mesecon:get_conductor(node.name)
|
||||
if conductor then
|
||||
if conductor.state then
|
||||
return conductor.state == mesecon.state.on
|
||||
end
|
||||
if conductor.states then
|
||||
if not rulename then
|
||||
return mesecon:getstate(node.name, conductor.states) ~= 1
|
||||
end
|
||||
local bit = mesecon:rule2bit(rulename, mesecon:conductor_get_rules(node))
|
||||
local binstate = mesecon:getbinstate(node.name, conductor.states)
|
||||
return mesecon:get_bit(binstate, bit)
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function mesecon:is_conductor_off(nodename)
|
||||
local conductor = mesecon:get_conductor(nodename)
|
||||
if conductor and conductor.state == mesecon.state.off then
|
||||
return true
|
||||
function mesecon:is_conductor_off(node, rulename)
|
||||
local conductor = mesecon:get_conductor(node.name)
|
||||
if conductor then
|
||||
if conductor.state then
|
||||
return conductor.state == mesecon.state.off
|
||||
end
|
||||
if conductor.states then
|
||||
if not rulename then
|
||||
return mesecon:getstate(node.name, conductor.states) == 1
|
||||
end
|
||||
local bit = mesecon:rule2bit(rulename, mesecon:conductor_get_rules(node))
|
||||
local binstate = mesecon:getbinstate(node.name, conductor.states)
|
||||
return not mesecon:get_bit(binstate, bit)
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
@ -236,20 +342,36 @@ function mesecon:is_conductor(nodename)
|
||||
return false
|
||||
end
|
||||
|
||||
function mesecon:get_conductor_on(offstate)
|
||||
local conductor = mesecon:get_conductor(offstate)
|
||||
function mesecon:get_conductor_on(node_off, rulename)
|
||||
local conductor = mesecon:get_conductor(node_off.name)
|
||||
if conductor then
|
||||
if conductor.onstate then
|
||||
return conductor.onstate
|
||||
end
|
||||
return false
|
||||
if conductor.states then
|
||||
local bit = mesecon:rule2bit(rulename, mesecon:conductor_get_rules(node_off))
|
||||
local binstate = mesecon:getbinstate(node_off.name, conductor.states)
|
||||
binstate = mesecon:set_bit(binstate, bit, "1")
|
||||
return conductor.states[tonumber(binstate,2)+1]
|
||||
end
|
||||
end
|
||||
return offstate
|
||||
end
|
||||
|
||||
function mesecon:get_conductor_off(onstate)
|
||||
local conductor = mesecon:get_conductor(onstate)
|
||||
function mesecon:get_conductor_off(node_on, rulename)
|
||||
local conductor = mesecon:get_conductor(node_on.name)
|
||||
if conductor then
|
||||
if conductor.offstate then
|
||||
return conductor.offstate
|
||||
end
|
||||
return false
|
||||
if conductor.states then
|
||||
local bit = mesecon:rule2bit(rulename, mesecon:conductor_get_rules(node_on))
|
||||
local binstate = mesecon:getbinstate(node_on.name, conductor.states)
|
||||
binstate = mesecon:set_bit(binstate, bit, "0")
|
||||
return conductor.states[tonumber(binstate,2)+1]
|
||||
end
|
||||
end
|
||||
return onstate
|
||||
end
|
||||
|
||||
function mesecon:conductor_get_rules(node)
|
||||
@ -267,34 +389,44 @@ end
|
||||
|
||||
-- some more general high-level stuff
|
||||
|
||||
function mesecon:is_power_on(pos)
|
||||
local node = minetest.env:get_node(pos)
|
||||
if mesecon:is_conductor_on(node.name) or mesecon:is_receptor_on(node.name) then
|
||||
function mesecon:is_power_on(pos, rulename)
|
||||
local node = minetest.get_node(pos)
|
||||
if mesecon:is_conductor_on(node, rulename) or mesecon:is_receptor_on(node.name) then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function mesecon:is_power_off(pos)
|
||||
local node = minetest.env:get_node(pos)
|
||||
if mesecon:is_conductor_off(node.name) or mesecon:is_receptor_off(node.name) then
|
||||
function mesecon:is_power_off(pos, rulename)
|
||||
local node = minetest.get_node(pos)
|
||||
if mesecon:is_conductor_off(node, rulename) or mesecon:is_receptor_off(node.name) then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function mesecon:turnon(pos, rulename)
|
||||
local node = minetest.env:get_node(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
|
||||
if mesecon:is_conductor_off(node.name) then
|
||||
if mesecon:is_conductor_off(node, rulename) then
|
||||
local rules = mesecon:conductor_get_rules(node)
|
||||
minetest.env:add_node(pos, {name = mesecon:get_conductor_on(node.name), param2 = node.param2})
|
||||
|
||||
for _, rule in ipairs(rules) do
|
||||
if not rulename then
|
||||
for _, rule in ipairs(mesecon:flattenrules(rules)) do
|
||||
if mesecon:connected_to_receptor(pos, rule) then
|
||||
mesecon:turnon(pos, rule)
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
minetest.swap_node(pos, {name = mesecon:get_conductor_on(node, rulename), param2 = node.param2})
|
||||
|
||||
for _, rule in ipairs(mesecon:rule2meta(rulename, rules)) do
|
||||
local np = mesecon:addPosRule(pos, rule)
|
||||
local link, rulename = mesecon:rules_link(pos, np)
|
||||
local rulenames = mesecon:rules_link_rule_all(pos, rule)
|
||||
|
||||
if link then
|
||||
for _, rulename in ipairs(rulenames) do
|
||||
mesecon:turnon(np, rulename)
|
||||
end
|
||||
end
|
||||
@ -307,17 +439,27 @@ function mesecon:turnon(pos, rulename)
|
||||
end
|
||||
|
||||
function mesecon:turnoff(pos, rulename)
|
||||
local node = minetest.env:get_node(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
|
||||
if mesecon:is_conductor_on(node.name) then
|
||||
if mesecon:is_conductor_on(node, rulename) then
|
||||
local rules = mesecon:conductor_get_rules(node)
|
||||
minetest.env:add_node(pos, {name = mesecon:get_conductor_off(node.name), param2 = node.param2})
|
||||
--[[
|
||||
if not rulename then
|
||||
for _, rule in ipairs(mesecon:flattenrules(rules)) do
|
||||
if mesecon:is_powered(pos, rule) then
|
||||
mesecon:turnoff(pos, rule)
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
--]]
|
||||
minetest.swap_node(pos, {name = mesecon:get_conductor_off(node, rulename), param2 = node.param2})
|
||||
|
||||
for _, rule in ipairs(rules) do
|
||||
for _, rule in ipairs(mesecon:rule2meta(rulename, rules)) do
|
||||
local np = mesecon:addPosRule(pos, rule)
|
||||
local link, rulename = mesecon:rules_link(pos, np)
|
||||
local rulenames = mesecon:rules_link_rule_all(pos, rule)
|
||||
|
||||
if link then
|
||||
for _, rulename in ipairs(rulenames) do
|
||||
mesecon:turnoff(np, rulename)
|
||||
end
|
||||
end
|
||||
@ -331,17 +473,17 @@ function mesecon:turnoff(pos, rulename)
|
||||
end
|
||||
|
||||
|
||||
function mesecon:connected_to_receptor(pos)
|
||||
local node = minetest.env:get_node(pos)
|
||||
function mesecon:connected_to_receptor(pos, rulename)
|
||||
local node = minetest.get_node(pos)
|
||||
|
||||
-- Check if conductors around are connected
|
||||
local rules = mesecon:get_any_inputrules(node)
|
||||
if not rules then return false end
|
||||
|
||||
for _, rule in ipairs(rules) do
|
||||
for _, rule in ipairs(mesecon:rule2meta(rulename, rules)) do
|
||||
local np = mesecon:addPosRule(pos, rule)
|
||||
if mesecon:rules_link(np, pos) then
|
||||
if mesecon:find_receptor_on(np, {}) then
|
||||
if mesecon:find_receptor_on(np, {}, mesecon:invertRule(rule)) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
@ -350,53 +492,65 @@ function mesecon:connected_to_receptor(pos)
|
||||
return false
|
||||
end
|
||||
|
||||
function mesecon:find_receptor_on(pos, checked)
|
||||
function mesecon:find_receptor_on(pos, checked, rulename)
|
||||
local node = minetest.get_node(pos)
|
||||
|
||||
if mesecon:is_receptor_on(node.name) then
|
||||
-- add current position to checked
|
||||
table.insert(checked, {x=pos.x, y=pos.y, z=pos.z})
|
||||
return true
|
||||
end
|
||||
|
||||
if mesecon:is_conductor(node.name) then
|
||||
local rules = mesecon:conductor_get_rules(node)
|
||||
local metaindex = mesecon:rule2metaindex(rulename, rules)
|
||||
-- find out if node has already been checked (to prevent from endless loop)
|
||||
for _, cp in ipairs(checked) do
|
||||
if mesecon:cmpPos(cp, pos) and cp.metaindex == metaindex then
|
||||
return false, checked
|
||||
end
|
||||
end
|
||||
-- add current position to checked
|
||||
table.insert(checked, {x=pos.x, y=pos.y, z=pos.z, metaindex = metaindex})
|
||||
for _, rule in ipairs(mesecon:rule2meta(rulename, rules)) do
|
||||
local np = mesecon:addPosRule(pos, rule)
|
||||
if mesecon:rules_link(np, pos) then
|
||||
if mesecon:find_receptor_on(np, checked, mesecon:invertRule(rule)) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
-- find out if node has already been checked (to prevent from endless loop)
|
||||
for _, cp in ipairs(checked) do
|
||||
if mesecon:cmpPos(cp, pos) then
|
||||
return false, checked
|
||||
end
|
||||
end
|
||||
|
||||
-- add current position to checked
|
||||
table.insert(checked, {x=pos.x, y=pos.y, z=pos.z})
|
||||
local node = minetest.env:get_node(pos)
|
||||
|
||||
if mesecon:is_receptor_on(node.name) then
|
||||
return true
|
||||
end
|
||||
|
||||
if mesecon:is_conductor(node.name) then
|
||||
local rules = mesecon:conductor_get_rules(node)
|
||||
for _, rule in ipairs(rules) do
|
||||
local np = mesecon:addPosRule(pos, rule)
|
||||
if mesecon:rules_link(np, pos) then
|
||||
if mesecon:find_receptor_on(np, checked) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function mesecon:rules_link(output, input, dug_outputrules) --output/input are positions (outputrules optional, used if node has been dug), second return value: the name of the affected input rule
|
||||
local outputnode = minetest.env:get_node(output)
|
||||
local inputnode = minetest.env:get_node(input)
|
||||
local outputnode = minetest.get_node(output)
|
||||
local inputnode = minetest.get_node(input)
|
||||
local outputrules = dug_outputrules or mesecon:get_any_outputrules (outputnode)
|
||||
local inputrules = mesecon:get_any_inputrules (inputnode)
|
||||
if not outputrules or not inputrules then
|
||||
return
|
||||
end
|
||||
|
||||
for _, outputrule in ipairs(outputrules) do
|
||||
for _, outputrule in ipairs(mesecon:flattenrules(outputrules)) do
|
||||
-- Check if output sends to input
|
||||
if mesecon:cmpPos(mesecon:addPosRule(output, outputrule), input) then
|
||||
for _, inputrule in ipairs(inputrules) do
|
||||
for _, inputrule in ipairs(mesecon:flattenrules(inputrules)) do
|
||||
-- Check if input accepts from output
|
||||
if mesecon:cmpPos(mesecon:addPosRule(input, inputrule), output) then
|
||||
return true, inputrule.name
|
||||
if inputrule.sx == nil or outputrule.sx == nil or mesecon:cmpSpecial(inputrule, outputrule) then
|
||||
return true, inputrule
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -404,20 +558,50 @@ function mesecon:rules_link(output, input, dug_outputrules) --output/input are p
|
||||
return false
|
||||
end
|
||||
|
||||
function mesecon:rules_link_rule_all(output, rule) --output/input are positions (outputrules optional, used if node has been dug), second return value: affected input rules
|
||||
local input = mesecon:addPosRule(output, rule)
|
||||
local inputnode = minetest.get_node(input)
|
||||
local inputrules = mesecon:get_any_inputrules (inputnode)
|
||||
if not inputrules then
|
||||
return {}
|
||||
end
|
||||
local rules = {}
|
||||
|
||||
for _, inputrule in ipairs(mesecon:flattenrules(inputrules)) do
|
||||
-- Check if input accepts from output
|
||||
if mesecon:cmpPos(mesecon:addPosRule(input, inputrule), output) then
|
||||
if inputrule.sx == nil or rule.sx == nil or mesecon:cmpSpecial(inputrule, rule) then
|
||||
rules[#rules+1] = inputrule
|
||||
end
|
||||
end
|
||||
end
|
||||
return rules
|
||||
end
|
||||
|
||||
function mesecon:rules_link_anydir(pos1, pos2)
|
||||
return mesecon:rules_link(pos1, pos2) or mesecon:rules_link(pos2, pos1)
|
||||
end
|
||||
|
||||
function mesecon:is_powered(pos)
|
||||
local node = minetest.env:get_node(pos)
|
||||
function mesecon:is_powered(pos, rule)
|
||||
local node = minetest.get_node(pos)
|
||||
local rules = mesecon:get_any_inputrules(node)
|
||||
if not rules then return false end
|
||||
|
||||
for _, rule in ipairs(rules) do
|
||||
if not rule then
|
||||
for _, rule in ipairs(mesecon:flattenrules(rules)) do
|
||||
local np = mesecon:addPosRule(pos, rule)
|
||||
local nn = minetest.env:get_node(np)
|
||||
local nn = minetest.get_node(np)
|
||||
|
||||
if (mesecon:is_conductor_on (nn.name) or mesecon:is_receptor_on (nn.name))
|
||||
if (mesecon:is_conductor_on (nn, mesecon:invertRule(rule)) or mesecon:is_receptor_on (nn.name))
|
||||
and mesecon:rules_link(np, pos) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
else
|
||||
local np = mesecon:addPosRule(pos, rule)
|
||||
local nn = minetest.get_node(np)
|
||||
|
||||
if (mesecon:is_conductor_on (nn, mesecon:invertRule(rule)) or mesecon:is_receptor_on (nn.name))
|
||||
and mesecon:rules_link(np, pos) then
|
||||
return true
|
||||
end
|
||||
@ -430,43 +614,83 @@ end
|
||||
function mesecon:rotate_rules_right(rules)
|
||||
local nr = {}
|
||||
for i, rule in ipairs(rules) do
|
||||
if rule.sx then
|
||||
table.insert(nr, {
|
||||
x = -rule.z,
|
||||
y = rule.y,
|
||||
z = rule.x,
|
||||
sx = -rule.sz,
|
||||
sy = rule.sy,
|
||||
sz = rule.sx})
|
||||
else
|
||||
table.insert(nr, {
|
||||
x = -rule.z,
|
||||
y = rule.y,
|
||||
z = rule.x})
|
||||
end
|
||||
end
|
||||
return nr
|
||||
end
|
||||
|
||||
function mesecon:rotate_rules_left(rules)
|
||||
local nr = {}
|
||||
for i, rule in ipairs(rules) do
|
||||
if rule.sx then
|
||||
table.insert(nr, {
|
||||
x = rule.z,
|
||||
y = rule.y,
|
||||
z = -rule.x,
|
||||
sx = rule.sz,
|
||||
sy = rule.sy,
|
||||
sz = -rule.sx})
|
||||
else
|
||||
table.insert(nr, {
|
||||
x = rule.z,
|
||||
y = rule.y,
|
||||
z = -rule.x})
|
||||
end
|
||||
end
|
||||
return nr
|
||||
end
|
||||
|
||||
function mesecon:rotate_rules_down(rules)
|
||||
local nr = {}
|
||||
for i, rule in ipairs(rules) do
|
||||
if rule.sx then
|
||||
table.insert(nr, {
|
||||
x = -rule.y,
|
||||
y = rule.x,
|
||||
z = rule.z,
|
||||
sx = -rule.sy,
|
||||
sy = rule.sx,
|
||||
sz = rule.sz})
|
||||
else
|
||||
table.insert(nr, {
|
||||
x = -rule.y,
|
||||
y = rule.x,
|
||||
z = rule.z})
|
||||
end
|
||||
end
|
||||
return nr
|
||||
end
|
||||
|
||||
function mesecon:rotate_rules_up(rules)
|
||||
local nr = {}
|
||||
for i, rule in ipairs(rules) do
|
||||
if rule.sx then
|
||||
table.insert(nr, {
|
||||
x = rule.y,
|
||||
y = -rule.x,
|
||||
z = rule.z,
|
||||
sx = rule.sy,
|
||||
sy = -rule.sx,
|
||||
sz = rule.sz})
|
||||
else
|
||||
table.insert(nr, {
|
||||
x = rule.y,
|
||||
y = -rule.x,
|
||||
z = rule.z})
|
||||
end
|
||||
end
|
||||
return nr
|
||||
end
|
||||
|
@ -0,0 +1,5 @@
|
||||
minetest.swap_node = minetest.swap_node or function(pos, node)
|
||||
local data = minetest.get_meta(pos):to_table()
|
||||
minetest.add_node(pos, node)
|
||||
minetest.get_meta(pos):from_table(data)
|
||||
end
|
@ -1,29 +1,38 @@
|
||||
mesecon.on_placenode = function (pos)
|
||||
local node = minetest.env:get_node(pos)
|
||||
mesecon.on_placenode = function (pos, node)
|
||||
if mesecon:is_receptor_on(node.name) then
|
||||
mesecon:receptor_on(pos, mesecon:receptor_get_rules(node))
|
||||
elseif mesecon:is_powered(pos) then
|
||||
if mesecon:is_conductor(node.name) then
|
||||
mesecon:turnon (pos)
|
||||
mesecon:receptor_on (pos, mesecon:conductor_get_rules(node))
|
||||
--mesecon:receptor_on (pos, mesecon:conductor_get_rules(node))
|
||||
else
|
||||
mesecon:changesignal(pos, node)
|
||||
mesecon:changesignal(pos, node, mesecon:effector_get_rules(node), "on")
|
||||
mesecon:activate(pos, node)
|
||||
end
|
||||
elseif mesecon:is_conductor_on(node.name) then
|
||||
mesecon:swap_node(pos, mesecon:get_conductor_off(node.name))
|
||||
elseif mesecon:is_conductor_on(node) then
|
||||
minetest.swap_node(pos, {name = mesecon:get_conductor_off(node)})
|
||||
elseif mesecon:is_effector_on (node.name) then
|
||||
mesecon:deactivate(pos, node)
|
||||
end
|
||||
end
|
||||
|
||||
mesecon.on_dignode = function (pos, node)
|
||||
if mesecon:is_conductor_on(node.name) then
|
||||
mesecon:receptor_off(pos, mesecon:conductor_get_rules(node))
|
||||
if mesecon:is_conductor_on(node) then
|
||||
mesecon:receptor_off_i(pos, mesecon:conductor_get_rules(node))
|
||||
elseif mesecon:is_receptor_on(node.name) then
|
||||
mesecon:receptor_off(pos, mesecon:receptor_get_rules(node))
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"group:overheat"},
|
||||
interval = 1.0,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("heat",0)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_on_placenode(mesecon.on_placenode)
|
||||
minetest.register_on_dignode(mesecon.on_dignode)
|
||||
|
@ -5,3 +5,5 @@ PRESSURE_PLATE_INTERVAL = 0.1
|
||||
OBJECT_DETECTOR_RADIUS = 6
|
||||
PISTON_MAXIMUM_PUSH = 15
|
||||
MOVESTONE_MAXIMUM_PUSH = 100
|
||||
MESECONS_GLOBALSTEP = true -- true = receptors/effectors won't be updated
|
||||
-- until next globalstep, decreases server load
|
||||
|
@ -1,19 +1,160 @@
|
||||
function mesecon:swap_node(pos, name)
|
||||
local node = minetest.env:get_node(pos)
|
||||
local data = minetest.env:get_meta(pos):to_table()
|
||||
node.name = name
|
||||
minetest.env:add_node(pos, node)
|
||||
minetest.env:get_meta(pos):from_table(data)
|
||||
end
|
||||
|
||||
function mesecon:move_node(pos, newpos)
|
||||
local node = minetest.env:get_node(pos)
|
||||
local meta = minetest.env:get_meta(pos):to_table()
|
||||
minetest.env:remove_node(pos)
|
||||
minetest.env:add_node(newpos, node)
|
||||
minetest.env:get_meta(pos):from_table(meta)
|
||||
local node = minetest.get_node(pos)
|
||||
local meta = minetest.get_meta(pos):to_table()
|
||||
minetest.remove_node(pos)
|
||||
minetest.add_node(newpos, node)
|
||||
minetest.get_meta(pos):from_table(meta)
|
||||
end
|
||||
|
||||
--[[ new functions:
|
||||
mesecon:flattenrules(allrules)
|
||||
mesecon:rule2bit(findrule, allrules)
|
||||
mesecon:rule2meta(findrule, allrules)
|
||||
dec2bin(n)
|
||||
mesecon:getstate(nodename, states)
|
||||
mesecon:getbinstate(nodename, states)
|
||||
mesecon:get_bit(binary, bit)
|
||||
mesecon:set_bit(binary, bit, value)
|
||||
mesecon:invertRule(r)
|
||||
--]]
|
||||
|
||||
function mesecon:flattenrules(allrules)
|
||||
--[[
|
||||
{
|
||||
{
|
||||
{xyz},
|
||||
{xyz},
|
||||
},
|
||||
{
|
||||
{xyz},
|
||||
{xyz},
|
||||
},
|
||||
}
|
||||
--]]
|
||||
if allrules[1] and
|
||||
allrules[1].x then
|
||||
return allrules
|
||||
end
|
||||
|
||||
local shallowrules = {}
|
||||
for _, metarule in ipairs( allrules) do
|
||||
for _, rule in ipairs(metarule ) do
|
||||
table.insert(shallowrules, rule)
|
||||
end
|
||||
end
|
||||
return shallowrules
|
||||
--[[
|
||||
{
|
||||
{xyz},
|
||||
{xyz},
|
||||
{xyz},
|
||||
{xyz},
|
||||
}
|
||||
--]]
|
||||
end
|
||||
|
||||
function mesecon:rule2bit(findrule, allrules)
|
||||
--get the bit of the metarule the rule is in, or bit 1
|
||||
if (allrules[1] and
|
||||
allrules[1].x) or
|
||||
not findrule then
|
||||
return 1
|
||||
end
|
||||
for m,metarule in ipairs( allrules) do
|
||||
for _, rule in ipairs(metarule ) do
|
||||
if mesecon:cmpPos(findrule, rule) and mesecon:cmpSpecial(findrule, rule) then
|
||||
return m
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mesecon:rule2metaindex(findrule, allrules)
|
||||
--get the metarule the rule is in, or allrules
|
||||
|
||||
if allrules[1].x then
|
||||
return nil
|
||||
end
|
||||
|
||||
if not(findrule) then
|
||||
return mesecon:flattenrules(allrules)
|
||||
end
|
||||
|
||||
for m, metarule in ipairs( allrules) do
|
||||
for _, rule in ipairs(metarule ) do
|
||||
if mesecon:cmpPos(findrule, rule) and mesecon:cmpSpecial(findrule, rule) then
|
||||
return m
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mesecon:rule2meta(findrule, allrules)
|
||||
local index = mesecon:rule2metaindex(findrule, allrules)
|
||||
if index == nil then
|
||||
if allrules[1].x then
|
||||
return allrules
|
||||
else
|
||||
return {}
|
||||
end
|
||||
end
|
||||
return allrules[index]
|
||||
end
|
||||
|
||||
if convert_base then
|
||||
print(
|
||||
"base2dec is tonumber(num,base1)\n"..
|
||||
"commonlib needs dec2base(num,base2)\n"..
|
||||
"and it needs base2base(num,base1,base2),\n"..
|
||||
"which is dec2base(tonumber(num,base1),base2)"
|
||||
)
|
||||
else
|
||||
function dec2bin(n)
|
||||
local x, y = math.floor(n / 2), n % 2
|
||||
if (n > 1) then
|
||||
return dec2bin(x)..y
|
||||
else
|
||||
return ""..y
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mesecon:getstate(nodename, states)
|
||||
for state, name in ipairs(states) do
|
||||
if name == nodename then
|
||||
return state
|
||||
end
|
||||
end
|
||||
error(nodename.." doesn't mention itself in "..dump(states))
|
||||
end
|
||||
|
||||
function mesecon:getbinstate(nodename, states)
|
||||
return dec2bin(mesecon:getstate(nodename, states)-1)
|
||||
end
|
||||
|
||||
function mesecon:get_bit(binary,bit)
|
||||
bit = bit or 1
|
||||
local c = binary:len()-(bit-1)
|
||||
return binary:sub(c,c) == "1"
|
||||
end
|
||||
|
||||
function mesecon:set_bit(binary,bit,value)
|
||||
if value == "1" then
|
||||
if not mesecon:get_bit(binary,bit) then
|
||||
return dec2bin(tonumber(binary,2)+math.pow(2,bit-1))
|
||||
end
|
||||
elseif value == "0" then
|
||||
if mesecon:get_bit(binary,bit) then
|
||||
return dec2bin(tonumber(binary,2)-math.pow(2,bit-1))
|
||||
end
|
||||
end
|
||||
return binary
|
||||
|
||||
end
|
||||
|
||||
function mesecon:invertRule(r)
|
||||
return {x = -r.x, y = -r.y, z = -r.z, sx = r.sx, sy = r.sy, sz = r.sz}
|
||||
end
|
||||
|
||||
function mesecon:addPosRule(p, r)
|
||||
return {x = p.x + r.x, y = p.y + r.y, z = p.z + r.z}
|
||||
@ -23,6 +164,10 @@ function mesecon:cmpPos(p1, p2)
|
||||
return (p1.x == p2.x and p1.y == p2.y and p1.z == p2.z)
|
||||
end
|
||||
|
||||
function mesecon:cmpSpecial(r1, r2)
|
||||
return (r1.sx == r2.sx and r1.sy == r2.sy and r1.sz == r2.sz)
|
||||
end
|
||||
|
||||
function mesecon:tablecopy(table) -- deep table copy
|
||||
local newtable = {}
|
||||
|
||||
|
@ -207,7 +207,7 @@ function mesecon:update_autoconnect(pos, secondcall, replace_old)
|
||||
mesecon:update_autoconnect(zmympos, true)
|
||||
end
|
||||
|
||||
nodename = minetest.env:get_node(pos).name
|
||||
nodename = minetest.get_node(pos).name
|
||||
if string.find(nodename, "mesecons:wire_") == nil and not replace_old then return nil end
|
||||
|
||||
if mesecon:rules_link_anydir(pos, xppos) then xp = 1 else xp = 0 end
|
||||
@ -235,14 +235,13 @@ function mesecon:update_autoconnect(pos, secondcall, replace_old)
|
||||
|
||||
|
||||
if string.find(nodename, "_off") ~= nil then
|
||||
minetest.env:set_node(pos, {name = "mesecons:wire_"..nodeid.."_off"})
|
||||
minetest.set_node(pos, {name = "mesecons:wire_"..nodeid.."_off"})
|
||||
else
|
||||
minetest.env:set_node(pos, {name = "mesecons:wire_"..nodeid.."_on" })
|
||||
minetest.set_node(pos, {name = "mesecons:wire_"..nodeid.."_on" })
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.registered_nodes["default:stone_with_mese"] == nil then
|
||||
|
||||
if not minetest.registered_nodes["default:stone_with_mese"] then --before MESE update, use old recipes
|
||||
minetest.register_craft({
|
||||
output = "mesecons:wire_00000000_off 18",
|
||||
recipe = {
|
||||
|
@ -1,4 +1,25 @@
|
||||
-- The BLINKY_PLANT
|
||||
minetest.register_node("mesecons_blinkyplant:blinky_plant", {
|
||||
drawtype = "plantlike",
|
||||
visual_scale = 1,
|
||||
tiles = {"jeija_blinky_plant_off.png"},
|
||||
inventory_image = "jeija_blinky_plant_off.png",
|
||||
walkable = false,
|
||||
groups = {dig_immediate=3, not_in_creative_inventory=1},
|
||||
drop="mesecons_blinkyplant:blinky_plant_off 1",
|
||||
description="Deactivated Blinky Plant",
|
||||
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},
|
||||
},
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.off
|
||||
}},
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
minetest.set_node(pos, {name="mesecons_blinkyplant:blinky_plant_off"})
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("mesecons_blinkyplant:blinky_plant_off", {
|
||||
drawtype = "plantlike",
|
||||
@ -16,7 +37,10 @@ minetest.register_node("mesecons_blinkyplant:blinky_plant_off", {
|
||||
},
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.off
|
||||
}}
|
||||
}},
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
minetest.set_node(pos, {name="mesecons_blinkyplant:blinky_plant"})
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("mesecons_blinkyplant:blinky_plant_on", {
|
||||
@ -37,7 +61,11 @@ minetest.register_node("mesecons_blinkyplant:blinky_plant_on", {
|
||||
},
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.on
|
||||
}}
|
||||
}},
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
minetest.set_node(pos, {name = "mesecons_blinkyplant:blinky_plant"})
|
||||
mesecon:receptor_off(pos)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
@ -54,8 +82,8 @@ minetest.register_abm(
|
||||
interval = BLINKY_PLANT_INTERVAL,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
--minetest.env:remove_node(pos)
|
||||
minetest.env:add_node(pos, {name="mesecons_blinkyplant:blinky_plant_on"})
|
||||
--minetest.remove_node(pos)
|
||||
minetest.add_node(pos, {name="mesecons_blinkyplant:blinky_plant_on"})
|
||||
nodeupdate(pos)
|
||||
mesecon:receptor_on(pos)
|
||||
end,
|
||||
@ -66,8 +94,8 @@ minetest.register_abm({
|
||||
interval = BLINKY_PLANT_INTERVAL,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
--minetest.env:remove_node(pos)
|
||||
minetest.env:add_node(pos, {name="mesecons_blinkyplant:blinky_plant_off"})
|
||||
--minetest.remove_node(pos)
|
||||
minetest.add_node(pos, {name="mesecons_blinkyplant:blinky_plant_off"})
|
||||
nodeupdate(pos)
|
||||
mesecon:receptor_off(pos)
|
||||
end,
|
||||
|
@ -3,9 +3,9 @@
|
||||
-- and then turns off again
|
||||
|
||||
mesecon.button_turnoff = function (pos)
|
||||
local node = minetest.env:get_node(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name=="mesecons_button:button_on" then --has not been dug
|
||||
mesecon:swap_node(pos, "mesecons_button:button_off")
|
||||
minetest.swap_node(pos, {name = "mesecons_button:button_off", param2=node.param2})
|
||||
minetest.sound_play("mesecons_button_pop", {pos=pos})
|
||||
local rules = mesecon.rules.buttonlike_get(node)
|
||||
mesecon:receptor_off(pos, rules)
|
||||
@ -41,7 +41,7 @@ minetest.register_node("mesecons_button:button_off", {
|
||||
groups = {dig_immediate=2, mesecon_needs_receiver = 1},
|
||||
description = "Button",
|
||||
on_punch = function (pos, node)
|
||||
mesecon:swap_node(pos, "mesecons_button:button_on")
|
||||
minetest.swap_node(pos, {name = "mesecons_button:button_on", param2=node.param2})
|
||||
mesecon:receptor_on(pos, mesecon.rules.buttonlike_get(node))
|
||||
minetest.sound_play("mesecons_button_push", {pos=pos})
|
||||
minetest.after(1, mesecon.button_turnoff, pos)
|
||||
|
@ -16,7 +16,7 @@ minetest.register_chatcommand("tell", {
|
||||
minetest.chat_send_player(name, "Invalid usage: " .. param)
|
||||
return
|
||||
end
|
||||
if not minetest.env:get_player_by_name(target) then
|
||||
if not minetest.get_player_by_name(target) then
|
||||
minetest.chat_send_player(name, "Invalid target: " .. target)
|
||||
end
|
||||
minetest.chat_send_player(target, name .. " whispers: " .. message, false)
|
||||
@ -41,7 +41,7 @@ minetest.register_chatcommand("hp", {
|
||||
minetest.chat_send_player(name, "Invalid usage: " .. param)
|
||||
return
|
||||
end
|
||||
local player = minetest.env:get_player_by_name(target)
|
||||
local player = minetest.get_player_by_name(target)
|
||||
if player then
|
||||
player:set_hp(value)
|
||||
else
|
||||
@ -72,7 +72,7 @@ local initialize_data = function(meta, player, command, param)
|
||||
end
|
||||
|
||||
local construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
meta:set_string("player", "@nearest")
|
||||
meta:set_string("command", "time")
|
||||
@ -85,14 +85,17 @@ end
|
||||
|
||||
local after_place = function(pos, placer)
|
||||
if placer then
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("owner", placer:get_player_name())
|
||||
initialize_data(meta, "@nearest", "time", "7000")
|
||||
end
|
||||
end
|
||||
|
||||
local receive_fields = function(pos, formname, fields, sender)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
if fields.quit then
|
||||
return
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
if fields.nearest then
|
||||
initialize_data(meta, "@nearest", fields.command, fields.param)
|
||||
elseif fields.farthest then
|
||||
@ -144,9 +147,9 @@ local commandblock_action_on = function(pos, node)
|
||||
return
|
||||
end
|
||||
|
||||
mesecon:swap_node(pos, "mesecons_commandblock:commandblock_on")
|
||||
minetest.swap_node(pos, {name = "mesecons_commandblock:commandblock_on"})
|
||||
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local command = minetest.chatcommands[meta:get_string("command")]
|
||||
if command == nil then
|
||||
return
|
||||
@ -166,7 +169,7 @@ end
|
||||
|
||||
local commandblock_action_off = function(pos, node)
|
||||
if node.name == "mesecons_commandblock:commandblock_on" then
|
||||
mesecon:swap_node(pos, "mesecons_commandblock:commandblock_off")
|
||||
minetest.swap_node(pos, {name = "mesecons_commandblock:commandblock_off"})
|
||||
end
|
||||
end
|
||||
|
||||
@ -179,7 +182,7 @@ minetest.register_node("mesecons_commandblock:commandblock_off", {
|
||||
after_place_node = after_place,
|
||||
on_receive_fields = receive_fields,
|
||||
can_dig = function(pos,player)
|
||||
local owner = minetest.env:get_meta(pos):get_string("owner")
|
||||
local owner = minetest.get_meta(pos):get_string("owner")
|
||||
return owner == "" or owner == player:get_player_name()
|
||||
end,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
@ -197,7 +200,7 @@ minetest.register_node("mesecons_commandblock:commandblock_on", {
|
||||
after_place_node = after_place,
|
||||
on_receive_fields = receive_fields,
|
||||
can_dig = function(pos,player)
|
||||
local owner = minetest.env:get_meta(pos):get_string("owner")
|
||||
local owner = minetest.get_meta(pos):get_string("owner")
|
||||
return owner == "" or owner == player:get_player_name()
|
||||
end,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
|
@ -38,27 +38,27 @@ function doors:register_door(name, def)
|
||||
local tb = def.tiles_bottom
|
||||
|
||||
local function after_dig_node(pos, name)
|
||||
if minetest.env:get_node(pos).name == name then
|
||||
minetest.env:remove_node(pos)
|
||||
if minetest.get_node(pos).name == name then
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_rightclick(pos, dir, check_name, replace, replace_dir, params)
|
||||
pos.y = pos.y+dir
|
||||
if not minetest.env:get_node(pos).name == check_name then
|
||||
if not minetest.get_node(pos).name == check_name then
|
||||
return
|
||||
end
|
||||
local p2 = minetest.env:get_node(pos).param2
|
||||
local p2 = minetest.get_node(pos).param2
|
||||
p2 = params[p2+1]
|
||||
|
||||
local meta = minetest.env:get_meta(pos):to_table()
|
||||
minetest.env:set_node(pos, {name=replace_dir, param2=p2})
|
||||
minetest.env:get_meta(pos):from_table(meta)
|
||||
local meta = minetest.get_meta(pos):to_table()
|
||||
minetest.set_node(pos, {name=replace_dir, param2=p2})
|
||||
minetest.get_meta(pos):from_table(meta)
|
||||
|
||||
pos.y = pos.y-dir
|
||||
meta = minetest.env:get_meta(pos):to_table()
|
||||
minetest.env:set_node(pos, {name=replace, param2=p2})
|
||||
minetest.env:get_meta(pos):from_table(meta)
|
||||
meta = minetest.get_meta(pos):to_table()
|
||||
minetest.set_node(pos, {name=replace, param2=p2})
|
||||
minetest.get_meta(pos):from_table(meta)
|
||||
end
|
||||
|
||||
local function on_mesecons_signal_open (pos, node)
|
||||
@ -73,7 +73,7 @@ function doors:register_door(name, def)
|
||||
if not def.only_placer_can_open then
|
||||
return true
|
||||
end
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local pn = player:get_player_name()
|
||||
return meta:get_string("doors_owner") == pn
|
||||
end
|
||||
|
@ -30,14 +30,14 @@ end
|
||||
local delayer_activate = function(pos, node)
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
local time = def.delayer_time
|
||||
mesecon:swap_node(pos, def.delayer_onstate)
|
||||
minetest.swap_node(pos, {name = def.delayer_onstate, param2=node.param2})
|
||||
minetest.after(time, delayer_turnon , {pos = pos, node = node})
|
||||
end
|
||||
|
||||
local delayer_deactivate = function(pos, node)
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
local time = def.delayer_time
|
||||
mesecon:swap_node(pos, def.delayer_offstate)
|
||||
minetest.swap_node(pos, {name = def.delayer_offstate, param2=node.param2})
|
||||
minetest.after(time, delayer_turnoff, {pos = pos, node = node})
|
||||
end
|
||||
|
||||
@ -99,13 +99,13 @@ minetest.register_node("mesecons_delayer:delayer_off_"..tostring(i), {
|
||||
drop = 'mesecons_delayer:delayer_off_1',
|
||||
on_punch = function (pos, node)
|
||||
if node.name=="mesecons_delayer:delayer_off_1" then
|
||||
mesecon:swap_node(pos,"mesecons_delayer:delayer_off_2")
|
||||
minetest.swap_node(pos, {name = "mesecons_delayer:delayer_off_2", param2=node.param2})
|
||||
elseif node.name=="mesecons_delayer:delayer_off_2" then
|
||||
mesecon:swap_node(pos,"mesecons_delayer:delayer_off_3")
|
||||
minetest.swap_node(pos, {name = "mesecons_delayer:delayer_off_3", param2=node.param2})
|
||||
elseif node.name=="mesecons_delayer:delayer_off_3" then
|
||||
mesecon:swap_node(pos,"mesecons_delayer:delayer_off_4")
|
||||
minetest.swap_node(pos, {name = "mesecons_delayer:delayer_off_4", param2=node.param2})
|
||||
elseif node.name=="mesecons_delayer:delayer_off_4" then
|
||||
mesecon:swap_node(pos,"mesecons_delayer:delayer_off_1")
|
||||
minetest.swap_node(pos, {name = "mesecons_delayer:delayer_off_1", param2=node.param2})
|
||||
end
|
||||
end,
|
||||
delayer_time = delaytime,
|
||||
@ -154,13 +154,13 @@ minetest.register_node("mesecons_delayer:delayer_on_"..tostring(i), {
|
||||
drop = 'mesecons_delayer:delayer_off_1',
|
||||
on_punch = function (pos, node)
|
||||
if node.name=="mesecons_delayer:delayer_on_1" then
|
||||
mesecon:swap_node(pos,"mesecons_delayer:delayer_on_2")
|
||||
minetest.swap_node(pos, {name = "mesecons_delayer:delayer_on_2", param2=node.param2})
|
||||
elseif node.name=="mesecons_delayer:delayer_on_2" then
|
||||
mesecon:swap_node(pos,"mesecons_delayer:delayer_on_3")
|
||||
minetest.swap_node(pos, {name = "mesecons_delayer:delayer_on_3", param2=node.param2})
|
||||
elseif node.name=="mesecons_delayer:delayer_on_3" then
|
||||
mesecon:swap_node(pos,"mesecons_delayer:delayer_on_4")
|
||||
minetest.swap_node(pos, {name = "mesecons_delayer:delayer_on_4", param2=node.param2})
|
||||
elseif node.name=="mesecons_delayer:delayer_on_4" then
|
||||
mesecon:swap_node(pos,"mesecons_delayer:delayer_on_1")
|
||||
minetest.swap_node(pos, {name = "mesecons_delayer:delayer_on_1", param2=node.param2})
|
||||
end
|
||||
end,
|
||||
delayer_time = delaytime,
|
||||
|
@ -3,14 +3,17 @@
|
||||
-- The radius can be specified in mesecons/settings.lua
|
||||
|
||||
local object_detector_make_formspec = function (pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec", "size[9,2.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}]")
|
||||
end
|
||||
|
||||
local object_detector_on_receive_fields = function(pos, formname, fields)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
if fields.quit then
|
||||
return
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("scanname", fields.scanname)
|
||||
meta:set_string("digiline_channel", fields.digiline_channel)
|
||||
object_detector_make_formspec(pos)
|
||||
@ -18,10 +21,10 @@ end
|
||||
|
||||
-- returns true if player was found, false if not
|
||||
local object_detector_scan = function (pos)
|
||||
local objs = minetest.env:get_objects_inside_radius(pos, OBJECT_DETECTOR_RADIUS)
|
||||
local objs = minetest.get_objects_inside_radius(pos, OBJECT_DETECTOR_RADIUS)
|
||||
for k, obj in pairs(objs) do
|
||||
local isname = obj:get_player_name() -- "" is returned if it is not a player; "" ~= nil!
|
||||
local scanname = minetest.env:get_meta(pos):get_string("scanname")
|
||||
local scanname = minetest.get_meta(pos):get_string("scanname")
|
||||
if (isname == scanname and isname ~= "") or (isname ~= "" and scanname == "") then -- player with scanname found or not scanname specified
|
||||
return true
|
||||
end
|
||||
@ -33,7 +36,7 @@ end
|
||||
object_detector_digiline = {
|
||||
effector = {
|
||||
action = function (pos, node, channel, msg)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local active_channel = meta:get_string("digiline_channel")
|
||||
if channel == active_channel then
|
||||
meta:set_string("scanname", msg)
|
||||
@ -88,7 +91,7 @@ minetest.register_abm(
|
||||
chance = 1,
|
||||
action = function(pos)
|
||||
if object_detector_scan(pos) then
|
||||
mesecon:swap_node(pos, "mesecons_detector:object_detector_on")
|
||||
minetest.swap_node(pos, {name = "mesecons_detector:object_detector_on"})
|
||||
mesecon:receptor_on(pos)
|
||||
end
|
||||
end,
|
||||
@ -100,7 +103,7 @@ minetest.register_abm(
|
||||
chance = 1,
|
||||
action = function(pos)
|
||||
if not object_detector_scan(pos) then
|
||||
mesecon:swap_node(pos, "mesecons_detector:object_detector_off")
|
||||
minetest.swap_node(pos, {name = "mesecons_detector:object_detector_off"})
|
||||
mesecon:receptor_off(pos)
|
||||
end
|
||||
end,
|
||||
|
@ -1,49 +0,0 @@
|
||||
-- CODE NOT ACTIVE
|
||||
|
||||
local crossing_get_rules = function(node)
|
||||
--TODO: calculate the real port states and use rules to link to them only if
|
||||
end
|
||||
|
||||
minetest.register_node("mesecons_extrawires:crossing_on", {
|
||||
drawtype = "nodebox",
|
||||
tiles = {"jeija_insulated_wire_sides_on.png"},
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
stack_max = 99,
|
||||
selection_box = {type="fixed", fixed={-16/32-0.0001, -18/32, -16/32-0.001, 16/32+0.001, -5/32, 16/32+0.001}},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 },
|
||||
{ -3/32, -17/32, -16/32-0.001, 3/32, -13/32, -6/32 },
|
||||
{ -3/32, -13/32, -9/32, 3/32, -6/32, -6/32 },
|
||||
{ -3/32, -9/32, -9/32, 3/32, -6/32, 9/32 },
|
||||
{ -3/32, -13/32, 6/32, 3/32, -6/32, 9/32 },
|
||||
{ -3/32, -17/32, 6/32, 3/32, -13/32, 16/32+0.001 },
|
||||
},
|
||||
},
|
||||
groups = {dig_immediate=3, mesecon=3, mesecon_conductor_craftable=1, not_in_creative_inventory=1},
|
||||
mesecons = {
|
||||
receptor = {
|
||||
state = mesecon.state.on,
|
||||
rules = crossing_get_rules,
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "mesecons_extrawires:crossing",
|
||||
recipe = {
|
||||
"mesecons_insulated:insulated_off",
|
||||
"mesecons_insulated:insulated_off",
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "mesecons_insulated:insulated_off 2",
|
||||
recipe = {
|
||||
"mesecons_extrawires:crossing",
|
||||
},
|
||||
})
|
176
mesecons_extrawires/crossover.lua
Normal file
@ -0,0 +1,176 @@
|
||||
function crossover_get_rules(node)
|
||||
return {
|
||||
{--first wire
|
||||
{x=-1,y=0,z=0},
|
||||
{x=1,y=0,z=0},
|
||||
},
|
||||
{--second wire
|
||||
{x=0,y=0,z=-1},
|
||||
{x=0,y=0,z=1},
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
local crossover_states = {
|
||||
"mesecons_extrawires:crossover_off",
|
||||
"mesecons_extrawires:crossover_01",
|
||||
"mesecons_extrawires:crossover_10",
|
||||
"mesecons_extrawires:crossover_on",
|
||||
}
|
||||
|
||||
minetest.register_node("mesecons_extrawires:crossover_off", {
|
||||
description = "Insulated Crossover",
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"jeija_insulated_wire_crossing_tb_off.png",
|
||||
"jeija_insulated_wire_crossing_tb_off.png",
|
||||
"jeija_insulated_wire_ends_off.png"
|
||||
},
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
stack_max = 99,
|
||||
selection_box = {type="fixed", fixed={-16/32-0.0001, -18/32, -16/32-0.001, 16/32+0.001, -5/32, 16/32+0.001}},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 },
|
||||
{ -3/32, -17/32, -16/32-0.001, 3/32, -13/32, -6/32 },
|
||||
{ -3/32, -13/32, -9/32, 3/32, -6/32, -6/32 },
|
||||
{ -3/32, -9/32, -9/32, 3/32, -6/32, 9/32 },
|
||||
{ -3/32, -13/32, 6/32, 3/32, -6/32, 9/32 },
|
||||
{ -3/32, -17/32, 6/32, 3/32, -13/32, 16/32+0.001 },
|
||||
},
|
||||
},
|
||||
groups = {dig_immediate=3, mesecon=3, mesecon_conductor_craftable=1},
|
||||
mesecons = {
|
||||
conductor = {
|
||||
states = crossover_states,
|
||||
rules = crossover_get_rules(),
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_node("mesecons_extrawires:crossover_01", {
|
||||
description = "You hacker you!",
|
||||
drop = "mesecons_extrawires:crossover_off",
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"jeija_insulated_wire_crossing_tb_01.png",
|
||||
"jeija_insulated_wire_crossing_tb_01.png",
|
||||
"jeija_insulated_wire_ends_01x.png",
|
||||
"jeija_insulated_wire_ends_01x.png",
|
||||
"jeija_insulated_wire_ends_01z.png",
|
||||
"jeija_insulated_wire_ends_01z.png"
|
||||
},
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
stack_max = 99,
|
||||
selection_box = {type="fixed", fixed={-16/32-0.0001, -18/32, -16/32-0.001, 16/32+0.001, -5/32, 16/32+0.001}},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 },
|
||||
{ -3/32, -17/32, -16/32-0.001, 3/32, -13/32, -6/32 },
|
||||
{ -3/32, -13/32, -9/32, 3/32, -6/32, -6/32 },
|
||||
{ -3/32, -9/32, -9/32, 3/32, -6/32, 9/32 },
|
||||
{ -3/32, -13/32, 6/32, 3/32, -6/32, 9/32 },
|
||||
{ -3/32, -17/32, 6/32, 3/32, -13/32, 16/32+0.001 },
|
||||
},
|
||||
},
|
||||
groups = {dig_immediate=3, mesecon=3, mesecon_conductor_craftable=1, not_in_creative_inventory=1},
|
||||
mesecons = {
|
||||
conductor = {
|
||||
states = crossover_states,
|
||||
rules = crossover_get_rules(),
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_node("mesecons_extrawires:crossover_10", {
|
||||
description = "You hacker you!",
|
||||
drop = "mesecons_extrawires:crossover_off",
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"jeija_insulated_wire_crossing_tb_10.png",
|
||||
"jeija_insulated_wire_crossing_tb_10.png",
|
||||
"jeija_insulated_wire_ends_10x.png",
|
||||
"jeija_insulated_wire_ends_10x.png",
|
||||
"jeija_insulated_wire_ends_10z.png",
|
||||
"jeija_insulated_wire_ends_10z.png"
|
||||
},
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
stack_max = 99,
|
||||
selection_box = {type="fixed", fixed={-16/32-0.0001, -18/32, -16/32-0.001, 16/32+0.001, -5/32, 16/32+0.001}},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 },
|
||||
{ -3/32, -17/32, -16/32-0.001, 3/32, -13/32, -6/32 },
|
||||
{ -3/32, -13/32, -9/32, 3/32, -6/32, -6/32 },
|
||||
{ -3/32, -9/32, -9/32, 3/32, -6/32, 9/32 },
|
||||
{ -3/32, -13/32, 6/32, 3/32, -6/32, 9/32 },
|
||||
{ -3/32, -17/32, 6/32, 3/32, -13/32, 16/32+0.001 },
|
||||
},
|
||||
},
|
||||
groups = {dig_immediate=3, mesecon=3, mesecon_conductor_craftable=1, not_in_creative_inventory=1},
|
||||
mesecons = {
|
||||
conductor = {
|
||||
states = crossover_states,
|
||||
rules = crossover_get_rules(),
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_node("mesecons_extrawires:crossover_on", {
|
||||
description = "You hacker you!",
|
||||
drop = "mesecons_extrawires:crossover_off",
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"jeija_insulated_wire_crossing_tb_on.png",
|
||||
"jeija_insulated_wire_crossing_tb_on.png",
|
||||
"jeija_insulated_wire_ends_on.png",
|
||||
"jeija_insulated_wire_ends_on.png",
|
||||
"jeija_insulated_wire_ends_on.png",
|
||||
"jeija_insulated_wire_ends_on.png"
|
||||
},
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
stack_max = 99,
|
||||
selection_box = {type="fixed", fixed={-16/32-0.0001, -18/32, -16/32-0.001, 16/32+0.001, -5/32, 16/32+0.001}},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 },
|
||||
{ -3/32, -17/32, -16/32-0.001, 3/32, -13/32, -6/32 },
|
||||
{ -3/32, -13/32, -9/32, 3/32, -6/32, -6/32 },
|
||||
{ -3/32, -9/32, -9/32, 3/32, -6/32, 9/32 },
|
||||
{ -3/32, -13/32, 6/32, 3/32, -6/32, 9/32 },
|
||||
{ -3/32, -17/32, 6/32, 3/32, -13/32, 16/32+0.001 },
|
||||
},
|
||||
},
|
||||
groups = {dig_immediate=3, mesecon=3, mesecon_conductor_craftable=1, not_in_creative_inventory=1},
|
||||
mesecons = {
|
||||
conductor = {
|
||||
states = crossover_states,
|
||||
rules = crossover_get_rules(),
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "mesecons_extrawires:crossover_off",
|
||||
recipe = {
|
||||
"mesecons_insulated:insulated_off",
|
||||
"mesecons_insulated:insulated_off",
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "mesecons_insulated:insulated_off 2",
|
||||
recipe = {
|
||||
"mesecons_extrawires:crossover_off",
|
||||
},
|
||||
})
|
@ -1 +1,2 @@
|
||||
default
|
||||
mesecons
|
||||
|
@ -1,5 +1,4 @@
|
||||
-- dofile(minetest.get_modpath("mesecons_extrawires").."/crossing.lua");
|
||||
-- The crossing code is not active right now because it is hard to maintain
|
||||
dofile(minetest.get_modpath("mesecons_extrawires").."/crossover.lua");
|
||||
dofile(minetest.get_modpath("mesecons_extrawires").."/tjunction.lua");
|
||||
dofile(minetest.get_modpath("mesecons_extrawires").."/corner.lua");
|
||||
dofile(minetest.get_modpath("mesecons_extrawires").."/vertical.lua");
|
||||
|
@ -1,72 +1,68 @@
|
||||
local vbox = {
|
||||
local vertical_box = {
|
||||
type = "fixed",
|
||||
fixed = {-1/16, -.5, -1/16, 1/16, .5, 1/16}
|
||||
fixed = {-1/16, -8/16, -1/16, 1/16, 8/16, 1/16}
|
||||
}
|
||||
|
||||
local tbox = {
|
||||
local top_box = {
|
||||
type = "fixed",
|
||||
fixed = {{-.5, -.5, -.5, .5, -.5 + 1/16, .5}}
|
||||
fixed = {{-8/16, -8/16, -8/16, 8/16, -7/16, 8/16}}
|
||||
}
|
||||
|
||||
local bbox = {
|
||||
local bottom_box = {
|
||||
type = "fixed",
|
||||
fixed = {{ -.5, -.5 , -.5, .5, -.5+1/16, .5},
|
||||
{-1/16, -.5+1/16, -1/16, 1/16, .5 , 1/16}}
|
||||
fixed = {
|
||||
{-8/16, -8/16, -8/16, 8/16, -7/16, 8/16},
|
||||
{-1/16, -7/16, -1/16, 1/16, 8/16, 1/16},
|
||||
}
|
||||
}
|
||||
|
||||
local vrules =
|
||||
{{x = 0, y = 1, z = 0},
|
||||
{x = 0, y =-1, z = 0}}
|
||||
local vertical_rules = {
|
||||
{x=0, y=1, z=0},
|
||||
{x=0, y=-1, z=0},
|
||||
}
|
||||
|
||||
local trules =
|
||||
{{x = 1, y = 0, z = 0},
|
||||
local top_rules = {
|
||||
{x=1,y=0, z=0},
|
||||
{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 brules =
|
||||
{{x = 1, y = 0, z = 0},
|
||||
local bottom_rules = {
|
||||
{x=1, y=0, z=0},
|
||||
{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 vertical_updatepos = function (pos)
|
||||
local node = minetest.env:get_node(pos)
|
||||
if minetest.registered_nodes[node.name].is_vertical_conductor then
|
||||
local node_above = minetest.env:get_node(mesecon:addPosRule(pos, vrules[1]))
|
||||
local node_below = minetest.env:get_node(mesecon:addPosRule(pos, vrules[2]))
|
||||
local node = minetest.get_node(pos)
|
||||
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].is_vertical_conductor then
|
||||
local node_above = minetest.get_node(mesecon:addPosRule(pos, vertical_rules[1]))
|
||||
local node_below = minetest.get_node(mesecon:addPosRule(pos, vertical_rules[2]))
|
||||
local namestate = minetest.registered_nodes[node.name].vertical_conductor_state
|
||||
|
||||
-- above and below: vertical mesecon
|
||||
if minetest.registered_nodes[node_above.name].is_vertical_conductor
|
||||
and minetest.registered_nodes[node_below.name].is_vertical_conductor then
|
||||
minetest.env:add_node (pos,
|
||||
{name = "mesecons_extrawires:vertical_"..namestate})
|
||||
local above = minetest.registered_nodes[node_above.name] and minetest.registered_nodes[node_above.name].is_vertical_conductor
|
||||
local below = minetest.registered_nodes[node_below.name] and minetest.registered_nodes[node_below.name].is_vertical_conductor
|
||||
|
||||
-- above only: bottom
|
||||
elseif minetest.registered_nodes[node_above.name].is_vertical_conductor
|
||||
and not minetest.registered_nodes[node_below.name].is_vertical_conductor then
|
||||
minetest.env:add_node (pos,
|
||||
{name = "mesecons_extrawires:vertical_bottom_"..namestate})
|
||||
|
||||
-- below only: top
|
||||
elseif not minetest.registered_nodes[node_above.name].is_vertical_conductor
|
||||
and minetest.registered_nodes[node_below.name].is_vertical_conductor then
|
||||
minetest.env:add_node (pos,
|
||||
{name = "mesecons_extrawires:vertical_top_"..namestate})
|
||||
if above and below then -- above and below: vertical mesecon
|
||||
minetest.add_node(pos, {name = "mesecons_extrawires:vertical_" .. namestate})
|
||||
elseif above and not below then -- above only: bottom
|
||||
minetest.add_node(pos, {name = "mesecons_extrawires:vertical_bottom_" .. namestate})
|
||||
elseif not above and below then -- below only: top
|
||||
minetest.add_node(pos, {name = "mesecons_extrawires:vertical_top_" .. namestate})
|
||||
else -- no vertical wire above, no vertical wire below: use default wire
|
||||
minetest.env:add_node (pos,
|
||||
{name = "mesecons_extrawires:vertical_"..namestate})
|
||||
minetest.add_node(pos, {name = "mesecons_extrawires:vertical_" .. namestate})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local vertical_update = function (pos, node)
|
||||
vertical_updatepos(pos) -- this one
|
||||
vertical_updatepos(mesecon:addPosRule(pos, vrules[1])) -- above
|
||||
vertical_updatepos(mesecon:addPosRule(pos, vrules[2])) -- below
|
||||
vertical_updatepos(mesecon:addPosRule(pos, vertical_rules[1])) -- above
|
||||
vertical_updatepos(mesecon:addPosRule(pos, vertical_rules[2])) -- below
|
||||
end
|
||||
|
||||
-- Vertical wire
|
||||
@ -78,18 +74,18 @@ minetest.register_node("mesecons_extrawires:vertical_on", {
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
groups = {dig_immediate=3, not_in_creative_inventory=1},
|
||||
selection_box = vbox,
|
||||
node_box = vbox,
|
||||
selection_box = vertical_box,
|
||||
node_box = vertical_box,
|
||||
is_vertical_conductor = true,
|
||||
vertical_conductor_state = "on",
|
||||
mesecons = {conductor = {
|
||||
state = mesecon.state.on,
|
||||
offstate = "mesecons_extrawires:vertical_off",
|
||||
rules = vrules
|
||||
rules = vertical_rules,
|
||||
}},
|
||||
drop = {"mesecons_extrawires:vertical_off"},
|
||||
drop = "mesecons_extrawires:vertical_off",
|
||||
after_place_node = vertical_update,
|
||||
after_dig_node = vertical_update
|
||||
after_dig_node = vertical_update,
|
||||
})
|
||||
|
||||
minetest.register_node("mesecons_extrawires:vertical_off", {
|
||||
@ -100,17 +96,17 @@ minetest.register_node("mesecons_extrawires:vertical_off", {
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
groups = {dig_immediate=3},
|
||||
selection_box = vbox,
|
||||
node_box = vbox,
|
||||
selection_box = vertical_box,
|
||||
node_box = vertical_box,
|
||||
is_vertical_conductor = true,
|
||||
vertical_conductor_state = "off",
|
||||
mesecons = {conductor = {
|
||||
state = mesecon.state.off,
|
||||
onstate = "mesecons_extrawires:vertical_on",
|
||||
rules = vrules
|
||||
rules = vertical_rules,
|
||||
}},
|
||||
after_place_node = vertical_update,
|
||||
after_dig_node = vertical_update
|
||||
after_dig_node = vertical_update,
|
||||
})
|
||||
|
||||
-- Vertical wire top
|
||||
@ -122,18 +118,18 @@ minetest.register_node("mesecons_extrawires:vertical_top_on", {
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
groups = {dig_immediate=3, not_in_creative_inventory=1},
|
||||
selection_box = tbox,
|
||||
node_box = tbox,
|
||||
selection_box = top_box,
|
||||
node_box = top_box,
|
||||
is_vertical_conductor = true,
|
||||
vertical_conductor_state = "on",
|
||||
mesecons = {conductor = {
|
||||
state = mesecon.state.on,
|
||||
offstate = "mesecons_extrawires:vertical_top_off",
|
||||
rules = trules
|
||||
rules = top_rules,
|
||||
}},
|
||||
drop = {"mesecons_extrawires:vertical_off"},
|
||||
drop = "mesecons_extrawires:vertical_off",
|
||||
after_place_node = vertical_update,
|
||||
after_dig_node = vertical_update
|
||||
after_dig_node = vertical_update,
|
||||
})
|
||||
|
||||
minetest.register_node("mesecons_extrawires:vertical_top_off", {
|
||||
@ -144,18 +140,18 @@ minetest.register_node("mesecons_extrawires:vertical_top_off", {
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
groups = {dig_immediate=3, not_in_creative_inventory=1},
|
||||
selection_box = tbox,
|
||||
node_box = tbox,
|
||||
selection_box = top_box,
|
||||
node_box = top_box,
|
||||
is_vertical_conductor = true,
|
||||
vertical_conductor_state = "off",
|
||||
mesecons = {conductor = {
|
||||
state = mesecon.state.off,
|
||||
onstate = "mesecons_extrawires:vertical_top_on",
|
||||
rules = trules
|
||||
rules = top_rules,
|
||||
}},
|
||||
drop = {"mesecons_extrawires:vertical_off"},
|
||||
drop = "mesecons_extrawires:vertical_off",
|
||||
after_place_node = vertical_update,
|
||||
after_dig_node = vertical_update
|
||||
after_dig_node = vertical_update,
|
||||
})
|
||||
|
||||
-- Vertical wire bottom
|
||||
@ -168,16 +164,16 @@ minetest.register_node("mesecons_extrawires:vertical_bottom_on", {
|
||||
sunlight_propagates = true,
|
||||
vertical_conductor_state = "on",
|
||||
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
|
||||
selection_box = bbox,
|
||||
node_box = bbox,
|
||||
selection_box = bottom_box,
|
||||
node_box = bottom_box,
|
||||
mesecons = {conductor = {
|
||||
state = mesecon.state.on,
|
||||
offstate = "mesecons_extrawires:vertical_bottom_off",
|
||||
rules = brules
|
||||
rules = bottom_rules,
|
||||
}},
|
||||
drop = {"mesecons_extrawires:vertical_off"},
|
||||
drop = "mesecons_extrawires:vertical_off",
|
||||
after_place_node = vertical_update,
|
||||
after_dig_node = vertical_update
|
||||
after_dig_node = vertical_update,
|
||||
})
|
||||
|
||||
minetest.register_node("mesecons_extrawires:vertical_bottom_off", {
|
||||
@ -188,18 +184,18 @@ minetest.register_node("mesecons_extrawires:vertical_bottom_off", {
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
|
||||
selection_box = bbox,
|
||||
node_box = bbox,
|
||||
selection_box = bottom_box,
|
||||
node_box = bottom_box,
|
||||
is_vertical_conductor = true,
|
||||
vertical_conductor_state = "off",
|
||||
mesecons = {conductor = {
|
||||
state = mesecon.state.off,
|
||||
onstate = "mesecons_extrawires:vertical_bottom_on",
|
||||
rules = brules
|
||||
rules = bottom_rules,
|
||||
}},
|
||||
drop = {"mesecons_extrawires:vertical_off"},
|
||||
drop = "mesecons_extrawires:vertical_off",
|
||||
after_place_node = vertical_update,
|
||||
after_dig_node = vertical_update
|
||||
after_dig_node = vertical_update,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
|
@ -27,7 +27,7 @@ function update_gate(pos)
|
||||
gate = get_gate(pos)
|
||||
L = rotate_ports(
|
||||
yc_get_real_portstates(pos),
|
||||
minetest.env:get_node(pos).param2
|
||||
minetest.get_node(pos).param2
|
||||
)
|
||||
if gate == "diode" then
|
||||
set_gate(pos, L.a)
|
||||
@ -44,40 +44,41 @@ end
|
||||
|
||||
function set_gate(pos, on)
|
||||
gate = get_gate(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if on ~= gate_state(pos) then
|
||||
yc_heat(meta)
|
||||
minetest.after(0.5, yc_cool, meta)
|
||||
--minetest.after(0.5, yc_cool, meta)
|
||||
if yc_overheat(meta) then
|
||||
pop_gate(pos)
|
||||
else
|
||||
local node = minetest.get_node(pos)
|
||||
if on then
|
||||
mesecon:swap_node(pos, "mesecons_gates:"..gate.."_on")
|
||||
minetest.swap_node(pos, {name = "mesecons_gates:"..gate.."_on", param2=node.param2})
|
||||
mesecon:receptor_on(pos,
|
||||
gate_get_output_rules(minetest.env:get_node(pos)))
|
||||
gate_get_output_rules(node))
|
||||
else
|
||||
mesecon:swap_node(pos, "mesecons_gates:"..gate.."_off")
|
||||
minetest.swap_node(pos, {name = "mesecons_gates:"..gate.."_off", param2=node.param2})
|
||||
mesecon:receptor_off(pos,
|
||||
gate_get_output_rules(minetest.env:get_node(pos)))
|
||||
gate_get_output_rules(node))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function get_gate(pos)
|
||||
return minetest.registered_nodes[minetest.env:get_node(pos).name].mesecons_gate
|
||||
return minetest.registered_nodes[minetest.get_node(pos).name].mesecons_gate
|
||||
end
|
||||
|
||||
function gate_state(pos)
|
||||
name = minetest.env:get_node(pos).name
|
||||
name = minetest.get_node(pos).name
|
||||
return string.find(name, "_on") ~= nil
|
||||
end
|
||||
|
||||
function pop_gate(pos)
|
||||
gate = get_gate(pos)
|
||||
minetest.env:remove_node(pos)
|
||||
minetest.remove_node(pos)
|
||||
minetest.after(0.2, yc_overheat_off, pos)
|
||||
minetest.env:add_item(pos, "mesecons_gates:"..gate.."_off")
|
||||
minetest.add_item(pos, "mesecons_gates:"..gate.."_off")
|
||||
end
|
||||
|
||||
function rotate_ports(L, param2)
|
||||
@ -112,13 +113,13 @@ for _, gate in ipairs(gates) do
|
||||
drop = nodename.."_off"
|
||||
nodename = nodename.."_"..onoff
|
||||
description = "You hacker you!"
|
||||
groups = {dig_immediate=2, not_in_creative_inventory=1}
|
||||
groups = {dig_immediate=2, not_in_creative_inventory=1, overheat = 1}
|
||||
else
|
||||
onoff = "off"
|
||||
drop = nil
|
||||
nodename = nodename.."_"..onoff
|
||||
description = gate.name.." Gate"
|
||||
groups = {dig_immediate=2}
|
||||
groups = {dig_immediate=2, overheat = 1}
|
||||
end
|
||||
|
||||
tiles = "jeija_microcontroller_bottom.png^"..
|
||||
@ -150,7 +151,7 @@ for _, gate in ipairs(gates) do
|
||||
node_box = node_box,
|
||||
walkable = true,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("heat", 0)
|
||||
update_gate(pos)
|
||||
end,
|
||||
|
@ -63,8 +63,8 @@ nodenames = {"mesecons_hydroturbine:hydro_turbine_off"},
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local waterpos={x=pos.x, y=pos.y+1, z=pos.z}
|
||||
if minetest.env:get_node(waterpos).name=="default:water_flowing" then
|
||||
minetest.env:add_node(pos, {name="mesecons_hydroturbine:hydro_turbine_on"})
|
||||
if minetest.get_node(waterpos).name=="default:water_flowing" then
|
||||
minetest.add_node(pos, {name="mesecons_hydroturbine:hydro_turbine_on"})
|
||||
nodeupdate(pos)
|
||||
mesecon:receptor_on(pos)
|
||||
end
|
||||
@ -77,8 +77,8 @@ nodenames = {"mesecons_hydroturbine:hydro_turbine_on"},
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local waterpos={x=pos.x, y=pos.y+1, z=pos.z}
|
||||
if minetest.env:get_node(waterpos).name~="default:water_flowing" then
|
||||
minetest.env:add_node(pos, {name="mesecons_hydroturbine:hydro_turbine_off"})
|
||||
if minetest.get_node(waterpos).name~="default:water_flowing" then
|
||||
minetest.add_node(pos, {name="mesecons_hydroturbine:hydro_turbine_off"})
|
||||
nodeupdate(pos)
|
||||
mesecon:receptor_off(pos)
|
||||
end
|
||||
|
@ -25,7 +25,7 @@ minetest.register_node("mesecons_lamp:lamp_on", {
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
mesecons = {effector = {
|
||||
action_off = function (pos, node)
|
||||
mesecon:swap_node(pos, "mesecons_lamp:lamp_off")
|
||||
minetest.swap_node(pos, {name = "mesecons_lamp:lamp_off", param2 = node.param2})
|
||||
end
|
||||
}}
|
||||
})
|
||||
@ -46,7 +46,7 @@ minetest.register_node("mesecons_lamp:lamp_off", {
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
mesecons = {effector = {
|
||||
action_on = function (pos, node)
|
||||
mesecon:swap_node(pos, "mesecons_lamp:lamp_on")
|
||||
minetest.swap_node(pos, {name = "mesecons_lamp:lamp_on", param2 = node.param2})
|
||||
end
|
||||
}}
|
||||
})
|
||||
|
@ -1,3 +1,19 @@
|
||||
local lightstone_rules = {
|
||||
{x=0, y=0, z=-1},
|
||||
{x=1, y=0, z=0},
|
||||
{x=-1, y=0, z=0},
|
||||
{x=0, y=0, z=1},
|
||||
{x=1, y=1, z=0},
|
||||
{x=1, y=-1, z=0},
|
||||
{x=-1, y=1, z=0},
|
||||
{x=-1, y=-1, z=0},
|
||||
{x=0, y=1, z=1},
|
||||
{x=0, y=-1, z=1},
|
||||
{x=0, y=1, z=-1},
|
||||
{x=0, y=-1, z=-1},
|
||||
{x=0, y=-1, z=0},
|
||||
}
|
||||
|
||||
function mesecon:lightstone_add(name, base_item, texture_off, texture_on)
|
||||
minetest.register_node("mesecons_lightstone:lightstone_" .. name .. "_off", {
|
||||
tiles = {texture_off},
|
||||
@ -5,9 +21,10 @@ function mesecon:lightstone_add(name, base_item, texture_off, texture_on)
|
||||
description=name.." Lightstone",
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = {effector = {
|
||||
rules = lightstone_rules,
|
||||
action_on = function (pos, node)
|
||||
mesecon:swap_node(pos, "mesecons_lightstone:lightstone_" .. name .. "_on")
|
||||
end
|
||||
minetest.swap_node(pos, {name = "mesecons_lightstone:lightstone_" .. name .. "_on", param2 = node.param2})
|
||||
end,
|
||||
}}
|
||||
})
|
||||
minetest.register_node("mesecons_lightstone:lightstone_" .. name .. "_on", {
|
||||
@ -17,9 +34,10 @@ function mesecon:lightstone_add(name, base_item, texture_off, texture_on)
|
||||
light_source = LIGHT_MAX-2,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = {effector = {
|
||||
rules = lightstone_rules,
|
||||
action_off = function (pos, node)
|
||||
mesecon:swap_node(pos, "mesecons_lightstone:lightstone_" .. name .. "_off")
|
||||
end
|
||||
minetest.swap_node(pos, {name = "mesecons_lightstone:lightstone_" .. name .. "_off", param2 = node.param2})
|
||||
end,
|
||||
}}
|
||||
})
|
||||
|
||||
|
@ -33,13 +33,13 @@ rules.d = {x = 0, y = 0, z = -1, name="D"}
|
||||
|
||||
local get_real_portstates = function(pos) -- determine if ports are powered (by itself or from outside)
|
||||
ports = {
|
||||
a = mesecon:is_power_on(mesecon:addPosRule(pos, rules.a))
|
||||
a = mesecon:is_power_on(mesecon:addPosRule(pos, rules.a), mesecon:invertRule(rules.a))
|
||||
and mesecon:rules_link(mesecon:addPosRule(pos, rules.a), pos),
|
||||
b = mesecon:is_power_on(mesecon:addPosRule(pos, rules.b))
|
||||
b = mesecon:is_power_on(mesecon:addPosRule(pos, rules.b), mesecon:invertRule(rules.b))
|
||||
and mesecon:rules_link(mesecon:addPosRule(pos, rules.b), pos),
|
||||
c = mesecon:is_power_on(mesecon:addPosRule(pos, rules.c))
|
||||
c = mesecon:is_power_on(mesecon:addPosRule(pos, rules.c), mesecon:invertRule(rules.c))
|
||||
and mesecon:rules_link(mesecon:addPosRule(pos, rules.c), pos),
|
||||
d = mesecon:is_power_on(mesecon:addPosRule(pos, rules.d))
|
||||
d = mesecon:is_power_on(mesecon:addPosRule(pos, rules.d), mesecon:invertRule(rules.d))
|
||||
and mesecon:rules_link(mesecon:addPosRule(pos, rules.d), pos),
|
||||
}
|
||||
return ports
|
||||
@ -72,7 +72,8 @@ local setport = function (pos, rule, state)
|
||||
end
|
||||
|
||||
local action = function (pos, ports)
|
||||
local name = minetest.env:get_node(pos).name
|
||||
local node = minetest.get_node(pos)
|
||||
local name = node.name
|
||||
local vports = minetest.registered_nodes[name].virtual_portstates
|
||||
local newname = generate_name(ports)
|
||||
|
||||
@ -80,7 +81,7 @@ local action = function (pos, ports)
|
||||
local rules_on = {}
|
||||
local rules_off = {}
|
||||
|
||||
mesecon:swap_node(pos, newname)
|
||||
minetest.swap_node(pos, {name = newname, param2 = node.param2})
|
||||
|
||||
if ports.a ~= vports.a then setport(pos, rules.a, ports.a) end
|
||||
if ports.b ~= vports.b then setport(pos, rules.b, ports.b) end
|
||||
@ -100,17 +101,17 @@ local heat = function (meta) -- warm up
|
||||
end
|
||||
end
|
||||
|
||||
local cool = function (meta) -- cool down after a while
|
||||
h = meta:get_int("heat")
|
||||
if h ~= nil then
|
||||
meta:set_int("heat", h - 1)
|
||||
end
|
||||
end
|
||||
--local cool = function (meta) -- cool down after a while
|
||||
-- h = meta:get_int("heat")
|
||||
-- if h ~= nil then
|
||||
-- meta:set_int("heat", h - 1)
|
||||
-- end
|
||||
--end
|
||||
|
||||
local overheat = function (meta) -- determine if too hot
|
||||
h = meta:get_int("heat")
|
||||
if h == nil then return true end -- if nil then overheat
|
||||
if h > 20 then
|
||||
if h > 40 then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
@ -127,7 +128,7 @@ end
|
||||
|
||||
local code_prohibited = function(code)
|
||||
-- Clean code
|
||||
local prohibited = {"while", "for", "repeat", "until", "function"}
|
||||
local prohibited = {"while", "for", "repeat", "until", "function", "goto"}
|
||||
for _, p in ipairs(prohibited) do
|
||||
if string.find(code, p) then
|
||||
return "Prohibited command: "..p
|
||||
@ -135,10 +136,34 @@ local code_prohibited = function(code)
|
||||
end
|
||||
end
|
||||
|
||||
local safeprint = function(param)
|
||||
local safe_print = function(param)
|
||||
print(dump(param))
|
||||
end
|
||||
|
||||
deep_copy = function(original, visited) --deep copy that removes functions
|
||||
visited = visited or {}
|
||||
if visited[original] ~= nil then --already visited this node
|
||||
return visited[original]
|
||||
end
|
||||
if type(original) == 'table' then --nested table
|
||||
local copy = {}
|
||||
visited[original] = copy
|
||||
for key, value in next, original, nil do
|
||||
copy[deep_copy(key, visited)] = deep_copy(value, visited)
|
||||
end
|
||||
setmetatable(copy, deep_copy(getmetatable(original), visited))
|
||||
return copy
|
||||
elseif type(original) == 'function' then --ignore functions
|
||||
return nil
|
||||
else --by-value type
|
||||
return original
|
||||
end
|
||||
end
|
||||
|
||||
local safe_serialize = function(value)
|
||||
return minetest.serialize(deep_copy(value))
|
||||
end
|
||||
|
||||
local interrupt = function(params)
|
||||
lc_update(params.pos, {type="interrupt", iid = params.iid})
|
||||
end
|
||||
@ -147,18 +172,19 @@ local getinterrupt = function(pos)
|
||||
local interrupt = function (time, iid) -- iid = interrupt id
|
||||
if type(time) ~= "number" then return end
|
||||
local iid = iid or math.random()
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local interrupts = minetest.deserialize(meta:get_string("lc_interrupts")) or {}
|
||||
local found = false
|
||||
local search = safe_serialize(iid)
|
||||
for _, i in ipairs(interrupts) do
|
||||
if minetest.serialize(i) == minetest.serialize(iid) then
|
||||
if safe_serialize(i) == search then
|
||||
found = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if not found then
|
||||
table.insert(interrupts, iid)
|
||||
meta:set_string("lc_interrupts", minetest.serialize(interrupts))
|
||||
meta:set_string("lc_interrupts", safe_serialize(interrupts))
|
||||
end
|
||||
minetest.after(time, interrupt, {pos=pos, iid = iid})
|
||||
end
|
||||
@ -176,12 +202,12 @@ end
|
||||
|
||||
local create_environment = function(pos, mem, event)
|
||||
-- Gather variables for the environment
|
||||
local vports = minetest.registered_nodes[minetest.env:get_node(pos).name].virtual_portstates
|
||||
local vports = minetest.registered_nodes[minetest.get_node(pos).name].virtual_portstates
|
||||
vports = {a = vports.a, b = vports.b, c = vports.c, d = vports.d}
|
||||
local rports = get_real_portstates(pos)
|
||||
|
||||
return {
|
||||
print = safeprint,
|
||||
print = safe_print,
|
||||
pin = merge_portstates(vports, rports),
|
||||
port = vports,
|
||||
interrupt = getinterrupt(pos),
|
||||
@ -258,10 +284,11 @@ end
|
||||
local do_overheat = function (pos, meta)
|
||||
-- Overheat protection
|
||||
heat(meta)
|
||||
minetest.after(0.5, cool, meta)
|
||||
--minetest.after(0.5, cool, meta)
|
||||
if overheat(meta) then
|
||||
mesecon:swap_node(pos, BASENAME.."_burnt")
|
||||
minetest.env:get_meta(pos):set_string("lc_interrupts", "")
|
||||
local node = minetest.get_node(pos)
|
||||
minetest.swap_node(pos, {name = BASENAME.."_burnt", param2 = node.param2})
|
||||
minetest.get_meta(pos):set_string("lc_interrupts", "")
|
||||
minetest.after(0.2, overheat_off, pos) -- wait for pending operations
|
||||
return true
|
||||
end
|
||||
@ -272,15 +299,16 @@ local load_memory = function(meta)
|
||||
end
|
||||
|
||||
local save_memory = function(meta, mem)
|
||||
meta:set_string("lc_memory", minetest.serialize(mem))
|
||||
meta:set_string("lc_memory", safe_serialize(mem))
|
||||
end
|
||||
|
||||
local interrupt_allow = function (meta, event)
|
||||
if event.type ~= "interrupt" then return true end
|
||||
|
||||
local interrupts = minetest.deserialize(meta:get_string("lc_interrupts")) or {}
|
||||
local search = safe_serialize(event.iid)
|
||||
for _, i in ipairs(interrupts) do
|
||||
if minetest.serialize(i) == minetest.serialize(event.iid) then
|
||||
if safe_serialize(i) == search then
|
||||
return true
|
||||
end
|
||||
end
|
||||
@ -300,7 +328,7 @@ end
|
||||
----------------------
|
||||
|
||||
lc_update = function (pos, event)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if not interrupt_allow(meta, event) then return end
|
||||
if do_overheat(pos, meta) then return end
|
||||
|
||||
@ -327,17 +355,10 @@ lc_update = function (pos, event)
|
||||
end
|
||||
|
||||
local reset_meta = function(pos, code, errmsg)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("code", code)
|
||||
if minetest.formspec_escape then
|
||||
code = minetest.formspec_escape(code or "")
|
||||
errmsg = minetest.formspec_escape(errmsg or "")
|
||||
else
|
||||
code = string.gsub(code or "", "%[", "(") -- would otherwise
|
||||
code = string.gsub(code, "%]", ")") -- corrupt formspec
|
||||
errmsg = string.gsub(errmsg or "", "%[", "(") -- would otherwise
|
||||
errmsg = string.gsub(errmsg, "%]", ")") -- corrupt formspec
|
||||
end
|
||||
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.."]"..
|
||||
@ -348,16 +369,18 @@ local reset_meta = function(pos, code, errmsg)
|
||||
end
|
||||
|
||||
local reset = function (pos)
|
||||
minetest.env:get_meta(pos):set_string("lc_interrupts", "")
|
||||
minetest.get_meta(pos):set_string("lc_interrupts", "")
|
||||
action(pos, {a=false, b=false, c=false, d=false}, true)
|
||||
end
|
||||
|
||||
-- ______
|
||||
-- |
|
||||
-- | | |
|
||||
-- |___| | __ ___ _ __ _ _
|
||||
-- | | | | |\ | | |_| | | | | |_ |_|
|
||||
-- | |______ |__| | \| | | \ |__| |_ |_ |_ |\
|
||||
-- |
|
||||
-- | __ ___ _ __ _ _
|
||||
-- | | | | | |\ | | |_| | | | | |_ |_|
|
||||
-- |___| |______ |__| | \| | | \ |__| |_ |_ |_ |\
|
||||
-- |
|
||||
-- |
|
||||
--
|
||||
|
||||
-----------------------
|
||||
@ -412,9 +435,9 @@ if d == 1 then
|
||||
end
|
||||
|
||||
if a + b + c + d ~= 0 then
|
||||
groups = {dig_immediate=2, not_in_creative_inventory=1}
|
||||
groups = {dig_immediate=2, not_in_creative_inventory=1, overheat = 1}
|
||||
else
|
||||
groups = {dig_immediate=2}
|
||||
groups = {dig_immediate=2, overheat = 1}
|
||||
end
|
||||
|
||||
output_rules[cid] = {}
|
||||
@ -465,6 +488,9 @@ minetest.register_node(nodename, {
|
||||
node_box = nodebox,
|
||||
on_construct = reset_meta,
|
||||
on_receive_fields = function(pos, formname, fields)
|
||||
if fields.quit then
|
||||
return
|
||||
end
|
||||
reset(pos)
|
||||
reset_meta(pos, fields.code)
|
||||
local err = lc_update(pos, {type="program"})
|
||||
@ -508,6 +534,9 @@ minetest.register_node(BASENAME .. "_burnt", {
|
||||
node_box = nodebox,
|
||||
on_construct = reset_meta,
|
||||
on_receive_fields = function(pos, formname, fields)
|
||||
if fields.quit then
|
||||
return
|
||||
end
|
||||
reset(pos)
|
||||
reset_meta(pos, fields.code)
|
||||
local err = lc_update(pos, {type="program"})
|
||||
|
BIN
mesecons_microcontroller/MeseconMicro.odt
Normal file
@ -19,9 +19,9 @@ if tostring(d) == "1" then
|
||||
top = top.."^jeija_microcontroller_LED_D.png"
|
||||
end
|
||||
if tostring(d)..tostring(c)..tostring(b)..tostring(a) ~= "0000" then
|
||||
groups = {dig_immediate=2, not_in_creative_inventory=1, mesecon = 3}
|
||||
groups = {dig_immediate=2, not_in_creative_inventory=1, mesecon = 3, overheat = 1}
|
||||
else
|
||||
groups = {dig_immediate=2, mesecon = 3}
|
||||
groups = {dig_immediate=2, mesecon = 3, overheat = 1}
|
||||
end
|
||||
local rules={}
|
||||
if (a == 1) then table.insert(rules, {x = -1, y = 0, z = 0}) end
|
||||
@ -80,7 +80,7 @@ minetest.register_node(nodename, {
|
||||
}
|
||||
},
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("code", "")
|
||||
meta:set_string("formspec", "size[9,2.5]"..
|
||||
"field[0.256,-0.2;9,2;code;Code:;]"..
|
||||
@ -98,7 +98,10 @@ minetest.register_node(nodename, {
|
||||
meta:set_string("eeprom", r)
|
||||
end,
|
||||
on_receive_fields = function(pos, formanme, fields, sender)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
if fields.quit then
|
||||
return
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
if fields.band then
|
||||
fields.code = "sbi(C, A&B) :A and B are inputs, C is output"
|
||||
elseif fields.bxor then
|
||||
@ -116,7 +119,7 @@ minetest.register_node(nodename, {
|
||||
|
||||
meta:set_string("code", fields.code)
|
||||
meta:set_string("formspec", "size[9,2.5]"..
|
||||
"field[0.256,-0.2;9,2;code;Code:;"..fields.code.."]"..
|
||||
"field[0.256,-0.2;9,2;code;Code:;"..minetest.formspec_escape(fields.code).."]"..
|
||||
"button[0 ,0.2;1.5,3;band;AND]"..
|
||||
"button[1.5,0.2;1.5,3;bxor;XOR]"..
|
||||
"button[3 ,0.2;1.5,3;bnot;NOT]"..
|
||||
@ -151,7 +154,7 @@ minetest.register_craft({
|
||||
|
||||
function yc_reset(pos)
|
||||
yc_action(pos, {a=false, b=false, c=false, d=false})
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("heat", 0)
|
||||
meta:set_int("afterid", 0)
|
||||
local r = ""
|
||||
@ -160,13 +163,13 @@ function yc_reset(pos)
|
||||
end
|
||||
|
||||
function update_yc(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
yc_heat(meta)
|
||||
minetest.after(0.5, yc_cool, meta)
|
||||
--minetest.after(0.5, yc_cool, meta)
|
||||
if (yc_overheat(meta)) then
|
||||
minetest.env:remove_node(pos)
|
||||
minetest.remove_node(pos)
|
||||
minetest.after(0.2, yc_overheat_off, pos) --wait for pending parsings
|
||||
minetest.env:add_item(pos, "mesecons_microcontroller:microcontroller0000")
|
||||
minetest.add_item(pos, "mesecons_microcontroller:microcontroller0000")
|
||||
end
|
||||
|
||||
local code = meta:get_string("code")
|
||||
@ -195,7 +198,7 @@ function yc_code_remove_commentary(code)
|
||||
end
|
||||
|
||||
function yc_parsecode(code, pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local endi = 1
|
||||
local Lreal = yc_get_real_portstates(pos)
|
||||
local Lvirtual = yc_get_virtual_portstates(pos)
|
||||
@ -243,7 +246,7 @@ function yc_parsecode(code, pos)
|
||||
end
|
||||
if Lvirtual == nil then return nil end
|
||||
if eeprom == nil then return nil else
|
||||
minetest.env:get_meta(pos):set_string("eeprom", eeprom) end
|
||||
minetest.get_meta(pos):set_string("eeprom", eeprom) end
|
||||
end
|
||||
yc_action(pos, Lvirtual)
|
||||
return true
|
||||
@ -429,14 +432,14 @@ function yc_command_after(params, pos)
|
||||
local code = string.sub(params[2], 2, #params[2] - 1)
|
||||
|
||||
local afterid = math.random(10000)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("afterid", afterid)
|
||||
minetest.after(time, yc_command_after_execute, {pos = pos, code = code, afterid = afterid})
|
||||
return true
|
||||
end
|
||||
|
||||
function yc_command_after_execute(params)
|
||||
local meta = minetest.env:get_meta(params.pos)
|
||||
local meta = minetest.get_meta(params.pos)
|
||||
if meta:get_int("afterid") == params.afterid then --make sure the node has not been changed
|
||||
if yc_parsecode(params.code, params.pos) == nil then
|
||||
meta:set_string("infotext", "Code in after() not valid!")
|
||||
@ -590,7 +593,8 @@ function yc_action(pos, L) --L-->Lvirtual
|
||||
..tonumber(L.c and 1 or 0)
|
||||
..tonumber(L.b and 1 or 0)
|
||||
..tonumber(L.a and 1 or 0)
|
||||
mesecon:swap_node(pos, name)
|
||||
local node = minetest.get_node(pos)
|
||||
minetest.swap_node(pos, {name = name, param2 = node.param2})
|
||||
|
||||
yc_action_setports(pos, L, Lv)
|
||||
end
|
||||
@ -635,16 +639,24 @@ function yc_get_real_portstates(pos) -- port powered or not (by itself or from o
|
||||
rulesC = mesecon:get_rules("mesecons_microcontroller:microcontroller0100")
|
||||
rulesD = mesecon:get_rules("mesecons_microcontroller:microcontroller1000")
|
||||
L = {
|
||||
a = mesecon:is_power_on({x=pos.x+rulesA[1].x, y=pos.y+rulesA[1].y, z=pos.z+rulesA[1].z}) and mesecon:rules_link({x=pos.x+rulesA[1].x, y=pos.y+rulesA[1].y, z=pos.z+rulesA[1].z}, pos),
|
||||
b = mesecon:is_power_on({x=pos.x+rulesB[1].x, y=pos.y+rulesB[1].y, z=pos.z+rulesB[1].z}) and mesecon:rules_link({x=pos.x+rulesB[1].x, y=pos.y+rulesB[1].y, z=pos.z+rulesB[1].z}, pos),
|
||||
c = mesecon:is_power_on({x=pos.x+rulesC[1].x, y=pos.y+rulesC[1].y, z=pos.z+rulesC[1].z}) and mesecon:rules_link({x=pos.x+rulesC[1].x, y=pos.y+rulesC[1].y, z=pos.z+rulesC[1].z}, pos),
|
||||
d = mesecon:is_power_on({x=pos.x+rulesD[1].x, y=pos.y+rulesD[1].y, z=pos.z+rulesD[1].z}) and mesecon:rules_link({x=pos.x+rulesD[1].x, y=pos.y+rulesD[1].y, z=pos.z+rulesD[1].z}, pos)
|
||||
a = mesecon:is_power_on(mesecon:addPosRule(pos, rulesA[1]),
|
||||
mesecon:invertRule(rulesA[1])) and
|
||||
mesecon:rules_link(mesecon:addPosRule(pos, rulesA[1]), pos),
|
||||
b = mesecon:is_power_on(mesecon:addPosRule(pos, rulesB[1]),
|
||||
mesecon:invertRule(rulesB[1])) and
|
||||
mesecon:rules_link(mesecon:addPosRule(pos, rulesB[1]), pos),
|
||||
c = mesecon:is_power_on(mesecon:addPosRule(pos, rulesC[1]),
|
||||
mesecon:invertRule(rulesC[1])) and
|
||||
mesecon:rules_link(mesecon:addPosRule(pos, rulesC[1]), pos),
|
||||
d = mesecon:is_power_on(mesecon:addPosRule(pos, rulesD[1]),
|
||||
mesecon:invertRule(rulesD[1])) and
|
||||
mesecon:rules_link(mesecon:addPosRule(pos, rulesD[1]), pos),
|
||||
}
|
||||
return L
|
||||
end
|
||||
|
||||
function yc_get_virtual_portstates(pos) -- portstates according to the name
|
||||
name = minetest.env:get_node(pos).name
|
||||
name = minetest.get_node(pos).name
|
||||
b, a = string.find(name, ":microcontroller")
|
||||
if a == nil then return nil end
|
||||
a = a + 1
|
||||
@ -674,17 +686,18 @@ function yc_heat(meta)
|
||||
end
|
||||
end
|
||||
|
||||
function yc_cool(meta)
|
||||
h = meta:get_int("heat")
|
||||
if h ~= nil then
|
||||
meta:set_int("heat", h - 1)
|
||||
end
|
||||
end
|
||||
--function yc_cool(meta)
|
||||
-- h = meta:get_int("heat")
|
||||
-- if h ~= nil then
|
||||
-- meta:set_int("heat", h - 1)
|
||||
-- end
|
||||
--end
|
||||
|
||||
function yc_overheat(meta)
|
||||
if MESECONS_GLOBALSTEP then return false end
|
||||
h = meta:get_int("heat")
|
||||
if h == nil then return true end -- if nil the overheat
|
||||
if h>30 then
|
||||
if h>60 then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
|
@ -66,9 +66,9 @@ minetest.register_node("mesecons_movestones:movestone", {
|
||||
action_on = function (pos, node)
|
||||
local direction=mesecon:get_movestone_direction(pos)
|
||||
if not direction then return end
|
||||
minetest.env:remove_node(pos)
|
||||
minetest.remove_node(pos)
|
||||
mesecon:update_autoconnect(pos)
|
||||
minetest.env:add_entity(pos, "mesecons_movestones:movestone_entity")
|
||||
minetest.add_entity(pos, "mesecons_movestones:movestone_entity")
|
||||
end
|
||||
}}
|
||||
})
|
||||
@ -92,12 +92,14 @@ minetest.register_entity("mesecons_movestones:movestone_entity", {
|
||||
local direction = mesecon:get_movestone_direction(pos)
|
||||
|
||||
if not direction then -- no mesecon power
|
||||
local name = minetest.env:get_node(pos).name
|
||||
--push only solid nodes
|
||||
local name = minetest.get_node(pos).name
|
||||
if name ~= "air" and name ~= "ignore"
|
||||
and minetest.registered_nodes[name].liquidtype == "none" then
|
||||
and ((not minetest.registered_nodes[name])
|
||||
or minetest.registered_nodes[name].liquidtype == "none") then
|
||||
mesecon:mvps_push(pos, self.lastdir, MOVESTONE_MAXIMUM_PUSH)
|
||||
end
|
||||
minetest.env:add_node(pos, {name="mesecons_movestones:movestone"})
|
||||
minetest.add_node(pos, {name="mesecons_movestones:movestone"})
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
@ -105,7 +107,7 @@ minetest.register_entity("mesecons_movestones:movestone_entity", {
|
||||
local success, stack, oldstack =
|
||||
mesecon:mvps_push(pos, direction, MOVESTONE_MAXIMUM_PUSH)
|
||||
if not success then -- Too large stack/stopper in the way
|
||||
minetest.env:add_node(pos, {name="mesecons_movestones:movestone"})
|
||||
minetest.add_node(pos, {name="mesecons_movestones:movestone"})
|
||||
self.object:remove()
|
||||
return
|
||||
else
|
||||
@ -143,9 +145,9 @@ minetest.register_node("mesecons_movestones:sticky_movestone", {
|
||||
action_on = function (pos, node)
|
||||
local direction=mesecon:get_movestone_direction(pos)
|
||||
if not direction then return end
|
||||
minetest.env:remove_node(pos)
|
||||
minetest.remove_node(pos)
|
||||
mesecon:update_autoconnect(pos)
|
||||
minetest.env:add_entity(pos, "mesecons_movestones:sticky_movestone_entity")
|
||||
minetest.add_entity(pos, "mesecons_movestones:sticky_movestone_entity")
|
||||
end
|
||||
}}
|
||||
})
|
||||
@ -176,14 +178,16 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", {
|
||||
local direction = mesecon:get_movestone_direction(pos)
|
||||
|
||||
if not direction then -- no mesecon power
|
||||
local name = minetest.env:get_node(pos).name
|
||||
--push only solid nodes
|
||||
local name = minetest.get_node(pos).name
|
||||
if name ~= "air" and name ~= "ignore"
|
||||
and minetest.registered_nodes[name].liquidtype == "none" then
|
||||
and ((not minetest.registered_nodes[name])
|
||||
or minetest.registered_nodes[name].liquidtype == "none") then
|
||||
mesecon:mvps_push(pos, self.lastdir, MOVESTONE_MAXIMUM_PUSH)
|
||||
--STICKY
|
||||
mesecon:mvps_pull_all(pos, self.lastdir)
|
||||
end
|
||||
minetest.env:add_node(pos, {name="mesecons_movestones:sticky_movestone"})
|
||||
minetest.add_node(pos, {name="mesecons_movestones:sticky_movestone"})
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
@ -191,7 +195,7 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", {
|
||||
local success, stack, oldstack =
|
||||
mesecon:mvps_push(pos, direction, MOVESTONE_MAXIMUM_PUSH)
|
||||
if not success then -- Too large stack/stopper in the way
|
||||
minetest.env:add_node(pos, {name="mesecons_movestones:sticky_movestone"})
|
||||
minetest.add_node(pos, {name="mesecons_movestones:sticky_movestone"})
|
||||
self.object:remove()
|
||||
return
|
||||
else
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
mesecon.mvps_stoppers = {}
|
||||
mesecon.mvps_unmov = {}
|
||||
mesecon.on_mvps_move = {}
|
||||
|
||||
function mesecon:is_mvps_stopper(node, pushdir, stack, stackid)
|
||||
local get_stopper = mesecon.mvps_stoppers[node.name]
|
||||
@ -27,11 +28,22 @@ function mesecon:is_mvps_unmov(objectname)
|
||||
return mesecon.mvps_unmov[objectname]
|
||||
end
|
||||
|
||||
-- Functions to be called on mvps movement
|
||||
function mesecon:register_on_mvps_move(callback)
|
||||
mesecon.on_mvps_move[#mesecon.on_mvps_move+1] = callback
|
||||
end
|
||||
|
||||
local function on_mvps_move(moved_nodes)
|
||||
for _, callback in ipairs(mesecon.on_mvps_move) do
|
||||
callback(moved_nodes)
|
||||
end
|
||||
end
|
||||
|
||||
function mesecon:mvps_process_stack(stack)
|
||||
-- update mesecons for placed nodes ( has to be done after all nodes have been added )
|
||||
for _, n in ipairs(stack) do
|
||||
nodeupdate(n.pos)
|
||||
mesecon.on_placenode(n.pos, minetest.env:get_node(n.pos))
|
||||
mesecon.on_placenode(n.pos, minetest.get_node(n.pos))
|
||||
mesecon:update_autoconnect(n.pos)
|
||||
end
|
||||
end
|
||||
@ -41,14 +53,15 @@ function mesecon:mvps_get_stack(pos, dir, maximum)
|
||||
local np = {x = pos.x, y = pos.y, z = pos.z}
|
||||
local nodes = {}
|
||||
while true do
|
||||
local nn = minetest.env:get_node_or_nil(np)
|
||||
local nn = minetest.get_node_or_nil(np)
|
||||
if not nn or #nodes > maximum then
|
||||
-- don't push at all, something is in the way (unloaded map or too many nodes)
|
||||
return nil
|
||||
end
|
||||
|
||||
if nn.name == "air"
|
||||
or minetest.registered_nodes[nn.name].liquidtype ~= "none" then --is liquid
|
||||
or (minetest.registered_nodes[nn.name]
|
||||
and minetest.registered_nodes[nn.name].liquidtype ~= "none") then --is liquid
|
||||
break
|
||||
end
|
||||
|
||||
@ -72,8 +85,8 @@ function mesecon:mvps_push(pos, dir, maximum) -- pos: pos of mvps; dir: directio
|
||||
|
||||
-- remove all nodes
|
||||
for _, n in ipairs(nodes) do
|
||||
n.meta = minetest.env:get_meta(n.pos):to_table()
|
||||
minetest.env:remove_node(n.pos)
|
||||
n.meta = minetest.get_meta(n.pos):to_table()
|
||||
minetest.remove_node(n.pos)
|
||||
end
|
||||
|
||||
-- update mesecons for removed nodes ( has to be done after all nodes have been removed )
|
||||
@ -85,58 +98,98 @@ function mesecon:mvps_push(pos, dir, maximum) -- pos: pos of mvps; dir: directio
|
||||
-- add nodes
|
||||
for _, n in ipairs(nodes) do
|
||||
np = mesecon:addPosRule(n.pos, dir)
|
||||
minetest.env:add_node(np, n.node)
|
||||
minetest.env:get_meta(np):from_table(n.meta)
|
||||
minetest.add_node(np, n.node)
|
||||
minetest.get_meta(np):from_table(n.meta)
|
||||
end
|
||||
|
||||
local moved_nodes = {}
|
||||
local oldstack = mesecon:tablecopy(nodes)
|
||||
for i in ipairs(nodes) do
|
||||
moved_nodes[i] = {}
|
||||
moved_nodes[i].oldpos = nodes[i].pos
|
||||
nodes[i].pos = mesecon:addPosRule(nodes[i].pos, dir)
|
||||
moved_nodes[i].pos = nodes[i].pos
|
||||
moved_nodes[i].node = nodes[i].node
|
||||
moved_nodes[i].meta = nodes[i].meta
|
||||
end
|
||||
|
||||
on_mvps_move(moved_nodes)
|
||||
|
||||
return true, nodes, oldstack
|
||||
end
|
||||
|
||||
mesecon:register_on_mvps_move(function(moved_nodes)
|
||||
for _, n in ipairs(moved_nodes) do
|
||||
mesecon.on_placenode(n.pos, n.node)
|
||||
mesecon:update_autoconnect(n.pos)
|
||||
end
|
||||
end)
|
||||
|
||||
function mesecon:mvps_pull_single(pos, dir) -- pos: pos of mvps; direction: direction of pull (matches push direction for sticky pistons)
|
||||
np = mesecon:addPosRule(pos, dir)
|
||||
nn = minetest.env:get_node(np)
|
||||
nn = minetest.get_node(np)
|
||||
|
||||
if minetest.registered_nodes[nn.name].liquidtype == "none"
|
||||
and not mesecon:is_mvps_stopper(nn, {x = -dir.x, y = -dir.y, z = -dir.z}, {{pos = np, node = nn}}, 1) then
|
||||
local meta = minetest.env:get_meta(np):to_table()
|
||||
minetest.env:remove_node(np)
|
||||
minetest.env:add_node(pos, nn)
|
||||
minetest.env:get_meta(pos):from_table(meta)
|
||||
if ((not minetest.registered_nodes[nn.name]) --unregistered node
|
||||
or minetest.registered_nodes[nn.name].liquidtype == "none") --non-liquid node
|
||||
and not mesecon:is_mvps_stopper(nn, {x = -dir.x, y = -dir.y, z = -dir.z}, {{pos = np, node = nn}}, 1) then --non-stopper node
|
||||
local meta = minetest.get_meta(np):to_table()
|
||||
minetest.remove_node(np)
|
||||
minetest.add_node(pos, nn)
|
||||
minetest.get_meta(pos):from_table(meta)
|
||||
|
||||
nodeupdate(np)
|
||||
nodeupdate(pos)
|
||||
mesecon.on_dignode(np, nn)
|
||||
mesecon:update_autoconnect(np)
|
||||
on_mvps_move({{pos = pos, oldpos = np, node = nn, meta = meta}})
|
||||
end
|
||||
return {{pos = np, node = {param2 = 0, name = "air"}}, {pos = pos, node = nn}}
|
||||
end
|
||||
|
||||
function mesecon:mvps_pull_all(pos, direction) -- pos: pos of mvps; direction: direction of pull
|
||||
local lpos = {x=pos.x-direction.x, y=pos.y-direction.y, z=pos.z-direction.z} -- 1 away
|
||||
local lnode = minetest.env:get_node(lpos)
|
||||
local lnode = minetest.get_node(lpos)
|
||||
local lpos2 = {x=pos.x-direction.x*2, y=pos.y-direction.y*2, z=pos.z-direction.z*2} -- 2 away
|
||||
local lnode2 = minetest.env:get_node(lpos2)
|
||||
local lnode2 = minetest.get_node(lpos2)
|
||||
|
||||
if lnode.name ~= "ignore" and lnode.name ~= "air" and minetest.registered_nodes[lnode.name].liquidtype == "none" then return end
|
||||
if lnode2.name == "ignore" or lnode2.name == "air" or not(minetest.registered_nodes[lnode2.name].liquidtype == "none") then return end
|
||||
--avoid pulling solid nodes
|
||||
if lnode.name ~= "ignore"
|
||||
and lnode.name ~= "air"
|
||||
and ((not minetest.registered_nodes[lnode.name])
|
||||
or minetest.registered_nodes[lnode.name].liquidtype == "none") then
|
||||
return
|
||||
end
|
||||
|
||||
--avoid pulling empty or liquid nodes
|
||||
if lnode2.name == "ignore"
|
||||
or lnode2.name == "air"
|
||||
or (minetest.registered_nodes[lnode2.name]
|
||||
and minetest.registered_nodes[lnode2.name].liquidtype ~= "none") then
|
||||
return
|
||||
end
|
||||
|
||||
local moved_nodes = {}
|
||||
local oldpos = {x=lpos2.x + direction.x, y=lpos2.y + direction.y, z=lpos2.z + direction.z}
|
||||
repeat
|
||||
lnode2 = minetest.env:get_node(lpos2)
|
||||
minetest.env:add_node(oldpos, {name=lnode2.name})
|
||||
lnode2 = minetest.get_node(lpos2)
|
||||
local meta = minetest.get_meta(lnode2):to_table()
|
||||
minetest.add_node(oldpos, lnode2)
|
||||
minetest.get_meta(oldpos):from_table(meta)
|
||||
moved_nodes[#moved_nodes+1] = {pos = oldpos, oldpos = lnode2, node = lnode2, meta = meta}
|
||||
nodeupdate(oldpos)
|
||||
oldpos = {x=lpos2.x, y=lpos2.y, z=lpos2.z}
|
||||
lpos2.x = lpos2.x-direction.x
|
||||
lpos2.y = lpos2.y-direction.y
|
||||
lpos2.z = lpos2.z-direction.z
|
||||
lnode = minetest.env:get_node(lpos2)
|
||||
until lnode.name=="air" or lnode.name=="ignore" or not(minetest.registered_nodes[lnode2.name].liquidtype == "none")
|
||||
minetest.env:remove_node(oldpos)
|
||||
lnode = minetest.get_node(lpos2)
|
||||
until lnode.name == "air"
|
||||
or lnode.name == "ignore"
|
||||
or (minetest.registered_nodes[lnode.name]
|
||||
and minetest.registered_nodes[lnode.name].liquidtype ~= "none")
|
||||
minetest.remove_node(oldpos)
|
||||
mesecon.on_dignode(oldpos, lnode2)
|
||||
mesecon:update_autoconnect(oldpos)
|
||||
on_mvps_move(moved_nodes)
|
||||
end
|
||||
|
||||
function mesecon:mvps_move_objects(pos, dir, nodestack)
|
||||
@ -144,12 +197,12 @@ function mesecon:mvps_move_objects(pos, dir, nodestack)
|
||||
|
||||
-- Move object at tip of stack
|
||||
local pushpos = mesecon:addPosRule(pos, -- get pos at tip of stack
|
||||
{x = dir.x * (#nodestack),
|
||||
y = dir.y * (#nodestack),
|
||||
z = dir.z * (#nodestack)})
|
||||
{x = dir.x * #nodestack,
|
||||
y = dir.y * #nodestack,
|
||||
z = dir.z * #nodestack})
|
||||
|
||||
|
||||
local objects = minetest.env:get_objects_inside_radius(pushpos, 1)
|
||||
local objects = minetest.get_objects_inside_radius(pushpos, 1)
|
||||
for _, obj in ipairs(objects) do
|
||||
table.insert(objects_to_move, obj)
|
||||
end
|
||||
@ -159,7 +212,7 @@ function mesecon:mvps_move_objects(pos, dir, nodestack)
|
||||
-- If gravity positive and dir horizontal, push players standing on the stack
|
||||
for _, n in ipairs(nodestack) do
|
||||
local p_above = mesecon:addPosRule(n.pos, {x=0, y=1, z=0})
|
||||
local objects = minetest.env:get_objects_inside_radius(p_above, 1)
|
||||
local objects = minetest.get_objects_inside_radius(p_above, 1)
|
||||
for _, obj in ipairs(objects) do
|
||||
table.insert(objects_to_move, obj)
|
||||
end
|
||||
@ -170,8 +223,11 @@ function mesecon:mvps_move_objects(pos, dir, nodestack)
|
||||
local entity = obj:get_luaentity()
|
||||
if not entity or not mesecon:is_mvps_unmov(entity.name) then
|
||||
local np = mesecon:addPosRule(obj:getpos(), dir)
|
||||
local nn = minetest.env:get_node(np)
|
||||
if not minetest.registered_nodes[nn.name].walkable then
|
||||
|
||||
--move only if destination is not solid
|
||||
local nn = minetest.get_node(np)
|
||||
if not ((not minetest.registered_nodes[nn.name])
|
||||
or minetest.registered_nodes[nn.name].walkable) then
|
||||
obj:setpos(np)
|
||||
end
|
||||
end
|
||||
|
@ -6,12 +6,12 @@ minetest.register_node("mesecons_noteblock:noteblock", {
|
||||
visual_scale = 1.3,
|
||||
paramtype="light",
|
||||
after_place_node = function(pos)
|
||||
minetest.env:add_node(pos, {name="mesecons_noteblock:noteblock", param2=0})
|
||||
minetest.add_node(pos, {name="mesecons_noteblock:noteblock", param2=0})
|
||||
end,
|
||||
on_punch = function (pos, node) -- change sound when punched
|
||||
local param2 = node.param2+1
|
||||
if param2==12 then param2=0 end
|
||||
minetest.env:add_node(pos, {name = node.name, param2 = param2})
|
||||
minetest.add_node(pos, {name = node.name, param2 = param2})
|
||||
mesecon.noteblock_play(pos, param2)
|
||||
end,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
@ -25,9 +25,9 @@ minetest.register_node("mesecons_noteblock:noteblock", {
|
||||
minetest.register_craft({
|
||||
output = "mesecons_noteblock:noteblock 1",
|
||||
recipe = {
|
||||
{"default:wood", "default:wood", "default:wood"},
|
||||
{"group:wood", "group:wood", "group:wood"},
|
||||
{"group:mesecon_conductor_craftable", "default:steel_ingot", "group:mesecon_conductor_craftable"},
|
||||
{"default:wood", "default:wood", "default:wood"},
|
||||
{"group:wood", "group:wood", "group:wood"},
|
||||
}
|
||||
})
|
||||
|
||||
@ -58,7 +58,7 @@ mesecon.noteblock_play = function (pos, param2)
|
||||
elseif param2==7 then
|
||||
soundname="mesecons_noteblock_gsharp"
|
||||
end
|
||||
local block_below_name = minetest.env:get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
|
||||
local block_below_name = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
|
||||
if block_below_name == "default:glass" then
|
||||
soundname="mesecons_noteblock_hihat"
|
||||
end
|
||||
|
@ -56,16 +56,22 @@ end
|
||||
|
||||
local piston_remove_pusher = function(pos, node)
|
||||
pistonspec = minetest.registered_nodes[node.name].mesecons_piston
|
||||
if pushername == pistonspec.pusher then --make sure there actually is a pusher (for compatibility reasons mainly)
|
||||
return
|
||||
end
|
||||
|
||||
dir = piston_get_direction(pistonspec.dir, node)
|
||||
local pusherpos = mesecon:addPosRule(pos, dir)
|
||||
local pushername = minetest.env:get_node(pusherpos).name
|
||||
local pushername = minetest.get_node(pusherpos).name
|
||||
|
||||
if pushername == pistonspec.pusher then --make sure there actually is a pusher (for compatibility reasons mainly)
|
||||
minetest.env:remove_node(pusherpos)
|
||||
minetest.remove_node(pusherpos)
|
||||
minetest.sound_play("piston_retract", {
|
||||
pos = pos,
|
||||
max_hear_distance = 20,
|
||||
gain = 0.3,
|
||||
})
|
||||
nodeupdate(pusherpos)
|
||||
end
|
||||
end
|
||||
|
||||
local piston_on = function(pos, node)
|
||||
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
|
||||
@ -74,8 +80,13 @@ local piston_on = function (pos, node)
|
||||
local np = mesecon:addPosRule(pos, dir)
|
||||
local success, stack, oldstack = mesecon:mvps_push(np, dir, PISTON_MAXIMUM_PUSH)
|
||||
if success then
|
||||
minetest.env:add_node(pos, {param2 = node.param2, name = pistonspec.onname})
|
||||
minetest.env:add_node(np, {param2 = node.param2, name = pistonspec.pusher})
|
||||
minetest.add_node(pos, {param2 = node.param2, name = pistonspec.onname})
|
||||
minetest.add_node(np, {param2 = node.param2, name = pistonspec.pusher})
|
||||
minetest.sound_play("piston_extend", {
|
||||
pos = pos,
|
||||
max_hear_distance = 20,
|
||||
gain = 0.3,
|
||||
})
|
||||
mesecon:mvps_process_stack (stack)
|
||||
mesecon:mvps_move_objects (np, dir, oldstack)
|
||||
end
|
||||
@ -83,7 +94,7 @@ end
|
||||
|
||||
local piston_off = function(pos, node)
|
||||
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
|
||||
minetest.env:add_node(pos, {param2 = node.param2, name = pistonspec.offname})
|
||||
minetest.add_node(pos, {param2 = node.param2, name = pistonspec.offname})
|
||||
piston_remove_pusher(pos, node)
|
||||
|
||||
if pistonspec.sticky then
|
||||
@ -101,12 +112,12 @@ local piston_orientate = function (pos, placer)
|
||||
-- placer pitch in degrees
|
||||
local pitch = placer:get_look_pitch() * (180 / math.pi)
|
||||
|
||||
local node = minetest.env:get_node(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
|
||||
if pitch > 55 then --looking upwards
|
||||
minetest.env:add_node(pos, {name=pistonspec.piston_down})
|
||||
minetest.add_node(pos, {name=pistonspec.piston_down})
|
||||
elseif pitch < -55 then --looking downwards
|
||||
minetest.env:add_node(pos, {name=pistonspec.piston_up})
|
||||
minetest.add_node(pos, {name=pistonspec.piston_up})
|
||||
end
|
||||
end
|
||||
|
||||
@ -706,7 +717,7 @@ local piston_get_stopper = function (node, dir, stack, stackid)
|
||||
pistonspec = minetest.registered_nodes[node.name].mesecons_piston
|
||||
dir = piston_get_direction(pistonspec.dir, node)
|
||||
local pusherpos = mesecon:addPosRule(stack[stackid].pos, dir)
|
||||
local pushernode = minetest.env:get_node(pusherpos)
|
||||
local pushernode = minetest.get_node(pusherpos)
|
||||
|
||||
if minetest.registered_nodes[node.name].mesecons_piston.pusher == pushernode.name then
|
||||
for _, s in ipairs(stack) do
|
||||
@ -732,7 +743,7 @@ mesecon:register_mvps_stopper("mesecons_pistons:piston_down_sticky_on", piston_u
|
||||
minetest.register_craft({
|
||||
output = "mesecons_pistons:piston_normal_off 2",
|
||||
recipe = {
|
||||
{"default:wood", "default:wood", "default:wood"},
|
||||
{"group:wood", "group:wood", "group:wood"},
|
||||
{"default:cobble", "default:steel_ingot", "default:cobble"},
|
||||
{"default:cobble", "group:mesecon_conductor_craftable", "default:cobble"},
|
||||
}
|
||||
|
BIN
mesecons_pistons/sounds/piston_extend.ogg
Normal file
BIN
mesecons_pistons/sounds/piston_retract.ogg
Normal file
@ -9,18 +9,18 @@ local pp_box_on = {
|
||||
}
|
||||
|
||||
pp_on_timer = function (pos, elapsed)
|
||||
local node = minetest.env:get_node(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
local ppspec = minetest.registered_nodes[node.name].pressureplate
|
||||
|
||||
-- This is a workaround for a strange bug that occurs when the server is started
|
||||
-- For some reason the first time on_timer is called, the pos is wrong
|
||||
if not ppspec then return end
|
||||
|
||||
local objs = minetest.env:get_objects_inside_radius(pos, 1)
|
||||
local objs = minetest.get_objects_inside_radius(pos, 1)
|
||||
local two_below = mesecon:addPosRule(pos, {x = 0, y = -2, z = 0})
|
||||
|
||||
if objs[1] == nil and node.name == ppspec.onstate then
|
||||
minetest.env:add_node(pos, {name = ppspec.offstate})
|
||||
minetest.add_node(pos, {name = ppspec.offstate})
|
||||
mesecon:receptor_off(pos)
|
||||
-- force deactivation of mesecon two blocks below (hacky)
|
||||
if not mesecon:connected_to_receptor(two_below) then
|
||||
@ -30,7 +30,7 @@ pp_on_timer = function (pos, elapsed)
|
||||
for k, obj in pairs(objs) do
|
||||
local objpos = obj:getpos()
|
||||
if objpos.y > pos.y-1 and objpos.y < pos.y then
|
||||
minetest.env:add_node(pos, {name=ppspec.onstate})
|
||||
minetest.add_node(pos, {name=ppspec.onstate})
|
||||
mesecon:receptor_on(pos)
|
||||
-- force activation of mesecon two blocks below (hacky)
|
||||
mesecon:turnon(two_below)
|
||||
@ -71,7 +71,7 @@ function mesecon:register_pressure_plate(offstate, onstate, description, texture
|
||||
state = mesecon.state.off
|
||||
}},
|
||||
on_construct = function(pos)
|
||||
minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
|
||||
minetest.get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
|
||||
end,
|
||||
})
|
||||
|
||||
@ -90,7 +90,7 @@ function mesecon:register_pressure_plate(offstate, onstate, description, texture
|
||||
state = mesecon.state.on
|
||||
}},
|
||||
on_construct = function(pos)
|
||||
minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
|
||||
minetest.get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
local two_below = mesecon:addPosRule(pos, {x = 0, y = -2, z = 0})
|
||||
@ -114,7 +114,7 @@ mesecon:register_pressure_plate(
|
||||
{"jeija_pressure_plate_wood_on.png","jeija_pressure_plate_wood_on.png","jeija_pressure_plate_wood_on_edges.png"},
|
||||
"jeija_pressure_plate_wood_wield.png",
|
||||
"jeija_pressure_plate_wood_inv.png",
|
||||
{{"default:wood", "default:wood"}})
|
||||
{{"group:wood", "group:wood"}})
|
||||
|
||||
mesecon:register_pressure_plate(
|
||||
"mesecons_pressureplates:pressure_plate_stone_off",
|
||||
|
@ -8,7 +8,7 @@ minetest.register_node("mesecons_random:removestone", {
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = {effector = {
|
||||
action_on = function (pos, node)
|
||||
minetest.env:remove_node(pos)
|
||||
minetest.remove_node(pos)
|
||||
mesecon:update_autoconnect(pos)
|
||||
end
|
||||
}}
|
||||
@ -68,8 +68,8 @@ minetest.register_node("mesecons_random:ghoststone_active", {
|
||||
on_construct = function(pos)
|
||||
--remove shadow
|
||||
pos2 = {x = pos.x, y = pos.y + 1, z = pos.z}
|
||||
if ( minetest.env:get_node(pos2).name == "air" ) then
|
||||
minetest.env:dig_node(pos2)
|
||||
if ( minetest.get_node(pos2).name == "air" ) then
|
||||
minetest.dig_node(pos2)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
@ -91,7 +91,7 @@ mesecon:add_rules("receiver_pos_all", {
|
||||
|
||||
function mesecon:receiver_get_pos_from_rcpt(pos, param2)
|
||||
local rules = mesecon:get_rules("receiver_pos")
|
||||
if param2 == nil then param2 = minetest.env:get_node(pos).param2 end
|
||||
if param2 == nil then param2 = minetest.get_node(pos).param2 end
|
||||
if param2 == 2 then
|
||||
rules = mesecon:rotate_rules_left(rules)
|
||||
elseif param2 == 3 then
|
||||
@ -107,17 +107,17 @@ function mesecon:receiver_get_pos_from_rcpt(pos, param2)
|
||||
end
|
||||
|
||||
function mesecon:receiver_place(rcpt_pos)
|
||||
local node = minetest.env:get_node(rcpt_pos)
|
||||
local node = minetest.get_node(rcpt_pos)
|
||||
local pos = mesecon:receiver_get_pos_from_rcpt(rcpt_pos, node.param2)
|
||||
local nn = minetest.env:get_node(pos)
|
||||
local nn = minetest.get_node(pos)
|
||||
|
||||
if string.find(nn.name, "mesecons:wire_") ~= nil then
|
||||
minetest.env:dig_node(pos)
|
||||
minetest.dig_node(pos)
|
||||
if mesecon:is_power_on(rcpt_pos) then
|
||||
minetest.env:add_node(pos, {name = "mesecons_receiver:receiver_on", param2 = node.param2})
|
||||
minetest.add_node(pos, {name = "mesecons_receiver:receiver_on", param2 = node.param2})
|
||||
mesecon:receptor_on(pos, receiver_get_rules(node))
|
||||
else
|
||||
minetest.env:add_node(pos, {name = "mesecons_receiver:receiver_off", param2 = node.param2})
|
||||
minetest.add_node(pos, {name = "mesecons_receiver:receiver_off", param2 = node.param2})
|
||||
end
|
||||
mesecon:update_autoconnect(pos)
|
||||
end
|
||||
@ -125,11 +125,11 @@ end
|
||||
|
||||
function mesecon:receiver_remove(rcpt_pos, dugnode)
|
||||
local pos = mesecon:receiver_get_pos_from_rcpt(rcpt_pos, dugnode.param2)
|
||||
local nn = minetest.env:get_node(pos)
|
||||
local nn = minetest.get_node(pos)
|
||||
if string.find(nn.name, "mesecons_receiver:receiver_") ~=nil then
|
||||
minetest.env:dig_node(pos)
|
||||
minetest.dig_node(pos)
|
||||
local node = {name = "mesecons:wire_00000000_off"}
|
||||
minetest.env:add_node(pos, node)
|
||||
minetest.add_node(pos, node)
|
||||
mesecon:update_autoconnect(pos)
|
||||
mesecon.on_placenode(pos, node)
|
||||
end
|
||||
@ -156,7 +156,7 @@ minetest.register_on_placenode(function (pos, node)
|
||||
x = pos.x + rules[i].x,
|
||||
y = pos.y + rules[i].y,
|
||||
z = pos.z + rules[i].z}
|
||||
if minetest.get_item_group(minetest.env:get_node(np).name, "mesecon_needs_receiver") == 1 then
|
||||
if minetest.get_item_group(minetest.get_node(np).name, "mesecon_needs_receiver") == 1 then
|
||||
mesecon:receiver_place(np)
|
||||
end
|
||||
i = i + 1
|
||||
|
@ -71,10 +71,10 @@ minetest.register_abm(
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local light = minetest.env:get_node_light(pos, nil)
|
||||
local light = minetest.get_node_light(pos, nil)
|
||||
|
||||
if light >= 12 then
|
||||
minetest.env:set_node(pos, {name="mesecons_solarpanel:solar_panel_on", param2=node.param2})
|
||||
minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_on", param2=node.param2})
|
||||
mesecon:receptor_on(pos)
|
||||
end
|
||||
end,
|
||||
@ -85,10 +85,10 @@ minetest.register_abm(
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local light = minetest.env:get_node_light(pos, nil)
|
||||
local light = minetest.get_node_light(pos, nil)
|
||||
|
||||
if light < 12 then
|
||||
minetest.env:set_node(pos, {name="mesecons_solarpanel:solar_panel_off", param2=node.param2})
|
||||
minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_off", param2=node.param2})
|
||||
mesecon:receptor_off(pos)
|
||||
end
|
||||
end,
|
||||
|
@ -10,7 +10,7 @@ minetest.register_node("mesecons_switch:mesecon_switch_off", {
|
||||
state = mesecon.state.off
|
||||
}},
|
||||
on_punch = function(pos, node)
|
||||
mesecon:swap_node(pos, "mesecons_switch:mesecon_switch_on")
|
||||
minetest.swap_node(pos, {name = "mesecons_switch:mesecon_switch_on", param2 = node.param2})
|
||||
mesecon:receptor_on(pos)
|
||||
minetest.sound_play("mesecons_switch", {pos=pos})
|
||||
end
|
||||
@ -26,7 +26,7 @@ minetest.register_node("mesecons_switch:mesecon_switch_on", {
|
||||
state = mesecon.state.on
|
||||
}},
|
||||
on_punch = function(pos, node)
|
||||
mesecon:swap_node(pos, "mesecons_switch:mesecon_switch_off")
|
||||
minetest.swap_node(pos, {name = "mesecons_switch:mesecon_switch_off", param2 = node.param2})
|
||||
mesecon:receptor_off(pos)
|
||||
minetest.sound_play("mesecons_switch", {pos=pos})
|
||||
end
|
||||
|
After Width: | Height: | Size: 305 B |
After Width: | Height: | Size: 270 B |
After Width: | Height: | Size: 293 B |
After Width: | Height: | Size: 209 B |
BIN
mesecons_textures/textures/jeija_insulated_wire_ends_01x.png
Normal file
After Width: | Height: | Size: 246 B |
BIN
mesecons_textures/textures/jeija_insulated_wire_ends_01z.png
Normal file
After Width: | Height: | Size: 252 B |
BIN
mesecons_textures/textures/jeija_insulated_wire_ends_10x.png
Normal file
After Width: | Height: | Size: 238 B |
BIN
mesecons_textures/textures/jeija_insulated_wire_ends_10z.png
Normal file
After Width: | Height: | Size: 261 B |
Before Width: | Height: | Size: 173 B After Width: | Height: | Size: 142 B |
Before Width: | Height: | Size: 166 B After Width: | Height: | Size: 126 B |
@ -99,11 +99,11 @@ minetest.register_abm({
|
||||
|
||||
if is_powered then
|
||||
if node.name == "mesecons_torch:mesecon_torch_on" then
|
||||
mesecon:swap_node(pos, "mesecons_torch:mesecon_torch_off")
|
||||
minetest.swap_node(pos, {name = "mesecons_torch:mesecon_torch_off", param2 = node.param2})
|
||||
mesecon:receptor_off(pos, torch_get_output_rules(node))
|
||||
end
|
||||
elseif node.name == "mesecons_torch:mesecon_torch_off" then
|
||||
mesecon:swap_node(pos, "mesecons_torch:mesecon_torch_on")
|
||||
minetest.swap_node(pos, {name = "mesecons_torch:mesecon_torch_on", param2 = node.param2})
|
||||
mesecon:receptor_on(pos, torch_get_output_rules(node))
|
||||
end
|
||||
end
|
||||
|
@ -32,7 +32,7 @@ minetest.register_node("mesecons_walllever:wall_lever_off", {
|
||||
groups = {dig_immediate=2, mesecon_needs_receiver = 1},
|
||||
description="Lever",
|
||||
on_punch = function (pos, node)
|
||||
mesecon:swap_node(pos, "mesecons_walllever:wall_lever_on")
|
||||
minetest.swap_node(pos, {name = "mesecons_walllever:wall_lever_on", param2 = node.param2})
|
||||
mesecon:receptor_on(pos, mesecon.rules.buttonlike_get(node))
|
||||
minetest.sound_play("mesecons_lever", {pos=pos})
|
||||
end,
|
||||
@ -74,7 +74,7 @@ minetest.register_node("mesecons_walllever:wall_lever_on", {
|
||||
drop = "mesecons_walllever:wall_lever_off 1",
|
||||
description="Lever",
|
||||
on_punch = function (pos, node)
|
||||
mesecon:swap_node(pos, "mesecons_walllever:wall_lever_off")
|
||||
minetest.swap_node(pos, {name = "mesecons_walllever:wall_lever_off", param2 = node.param2})
|
||||
mesecon:receptor_off(pos, mesecon.rules.buttonlike_get(node))
|
||||
minetest.sound_play("mesecons_lever", {pos=pos})
|
||||
end,
|
||||
|