mirror of
				https://github.com/mt-mods/pipeworks.git
				synced 2025-11-04 10:25:29 +01:00 
			
		
		
		
	Compare commits
	
		
			170 Commits
		
	
	
		
			20180717
			...
			2f9f9a7b54
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 2f9f9a7b54 | |||
| 
						 | 
					7c74d0bdf3 | ||
| 
						 | 
					dc77d1056c | ||
| 
						 | 
					ab0713d9a5 | ||
| 
						 | 
					b6ae50be87 | ||
| 
						 | 
					e7cba4071b | ||
| 
						 | 
					d90c17edee | ||
| 
						 | 
					4f55610df5 | ||
| 
						 | 
					500cce8668 | ||
| 
						 | 
					cb3e7757fc | ||
| 
						 | 
					7f93e8aa0a | ||
| 
						 | 
					ebe2331619 | ||
| 
						 | 
					2f97a367f3 | ||
| 02322855d5 | |||
| 
						 | 
					9395013cde | ||
| 
						 | 
					2c880a3843 | ||
| 
						 | 
					56bcc7dbb7 | ||
| 
						 | 
					bd5a42356b | ||
| 
						 | 
					b0b675f715 | ||
| 
						 | 
					855937aec3 | ||
| 
						 | 
					fc0d4990b0 | ||
| 
						 | 
					5e9bfa049b | ||
| 
						 | 
					5345fe7af3 | ||
| 
						 | 
					8c251800db | ||
| 
						 | 
					b190d29d21 | ||
| 
						 | 
					e45eca76e1 | ||
| 
						 | 
					65cea1e33c | ||
| b11cb37123 | |||
| 
						 | 
					b6c02ac8de | ||
| 
						 | 
					54243764e0 | ||
| 
						 | 
					1823690dad | ||
| 503c1190ed | |||
| 
						 | 
					75894355d4 | ||
| 5bba517b03 | |||
| 
						 | 
					7b15bdbd1f | ||
| 
						 | 
					90425fde95 | ||
| 
						 | 
					1349ff8dd8 | ||
| 
						 | 
					3b31b6f9c0 | ||
| 
						 | 
					4fce320d9c | ||
| 
						 | 
					55ded7e569 | ||
| 
						 | 
					e3d94cb3a8 | ||
| 
						 | 
					97903327a5 | ||
| 
						 | 
					37eef73695 | ||
| 
						 | 
					3092ce771f | ||
| 
						 | 
					96ccd29dd2 | ||
| 
						 | 
					8e0b25fb2c | ||
| 
						 | 
					8a29f8844c | ||
| 
						 | 
					5aa0501872 | ||
| 66070dd801 | |||
| 
						 | 
					5618003be3 | ||
| 
						 | 
					06fd754216 | ||
| 
						 | 
					794cae675e | ||
| 
						 | 
					7d3a61e595 | ||
| 
						 | 
					a70115ab8d | ||
| 
						 | 
					23fe215721 | ||
| 
						 | 
					8f067db7cd | ||
| 
						 | 
					e082ea473b | ||
| 7ee74133e1 | |||
| 
						 | 
					cec6049dd1 | ||
| 
						 | 
					047718b3c3 | ||
| 
						 | 
					01f4ea066c | ||
| 
						 | 
					7ba685344c | ||
| 
						 | 
					c39d40e940 | ||
| 
						 | 
					48b082e014 | ||
| c01bd7b888 | |||
| 
						 | 
					2670fd88a9 | ||
| 
						 | 
					3536004667 | ||
| 
						 | 
					b53a1ee477 | ||
| 
						 | 
					29bac67d3a | ||
| e2fdcc4fb2 | |||
| 
						 | 
					db6d1bd9c1 | ||
| 
						 | 
					79dc5f5c7d | ||
| 
						 | 
					01d44056a2 | ||
| 
						 | 
					c7d44272e6 | ||
| 
						 | 
					5837d62979 | ||
| e4db1e885e | |||
| 
						 | 
					fc6efb450c | ||
| 
						 | 
					828c50e85d | ||
| 
						 | 
					4add40705f | ||
| 
						 | 
					a6e4f2dceb | ||
| 
						 | 
					7ad991ce40 | ||
| f7839444cd | |||
| 
						 | 
					d2954c5277 | ||
| 93f5fb3d87 | |||
| 
						 | 
					9ad6e5d07a | ||
| 
						 | 
					31e1255245 | ||
| a535bebd2e | |||
| 
						 | 
					a735d1a155 | ||
| be2776fc46 | |||
| 
						 | 
					a2c0dd1130 | ||
| 
						 | 
					f0ef43823c | ||
| 
						 | 
					17a602a5a1 | ||
| 
						 | 
					2294a23582 | ||
| 
						 | 
					b2d2ccbcba | ||
| ee03959a65 | |||
| 
						 | 
					8322f256c5 | ||
| 
						 | 
					ba7eb19317 | ||
| 4dd30df37a | |||
| 
						 | 
					065c953eba | ||
| 946da11206 | |||
| 
						 | 
					9a63d17e4a | ||
| 
						 | 
					d814357ddf | ||
| 
						 | 
					c2fe5fe956 | ||
| 
						 | 
					9dbaa5f4f6 | ||
| 77c8026400 | |||
| 
						 | 
					d93396600f | ||
| 
						 | 
					c966a8a57d | ||
| 70b521c721 | |||
| 
						 | 
					61b061f669 | ||
| 
						 | 
					fe91d5eb46 | ||
| 
						 | 
					eb1064ca6d | ||
| 
						 | 
					f54e25ec52 | ||
| 6d795b7d34 | |||
| 
						 | 
					dedb0dd54e | ||
| 
						 | 
					477a024034 | ||
| 92249b7941 | |||
| 
						 | 
					34cb0e7682 | ||
| 
						 | 
					505fc7cc49 | ||
| e04fb691ad | |||
| 
						 | 
					cb58a646cf | ||
| 
						 | 
					e3135c53f0 | ||
| ac80224371 | |||
| 
						 | 
					366d57f4da | ||
| 
						 | 
					c79e68a80c | ||
| 
						 | 
					9338c109a6 | ||
| 
						 | 
					63bee98948 | ||
| 
						 | 
					ee6c9991b9 | ||
| 34262ed8d5 | |||
| 
						 | 
					9eefe9c7bb | ||
| 
						 | 
					8281e3d068 | ||
| 
						 | 
					ed282b0298 | ||
| 
						 | 
					5410ea74f2 | ||
| 
						 | 
					4602290bc5 | ||
| 
						 | 
					64fb90f3e5 | ||
| 5cfe8d893f | |||
| 
						 | 
					99cb3a5d9d | ||
| 
						 | 
					728d4e179a | ||
| 
						 | 
					760e9e383c | ||
| 
						 | 
					62bc13078f | ||
| 
						 | 
					84d7104c66 | ||
| 
						 | 
					2ca825f991 | ||
| 
						 | 
					0fa88b7054 | ||
| 
						 | 
					8f03c0e684 | ||
| 975e20f704 | |||
| 
						 | 
					75cfac34e6 | ||
| 
						 | 
					d5fe933456 | ||
| 
						 | 
					6ad2c9f568 | ||
| 2693e2ecbb | |||
| 
						 | 
					05ca3e4f4f | ||
| 
						 | 
					c93df73a5c | ||
| 
						 | 
					27eb2ca9de | ||
| 
						 | 
					dc8778d7d3 | ||
| 
						 | 
					26e7b46415 | ||
| 
						 | 
					839b0ed4b1 | ||
| 
						 | 
					da764f4ce0 | ||
| 
						 | 
					ef5d30c92d | ||
| 
						 | 
					f2fff77e90 | ||
| 
						 | 
					f37b21e632 | ||
| 
						 | 
					c9a951c2e8 | ||
| 
						 | 
					f5a60ba407 | ||
| 
						 | 
					d7dfd11364 | ||
| 
						 | 
					4c20de48b2 | ||
| 
						 | 
					9725fa2f28 | ||
| 
						 | 
					25c00a6e05 | ||
| 
						 | 
					d8ed6d3af4 | ||
| 
						 | 
					a69c210b56 | ||
| 
						 | 
					cb8a4f3cec | ||
| 
						 | 
					002bcbf850 | ||
| 
						 | 
					6fdda18390 | ||
| 
						 | 
					6492b8ec76 | 
							
								
								
									
										13
									
								
								.github/workflows/luacheck.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								.github/workflows/luacheck.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,13 @@
 | 
			
		||||
name: luacheck
 | 
			
		||||
on: [push, pull_request]
 | 
			
		||||
jobs:
 | 
			
		||||
  build:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
    - uses: actions/checkout@master
 | 
			
		||||
    - name: apt
 | 
			
		||||
      run: sudo apt-get install -y luarocks
 | 
			
		||||
    - name: luacheck install
 | 
			
		||||
      run: luarocks install --local luacheck
 | 
			
		||||
    - name: luacheck run
 | 
			
		||||
      run: $HOME/.luarocks/bin/luacheck ./
 | 
			
		||||
							
								
								
									
										25
									
								
								.luacheckrc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								.luacheckrc
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
			
		||||
unused_args = false
 | 
			
		||||
max_line_length= 240
 | 
			
		||||
redefined = false
 | 
			
		||||
 | 
			
		||||
globals = {
 | 
			
		||||
	"pipeworks",
 | 
			
		||||
	"luaentity"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
read_globals = {
 | 
			
		||||
	-- Stdlib
 | 
			
		||||
	string = {fields = {"split"}},
 | 
			
		||||
	table = {fields = {"copy", "getn"}},
 | 
			
		||||
 | 
			
		||||
	-- Minetest
 | 
			
		||||
	"vector", "ItemStack",
 | 
			
		||||
	"dump", "minetest",
 | 
			
		||||
	"VoxelManip", "VoxelArea",
 | 
			
		||||
 | 
			
		||||
	-- mods
 | 
			
		||||
	"default", "mesecon", "digiline",
 | 
			
		||||
	"screwdriver", "unified_inventory",
 | 
			
		||||
	"i3", "mcl_experience", "awards"
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										961
									
								
								LICENSE
									
									
									
									
									
								
							
							
						
						
									
										961
									
								
								LICENSE
									
									
									
									
									
								
							@@ -1,534 +1,12 @@
 | 
			
		||||
                  GNU LESSER GENERAL PUBLIC LICENSE
 | 
			
		||||
                       Version 2.1, February 1999
 | 
			
		||||
License for code: LGPL 3.0
 | 
			
		||||
License for media and all other assets:  CC-by-SA 4.0
 | 
			
		||||
 | 
			
		||||
 Copyright (C) 1991, 1999 Free Software Foundation, Inc.
 | 
			
		||||
 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 | 
			
		||||
 Everyone is permitted to copy and distribute verbatim copies
 | 
			
		||||
 of this license document, but changing it is not allowed.
 | 
			
		||||
###############################################################################
 | 
			
		||||
 | 
			
		||||
[This is the first released version of the Lesser GPL.  It also counts
 | 
			
		||||
 as the successor of the GNU Library Public License, version 2, hence
 | 
			
		||||
 the version number 2.1.]
 | 
			
		||||
 | 
			
		||||
                            Preamble
 | 
			
		||||
 | 
			
		||||
  The licenses for most software are designed to take away your
 | 
			
		||||
freedom to share and change it.  By contrast, the GNU General Public
 | 
			
		||||
Licenses are intended to guarantee your freedom to share and change
 | 
			
		||||
free software--to make sure the software is free for all its users.
 | 
			
		||||
 | 
			
		||||
  This license, the Lesser General Public License, applies to some
 | 
			
		||||
specially designated software packages--typically libraries--of the
 | 
			
		||||
Free Software Foundation and other authors who decide to use it.  You
 | 
			
		||||
can use it too, but we suggest you first think carefully about whether
 | 
			
		||||
this license or the ordinary General Public License is the better
 | 
			
		||||
strategy to use in any particular case, based on the explanations below.
 | 
			
		||||
 | 
			
		||||
  When we speak of free software, we are referring to freedom of use,
 | 
			
		||||
not price.  Our General Public Licenses are designed to make sure that
 | 
			
		||||
you have the freedom to distribute copies of free software (and charge
 | 
			
		||||
for this service if you wish); that you receive source code or can get
 | 
			
		||||
it if you want it; that you can change the software and use pieces of
 | 
			
		||||
it in new free programs; and that you are informed that you can do
 | 
			
		||||
these things.
 | 
			
		||||
 | 
			
		||||
  To protect your rights, we need to make restrictions that forbid
 | 
			
		||||
distributors to deny you these rights or to ask you to surrender these
 | 
			
		||||
rights.  These restrictions translate to certain responsibilities for
 | 
			
		||||
you if you distribute copies of the library or if you modify it.
 | 
			
		||||
 | 
			
		||||
  For example, if you distribute copies of the library, whether gratis
 | 
			
		||||
or for a fee, you must give the recipients all the rights that we gave
 | 
			
		||||
you.  You must make sure that they, too, receive or can get the source
 | 
			
		||||
code.  If you link other code with the library, you must provide
 | 
			
		||||
complete object files to the recipients, so that they can relink them
 | 
			
		||||
with the library after making changes to the library and recompiling
 | 
			
		||||
it.  And you must show them these terms so they know their rights.
 | 
			
		||||
 | 
			
		||||
  We protect your rights with a two-step method: (1) we copyright the
 | 
			
		||||
library, and (2) we offer you this license, which gives you legal
 | 
			
		||||
permission to copy, distribute and/or modify the library.
 | 
			
		||||
 | 
			
		||||
  To protect each distributor, we want to make it very clear that
 | 
			
		||||
there is no warranty for the free library.  Also, if the library is
 | 
			
		||||
modified by someone else and passed on, the recipients should know
 | 
			
		||||
that what they have is not the original version, so that the original
 | 
			
		||||
author's reputation will not be affected by problems that might be
 | 
			
		||||
introduced by others.
 | 
			
		||||
 | 
			
		||||
  Finally, software patents pose a constant threat to the existence of
 | 
			
		||||
any free program.  We wish to make sure that a company cannot
 | 
			
		||||
effectively restrict the users of a free program by obtaining a
 | 
			
		||||
restrictive license from a patent holder.  Therefore, we insist that
 | 
			
		||||
any patent license obtained for a version of the library must be
 | 
			
		||||
consistent with the full freedom of use specified in this license.
 | 
			
		||||
 | 
			
		||||
  Most GNU software, including some libraries, is covered by the
 | 
			
		||||
ordinary GNU General Public License.  This license, the GNU Lesser
 | 
			
		||||
General Public License, applies to certain designated libraries, and
 | 
			
		||||
is quite different from the ordinary General Public License.  We use
 | 
			
		||||
this license for certain libraries in order to permit linking those
 | 
			
		||||
libraries into non-free programs.
 | 
			
		||||
 | 
			
		||||
  When a program is linked with a library, whether statically or using
 | 
			
		||||
a shared library, the combination of the two is legally speaking a
 | 
			
		||||
combined work, a derivative of the original library.  The ordinary
 | 
			
		||||
General Public License therefore permits such linking only if the
 | 
			
		||||
entire combination fits its criteria of freedom.  The Lesser General
 | 
			
		||||
Public License permits more lax criteria for linking other code with
 | 
			
		||||
the library.
 | 
			
		||||
 | 
			
		||||
  We call this license the "Lesser" General Public License because it
 | 
			
		||||
does Less to protect the user's freedom than the ordinary General
 | 
			
		||||
Public License.  It also provides other free software developers Less
 | 
			
		||||
of an advantage over competing non-free programs.  These disadvantages
 | 
			
		||||
are the reason we use the ordinary General Public License for many
 | 
			
		||||
libraries.  However, the Lesser license provides advantages in certain
 | 
			
		||||
special circumstances.
 | 
			
		||||
 | 
			
		||||
  For example, on rare occasions, there may be a special need to
 | 
			
		||||
encourage the widest possible use of a certain library, so that it becomes
 | 
			
		||||
a de-facto standard.  To achieve this, non-free programs must be
 | 
			
		||||
allowed to use the library.  A more frequent case is that a free
 | 
			
		||||
library does the same job as widely used non-free libraries.  In this
 | 
			
		||||
case, there is little to gain by limiting the free library to free
 | 
			
		||||
software only, so we use the Lesser General Public License.
 | 
			
		||||
 | 
			
		||||
  In other cases, permission to use a particular library in non-free
 | 
			
		||||
programs enables a greater number of people to use a large body of
 | 
			
		||||
free software.  For example, permission to use the GNU C Library in
 | 
			
		||||
non-free programs enables many more people to use the whole GNU
 | 
			
		||||
operating system, as well as its variant, the GNU/Linux operating
 | 
			
		||||
system.
 | 
			
		||||
 | 
			
		||||
  Although the Lesser General Public License is Less protective of the
 | 
			
		||||
users' freedom, it does ensure that the user of a program that is
 | 
			
		||||
linked with the Library has the freedom and the wherewithal to run
 | 
			
		||||
that program using a modified version of the Library.
 | 
			
		||||
 | 
			
		||||
  The precise terms and conditions for copying, distribution and
 | 
			
		||||
modification follow.  Pay close attention to the difference between a
 | 
			
		||||
"work based on the library" and a "work that uses the library".  The
 | 
			
		||||
former contains code derived from the library, whereas the latter must
 | 
			
		||||
be combined with the library in order to run.
 | 
			
		||||
 | 
			
		||||
                  GNU LESSER GENERAL PUBLIC LICENSE
 | 
			
		||||
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
 | 
			
		||||
 | 
			
		||||
  0. This License Agreement applies to any software library or other
 | 
			
		||||
program which contains a notice placed by the copyright holder or
 | 
			
		||||
other authorized party saying it may be distributed under the terms of
 | 
			
		||||
this Lesser General Public License (also called "this License").
 | 
			
		||||
Each licensee is addressed as "you".
 | 
			
		||||
 | 
			
		||||
  A "library" means a collection of software functions and/or data
 | 
			
		||||
prepared so as to be conveniently linked with application programs
 | 
			
		||||
(which use some of those functions and data) to form executables.
 | 
			
		||||
 | 
			
		||||
  The "Library", below, refers to any such software library or work
 | 
			
		||||
which has been distributed under these terms.  A "work based on the
 | 
			
		||||
Library" means either the Library or any derivative work under
 | 
			
		||||
copyright law: that is to say, a work containing the Library or a
 | 
			
		||||
portion of it, either verbatim or with modifications and/or translated
 | 
			
		||||
straightforwardly into another language.  (Hereinafter, translation is
 | 
			
		||||
included without limitation in the term "modification".)
 | 
			
		||||
 | 
			
		||||
  "Source code" for a work means the preferred form of the work for
 | 
			
		||||
making modifications to it.  For a library, complete source code means
 | 
			
		||||
all the source code for all modules it contains, plus any associated
 | 
			
		||||
interface definition files, plus the scripts used to control compilation
 | 
			
		||||
and installation of the library.
 | 
			
		||||
 | 
			
		||||
  Activities other than copying, distribution and modification are not
 | 
			
		||||
covered by this License; they are outside its scope.  The act of
 | 
			
		||||
running a program using the Library is not restricted, and output from
 | 
			
		||||
such a program is covered only if its contents constitute a work based
 | 
			
		||||
on the Library (independent of the use of the Library in a tool for
 | 
			
		||||
writing it).  Whether that is true depends on what the Library does
 | 
			
		||||
and what the program that uses the Library does.
 | 
			
		||||
 | 
			
		||||
  1. You may copy and distribute verbatim copies of the Library's
 | 
			
		||||
complete source code as you receive it, in any medium, provided that
 | 
			
		||||
you conspicuously and appropriately publish on each copy an
 | 
			
		||||
appropriate copyright notice and disclaimer of warranty; keep intact
 | 
			
		||||
all the notices that refer to this License and to the absence of any
 | 
			
		||||
warranty; and distribute a copy of this License along with the
 | 
			
		||||
Library.
 | 
			
		||||
 | 
			
		||||
  You may charge a fee for the physical act of transferring a copy,
 | 
			
		||||
and you may at your option offer warranty protection in exchange for a
 | 
			
		||||
fee.
 | 
			
		||||
 | 
			
		||||
  2. You may modify your copy or copies of the Library or any portion
 | 
			
		||||
of it, thus forming a work based on the Library, and copy and
 | 
			
		||||
distribute such modifications or work under the terms of Section 1
 | 
			
		||||
above, provided that you also meet all of these conditions:
 | 
			
		||||
 | 
			
		||||
    a) The modified work must itself be a software library.
 | 
			
		||||
 | 
			
		||||
    b) You must cause the files modified to carry prominent notices
 | 
			
		||||
    stating that you changed the files and the date of any change.
 | 
			
		||||
 | 
			
		||||
    c) You must cause the whole of the work to be licensed at no
 | 
			
		||||
    charge to all third parties under the terms of this License.
 | 
			
		||||
 | 
			
		||||
    d) If a facility in the modified Library refers to a function or a
 | 
			
		||||
    table of data to be supplied by an application program that uses
 | 
			
		||||
    the facility, other than as an argument passed when the facility
 | 
			
		||||
    is invoked, then you must make a good faith effort to ensure that,
 | 
			
		||||
    in the event an application does not supply such function or
 | 
			
		||||
    table, the facility still operates, and performs whatever part of
 | 
			
		||||
    its purpose remains meaningful.
 | 
			
		||||
 | 
			
		||||
    (For example, a function in a library to compute square roots has
 | 
			
		||||
    a purpose that is entirely well-defined independent of the
 | 
			
		||||
    application.  Therefore, Subsection 2d requires that any
 | 
			
		||||
    application-supplied function or table used by this function must
 | 
			
		||||
    be optional: if the application does not supply it, the square
 | 
			
		||||
    root function must still compute square roots.)
 | 
			
		||||
 | 
			
		||||
These requirements apply to the modified work as a whole.  If
 | 
			
		||||
identifiable sections of that work are not derived from the Library,
 | 
			
		||||
and can be reasonably considered independent and separate works in
 | 
			
		||||
themselves, then this License, and its terms, do not apply to those
 | 
			
		||||
sections when you distribute them as separate works.  But when you
 | 
			
		||||
distribute the same sections as part of a whole which is a work based
 | 
			
		||||
on the Library, the distribution of the whole must be on the terms of
 | 
			
		||||
this License, whose permissions for other licensees extend to the
 | 
			
		||||
entire whole, and thus to each and every part regardless of who wrote
 | 
			
		||||
it.
 | 
			
		||||
 | 
			
		||||
Thus, it is not the intent of this section to claim rights or contest
 | 
			
		||||
your rights to work written entirely by you; rather, the intent is to
 | 
			
		||||
exercise the right to control the distribution of derivative or
 | 
			
		||||
collective works based on the Library.
 | 
			
		||||
 | 
			
		||||
In addition, mere aggregation of another work not based on the Library
 | 
			
		||||
with the Library (or with a work based on the Library) on a volume of
 | 
			
		||||
a storage or distribution medium does not bring the other work under
 | 
			
		||||
the scope of this License.
 | 
			
		||||
 | 
			
		||||
  3. You may opt to apply the terms of the ordinary GNU General Public
 | 
			
		||||
License instead of this License to a given copy of the Library.  To do
 | 
			
		||||
this, you must alter all the notices that refer to this License, so
 | 
			
		||||
that they refer to the ordinary GNU General Public License, version 2,
 | 
			
		||||
instead of to this License.  (If a newer version than version 2 of the
 | 
			
		||||
ordinary GNU General Public License has appeared, then you can specify
 | 
			
		||||
that version instead if you wish.)  Do not make any other change in
 | 
			
		||||
these notices.
 | 
			
		||||
 | 
			
		||||
  Once this change is made in a given copy, it is irreversible for
 | 
			
		||||
that copy, so the ordinary GNU General Public License applies to all
 | 
			
		||||
subsequent copies and derivative works made from that copy.
 | 
			
		||||
 | 
			
		||||
  This option is useful when you wish to copy part of the code of
 | 
			
		||||
the Library into a program that is not a library.
 | 
			
		||||
 | 
			
		||||
  4. You may copy and distribute the Library (or a portion or
 | 
			
		||||
derivative of it, under Section 2) in object code or executable form
 | 
			
		||||
under the terms of Sections 1 and 2 above provided that you accompany
 | 
			
		||||
it with the complete corresponding machine-readable source code, which
 | 
			
		||||
must be distributed under the terms of Sections 1 and 2 above on a
 | 
			
		||||
medium customarily used for software interchange.
 | 
			
		||||
 | 
			
		||||
  If distribution of object code is made by offering access to copy
 | 
			
		||||
from a designated place, then offering equivalent access to copy the
 | 
			
		||||
source code from the same place satisfies the requirement to
 | 
			
		||||
distribute the source code, even though third parties are not
 | 
			
		||||
compelled to copy the source along with the object code.
 | 
			
		||||
 | 
			
		||||
  5. A program that contains no derivative of any portion of the
 | 
			
		||||
Library, but is designed to work with the Library by being compiled or
 | 
			
		||||
linked with it, is called a "work that uses the Library".  Such a
 | 
			
		||||
work, in isolation, is not a derivative work of the Library, and
 | 
			
		||||
therefore falls outside the scope of this License.
 | 
			
		||||
 | 
			
		||||
  However, linking a "work that uses the Library" with the Library
 | 
			
		||||
creates an executable that is a derivative of the Library (because it
 | 
			
		||||
contains portions of the Library), rather than a "work that uses the
 | 
			
		||||
library".  The executable is therefore covered by this License.
 | 
			
		||||
Section 6 states terms for distribution of such executables.
 | 
			
		||||
 | 
			
		||||
  When a "work that uses the Library" uses material from a header file
 | 
			
		||||
that is part of the Library, the object code for the work may be a
 | 
			
		||||
derivative work of the Library even though the source code is not.
 | 
			
		||||
Whether this is true is especially significant if the work can be
 | 
			
		||||
linked without the Library, or if the work is itself a library.  The
 | 
			
		||||
threshold for this to be true is not precisely defined by law.
 | 
			
		||||
 | 
			
		||||
  If such an object file uses only numerical parameters, data
 | 
			
		||||
structure layouts and accessors, and small macros and small inline
 | 
			
		||||
functions (ten lines or less in length), then the use of the object
 | 
			
		||||
file is unrestricted, regardless of whether it is legally a derivative
 | 
			
		||||
work.  (Executables containing this object code plus portions of the
 | 
			
		||||
Library will still fall under Section 6.)
 | 
			
		||||
 | 
			
		||||
  Otherwise, if the work is a derivative of the Library, you may
 | 
			
		||||
distribute the object code for the work under the terms of Section 6.
 | 
			
		||||
Any executables containing that work also fall under Section 6,
 | 
			
		||||
whether or not they are linked directly with the Library itself.
 | 
			
		||||
 | 
			
		||||
  6. As an exception to the Sections above, you may also combine or
 | 
			
		||||
link a "work that uses the Library" with the Library to produce a
 | 
			
		||||
work containing portions of the Library, and distribute that work
 | 
			
		||||
under terms of your choice, provided that the terms permit
 | 
			
		||||
modification of the work for the customer's own use and reverse
 | 
			
		||||
engineering for debugging such modifications.
 | 
			
		||||
 | 
			
		||||
  You must give prominent notice with each copy of the work that the
 | 
			
		||||
Library is used in it and that the Library and its use are covered by
 | 
			
		||||
this License.  You must supply a copy of this License.  If the work
 | 
			
		||||
during execution displays copyright notices, you must include the
 | 
			
		||||
copyright notice for the Library among them, as well as a reference
 | 
			
		||||
directing the user to the copy of this License.  Also, you must do one
 | 
			
		||||
of these things:
 | 
			
		||||
 | 
			
		||||
    a) Accompany the work with the complete corresponding
 | 
			
		||||
    machine-readable source code for the Library including whatever
 | 
			
		||||
    changes were used in the work (which must be distributed under
 | 
			
		||||
    Sections 1 and 2 above); and, if the work is an executable linked
 | 
			
		||||
    with the Library, with the complete machine-readable "work that
 | 
			
		||||
    uses the Library", as object code and/or source code, so that the
 | 
			
		||||
    user can modify the Library and then relink to produce a modified
 | 
			
		||||
    executable containing the modified Library.  (It is understood
 | 
			
		||||
    that the user who changes the contents of definitions files in the
 | 
			
		||||
    Library will not necessarily be able to recompile the application
 | 
			
		||||
    to use the modified definitions.)
 | 
			
		||||
 | 
			
		||||
    b) Use a suitable shared library mechanism for linking with the
 | 
			
		||||
    Library.  A suitable mechanism is one that (1) uses at run time a
 | 
			
		||||
    copy of the library already present on the user's computer system,
 | 
			
		||||
    rather than copying library functions into the executable, and (2)
 | 
			
		||||
    will operate properly with a modified version of the library, if
 | 
			
		||||
    the user installs one, as long as the modified version is
 | 
			
		||||
    interface-compatible with the version that the work was made with.
 | 
			
		||||
 | 
			
		||||
    c) Accompany the work with a written offer, valid for at
 | 
			
		||||
    least three years, to give the same user the materials
 | 
			
		||||
    specified in Subsection 6a, above, for a charge no more
 | 
			
		||||
    than the cost of performing this distribution.
 | 
			
		||||
 | 
			
		||||
    d) If distribution of the work is made by offering access to copy
 | 
			
		||||
    from a designated place, offer equivalent access to copy the above
 | 
			
		||||
    specified materials from the same place.
 | 
			
		||||
 | 
			
		||||
    e) Verify that the user has already received a copy of these
 | 
			
		||||
    materials or that you have already sent this user a copy.
 | 
			
		||||
 | 
			
		||||
  For an executable, the required form of the "work that uses the
 | 
			
		||||
Library" must include any data and utility programs needed for
 | 
			
		||||
reproducing the executable from it.  However, as a special exception,
 | 
			
		||||
the materials to be distributed need not include anything that is
 | 
			
		||||
normally distributed (in either source or binary form) with the major
 | 
			
		||||
components (compiler, kernel, and so on) of the operating system on
 | 
			
		||||
which the executable runs, unless that component itself accompanies
 | 
			
		||||
the executable.
 | 
			
		||||
 | 
			
		||||
  It may happen that this requirement contradicts the license
 | 
			
		||||
restrictions of other proprietary libraries that do not normally
 | 
			
		||||
accompany the operating system.  Such a contradiction means you cannot
 | 
			
		||||
use both them and the Library together in an executable that you
 | 
			
		||||
distribute.
 | 
			
		||||
 | 
			
		||||
  7. You may place library facilities that are a work based on the
 | 
			
		||||
Library side-by-side in a single library together with other library
 | 
			
		||||
facilities not covered by this License, and distribute such a combined
 | 
			
		||||
library, provided that the separate distribution of the work based on
 | 
			
		||||
the Library and of the other library facilities is otherwise
 | 
			
		||||
permitted, and provided that you do these two things:
 | 
			
		||||
 | 
			
		||||
    a) Accompany the combined library with a copy of the same work
 | 
			
		||||
    based on the Library, uncombined with any other library
 | 
			
		||||
    facilities.  This must be distributed under the terms of the
 | 
			
		||||
    Sections above.
 | 
			
		||||
 | 
			
		||||
    b) Give prominent notice with the combined library of the fact
 | 
			
		||||
    that part of it is a work based on the Library, and explaining
 | 
			
		||||
    where to find the accompanying uncombined form of the same work.
 | 
			
		||||
 | 
			
		||||
  8. You may not copy, modify, sublicense, link with, or distribute
 | 
			
		||||
the Library except as expressly provided under this License.  Any
 | 
			
		||||
attempt otherwise to copy, modify, sublicense, link with, or
 | 
			
		||||
distribute the Library is void, and will automatically terminate your
 | 
			
		||||
rights under this License.  However, parties who have received copies,
 | 
			
		||||
or rights, from you under this License will not have their licenses
 | 
			
		||||
terminated so long as such parties remain in full compliance.
 | 
			
		||||
 | 
			
		||||
  9. You are not required to accept this License, since you have not
 | 
			
		||||
signed it.  However, nothing else grants you permission to modify or
 | 
			
		||||
distribute the Library or its derivative works.  These actions are
 | 
			
		||||
prohibited by law if you do not accept this License.  Therefore, by
 | 
			
		||||
modifying or distributing the Library (or any work based on the
 | 
			
		||||
Library), you indicate your acceptance of this License to do so, and
 | 
			
		||||
all its terms and conditions for copying, distributing or modifying
 | 
			
		||||
the Library or works based on it.
 | 
			
		||||
 | 
			
		||||
  10. Each time you redistribute the Library (or any work based on the
 | 
			
		||||
Library), the recipient automatically receives a license from the
 | 
			
		||||
original licensor to copy, distribute, link with or modify the Library
 | 
			
		||||
subject to these terms and conditions.  You may not impose any further
 | 
			
		||||
restrictions on the recipients' exercise of the rights granted herein.
 | 
			
		||||
You are not responsible for enforcing compliance by third parties with
 | 
			
		||||
this License.
 | 
			
		||||
 | 
			
		||||
  11. If, as a consequence of a court judgment or allegation of patent
 | 
			
		||||
infringement or for any other reason (not limited to patent issues),
 | 
			
		||||
conditions are imposed on you (whether by court order, agreement or
 | 
			
		||||
otherwise) that contradict the conditions of this License, they do not
 | 
			
		||||
excuse you from the conditions of this License.  If you cannot
 | 
			
		||||
distribute so as to satisfy simultaneously your obligations under this
 | 
			
		||||
License and any other pertinent obligations, then as a consequence you
 | 
			
		||||
may not distribute the Library at all.  For example, if a patent
 | 
			
		||||
license would not permit royalty-free redistribution of the Library by
 | 
			
		||||
all those who receive copies directly or indirectly through you, then
 | 
			
		||||
the only way you could satisfy both it and this License would be to
 | 
			
		||||
refrain entirely from distribution of the Library.
 | 
			
		||||
 | 
			
		||||
If any portion of this section is held invalid or unenforceable under any
 | 
			
		||||
particular circumstance, the balance of the section is intended to apply,
 | 
			
		||||
and the section as a whole is intended to apply in other circumstances.
 | 
			
		||||
 | 
			
		||||
It is not the purpose of this section to induce you to infringe any
 | 
			
		||||
patents or other property right claims or to contest validity of any
 | 
			
		||||
such claims; this section has the sole purpose of protecting the
 | 
			
		||||
integrity of the free software distribution system which is
 | 
			
		||||
implemented by public license practices.  Many people have made
 | 
			
		||||
generous contributions to the wide range of software distributed
 | 
			
		||||
through that system in reliance on consistent application of that
 | 
			
		||||
system; it is up to the author/donor to decide if he or she is willing
 | 
			
		||||
to distribute software through any other system and a licensee cannot
 | 
			
		||||
impose that choice.
 | 
			
		||||
 | 
			
		||||
This section is intended to make thoroughly clear what is believed to
 | 
			
		||||
be a consequence of the rest of this License.
 | 
			
		||||
 | 
			
		||||
  12. If the distribution and/or use of the Library is restricted in
 | 
			
		||||
certain countries either by patents or by copyrighted interfaces, the
 | 
			
		||||
original copyright holder who places the Library under this License may add
 | 
			
		||||
an explicit geographical distribution limitation excluding those countries,
 | 
			
		||||
so that distribution is permitted only in or among countries not thus
 | 
			
		||||
excluded.  In such case, this License incorporates the limitation as if
 | 
			
		||||
written in the body of this License.
 | 
			
		||||
 | 
			
		||||
  13. The Free Software Foundation may publish revised and/or new
 | 
			
		||||
versions of the Lesser General Public License from time to time.
 | 
			
		||||
Such new versions will be similar in spirit to the present version,
 | 
			
		||||
but may differ in detail to address new problems or concerns.
 | 
			
		||||
 | 
			
		||||
Each version is given a distinguishing version number.  If the Library
 | 
			
		||||
specifies a version number of this License which applies to it and
 | 
			
		||||
"any later version", you have the option of following the terms and
 | 
			
		||||
conditions either of that version or of any later version published by
 | 
			
		||||
the Free Software Foundation.  If the Library does not specify a
 | 
			
		||||
license version number, you may choose any version ever published by
 | 
			
		||||
the Free Software Foundation.
 | 
			
		||||
 | 
			
		||||
  14. If you wish to incorporate parts of the Library into other free
 | 
			
		||||
programs whose distribution conditions are incompatible with these,
 | 
			
		||||
write to the author to ask for permission.  For software which is
 | 
			
		||||
copyrighted by the Free Software Foundation, write to the Free
 | 
			
		||||
Software Foundation; we sometimes make exceptions for this.  Our
 | 
			
		||||
decision will be guided by the two goals of preserving the free status
 | 
			
		||||
of all derivatives of our free software and of promoting the sharing
 | 
			
		||||
and reuse of software generally.
 | 
			
		||||
 | 
			
		||||
                            NO WARRANTY
 | 
			
		||||
 | 
			
		||||
  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
 | 
			
		||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
 | 
			
		||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
 | 
			
		||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
 | 
			
		||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 | 
			
		||||
PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
 | 
			
		||||
LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
 | 
			
		||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
 | 
			
		||||
 | 
			
		||||
  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
 | 
			
		||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
 | 
			
		||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
 | 
			
		||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
 | 
			
		||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
 | 
			
		||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
 | 
			
		||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
 | 
			
		||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
 | 
			
		||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
 | 
			
		||||
DAMAGES.
 | 
			
		||||
 | 
			
		||||
                     END OF TERMS AND CONDITIONS
 | 
			
		||||
 | 
			
		||||
           How to Apply These Terms to Your New Libraries
 | 
			
		||||
 | 
			
		||||
  If you develop a new library, and you want it to be of the greatest
 | 
			
		||||
possible use to the public, we recommend making it free software that
 | 
			
		||||
everyone can redistribute and change.  You can do so by permitting
 | 
			
		||||
redistribution under these terms (or, alternatively, under the terms of the
 | 
			
		||||
ordinary General Public License).
 | 
			
		||||
 | 
			
		||||
  To apply these terms, attach the following notices to the library.  It is
 | 
			
		||||
safest to attach them to the start of each source file to most effectively
 | 
			
		||||
convey the exclusion of warranty; and each file should have at least the
 | 
			
		||||
"copyright" line and a pointer to where the full notice is found.
 | 
			
		||||
 | 
			
		||||
    <one line to give the library's name and a brief idea of what it does.>
 | 
			
		||||
    Copyright (C) <year>  <name of author>
 | 
			
		||||
 | 
			
		||||
    This library is free software; you can redistribute it and/or
 | 
			
		||||
    modify it under the terms of the GNU Lesser General Public
 | 
			
		||||
    License as published by the Free Software Foundation; either
 | 
			
		||||
    version 2.1 of the License, or (at your option) any later version.
 | 
			
		||||
 | 
			
		||||
    This library is distributed in the hope that it will be useful,
 | 
			
		||||
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
			
		||||
    Lesser General Public License for more details.
 | 
			
		||||
 | 
			
		||||
    You should have received a copy of the GNU Lesser General Public
 | 
			
		||||
    License along with this library; if not, write to the Free Software
 | 
			
		||||
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 | 
			
		||||
 | 
			
		||||
Also add information on how to contact you by electronic and paper mail.
 | 
			
		||||
 | 
			
		||||
You should also get your employer (if you work as a programmer) or your
 | 
			
		||||
school, if any, to sign a "copyright disclaimer" for the library, if
 | 
			
		||||
necessary.  Here is a sample; alter the names:
 | 
			
		||||
 | 
			
		||||
  Yoyodyne, Inc., hereby disclaims all copyright interest in the
 | 
			
		||||
  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
 | 
			
		||||
 | 
			
		||||
  <signature of Ty Coon>, 1 April 1990
 | 
			
		||||
  Ty Coon, President of Vice
 | 
			
		||||
 | 
			
		||||
That's all there is to it!
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
--------------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
Some code in lua_tube.lua is copied from The Mesecons Mod for Minetest:
 | 
			
		||||
 | 
			
		||||
License of source code
 | 
			
		||||
----------------------
 | 
			
		||||
Copyright (C) 2011-2016 Mesecons Mod Developer Team and contributors
 | 
			
		||||
 | 
			
		||||
This program is free software; you can redistribute the Mesecons Mod and/or
 | 
			
		||||
modify it under the terms of the GNU Lesser General Public License version 3
 | 
			
		||||
published by the Free Software Foundation.
 | 
			
		||||
 | 
			
		||||
This library is distributed in the hope that it will be useful,
 | 
			
		||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
			
		||||
Library General Public License for more details.
 | 
			
		||||
 | 
			
		||||
You should have received a copy of the GNU Library General Public
 | 
			
		||||
License along with this library; if not, write to the
 | 
			
		||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 | 
			
		||||
Boston, MA  02110-1301, USA.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
GNU LESSER GENERAL PUBLIC LICENSE
 | 
			
		||||
                   GNU LESSER GENERAL PUBLIC LICENSE
 | 
			
		||||
                       Version 3, 29 June 2007
 | 
			
		||||
 | 
			
		||||
 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
 | 
			
		||||
 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
 | 
			
		||||
 Everyone is permitted to copy and distribute verbatim copies
 | 
			
		||||
 of this license document, but changing it is not allowed.
 | 
			
		||||
 | 
			
		||||
@@ -691,3 +169,432 @@ apply, that proxy's public statement of acceptance of any version is
 | 
			
		||||
permanent authorization for you to choose that version for the
 | 
			
		||||
Library.
 | 
			
		||||
 | 
			
		||||
###############################################################################
 | 
			
		||||
 | 
			
		||||
Attribution-ShareAlike 4.0 International
 | 
			
		||||
 | 
			
		||||
=======================================================================
 | 
			
		||||
 | 
			
		||||
Creative Commons Corporation ("Creative Commons") is not a law firm and
 | 
			
		||||
does not provide legal services or legal advice. Distribution of
 | 
			
		||||
Creative Commons public licenses does not create a lawyer-client or
 | 
			
		||||
other relationship. Creative Commons makes its licenses and related
 | 
			
		||||
information available on an "as-is" basis. Creative Commons gives no
 | 
			
		||||
warranties regarding its licenses, any material licensed under their
 | 
			
		||||
terms and conditions, or any related information. Creative Commons
 | 
			
		||||
disclaims all liability for damages resulting from their use to the
 | 
			
		||||
fullest extent possible.
 | 
			
		||||
 | 
			
		||||
Using Creative Commons Public Licenses
 | 
			
		||||
 | 
			
		||||
Creative Commons public licenses provide a standard set of terms and
 | 
			
		||||
conditions that creators and other rights holders may use to share
 | 
			
		||||
original works of authorship and other material subject to copyright
 | 
			
		||||
and certain other rights specified in the public license below. The
 | 
			
		||||
following considerations are for informational purposes only, are not
 | 
			
		||||
exhaustive, and do not form part of our licenses.
 | 
			
		||||
 | 
			
		||||
     Considerations for licensors: Our public licenses are
 | 
			
		||||
     intended for use by those authorized to give the public
 | 
			
		||||
     permission to use material in ways otherwise restricted by
 | 
			
		||||
     copyright and certain other rights. Our licenses are
 | 
			
		||||
     irrevocable. Licensors should read and understand the terms
 | 
			
		||||
     and conditions of the license they choose before applying it.
 | 
			
		||||
     Licensors should also secure all rights necessary before
 | 
			
		||||
     applying our licenses so that the public can reuse the
 | 
			
		||||
     material as expected. Licensors should clearly mark any
 | 
			
		||||
     material not subject to the license. This includes other CC-
 | 
			
		||||
     licensed material, or material used under an exception or
 | 
			
		||||
     limitation to copyright. More considerations for licensors:
 | 
			
		||||
	wiki.creativecommons.org/Considerations_for_licensors
 | 
			
		||||
 | 
			
		||||
     Considerations for the public: By using one of our public
 | 
			
		||||
     licenses, a licensor grants the public permission to use the
 | 
			
		||||
     licensed material under specified terms and conditions. If
 | 
			
		||||
     the licensor's permission is not necessary for any reason--for
 | 
			
		||||
     example, because of any applicable exception or limitation to
 | 
			
		||||
     copyright--then that use is not regulated by the license. Our
 | 
			
		||||
     licenses grant only permissions under copyright and certain
 | 
			
		||||
     other rights that a licensor has authority to grant. Use of
 | 
			
		||||
     the licensed material may still be restricted for other
 | 
			
		||||
     reasons, including because others have copyright or other
 | 
			
		||||
     rights in the material. A licensor may make special requests,
 | 
			
		||||
     such as asking that all changes be marked or described.
 | 
			
		||||
     Although not required by our licenses, you are encouraged to
 | 
			
		||||
     respect those requests where reasonable. More considerations
 | 
			
		||||
     for the public: 
 | 
			
		||||
	wiki.creativecommons.org/Considerations_for_licensees
 | 
			
		||||
 | 
			
		||||
=======================================================================
 | 
			
		||||
 | 
			
		||||
Creative Commons Attribution-ShareAlike 4.0 International Public
 | 
			
		||||
License
 | 
			
		||||
 | 
			
		||||
By exercising the Licensed Rights (defined below), You accept and agree
 | 
			
		||||
to be bound by the terms and conditions of this Creative Commons
 | 
			
		||||
Attribution-ShareAlike 4.0 International Public License ("Public
 | 
			
		||||
License"). To the extent this Public License may be interpreted as a
 | 
			
		||||
contract, You are granted the Licensed Rights in consideration of Your
 | 
			
		||||
acceptance of these terms and conditions, and the Licensor grants You
 | 
			
		||||
such rights in consideration of benefits the Licensor receives from
 | 
			
		||||
making the Licensed Material available under these terms and
 | 
			
		||||
conditions.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Section 1 -- Definitions.
 | 
			
		||||
 | 
			
		||||
  a. Adapted Material means material subject to Copyright and Similar
 | 
			
		||||
     Rights that is derived from or based upon the Licensed Material
 | 
			
		||||
     and in which the Licensed Material is translated, altered,
 | 
			
		||||
     arranged, transformed, or otherwise modified in a manner requiring
 | 
			
		||||
     permission under the Copyright and Similar Rights held by the
 | 
			
		||||
     Licensor. For purposes of this Public License, where the Licensed
 | 
			
		||||
     Material is a musical work, performance, or sound recording,
 | 
			
		||||
     Adapted Material is always produced where the Licensed Material is
 | 
			
		||||
     synched in timed relation with a moving image.
 | 
			
		||||
 | 
			
		||||
  b. Adapter's License means the license You apply to Your Copyright
 | 
			
		||||
     and Similar Rights in Your contributions to Adapted Material in
 | 
			
		||||
     accordance with the terms and conditions of this Public License.
 | 
			
		||||
 | 
			
		||||
  c. BY-SA Compatible License means a license listed at
 | 
			
		||||
     creativecommons.org/compatiblelicenses, approved by Creative
 | 
			
		||||
     Commons as essentially the equivalent of this Public License.
 | 
			
		||||
 | 
			
		||||
  d. Copyright and Similar Rights means copyright and/or similar rights
 | 
			
		||||
     closely related to copyright including, without limitation,
 | 
			
		||||
     performance, broadcast, sound recording, and Sui Generis Database
 | 
			
		||||
     Rights, without regard to how the rights are labeled or
 | 
			
		||||
     categorized. For purposes of this Public License, the rights
 | 
			
		||||
     specified in Section 2(b)(1)-(2) are not Copyright and Similar
 | 
			
		||||
     Rights.
 | 
			
		||||
 | 
			
		||||
  e. Effective Technological Measures means those measures that, in the
 | 
			
		||||
     absence of proper authority, may not be circumvented under laws
 | 
			
		||||
     fulfilling obligations under Article 11 of the WIPO Copyright
 | 
			
		||||
     Treaty adopted on December 20, 1996, and/or similar international
 | 
			
		||||
     agreements.
 | 
			
		||||
 | 
			
		||||
  f. Exceptions and Limitations means fair use, fair dealing, and/or
 | 
			
		||||
     any other exception or limitation to Copyright and Similar Rights
 | 
			
		||||
     that applies to Your use of the Licensed Material.
 | 
			
		||||
 | 
			
		||||
  g. License Elements means the license attributes listed in the name
 | 
			
		||||
     of a Creative Commons Public License. The License Elements of this
 | 
			
		||||
     Public License are Attribution and ShareAlike.
 | 
			
		||||
 | 
			
		||||
  h. Licensed Material means the artistic or literary work, database,
 | 
			
		||||
     or other material to which the Licensor applied this Public
 | 
			
		||||
     License.
 | 
			
		||||
 | 
			
		||||
  i. Licensed Rights means the rights granted to You subject to the
 | 
			
		||||
     terms and conditions of this Public License, which are limited to
 | 
			
		||||
     all Copyright and Similar Rights that apply to Your use of the
 | 
			
		||||
     Licensed Material and that the Licensor has authority to license.
 | 
			
		||||
 | 
			
		||||
  j. Licensor means the individual(s) or entity(ies) granting rights
 | 
			
		||||
     under this Public License.
 | 
			
		||||
 | 
			
		||||
  k. Share means to provide material to the public by any means or
 | 
			
		||||
     process that requires permission under the Licensed Rights, such
 | 
			
		||||
     as reproduction, public display, public performance, distribution,
 | 
			
		||||
     dissemination, communication, or importation, and to make material
 | 
			
		||||
     available to the public including in ways that members of the
 | 
			
		||||
     public may access the material from a place and at a time
 | 
			
		||||
     individually chosen by them.
 | 
			
		||||
 | 
			
		||||
  l. Sui Generis Database Rights means rights other than copyright
 | 
			
		||||
     resulting from Directive 96/9/EC of the European Parliament and of
 | 
			
		||||
     the Council of 11 March 1996 on the legal protection of databases,
 | 
			
		||||
     as amended and/or succeeded, as well as other essentially
 | 
			
		||||
     equivalent rights anywhere in the world.
 | 
			
		||||
 | 
			
		||||
  m. You means the individual or entity exercising the Licensed Rights
 | 
			
		||||
     under this Public License. Your has a corresponding meaning.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Section 2 -- Scope.
 | 
			
		||||
 | 
			
		||||
  a. License grant.
 | 
			
		||||
 | 
			
		||||
       1. Subject to the terms and conditions of this Public License,
 | 
			
		||||
          the Licensor hereby grants You a worldwide, royalty-free,
 | 
			
		||||
          non-sublicensable, non-exclusive, irrevocable license to
 | 
			
		||||
          exercise the Licensed Rights in the Licensed Material to:
 | 
			
		||||
 | 
			
		||||
            a. reproduce and Share the Licensed Material, in whole or
 | 
			
		||||
               in part; and
 | 
			
		||||
 | 
			
		||||
            b. produce, reproduce, and Share Adapted Material.
 | 
			
		||||
 | 
			
		||||
       2. Exceptions and Limitations. For the avoidance of doubt, where
 | 
			
		||||
          Exceptions and Limitations apply to Your use, this Public
 | 
			
		||||
          License does not apply, and You do not need to comply with
 | 
			
		||||
          its terms and conditions.
 | 
			
		||||
 | 
			
		||||
       3. Term. The term of this Public License is specified in Section
 | 
			
		||||
          6(a).
 | 
			
		||||
 | 
			
		||||
       4. Media and formats; technical modifications allowed. The
 | 
			
		||||
          Licensor authorizes You to exercise the Licensed Rights in
 | 
			
		||||
          all media and formats whether now known or hereafter created,
 | 
			
		||||
          and to make technical modifications necessary to do so. The
 | 
			
		||||
          Licensor waives and/or agrees not to assert any right or
 | 
			
		||||
          authority to forbid You from making technical modifications
 | 
			
		||||
          necessary to exercise the Licensed Rights, including
 | 
			
		||||
          technical modifications necessary to circumvent Effective
 | 
			
		||||
          Technological Measures. For purposes of this Public License,
 | 
			
		||||
          simply making modifications authorized by this Section 2(a)
 | 
			
		||||
          (4) never produces Adapted Material.
 | 
			
		||||
 | 
			
		||||
       5. Downstream recipients.
 | 
			
		||||
 | 
			
		||||
            a. Offer from the Licensor -- Licensed Material. Every
 | 
			
		||||
               recipient of the Licensed Material automatically
 | 
			
		||||
               receives an offer from the Licensor to exercise the
 | 
			
		||||
               Licensed Rights under the terms and conditions of this
 | 
			
		||||
               Public License.
 | 
			
		||||
 | 
			
		||||
            b. Additional offer from the Licensor -- Adapted Material.
 | 
			
		||||
               Every recipient of Adapted Material from You
 | 
			
		||||
               automatically receives an offer from the Licensor to
 | 
			
		||||
               exercise the Licensed Rights in the Adapted Material
 | 
			
		||||
               under the conditions of the Adapter's License You apply.
 | 
			
		||||
 | 
			
		||||
            c. No downstream restrictions. You may not offer or impose
 | 
			
		||||
               any additional or different terms or conditions on, or
 | 
			
		||||
               apply any Effective Technological Measures to, the
 | 
			
		||||
               Licensed Material if doing so restricts exercise of the
 | 
			
		||||
               Licensed Rights by any recipient of the Licensed
 | 
			
		||||
               Material.
 | 
			
		||||
 | 
			
		||||
       6. No endorsement. Nothing in this Public License constitutes or
 | 
			
		||||
          may be construed as permission to assert or imply that You
 | 
			
		||||
          are, or that Your use of the Licensed Material is, connected
 | 
			
		||||
          with, or sponsored, endorsed, or granted official status by,
 | 
			
		||||
          the Licensor or others designated to receive attribution as
 | 
			
		||||
          provided in Section 3(a)(1)(A)(i).
 | 
			
		||||
 | 
			
		||||
  b. Other rights.
 | 
			
		||||
 | 
			
		||||
       1. Moral rights, such as the right of integrity, are not
 | 
			
		||||
          licensed under this Public License, nor are publicity,
 | 
			
		||||
          privacy, and/or other similar personality rights; however, to
 | 
			
		||||
          the extent possible, the Licensor waives and/or agrees not to
 | 
			
		||||
          assert any such rights held by the Licensor to the limited
 | 
			
		||||
          extent necessary to allow You to exercise the Licensed
 | 
			
		||||
          Rights, but not otherwise.
 | 
			
		||||
 | 
			
		||||
       2. Patent and trademark rights are not licensed under this
 | 
			
		||||
          Public License.
 | 
			
		||||
 | 
			
		||||
       3. To the extent possible, the Licensor waives any right to
 | 
			
		||||
          collect royalties from You for the exercise of the Licensed
 | 
			
		||||
          Rights, whether directly or through a collecting society
 | 
			
		||||
          under any voluntary or waivable statutory or compulsory
 | 
			
		||||
          licensing scheme. In all other cases the Licensor expressly
 | 
			
		||||
          reserves any right to collect such royalties.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Section 3 -- License Conditions.
 | 
			
		||||
 | 
			
		||||
Your exercise of the Licensed Rights is expressly made subject to the
 | 
			
		||||
following conditions.
 | 
			
		||||
 | 
			
		||||
  a. Attribution.
 | 
			
		||||
 | 
			
		||||
       1. If You Share the Licensed Material (including in modified
 | 
			
		||||
          form), You must:
 | 
			
		||||
 | 
			
		||||
            a. retain the following if it is supplied by the Licensor
 | 
			
		||||
               with the Licensed Material:
 | 
			
		||||
 | 
			
		||||
                 i. identification of the creator(s) of the Licensed
 | 
			
		||||
                    Material and any others designated to receive
 | 
			
		||||
                    attribution, in any reasonable manner requested by
 | 
			
		||||
                    the Licensor (including by pseudonym if
 | 
			
		||||
                    designated);
 | 
			
		||||
 | 
			
		||||
                ii. a copyright notice;
 | 
			
		||||
 | 
			
		||||
               iii. a notice that refers to this Public License;
 | 
			
		||||
 | 
			
		||||
                iv. a notice that refers to the disclaimer of
 | 
			
		||||
                    warranties;
 | 
			
		||||
 | 
			
		||||
                 v. a URI or hyperlink to the Licensed Material to the
 | 
			
		||||
                    extent reasonably practicable;
 | 
			
		||||
 | 
			
		||||
            b. indicate if You modified the Licensed Material and
 | 
			
		||||
               retain an indication of any previous modifications; and
 | 
			
		||||
 | 
			
		||||
            c. indicate the Licensed Material is licensed under this
 | 
			
		||||
               Public License, and include the text of, or the URI or
 | 
			
		||||
               hyperlink to, this Public License.
 | 
			
		||||
 | 
			
		||||
       2. You may satisfy the conditions in Section 3(a)(1) in any
 | 
			
		||||
          reasonable manner based on the medium, means, and context in
 | 
			
		||||
          which You Share the Licensed Material. For example, it may be
 | 
			
		||||
          reasonable to satisfy the conditions by providing a URI or
 | 
			
		||||
          hyperlink to a resource that includes the required
 | 
			
		||||
          information.
 | 
			
		||||
 | 
			
		||||
       3. If requested by the Licensor, You must remove any of the
 | 
			
		||||
          information required by Section 3(a)(1)(A) to the extent
 | 
			
		||||
          reasonably practicable.
 | 
			
		||||
 | 
			
		||||
  b. ShareAlike.
 | 
			
		||||
 | 
			
		||||
     In addition to the conditions in Section 3(a), if You Share
 | 
			
		||||
     Adapted Material You produce, the following conditions also apply.
 | 
			
		||||
 | 
			
		||||
       1. The Adapter's License You apply must be a Creative Commons
 | 
			
		||||
          license with the same License Elements, this version or
 | 
			
		||||
          later, or a BY-SA Compatible License.
 | 
			
		||||
 | 
			
		||||
       2. You must include the text of, or the URI or hyperlink to, the
 | 
			
		||||
          Adapter's License You apply. You may satisfy this condition
 | 
			
		||||
          in any reasonable manner based on the medium, means, and
 | 
			
		||||
          context in which You Share Adapted Material.
 | 
			
		||||
 | 
			
		||||
       3. You may not offer or impose any additional or different terms
 | 
			
		||||
          or conditions on, or apply any Effective Technological
 | 
			
		||||
          Measures to, Adapted Material that restrict exercise of the
 | 
			
		||||
          rights granted under the Adapter's License You apply.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Section 4 -- Sui Generis Database Rights.
 | 
			
		||||
 | 
			
		||||
Where the Licensed Rights include Sui Generis Database Rights that
 | 
			
		||||
apply to Your use of the Licensed Material:
 | 
			
		||||
 | 
			
		||||
  a. for the avoidance of doubt, Section 2(a)(1) grants You the right
 | 
			
		||||
     to extract, reuse, reproduce, and Share all or a substantial
 | 
			
		||||
     portion of the contents of the database;
 | 
			
		||||
 | 
			
		||||
  b. if You include all or a substantial portion of the database
 | 
			
		||||
     contents in a database in which You have Sui Generis Database
 | 
			
		||||
     Rights, then the database in which You have Sui Generis Database
 | 
			
		||||
     Rights (but not its individual contents) is Adapted Material,
 | 
			
		||||
 | 
			
		||||
     including for purposes of Section 3(b); and
 | 
			
		||||
  c. You must comply with the conditions in Section 3(a) if You Share
 | 
			
		||||
     all or a substantial portion of the contents of the database.
 | 
			
		||||
 | 
			
		||||
For the avoidance of doubt, this Section 4 supplements and does not
 | 
			
		||||
replace Your obligations under this Public License where the Licensed
 | 
			
		||||
Rights include other Copyright and Similar Rights.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
 | 
			
		||||
 | 
			
		||||
  a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
 | 
			
		||||
     EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
 | 
			
		||||
     AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
 | 
			
		||||
     ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
 | 
			
		||||
     IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
 | 
			
		||||
     WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
 | 
			
		||||
     PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
 | 
			
		||||
     ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
 | 
			
		||||
     KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
 | 
			
		||||
     ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
 | 
			
		||||
 | 
			
		||||
  b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
 | 
			
		||||
     TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
 | 
			
		||||
     NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
 | 
			
		||||
     INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
 | 
			
		||||
     COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
 | 
			
		||||
     USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
 | 
			
		||||
     ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
 | 
			
		||||
     DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
 | 
			
		||||
     IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
 | 
			
		||||
 | 
			
		||||
  c. The disclaimer of warranties and limitation of liability provided
 | 
			
		||||
     above shall be interpreted in a manner that, to the extent
 | 
			
		||||
     possible, most closely approximates an absolute disclaimer and
 | 
			
		||||
     waiver of all liability.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Section 6 -- Term and Termination.
 | 
			
		||||
 | 
			
		||||
  a. This Public License applies for the term of the Copyright and
 | 
			
		||||
     Similar Rights licensed here. However, if You fail to comply with
 | 
			
		||||
     this Public License, then Your rights under this Public License
 | 
			
		||||
     terminate automatically.
 | 
			
		||||
 | 
			
		||||
  b. Where Your right to use the Licensed Material has terminated under
 | 
			
		||||
     Section 6(a), it reinstates:
 | 
			
		||||
 | 
			
		||||
       1. automatically as of the date the violation is cured, provided
 | 
			
		||||
          it is cured within 30 days of Your discovery of the
 | 
			
		||||
          violation; or
 | 
			
		||||
 | 
			
		||||
       2. upon express reinstatement by the Licensor.
 | 
			
		||||
 | 
			
		||||
     For the avoidance of doubt, this Section 6(b) does not affect any
 | 
			
		||||
     right the Licensor may have to seek remedies for Your violations
 | 
			
		||||
     of this Public License.
 | 
			
		||||
 | 
			
		||||
  c. For the avoidance of doubt, the Licensor may also offer the
 | 
			
		||||
     Licensed Material under separate terms or conditions or stop
 | 
			
		||||
     distributing the Licensed Material at any time; however, doing so
 | 
			
		||||
     will not terminate this Public License.
 | 
			
		||||
 | 
			
		||||
  d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
 | 
			
		||||
     License.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Section 7 -- Other Terms and Conditions.
 | 
			
		||||
 | 
			
		||||
  a. The Licensor shall not be bound by any additional or different
 | 
			
		||||
     terms or conditions communicated by You unless expressly agreed.
 | 
			
		||||
 | 
			
		||||
  b. Any arrangements, understandings, or agreements regarding the
 | 
			
		||||
     Licensed Material not stated herein are separate from and
 | 
			
		||||
     independent of the terms and conditions of this Public License.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Section 8 -- Interpretation.
 | 
			
		||||
 | 
			
		||||
  a. For the avoidance of doubt, this Public License does not, and
 | 
			
		||||
     shall not be interpreted to, reduce, limit, restrict, or impose
 | 
			
		||||
     conditions on any use of the Licensed Material that could lawfully
 | 
			
		||||
     be made without permission under this Public License.
 | 
			
		||||
 | 
			
		||||
  b. To the extent possible, if any provision of this Public License is
 | 
			
		||||
     deemed unenforceable, it shall be automatically reformed to the
 | 
			
		||||
     minimum extent necessary to make it enforceable. If the provision
 | 
			
		||||
     cannot be reformed, it shall be severed from this Public License
 | 
			
		||||
     without affecting the enforceability of the remaining terms and
 | 
			
		||||
     conditions.
 | 
			
		||||
 | 
			
		||||
  c. No term or condition of this Public License will be waived and no
 | 
			
		||||
     failure to comply consented to unless expressly agreed to by the
 | 
			
		||||
     Licensor.
 | 
			
		||||
 | 
			
		||||
  d. Nothing in this Public License constitutes or may be interpreted
 | 
			
		||||
     as a limitation upon, or waiver of, any privileges and immunities
 | 
			
		||||
     that apply to the Licensor or You, including from the legal
 | 
			
		||||
     processes of any jurisdiction or authority.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
=======================================================================
 | 
			
		||||
 | 
			
		||||
Creative Commons is not a party to its public
 | 
			
		||||
licenses. Notwithstanding, Creative Commons may elect to apply one of
 | 
			
		||||
its public licenses to material it publishes and in those instances
 | 
			
		||||
will be considered the “Licensor.” The text of the Creative Commons
 | 
			
		||||
public licenses is dedicated to the public domain under the CC0 Public
 | 
			
		||||
Domain Dedication. Except for the limited purpose of indicating that
 | 
			
		||||
material is shared under a Creative Commons public license or as
 | 
			
		||||
otherwise permitted by the Creative Commons policies published at
 | 
			
		||||
creativecommons.org/policies, Creative Commons does not authorize the
 | 
			
		||||
use of the trademark "Creative Commons" or any other trademark or logo
 | 
			
		||||
of Creative Commons without its prior written consent including,
 | 
			
		||||
without limitation, in connection with any unauthorized modifications
 | 
			
		||||
to any of its public licenses or any other arrangements,
 | 
			
		||||
understandings, or agreements concerning use of licensed material. For
 | 
			
		||||
the avoidance of doubt, this paragraph does not form part of the
 | 
			
		||||
public licenses.
 | 
			
		||||
 | 
			
		||||
Creative Commons may be contacted at creativecommons.org.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										6
									
								
								README
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								README
									
									
									
									
									
								
							@@ -1,7 +1,7 @@
 | 
			
		||||
This mod uses nodeboxes to supply a complete set of 3D pipes and tubes, 
 | 
			
		||||
along devices that work with them.
 | 
			
		||||
 | 
			
		||||
See https://github.com/VanessaE/pipeworks/wiki/ for detailed information about usage of this mod.
 | 
			
		||||
See https://github.com/mt-mods/pipeworks/wiki/ for detailed information about usage of this mod.
 | 
			
		||||
 | 
			
		||||
Unlike the previous version of this mod, these pipes are rounded, and when 
 | 
			
		||||
placed, they'll automatically join together as needed.  Pipes can go vertically 
 | 
			
		||||
@@ -20,3 +20,7 @@ This mod is a work in progress.
 | 
			
		||||
 | 
			
		||||
Please note that owing to the nature of this mod, I have opted to use 64px 
 | 
			
		||||
textures.  Anything less just looks terrible.
 | 
			
		||||
 | 
			
		||||
The teleport tube database used to be kept in a file named 'teleport_tubes'.
 | 
			
		||||
The database is now kept in mod storage. The migration from 'teleport_tubes' is
 | 
			
		||||
automatic. The old file is then kept around but is not used at all.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										168
									
								
								autocrafter.lua
									
									
									
									
									
								
							
							
						
						
									
										168
									
								
								autocrafter.lua
									
									
									
									
									
								
							@@ -1,3 +1,4 @@
 | 
			
		||||
local S = minetest.get_translator("pipeworks")
 | 
			
		||||
local autocrafterCache = {}  -- caches some recipe data to avoid to call the slow function minetest.get_craft_result() every second
 | 
			
		||||
 | 
			
		||||
local craft_time = 1
 | 
			
		||||
@@ -16,7 +17,7 @@ end
 | 
			
		||||
local function get_item_info(stack)
 | 
			
		||||
	local name = stack:get_name()
 | 
			
		||||
	local def = minetest.registered_items[name]
 | 
			
		||||
	local description = def and def.description or "Unknown item"
 | 
			
		||||
	local description = def and def.description or S("Unknown item")
 | 
			
		||||
	return description, name
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@@ -34,25 +35,42 @@ end
 | 
			
		||||
 | 
			
		||||
local function autocraft(inventory, craft)
 | 
			
		||||
	if not craft then return false end
 | 
			
		||||
	local output_item = craft.output.item
 | 
			
		||||
 | 
			
		||||
	-- check if we have enough room in dst
 | 
			
		||||
	if not inventory:room_for_item("dst", output_item) then	return false end
 | 
			
		||||
	local consumption = craft.consumption
 | 
			
		||||
	local inv_index = count_index(inventory:get_list("src"))
 | 
			
		||||
	-- check if we have enough material available
 | 
			
		||||
	for itemname, number in pairs(consumption) do
 | 
			
		||||
	local inv_index = count_index(inventory:get_list("src"))
 | 
			
		||||
	for itemname, number in pairs(craft.consumption) do
 | 
			
		||||
		if (not inv_index[itemname]) or inv_index[itemname] < number then return false end
 | 
			
		||||
	end
 | 
			
		||||
	-- check if output and all replacements fit in dst
 | 
			
		||||
	local output = craft.output.item
 | 
			
		||||
	local out_items = count_index(craft.decremented_input.items)
 | 
			
		||||
	out_items[output:get_name()] = (out_items[output:get_name()] or 0) + output:get_count()
 | 
			
		||||
	local empty_count = 0
 | 
			
		||||
	for _,item in pairs(inventory:get_list("dst")) do
 | 
			
		||||
		if item:is_empty() then
 | 
			
		||||
			empty_count = empty_count + 1
 | 
			
		||||
		else
 | 
			
		||||
			local name = item:get_name()
 | 
			
		||||
			if out_items[name] then
 | 
			
		||||
				out_items[name] = out_items[name] - item:get_free_space()
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
	for _,count in pairs(out_items) do
 | 
			
		||||
		if count > 0 then
 | 
			
		||||
			empty_count = empty_count - 1
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
	if empty_count < 0 then
 | 
			
		||||
		return false
 | 
			
		||||
	end
 | 
			
		||||
	-- consume material
 | 
			
		||||
	for itemname, number in pairs(consumption) do
 | 
			
		||||
		for i = 1, number do -- We have to do that since remove_item does not work if count > stack_max
 | 
			
		||||
	for itemname, number in pairs(craft.consumption) do
 | 
			
		||||
		for _ = 1, number do -- We have to do that since remove_item does not work if count > stack_max
 | 
			
		||||
			inventory:remove_item("src", ItemStack(itemname))
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	-- craft the result into the dst inventory and add any "replacements" as well
 | 
			
		||||
	inventory:add_item("dst", output_item)
 | 
			
		||||
	inventory:add_item("dst", output)
 | 
			
		||||
	for i = 1, 9 do
 | 
			
		||||
		inventory:add_item("dst", craft.decremented_input.items[i])
 | 
			
		||||
	end
 | 
			
		||||
@@ -66,13 +84,16 @@ local function run_autocrafter(pos, elapsed)
 | 
			
		||||
	local inventory = meta:get_inventory()
 | 
			
		||||
	local craft = get_craft(pos, inventory)
 | 
			
		||||
	local output_item = craft.output.item
 | 
			
		||||
	-- NALC: existence de limitgroup ?
 | 
			
		||||
	local limitcraft = minetest.get_item_group(output_item:get_name(), "limitcraft") or 0
 | 
			
		||||
	-- only use crafts that have an actual result
 | 
			
		||||
	if output_item:is_empty() then
 | 
			
		||||
		meta:set_string("infotext", "unconfigured Autocrafter: unknown recipe")
 | 
			
		||||
	-- NALC: ou si l'item n'est pas dans le group limitcraft
 | 
			
		||||
	if output_item:is_empty() or limitcraft > 0 then
 | 
			
		||||
		meta:set_string("infotext", S("unconfigured Autocrafter: unknown recipe"))
 | 
			
		||||
		return false
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	for step = 1, math.floor(elapsed/craft_time) do
 | 
			
		||||
	for _ = 1, math.floor(elapsed/craft_time) do
 | 
			
		||||
		local continue = autocraft(inventory, craft)
 | 
			
		||||
		if not continue then return false end
 | 
			
		||||
	end
 | 
			
		||||
@@ -101,11 +122,10 @@ local function after_recipe_change(pos, inventory)
 | 
			
		||||
	if inventory:is_empty("recipe") then
 | 
			
		||||
		minetest.get_node_timer(pos):stop()
 | 
			
		||||
		autocrafterCache[minetest.hash_node_position(pos)] = nil
 | 
			
		||||
		meta:set_string("infotext", "unconfigured Autocrafter")
 | 
			
		||||
		meta:set_string("infotext", S("unconfigured Autocrafter"))
 | 
			
		||||
		inventory:set_stack("output", 1, "")
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
	local recipe_changed = false
 | 
			
		||||
	local recipe = inventory:get_list("recipe")
 | 
			
		||||
 | 
			
		||||
	local hash = minetest.hash_node_position(pos)
 | 
			
		||||
@@ -126,7 +146,7 @@ local function after_recipe_change(pos, inventory)
 | 
			
		||||
	craft = craft or get_craft(pos, inventory, hash)
 | 
			
		||||
	local output_item = craft.output.item
 | 
			
		||||
	local description, name = get_item_info(output_item)
 | 
			
		||||
	meta:set_string("infotext", string.format("'%s' Autocrafter (%s)", description, name))
 | 
			
		||||
	meta:set_string("infotext", S("'@1' Autocrafter (@2)", description, name))
 | 
			
		||||
	inventory:set_stack("output", 1, output_item)
 | 
			
		||||
 | 
			
		||||
	after_inventory_change(pos)
 | 
			
		||||
@@ -172,26 +192,47 @@ end
 | 
			
		||||
local function update_meta(meta, enabled)
 | 
			
		||||
	local state = enabled and "on" or "off"
 | 
			
		||||
	meta:set_int("enabled", enabled and 1 or 0)
 | 
			
		||||
	local fs = 	"size[8,12]"..
 | 
			
		||||
			"list[context;recipe;0,0;3,3;]"..
 | 
			
		||||
			"image[3,1;1,1;gui_hb_bg.png^[colorize:#141318:255]"..
 | 
			
		||||
			"list[context;output;3,1;1,1;]"..
 | 
			
		||||
			"image_button[3,2;1,0.6;pipeworks_button_" .. state .. ".png;" .. state .. ";;;false;pipeworks_button_interm.png]" ..
 | 
			
		||||
			"list[context;src;0,4.5;8,3;]"..
 | 
			
		||||
			"list[context;dst;4,0;4,3;]"..
 | 
			
		||||
			default.gui_bg..
 | 
			
		||||
			default.gui_bg_img..
 | 
			
		||||
			default.gui_slots..
 | 
			
		||||
			default.get_hotbar_bg(0,8) ..
 | 
			
		||||
			"list[current_player;main;0,8;8,4;]" ..
 | 
			
		||||
			"listring[current_player;main]"..
 | 
			
		||||
			"listring[context;src]" ..
 | 
			
		||||
			"listring[current_player;main]"..
 | 
			
		||||
			"listring[context;dst]" ..
 | 
			
		||||
			"listring[current_player;main]"
 | 
			
		||||
	local list_backgrounds = ""
 | 
			
		||||
	if minetest.get_modpath("i3") or minetest.get_modpath("mcl_formspec") then
 | 
			
		||||
		list_backgrounds = "style_type[box;colors=#666]"
 | 
			
		||||
		for i=0, 2 do
 | 
			
		||||
			for j=0, 2 do
 | 
			
		||||
				list_backgrounds = list_backgrounds .. "box[".. 0.22+(i*1.25) ..",".. 0.22+(j*1.25) ..";1,1;]"
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
		for i=0, 3 do
 | 
			
		||||
			for j=0, 2 do
 | 
			
		||||
				list_backgrounds = list_backgrounds .. "box[".. 5.28+(i*1.25) ..",".. 0.22+(j*1.25) ..";1,1;]"
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
		for i=0, 7 do
 | 
			
		||||
			for j=0, 2 do
 | 
			
		||||
				list_backgrounds = list_backgrounds .. "box[".. 0.22+(i*1.25) ..",".. 5+(j*1.25) ..";1,1;]"
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
	local size = "10.2,14"
 | 
			
		||||
	local fs =
 | 
			
		||||
		"formspec_version[2]"..
 | 
			
		||||
		"size["..size.."]"..
 | 
			
		||||
		pipeworks.fs_helpers.get_prepends(size)..
 | 
			
		||||
		list_backgrounds..
 | 
			
		||||
		"list[context;recipe;0.22,0.22;3,3;]"..
 | 
			
		||||
		"image[4,1.45;1,1;[combine:16x16^[noalpha^[colorize:#141318:255]"..
 | 
			
		||||
		"list[context;output;4,1.45;1,1;]"..
 | 
			
		||||
		"image_button[4,2.6;1,0.6;pipeworks_button_" .. state .. ".png;" .. state .. ";;;false;pipeworks_button_interm.png]" ..
 | 
			
		||||
		"list[context;dst;5.28,0.22;4,3;]"..
 | 
			
		||||
		"list[context;src;0.22,5;8,3;]"..
 | 
			
		||||
		pipeworks.fs_helpers.get_inv(9)..
 | 
			
		||||
		"listring[current_player;main]"..
 | 
			
		||||
		"listring[context;src]" ..
 | 
			
		||||
		"listring[current_player;main]"..
 | 
			
		||||
		"listring[context;dst]" ..
 | 
			
		||||
		"listring[current_player;main]"
 | 
			
		||||
	if minetest.get_modpath("digilines") then
 | 
			
		||||
		fs = fs.."field[1,3.5;4,1;channel;Channel;${channel}]"
 | 
			
		||||
		fs = fs.."button_exit[5,3.2;2,1;save;Save]"
 | 
			
		||||
		fs = fs.."field[0.22,4.1;4.5,0.75;channel;"..S("Channel")..";${channel}]"..
 | 
			
		||||
			"button[5,4.1;1.5,0.75;set_channel;"..S("Set").."]"..
 | 
			
		||||
			"button_exit[6.8,4.1;2,0.75;close;"..S("Close").."]"
 | 
			
		||||
	end
 | 
			
		||||
	meta:set_string("formspec",fs)
 | 
			
		||||
 | 
			
		||||
@@ -200,13 +241,13 @@ local function update_meta(meta, enabled)
 | 
			
		||||
	-- this might be more written code, but actually executes less
 | 
			
		||||
	local output = meta:get_inventory():get_stack("output", 1)
 | 
			
		||||
	if output:is_empty() then -- doesn't matter if paused or not
 | 
			
		||||
		meta:set_string("infotext", "unconfigured Autocrafter")
 | 
			
		||||
		meta:set_string("infotext", S("unconfigured Autocrafter"))
 | 
			
		||||
		return false
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	local description, name = get_item_info(output)
 | 
			
		||||
	local infotext = enabled and string.format("'%s' Autocrafter (%s)", description, name)
 | 
			
		||||
				or string.format("paused '%s' Autocrafter", description)
 | 
			
		||||
	local infotext = enabled and S("'@1' Autocrafter (@2)", description, name)
 | 
			
		||||
				or S("paused '@1' Autocrafter", description)
 | 
			
		||||
 | 
			
		||||
	meta:set_string("infotext", infotext)
 | 
			
		||||
	return enabled
 | 
			
		||||
@@ -226,7 +267,7 @@ local function upgrade_autocrafter(pos, meta)
 | 
			
		||||
		update_meta(meta, true)
 | 
			
		||||
 | 
			
		||||
		if meta:get_string("virtual_items") == "1" then -- we are version 2
 | 
			
		||||
			-- we allready dropped stuff, so lets remove the metadatasetting (we are not being called again for this node)
 | 
			
		||||
			-- we already dropped stuff, so lets remove the metadatasetting (we are not being called again for this node)
 | 
			
		||||
			meta:set_string("virtual_items", "")
 | 
			
		||||
		else -- we are version 1
 | 
			
		||||
			local recipe = inv:get_list("recipe")
 | 
			
		||||
@@ -248,10 +289,11 @@ local function upgrade_autocrafter(pos, meta)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
minetest.register_node("pipeworks:autocrafter", {
 | 
			
		||||
	description = "Autocrafter",
 | 
			
		||||
	description = S("Autocrafter"),
 | 
			
		||||
	drawtype = "normal",
 | 
			
		||||
	tiles = {"pipeworks_autocrafter.png"},
 | 
			
		||||
	groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1},
 | 
			
		||||
	groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1, dig_generic = 1, axey=1, handy=1, pickaxey=1},
 | 
			
		||||
	_mcl_hardness=0.8,
 | 
			
		||||
	tube = {insert_object = function(pos, node, stack, direction)
 | 
			
		||||
			local meta = minetest.get_meta(pos)
 | 
			
		||||
			local inv = meta:get_inventory()
 | 
			
		||||
@@ -276,7 +318,9 @@ minetest.register_node("pipeworks:autocrafter", {
 | 
			
		||||
		update_meta(meta, false)
 | 
			
		||||
	end,
 | 
			
		||||
	on_receive_fields = function(pos, formname, fields, sender)
 | 
			
		||||
		if not pipeworks.may_configure(pos, sender) then return end
 | 
			
		||||
		if (fields.quit and not fields.key_enter_field) or not pipeworks.may_configure(pos, sender) then
 | 
			
		||||
			return
 | 
			
		||||
		end
 | 
			
		||||
		local meta = minetest.get_meta(pos)
 | 
			
		||||
		if fields.on then
 | 
			
		||||
			update_meta(meta, false)
 | 
			
		||||
@@ -285,8 +329,9 @@ minetest.register_node("pipeworks:autocrafter", {
 | 
			
		||||
			if update_meta(meta, true) then
 | 
			
		||||
				start_crafter(pos)
 | 
			
		||||
			end
 | 
			
		||||
		elseif fields.save then
 | 
			
		||||
			meta:set_string("channel",fields.channel)
 | 
			
		||||
		end
 | 
			
		||||
		if fields.channel then
 | 
			
		||||
			meta:set_string("channel", fields.channel)
 | 
			
		||||
		end
 | 
			
		||||
	end,
 | 
			
		||||
	can_dig = function(pos, player)
 | 
			
		||||
@@ -388,6 +433,27 @@ minetest.register_node("pipeworks:autocrafter", {
 | 
			
		||||
						end
 | 
			
		||||
					end
 | 
			
		||||
					after_recipe_change(pos,inv)
 | 
			
		||||
				elseif msg == "get_recipe" then
 | 
			
		||||
					local meta = minetest.get_meta(pos)
 | 
			
		||||
					local inv = meta:get_inventory()
 | 
			
		||||
					local recipe = {}
 | 
			
		||||
					for y=0,2,1 do
 | 
			
		||||
						local row = {}
 | 
			
		||||
						for x=1,3,1 do
 | 
			
		||||
							local slot = y*3+x
 | 
			
		||||
							table.insert(row, inv:get_stack("recipe",slot):get_name())
 | 
			
		||||
						end
 | 
			
		||||
						table.insert(recipe, row)
 | 
			
		||||
					end
 | 
			
		||||
					local setchan = meta:get_string("channel")
 | 
			
		||||
					local output = inv:get_stack("output", 1)
 | 
			
		||||
					digiline:receptor_send(pos, digiline.rules.default, setchan, {
 | 
			
		||||
						recipe = recipe,
 | 
			
		||||
						result = {
 | 
			
		||||
							name = output:get_name(),
 | 
			
		||||
							count = output:get_count(),
 | 
			
		||||
						}
 | 
			
		||||
					  })
 | 
			
		||||
				elseif msg == "off" then
 | 
			
		||||
					update_meta(meta, false)
 | 
			
		||||
					minetest.get_node_timer(pos):stop()
 | 
			
		||||
@@ -402,12 +468,4 @@ minetest.register_node("pipeworks:autocrafter", {
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
minetest.register_craft( {
 | 
			
		||||
	output = "pipeworks:autocrafter 2",
 | 
			
		||||
	recipe = {
 | 
			
		||||
	        { "default:steel_ingot", "default:mese_crystal", "default:steel_ingot" },
 | 
			
		||||
	        { "homedecor:plastic_sheeting", "default:steel_ingot", "homedecor:plastic_sheeting" },
 | 
			
		||||
	        { "default:steel_ingot", "default:mese_crystal", "default:steel_ingot" }
 | 
			
		||||
	},
 | 
			
		||||
})
 | 
			
		||||
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:autocrafter"
 | 
			
		||||
 
 | 
			
		||||
@@ -53,34 +53,35 @@ local function tube_autoroute(pos)
 | 
			
		||||
	}
 | 
			
		||||
	-- xm = 1, xp = 2, ym = 3, yp = 4, zm = 5, zp = 6
 | 
			
		||||
 | 
			
		||||
	local positions = {}
 | 
			
		||||
	local nodes = {}
 | 
			
		||||
	for i, adj in ipairs(adjustments) do
 | 
			
		||||
		positions[i] = vector.add(pos, adj)
 | 
			
		||||
		nodes[i] = minetest.get_node(positions[i])
 | 
			
		||||
	end
 | 
			
		||||
	local adjlist = {} -- this will be used in item_transport
 | 
			
		||||
 | 
			
		||||
	for i, adj in ipairs(adjustments) do
 | 
			
		||||
		local position = vector.add(pos, adj)
 | 
			
		||||
		local node = minetest.get_node(position)
 | 
			
		||||
 | 
			
		||||
	for i, node in ipairs(nodes) do
 | 
			
		||||
		local idef = minetest.registered_nodes[node.name]
 | 
			
		||||
		-- handle the tubes themselves
 | 
			
		||||
		if is_tube(node.name) then
 | 
			
		||||
			active[i] = 1
 | 
			
		||||
			table.insert(adjlist, adj)
 | 
			
		||||
		-- handle new style connectors
 | 
			
		||||
		elseif idef and idef.tube and idef.tube.connect_sides then
 | 
			
		||||
			local dir = adjustments[i]
 | 
			
		||||
			if idef.tube.connect_sides[nodeside(node, vector.multiply(dir, -1))] then
 | 
			
		||||
			if idef.tube.connect_sides[nodeside(node, vector.multiply(adj, -1))] then
 | 
			
		||||
				active[i] = 1
 | 
			
		||||
				table.insert(adjlist, adj)
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	minetest.get_meta(pos):set_string("adjlist", minetest.serialize(adjlist))
 | 
			
		||||
 | 
			
		||||
	-- all sides checked, now figure which tube to use.
 | 
			
		||||
 | 
			
		||||
	local nodedef = minetest.registered_nodes[nctr.name]
 | 
			
		||||
	local basename = nodedef.basename
 | 
			
		||||
	if nodedef.style == "old" then
 | 
			
		||||
		local nsurround = ""
 | 
			
		||||
		for i, n in ipairs(active) do
 | 
			
		||||
		for _, n in ipairs(active) do
 | 
			
		||||
			nsurround = nsurround..n
 | 
			
		||||
		end
 | 
			
		||||
		nctr.name = basename.."_"..nsurround
 | 
			
		||||
@@ -111,6 +112,22 @@ function pipeworks.after_dig(pos)
 | 
			
		||||
	pipeworks.scan_for_tube_objects(pos)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Screwdriver calls this function before rotating a node.
 | 
			
		||||
-- However, connections must be updated *after* the node is rotated
 | 
			
		||||
-- So, this function does the rotation itself and returns `true`.
 | 
			
		||||
-- (Note: screwdriver already checks for protected areas.)
 | 
			
		||||
 | 
			
		||||
-- This should only be used for tubes that don't autoconnect.
 | 
			
		||||
-- (For example, one-way tubes.)
 | 
			
		||||
-- Autoconnecting tubes will just revert back to their original state
 | 
			
		||||
-- when they are updated.
 | 
			
		||||
function pipeworks.on_rotate(pos, node, user, mode, new_param2)
 | 
			
		||||
	node.param2 = new_param2
 | 
			
		||||
	minetest.swap_node(pos, node)
 | 
			
		||||
	pipeworks.scan_for_tube_objects(pos)
 | 
			
		||||
	return true
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if minetest.get_modpath("mesecons_mvps") then
 | 
			
		||||
	mesecon.register_on_mvps_move(function(moved_nodes)
 | 
			
		||||
		for _, n in ipairs(moved_nodes) do
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										93
									
								
								common.lua
									
									
									
									
									
								
							
							
						
						
									
										93
									
								
								common.lua
									
									
									
									
									
								
							@@ -86,10 +86,9 @@ function pipeworks.table_contains(tbl, element)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function pipeworks.table_extend(tbl, tbl2)
 | 
			
		||||
	local index = #tbl + 1
 | 
			
		||||
	for _, elt in ipairs(tbl2) do
 | 
			
		||||
		tbl[index] = elt
 | 
			
		||||
		index = index + 1
 | 
			
		||||
	local oldlength = #tbl
 | 
			
		||||
	for i = 1,#tbl2 do
 | 
			
		||||
		tbl[oldlength + i] = tbl2[i]
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@@ -115,7 +114,7 @@ local fs_helpers = {}
 | 
			
		||||
pipeworks.fs_helpers = fs_helpers
 | 
			
		||||
function fs_helpers.on_receive_fields(pos, fields)
 | 
			
		||||
	local meta = minetest.get_meta(pos)
 | 
			
		||||
	for field, value in pairs(fields) do
 | 
			
		||||
	for field in pairs(fields) do
 | 
			
		||||
		if pipeworks.string_startswith(field, "fs_helpers_cycling:") then
 | 
			
		||||
			local l = field:split(":")
 | 
			
		||||
			local new_value = tonumber(l[2])
 | 
			
		||||
@@ -144,6 +143,81 @@ function fs_helpers.cycling_button(meta, base, meta_name, values)
 | 
			
		||||
	return base..";"..(texture_name and texture_name..";" or "")..field..";"..minetest.formspec_escape(text)..(addopts and ";"..addopts or "").."]"
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function fs_helpers.get_inv(y)
 | 
			
		||||
	local fs = {}
 | 
			
		||||
	if minetest.get_modpath("i3") then
 | 
			
		||||
		local inv_x = i3.settings.legacy_inventory and 0.75 or 0.22
 | 
			
		||||
		local inv_y = (y + 0.4) or 6.9
 | 
			
		||||
		local size, spacing = 1, 0.1
 | 
			
		||||
		local hotbar_len = i3.settings.hotbar_len or (i3.settings.legacy_inventory and 8 or 9)
 | 
			
		||||
		local inv_size = i3.settings.inv_size or (hotbar_len * 4)
 | 
			
		||||
 | 
			
		||||
		table.insert(fs, "style_type[box;colors=#77777710,#77777710,#777,#777]")
 | 
			
		||||
 | 
			
		||||
		for i = 0, hotbar_len - 1 do
 | 
			
		||||
			table.insert(fs, "box["..(i * size + inv_x + (i * spacing))..","..inv_y..";"..size..","..size..";]")
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		table.insert(fs, "style_type[list;size="..size..";spacing="..spacing.."]")
 | 
			
		||||
		table.insert(fs, "list[current_player;main;"..inv_x..","..inv_y..";"..hotbar_len..",1;]")
 | 
			
		||||
 | 
			
		||||
		table.insert(fs, "style_type[box;colors=#666]")
 | 
			
		||||
		for i=0, 2 do
 | 
			
		||||
			for j=0, hotbar_len - 1 do
 | 
			
		||||
				table.insert(fs, "box["..0.2+(j*0.1)+(j*size)..","..(inv_y+size+spacing+0.05)+(i*0.1)+(i*size)..";"..size..","..size..";]")
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		table.insert(fs, "style_type[list;size="..size..";spacing="..spacing.."]")
 | 
			
		||||
		table.insert(fs, "list[current_player;main;"..inv_x..","..(inv_y + 1.15)..";"..hotbar_len..","..(inv_size / hotbar_len)..";"..hotbar_len.."]")
 | 
			
		||||
	elseif minetest.get_modpath("mcl_formspec") then
 | 
			
		||||
		local inv_x = 0.22
 | 
			
		||||
		local inv_y = (y + 0.4) or 6.9
 | 
			
		||||
		local size, spacing = 1, 0.1
 | 
			
		||||
		local hotbar_len = 9
 | 
			
		||||
		local inv_size = hotbar_len * 4
 | 
			
		||||
 | 
			
		||||
		table.insert(fs, "style_type[box;colors=#77777710,#77777710,#777,#777]")
 | 
			
		||||
 | 
			
		||||
		for i = 0, hotbar_len - 1 do
 | 
			
		||||
			table.insert(fs, "box["..(i * size + inv_x + (i * spacing))..","..inv_y..";"..size..","..size..";]")
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		table.insert(fs, "style_type[list;size="..size..";spacing="..spacing.."]")
 | 
			
		||||
		table.insert(fs, "list[current_player;main;"..inv_x..","..inv_y..";"..hotbar_len..",1;]")
 | 
			
		||||
 | 
			
		||||
		table.insert(fs, "style_type[box;colors=#666]")
 | 
			
		||||
		for i=0, 2 do
 | 
			
		||||
			for j=0, hotbar_len - 1 do
 | 
			
		||||
				table.insert(fs, "box["..0.2+(j*0.1)+(j*size)..","..(inv_y+size+spacing+0.05)+(i*0.1)+(i*size)..";"..size..","..size..";]")
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		table.insert(fs, "style_type[list;size="..size..";spacing="..spacing.."]")
 | 
			
		||||
		table.insert(fs, "list[current_player;main;"..inv_x..","..(inv_y + 1.15)..";"..hotbar_len..","..(inv_size / hotbar_len)..";"..hotbar_len.."]")
 | 
			
		||||
	else
 | 
			
		||||
		table.insert(fs, "list[current_player;main;0.22,"..y..";8,4;]")
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	return table.concat(fs, "")
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function fs_helpers.get_prepends(size)
 | 
			
		||||
	local prepend = {}
 | 
			
		||||
 | 
			
		||||
	if minetest.get_modpath("i3") then
 | 
			
		||||
		prepend = {
 | 
			
		||||
			"no_prepend[]",
 | 
			
		||||
			"bgcolor[black;neither]",
 | 
			
		||||
			"background9[0,0;"..size..";i3_bg_full.png;false;10]",
 | 
			
		||||
			"style_type[button;border=false;bgimg=[combine:16x16^[noalpha^[colorize:#6b6b6b]",
 | 
			
		||||
			"listcolors[#0000;#ffffff20]"
 | 
			
		||||
		}
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	return table.concat(prepend, "")
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
---------
 | 
			
		||||
-- Env --
 | 
			
		||||
---------
 | 
			
		||||
@@ -184,7 +258,7 @@ function pipeworks.create_fake_player(def, is_dynamic)
 | 
			
		||||
		is_player = delay(true),
 | 
			
		||||
		is_fake_player = true,
 | 
			
		||||
 | 
			
		||||
		_formspec = def.formspec or default.gui_survival_form,
 | 
			
		||||
		_formspec = def.formspec or "",
 | 
			
		||||
		_hp = def.hp or 20,
 | 
			
		||||
		_breath = 11,
 | 
			
		||||
		_pos = def.position and table.copy(def.position) or vector.new(),
 | 
			
		||||
@@ -224,7 +298,7 @@ function pipeworks.create_fake_player(def, is_dynamic)
 | 
			
		||||
				return self._inventory:set_stack(def.wield_list,
 | 
			
		||||
					self._wield_index, item)
 | 
			
		||||
			end
 | 
			
		||||
			_wielded_item = ItemStack(item)
 | 
			
		||||
			self._wielded_item = ItemStack(item)
 | 
			
		||||
		end,
 | 
			
		||||
		get_wielded_item = function(self, item)
 | 
			
		||||
			if self._inventory and def.wield_list then
 | 
			
		||||
@@ -243,17 +317,18 @@ function pipeworks.create_fake_player(def, is_dynamic)
 | 
			
		||||
		set_bone_position = delay(),
 | 
			
		||||
		hud_change = delay(),
 | 
			
		||||
	}
 | 
			
		||||
	local _trash
 | 
			
		||||
	-- Getter & setter functions
 | 
			
		||||
	p.get_inventory_formspec, p.set_inventory_formspec
 | 
			
		||||
		= get_set_wrap("formspec", is_dynamic)
 | 
			
		||||
	p.get_breath, p.set_breath = get_set_wrap("breath", is_dynamic)
 | 
			
		||||
	p.get_hp, p.set_hp = get_set_wrap("hp", is_dynamic)
 | 
			
		||||
	p.get_pos, p.set_pos = get_set_wrap("pos", is_dynamic)
 | 
			
		||||
	_trash, p.move_to = get_set_wrap("pos", is_dynamic)
 | 
			
		||||
	p.get_wield_index, p.set_wield_index = get_set_wrap("wield_index", true)
 | 
			
		||||
	p.get_properties, p.set_properties = get_set_wrap("properties", false)
 | 
			
		||||
 | 
			
		||||
	-- For players, move_to and get_pos do the same
 | 
			
		||||
	p.move_to = p.get_pos
 | 
			
		||||
 | 
			
		||||
	-- Backwards compatibilty
 | 
			
		||||
	p.getpos = p.get_pos
 | 
			
		||||
	p.setpos = p.set_pos
 | 
			
		||||
 
 | 
			
		||||
@@ -11,33 +11,72 @@ local tube_entry = "^pipeworks_tube_connection_wooden.png"
 | 
			
		||||
-- Chest Locals
 | 
			
		||||
local open_chests = {}
 | 
			
		||||
 | 
			
		||||
local function get_chest_formspec(pos)
 | 
			
		||||
	local spos = pos.x .. "," .. pos.y .. "," .. pos.z
 | 
			
		||||
	local formspec =
 | 
			
		||||
		"size[8,9]" ..
 | 
			
		||||
		default.gui_bg ..
 | 
			
		||||
		default.gui_bg_img ..
 | 
			
		||||
		default.gui_slots ..
 | 
			
		||||
		"list[nodemeta:" .. spos .. ";main;0,0.3;8,4;]" ..
 | 
			
		||||
		"list[current_player;main;0,4.85;8,1;]" ..
 | 
			
		||||
		"list[current_player;main;0,6.08;8,3;8]" ..
 | 
			
		||||
		"listring[nodemeta:" .. spos .. ";main]" ..
 | 
			
		||||
		"listring[current_player;main]" ..
 | 
			
		||||
		default.get_hotbar_bg(0,4.85)
 | 
			
		||||
local get_chest_formspec
 | 
			
		||||
 | 
			
		||||
	-- Pipeworks Switch
 | 
			
		||||
	formspec = formspec ..
 | 
			
		||||
		fs_helpers.cycling_button(
 | 
			
		||||
			minetest.get_meta(pos),
 | 
			
		||||
			pipeworks.button_base,
 | 
			
		||||
			"splitstacks",
 | 
			
		||||
			{
 | 
			
		||||
				pipeworks.button_off,
 | 
			
		||||
				pipeworks.button_on
 | 
			
		||||
			}
 | 
			
		||||
		)..pipeworks.button_label
 | 
			
		||||
if minetest.get_modpath("default") then
 | 
			
		||||
	function get_chest_formspec(pos)
 | 
			
		||||
		local spos = pos.x .. "," .. pos.y .. "," .. pos.z
 | 
			
		||||
		local formspec =
 | 
			
		||||
			"size[8,9]" ..
 | 
			
		||||
			default.gui_bg ..
 | 
			
		||||
			default.gui_bg_img ..
 | 
			
		||||
			default.gui_slots ..
 | 
			
		||||
			"list[nodemeta:" .. spos .. ";main;0,0.3;8,4;]" ..
 | 
			
		||||
			"list[current_player;main;0,4.85;8,1;]" ..
 | 
			
		||||
			"list[current_player;main;0,6.08;8,3;8]" ..
 | 
			
		||||
			"listring[nodemeta:" .. spos .. ";main]" ..
 | 
			
		||||
			"listring[current_player;main]" ..
 | 
			
		||||
			default.get_hotbar_bg(0,4.85)
 | 
			
		||||
 | 
			
		||||
	return formspec
 | 
			
		||||
		-- Pipeworks Switch
 | 
			
		||||
		formspec = formspec ..
 | 
			
		||||
			fs_helpers.cycling_button(
 | 
			
		||||
				minetest.get_meta(pos),
 | 
			
		||||
				pipeworks.button_base,
 | 
			
		||||
				"splitstacks",
 | 
			
		||||
				{
 | 
			
		||||
					pipeworks.button_off,
 | 
			
		||||
					pipeworks.button_on
 | 
			
		||||
				}
 | 
			
		||||
			)..pipeworks.button_label
 | 
			
		||||
 | 
			
		||||
		return formspec
 | 
			
		||||
	end
 | 
			
		||||
else
 | 
			
		||||
	local function get_hotbar_bg(x,y)
 | 
			
		||||
		local out = ""
 | 
			
		||||
		for i=0,7,1 do
 | 
			
		||||
			out = out .."image["..x+i..","..y..";1,1;gui_hb_bg.png]"
 | 
			
		||||
		end
 | 
			
		||||
		return out
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	function get_chest_formspec(pos)
 | 
			
		||||
		local spos = pos.x .. "," .. pos.y .. "," .. pos.z
 | 
			
		||||
		local formspec =
 | 
			
		||||
			"size[10,9]" ..
 | 
			
		||||
			"background9[8,8;8,9;hades_chests_chestui.png;true;8]"..
 | 
			
		||||
			"list[nodemeta:" .. spos .. ";main;0,0.3;10,4;]" ..
 | 
			
		||||
			"list[current_player;main;0,4.85;10,1;]" ..
 | 
			
		||||
			"list[current_player;main;0,6.08;10,3;10]" ..
 | 
			
		||||
			"listring[nodemeta:" .. spos .. ";main]" ..
 | 
			
		||||
			"listring[current_player;main]" ..
 | 
			
		||||
			get_hotbar_bg(0,4.85)
 | 
			
		||||
 | 
			
		||||
		-- Pipeworks Switch
 | 
			
		||||
		formspec = formspec ..
 | 
			
		||||
			fs_helpers.cycling_button(
 | 
			
		||||
				minetest.get_meta(pos),
 | 
			
		||||
				pipeworks.button_base,
 | 
			
		||||
				"splitstacks",
 | 
			
		||||
				{
 | 
			
		||||
					pipeworks.button_off,
 | 
			
		||||
					pipeworks.button_on
 | 
			
		||||
				}
 | 
			
		||||
			)..pipeworks.button_label
 | 
			
		||||
 | 
			
		||||
		return formspec
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function chest_lid_obstructed(pos)
 | 
			
		||||
@@ -65,22 +104,22 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
 | 
			
		||||
				local node = minetest.get_node(pos)
 | 
			
		||||
 | 
			
		||||
				open_chests[pn] = nil
 | 
			
		||||
				for k, v in pairs(open_chests) do
 | 
			
		||||
				for _, v in pairs(open_chests) do
 | 
			
		||||
					if v.pos.x == pos.x and v.pos.y == pos.y and v.pos.z == pos.z then
 | 
			
		||||
						return true
 | 
			
		||||
					end
 | 
			
		||||
				end
 | 
			
		||||
				minetest.after(0.2, function()
 | 
			
		||||
					minetest.swap_node(pos, { name = "default:" .. swap, param2 = node.param2 })
 | 
			
		||||
					if minetest.get_modpath("default") then
 | 
			
		||||
						minetest.swap_node(pos, { name = "default:" .. swap, param2 = node.param2 })
 | 
			
		||||
					end
 | 
			
		||||
 | 
			
		||||
					-- Pipeworks notification
 | 
			
		||||
					pipeworks.after_place(pos)
 | 
			
		||||
				end)
 | 
			
		||||
				minetest.sound_play(sound, {gain = 0.3, pos = pos, max_hear_distance = 10})
 | 
			
		||||
			end
 | 
			
		||||
 | 
			
		||||
			-- Pipeworks Switch
 | 
			
		||||
			if pipeworks.may_configure(pos, player) and not fields.quit then
 | 
			
		||||
			elseif pipeworks.may_configure(pos, player) then
 | 
			
		||||
				-- Pipeworks Switch
 | 
			
		||||
				fs_helpers.on_receive_fields(pos, fields)
 | 
			
		||||
				minetest.show_formspec(player:get_player_name(), "pipeworks:chest_formspec", get_chest_formspec(pos))
 | 
			
		||||
			end
 | 
			
		||||
@@ -90,10 +129,18 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
-- Original Definitions
 | 
			
		||||
local old_chest_def = table.copy(minetest.registered_items["default:chest"])
 | 
			
		||||
local old_chest_open_def = table.copy(minetest.registered_items["default:chest_open"])
 | 
			
		||||
local old_chest_locked_def = table.copy(minetest.registered_items["default:chest_locked"])
 | 
			
		||||
local old_chest_locked_open_def = table.copy(minetest.registered_items["default:chest_locked_open"])
 | 
			
		||||
local old_chest_def, old_chest_open_def, old_chest_locked_def, old_chest_locked_open_def
 | 
			
		||||
if minetest.get_modpath("default") then
 | 
			
		||||
	old_chest_def = table.copy(minetest.registered_items["default:chest"])
 | 
			
		||||
	old_chest_open_def = table.copy(minetest.registered_items["default:chest_open"])
 | 
			
		||||
	old_chest_locked_def = table.copy(minetest.registered_items["default:chest_locked"])
 | 
			
		||||
	old_chest_locked_open_def = table.copy(minetest.registered_items["default:chest_locked_open"])
 | 
			
		||||
elseif minetest.get_modpath("hades_chests") then
 | 
			
		||||
	old_chest_def = table.copy(minetest.registered_items["hades_chests:chest"])
 | 
			
		||||
	old_chest_open_def = table.copy(minetest.registered_items["hades_chests:chest"])
 | 
			
		||||
	old_chest_locked_def = table.copy(minetest.registered_items["hades_chests:chest_locked"])
 | 
			
		||||
	old_chest_locked_open_def = table.copy(minetest.registered_items["hades_chests:chest_locked"])
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Override Construction
 | 
			
		||||
local override_protected, override, override_open, override_protected_open
 | 
			
		||||
@@ -118,9 +165,11 @@ override_protected = {
 | 
			
		||||
		minetest.sound_play(old_chest_locked_def.sound_open, {gain = 0.3,
 | 
			
		||||
				pos = pos, max_hear_distance = 10})
 | 
			
		||||
		if not chest_lid_obstructed(pos) then
 | 
			
		||||
			minetest.swap_node(pos,
 | 
			
		||||
					{ name = "default:" .. "chest_locked" .. "_open",
 | 
			
		||||
					param2 = node.param2 })
 | 
			
		||||
			if minetest.get_modpath("default") then
 | 
			
		||||
				minetest.swap_node(pos,
 | 
			
		||||
						{ name = "default:" .. "chest_locked" .. "_open",
 | 
			
		||||
						param2 = node.param2 })
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
		minetest.after(0.2, minetest.show_formspec,
 | 
			
		||||
				clicker:get_player_name(),
 | 
			
		||||
@@ -146,7 +195,8 @@ override_protected = {
 | 
			
		||||
		input_inventory = "main",
 | 
			
		||||
		connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1}
 | 
			
		||||
	},
 | 
			
		||||
	after_dig_node = pipeworks.after_dig
 | 
			
		||||
	after_dig_node = pipeworks.after_dig,
 | 
			
		||||
	on_rotate = pipeworks.on_rotate
 | 
			
		||||
}
 | 
			
		||||
override = {
 | 
			
		||||
	tiles = {
 | 
			
		||||
@@ -161,9 +211,11 @@ override = {
 | 
			
		||||
		minetest.sound_play(old_chest_def.sound_open, {gain = 0.3, pos = pos,
 | 
			
		||||
				max_hear_distance = 10})
 | 
			
		||||
		if not chest_lid_obstructed(pos) then
 | 
			
		||||
			minetest.swap_node(pos, {
 | 
			
		||||
					name = "default:" .. "chest" .. "_open",
 | 
			
		||||
					param2 = node.param2 })
 | 
			
		||||
			if minetest.get_modpath("default") then
 | 
			
		||||
				minetest.swap_node(pos, {
 | 
			
		||||
						name = "default:" .. "chest" .. "_open",
 | 
			
		||||
						param2 = node.param2 })
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
		minetest.after(0.2, minetest.show_formspec,
 | 
			
		||||
				clicker:get_player_name(),
 | 
			
		||||
@@ -190,7 +242,8 @@ override = {
 | 
			
		||||
		connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1}
 | 
			
		||||
	},
 | 
			
		||||
	after_place_node = pipeworks.after_place,
 | 
			
		||||
	after_dig_node = pipeworks.after_dig
 | 
			
		||||
	after_dig_node = pipeworks.after_dig,
 | 
			
		||||
	on_rotate = pipeworks.on_rotate
 | 
			
		||||
}
 | 
			
		||||
--[[local override_common = {
 | 
			
		||||
 | 
			
		||||
@@ -230,14 +283,21 @@ override.tiles = {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
-- Add the extra groups
 | 
			
		||||
for i,v in ipairs({override_protected, override, override_open, override_protected_open}) do
 | 
			
		||||
for _,v in ipairs({override_protected, override, override_open, override_protected_open}) do
 | 
			
		||||
	v.groups.tubedevice = 1
 | 
			
		||||
	v.groups.tubedevice_receiver = 1
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Override with the new modifications.
 | 
			
		||||
minetest.override_item("default:chest", override)
 | 
			
		||||
minetest.override_item("default:chest_open", override_open)
 | 
			
		||||
minetest.override_item("default:chest_locked", override_protected)
 | 
			
		||||
minetest.override_item("default:chest_locked_open", override_protected_open)
 | 
			
		||||
if minetest.get_modpath("default") then
 | 
			
		||||
	minetest.override_item("default:chest", override)
 | 
			
		||||
	minetest.override_item("default:chest_open", override_open)
 | 
			
		||||
	minetest.override_item("default:chest_locked", override_protected)
 | 
			
		||||
  minetest.override_item("default:chest_locked_open", override_protected_open)
 | 
			
		||||
elseif minetest.get_modpath("hades_chests") then
 | 
			
		||||
	minetest.override_item("hades_chests:chest", override)
 | 
			
		||||
	--minetest.override_item("hades_chests:chest_open", override_open)
 | 
			
		||||
	minetest.override_item("hades_chests:chest_locked", override_protected)
 | 
			
		||||
  --minetest.override_item("hades_chests:chest_locked_open", override_protected_open)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,277 +1,28 @@
 | 
			
		||||
 | 
			
		||||
-- this file is basically a modified copy of
 | 
			
		||||
-- minetest_game/mods/default/furnaces.lua
 | 
			
		||||
 | 
			
		||||
local fs_helpers = pipeworks.fs_helpers
 | 
			
		||||
 | 
			
		||||
tube_entry = "^pipeworks_tube_connection_stony.png"
 | 
			
		||||
 | 
			
		||||
local function active_formspec(fuel_percent, item_percent, pos, meta)
 | 
			
		||||
	local formspec =
 | 
			
		||||
		"size[8,8.5]"..
 | 
			
		||||
		default.gui_bg..
 | 
			
		||||
		default.gui_bg_img..
 | 
			
		||||
		default.gui_slots..
 | 
			
		||||
		"list[current_name;src;2.75,0.5;1,1;]"..
 | 
			
		||||
		"list[current_name;fuel;2.75,2.5;1,1;]"..
 | 
			
		||||
		"image[2.75,1.5;1,1;default_furnace_fire_bg.png^[lowpart:"..
 | 
			
		||||
		(100-fuel_percent)..":default_furnace_fire_fg.png]"..
 | 
			
		||||
		"image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[lowpart:"..
 | 
			
		||||
		(item_percent)..":gui_furnace_arrow_fg.png^[transformR270]"..
 | 
			
		||||
		"list[current_name;dst;4.75,0.96;2,2;]"..
 | 
			
		||||
		"list[current_player;main;0,4.25;8,1;]"..
 | 
			
		||||
		"list[current_player;main;0,5.5;8,3;8]"..
 | 
			
		||||
		"listring[current_name;dst]"..
 | 
			
		||||
		"listring[current_player;main]"..
 | 
			
		||||
		"listring[current_name;src]"..
 | 
			
		||||
		"listring[current_player;main]"..
 | 
			
		||||
		"listring[current_name;fuel]"..
 | 
			
		||||
		"listring[current_player;main]"..
 | 
			
		||||
		default.get_hotbar_bg(0, 4.25) ..
 | 
			
		||||
			fs_helpers.cycling_button(
 | 
			
		||||
				meta,
 | 
			
		||||
				"image_button[0,3.5;1,0.6",
 | 
			
		||||
				"split_material_stacks",
 | 
			
		||||
				{
 | 
			
		||||
					pipeworks.button_off,
 | 
			
		||||
					pipeworks.button_on
 | 
			
		||||
				}
 | 
			
		||||
			).."label[0.9,3.51;Allow splitting incoming material (not fuel) stacks from tubes]"
 | 
			
		||||
	return formspec
 | 
			
		||||
local def--, def_active
 | 
			
		||||
if minetest.get_modpath("default") then
 | 
			
		||||
	def = table.copy(minetest.registered_nodes["default:furnace"])
 | 
			
		||||
	--def_active = table.copy(minetest.registered_nodes["default:furnace_active"])
 | 
			
		||||
elseif minetest.get_modpath("hades_furnaces") then
 | 
			
		||||
	def = table.copy(minetest.registered_nodes["hades_furnaces:furnace"])
 | 
			
		||||
	--def_active = table.copy(minetest.registered_nodes["hades_furnaces:furnace_active"])
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function inactive_formspec(pos, meta)
 | 
			
		||||
	local formspec = "size[8,8.5]"..
 | 
			
		||||
	default.gui_bg..
 | 
			
		||||
	default.gui_bg_img..
 | 
			
		||||
	default.gui_slots..
 | 
			
		||||
	"list[current_name;src;2.75,0.5;1,1;]"..
 | 
			
		||||
	"list[current_name;fuel;2.75,2.5;1,1;]"..
 | 
			
		||||
	"image[2.75,1.5;1,1;default_furnace_fire_bg.png]"..
 | 
			
		||||
	"image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
 | 
			
		||||
	"list[current_name;dst;4.75,0.96;2,2;]"..
 | 
			
		||||
	"list[current_player;main;0,4.25;8,1;]"..
 | 
			
		||||
	"list[current_player;main;0,5.5;8,3;8]"..
 | 
			
		||||
	"listring[current_name;dst]"..
 | 
			
		||||
	"listring[current_player;main]"..
 | 
			
		||||
	"listring[current_name;src]"..
 | 
			
		||||
	"listring[current_player;main]"..
 | 
			
		||||
	"listring[current_name;fuel]"..
 | 
			
		||||
	"listring[current_player;main]"..
 | 
			
		||||
	default.get_hotbar_bg(0, 4.25) ..
 | 
			
		||||
		fs_helpers.cycling_button(
 | 
			
		||||
			meta,
 | 
			
		||||
			"image_button[0,3.5;1,0.6",
 | 
			
		||||
			"split_material_stacks",
 | 
			
		||||
			{
 | 
			
		||||
				pipeworks.button_off,
 | 
			
		||||
				pipeworks.button_on
 | 
			
		||||
			}
 | 
			
		||||
		).."label[0.9,3.51;Allow splitting incoming material (not fuel) stacks from tubes]"
 | 
			
		||||
	return formspec
 | 
			
		||||
end
 | 
			
		||||
local tube_entry = "^pipeworks_tube_connection_stony.png"
 | 
			
		||||
 | 
			
		||||
--
 | 
			
		||||
-- Node callback functions that are the same for active and inactive furnace
 | 
			
		||||
--
 | 
			
		||||
 | 
			
		||||
local function can_dig(pos, player)
 | 
			
		||||
	local meta = minetest.get_meta(pos);
 | 
			
		||||
	local inv = meta:get_inventory()
 | 
			
		||||
	return inv:is_empty("fuel") and inv:is_empty("dst") and inv:is_empty("src")
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
 | 
			
		||||
	if minetest.is_protected(pos, player:get_player_name()) then
 | 
			
		||||
		return 0
 | 
			
		||||
	end
 | 
			
		||||
	local meta = minetest.get_meta(pos)
 | 
			
		||||
	local inv = meta:get_inventory()
 | 
			
		||||
	if listname == "fuel" then
 | 
			
		||||
		if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then
 | 
			
		||||
			if inv:is_empty("src") then
 | 
			
		||||
				meta:set_string("infotext", "Furnace is empty")
 | 
			
		||||
			end
 | 
			
		||||
			return stack:get_count()
 | 
			
		||||
		else
 | 
			
		||||
			return 0
 | 
			
		||||
		end
 | 
			
		||||
	elseif listname == "src" then
 | 
			
		||||
		return stack:get_count()
 | 
			
		||||
	elseif listname == "dst" then
 | 
			
		||||
		return 0
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player)
 | 
			
		||||
	local meta = minetest.get_meta(pos)
 | 
			
		||||
	local inv = meta:get_inventory()
 | 
			
		||||
	local stack = inv:get_stack(from_list, from_index)
 | 
			
		||||
	return allow_metadata_inventory_put(pos, to_list, to_index, stack, player)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function allow_metadata_inventory_take(pos, listname, index, stack, player)
 | 
			
		||||
	if minetest.is_protected(pos, player:get_player_name()) then
 | 
			
		||||
		return 0
 | 
			
		||||
	end
 | 
			
		||||
	return stack:get_count()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function swap_node(pos, name)
 | 
			
		||||
	local node = minetest.get_node(pos)
 | 
			
		||||
	if node.name == name then
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
	node.name = name
 | 
			
		||||
	minetest.swap_node(pos, node)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function furnace_node_timer(pos, elapsed)
 | 
			
		||||
	--
 | 
			
		||||
	-- Inizialize metadata
 | 
			
		||||
	--
 | 
			
		||||
	local meta = minetest.get_meta(pos)
 | 
			
		||||
	local fuel_time = meta:get_float("fuel_time") or 0
 | 
			
		||||
	local src_time = meta:get_float("src_time") or 0
 | 
			
		||||
	local fuel_totaltime = meta:get_float("fuel_totaltime") or 0
 | 
			
		||||
 | 
			
		||||
	local inv = meta:get_inventory()
 | 
			
		||||
	local srclist, fuellist
 | 
			
		||||
 | 
			
		||||
	local cookable, cooked
 | 
			
		||||
	local fuel
 | 
			
		||||
 | 
			
		||||
	local update = true
 | 
			
		||||
	while update do
 | 
			
		||||
		update = false
 | 
			
		||||
 | 
			
		||||
		srclist = inv:get_list("src")
 | 
			
		||||
		fuellist = inv:get_list("fuel")
 | 
			
		||||
 | 
			
		||||
		--
 | 
			
		||||
		-- Cooking
 | 
			
		||||
		--
 | 
			
		||||
 | 
			
		||||
		-- Check if we have cookable content
 | 
			
		||||
		local aftercooked
 | 
			
		||||
		cooked, aftercooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
 | 
			
		||||
		cookable = cooked.time ~= 0
 | 
			
		||||
 | 
			
		||||
		-- Check if we have enough fuel to burn
 | 
			
		||||
		if fuel_time < fuel_totaltime then
 | 
			
		||||
			-- The furnace is currently active and has enough fuel
 | 
			
		||||
			fuel_time = fuel_time + elapsed
 | 
			
		||||
			-- If there is a cookable item then check if it is ready yet
 | 
			
		||||
			if cookable then
 | 
			
		||||
				src_time = src_time + elapsed
 | 
			
		||||
				if src_time >= cooked.time then
 | 
			
		||||
					-- Place result in dst list if possible
 | 
			
		||||
					if inv:room_for_item("dst", cooked.item) then
 | 
			
		||||
						inv:add_item("dst", cooked.item)
 | 
			
		||||
						inv:set_stack("src", 1, aftercooked.items[1])
 | 
			
		||||
						src_time = src_time - cooked.time
 | 
			
		||||
						update = true
 | 
			
		||||
					end
 | 
			
		||||
				end
 | 
			
		||||
			end
 | 
			
		||||
		else
 | 
			
		||||
			-- Furnace ran out of fuel
 | 
			
		||||
			if cookable then
 | 
			
		||||
				-- We need to get new fuel
 | 
			
		||||
				local afterfuel
 | 
			
		||||
				fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
 | 
			
		||||
 | 
			
		||||
				if fuel.time == 0 then
 | 
			
		||||
					-- No valid fuel in fuel list
 | 
			
		||||
					fuel_totaltime = 0
 | 
			
		||||
					src_time = 0
 | 
			
		||||
				else
 | 
			
		||||
					-- Take fuel from fuel list
 | 
			
		||||
					inv:set_stack("fuel", 1, afterfuel.items[1])
 | 
			
		||||
					update = true
 | 
			
		||||
					fuel_totaltime = fuel.time + (fuel_time - fuel_totaltime)
 | 
			
		||||
					src_time = src_time + elapsed
 | 
			
		||||
				end
 | 
			
		||||
			else
 | 
			
		||||
				-- We don't need to get new fuel since there is no cookable item
 | 
			
		||||
				fuel_totaltime = 0
 | 
			
		||||
				src_time = 0
 | 
			
		||||
			end
 | 
			
		||||
			fuel_time = 0
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		elapsed = 0
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	if fuel and fuel_totaltime > fuel.time then
 | 
			
		||||
		fuel_totaltime = fuel.time
 | 
			
		||||
	end
 | 
			
		||||
	if srclist[1]:is_empty() then
 | 
			
		||||
		src_time = 0
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	--
 | 
			
		||||
	-- Update formspec, infotext and node
 | 
			
		||||
	--
 | 
			
		||||
	local formspec = inactive_formspec(pos, meta)
 | 
			
		||||
	local item_state
 | 
			
		||||
	local item_percent = 0
 | 
			
		||||
	if cookable then
 | 
			
		||||
		item_percent = math.floor(src_time / cooked.time * 100)
 | 
			
		||||
		if item_percent > 100 then
 | 
			
		||||
			item_state = "100% (output full)"
 | 
			
		||||
		else
 | 
			
		||||
			item_state = item_percent .. "%"
 | 
			
		||||
		end
 | 
			
		||||
	else
 | 
			
		||||
		if srclist[1]:is_empty() then
 | 
			
		||||
			item_state = "Empty"
 | 
			
		||||
		else
 | 
			
		||||
			item_state = "Not cookable"
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	local fuel_state = "Empty"
 | 
			
		||||
	local active = "inactive "
 | 
			
		||||
	local result = false
 | 
			
		||||
 | 
			
		||||
	if fuel_totaltime ~= 0 then
 | 
			
		||||
		active = "active "
 | 
			
		||||
		local fuel_percent = math.floor(fuel_time / fuel_totaltime * 100)
 | 
			
		||||
		fuel_state = fuel_percent .. "%"
 | 
			
		||||
		formspec = active_formspec(fuel_percent, item_percent, pos, meta)
 | 
			
		||||
		swap_node(pos, "default:furnace_active")
 | 
			
		||||
		-- make sure timer restarts automatically
 | 
			
		||||
		result = true
 | 
			
		||||
	else
 | 
			
		||||
		if not fuellist[1]:is_empty() then
 | 
			
		||||
			fuel_state = "0%"
 | 
			
		||||
		end
 | 
			
		||||
		swap_node(pos, "default:furnace")
 | 
			
		||||
		-- stop timer on the inactive furnace
 | 
			
		||||
		minetest.get_node_timer(pos):stop()
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	local infotext = "Furnace " .. active .. "(Item: " .. item_state .. "; Fuel: " .. fuel_state .. ")"
 | 
			
		||||
 | 
			
		||||
	--
 | 
			
		||||
	-- Set meta values
 | 
			
		||||
	--
 | 
			
		||||
	meta:set_float("fuel_totaltime", fuel_totaltime)
 | 
			
		||||
	meta:set_float("fuel_time", fuel_time)
 | 
			
		||||
	meta:set_float("src_time", src_time)
 | 
			
		||||
	meta:set_string("formspec", formspec)
 | 
			
		||||
	meta:set_string("infotext", infotext)
 | 
			
		||||
 | 
			
		||||
	return result
 | 
			
		||||
end
 | 
			
		||||
local groups = def.groups
 | 
			
		||||
groups["tubedevice"] = 1
 | 
			
		||||
groups["tubedevice_receiver"] = 1
 | 
			
		||||
local groups_active = table.copy(groups)
 | 
			
		||||
groups_active["not_in_creative_inventory"] = 1
 | 
			
		||||
 | 
			
		||||
--
 | 
			
		||||
-- Node definitions
 | 
			
		||||
--
 | 
			
		||||
 | 
			
		||||
minetest.register_node(":default:furnace", {
 | 
			
		||||
	description = "Furnace",
 | 
			
		||||
local override = {
 | 
			
		||||
	tiles = {
 | 
			
		||||
		"default_furnace_top.png"..tube_entry,
 | 
			
		||||
		"default_furnace_bottom.png"..tube_entry,
 | 
			
		||||
@@ -280,7 +31,7 @@ minetest.register_node(":default:furnace", {
 | 
			
		||||
		"default_furnace_side.png"..tube_entry,
 | 
			
		||||
		"default_furnace_front.png"
 | 
			
		||||
	},
 | 
			
		||||
	groups = {cracky = 2, tubedevice = 1, tubedevice_receiver = 1},
 | 
			
		||||
	groups = groups,
 | 
			
		||||
	tube = {
 | 
			
		||||
		insert_object = function(pos, node, stack, direction)
 | 
			
		||||
			local meta = minetest.get_meta(pos)
 | 
			
		||||
@@ -308,58 +59,15 @@ minetest.register_node(":default:furnace", {
 | 
			
		||||
			end
 | 
			
		||||
		end,
 | 
			
		||||
		input_inventory = "dst",
 | 
			
		||||
		connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
 | 
			
		||||
		connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1}
 | 
			
		||||
	},
 | 
			
		||||
	paramtype2 = "facedir",
 | 
			
		||||
	legacy_facedir_simple = true,
 | 
			
		||||
	is_ground_content = false,
 | 
			
		||||
	sounds = default.node_sound_stone_defaults(),
 | 
			
		||||
 | 
			
		||||
	can_dig = can_dig,
 | 
			
		||||
 | 
			
		||||
	on_timer = furnace_node_timer,
 | 
			
		||||
 | 
			
		||||
	on_construct = function(pos)
 | 
			
		||||
		local meta = minetest.get_meta(pos)
 | 
			
		||||
		meta:set_string("formspec", inactive_formspec(pos, meta))
 | 
			
		||||
		local inv = meta:get_inventory()
 | 
			
		||||
		inv:set_size('src', 1)
 | 
			
		||||
		inv:set_size('fuel', 1)
 | 
			
		||||
		inv:set_size('dst', 4)
 | 
			
		||||
	end,
 | 
			
		||||
 | 
			
		||||
	on_metadata_inventory_move = function(pos)
 | 
			
		||||
		minetest.get_node_timer(pos):start(1.0)
 | 
			
		||||
	end,
 | 
			
		||||
	on_metadata_inventory_put = function(pos)
 | 
			
		||||
		-- start timer function, it will sort out whether furnace can burn or not.
 | 
			
		||||
		minetest.get_node_timer(pos):start(1.0)
 | 
			
		||||
	end,
 | 
			
		||||
	on_blast = function(pos)
 | 
			
		||||
		local drops = {}
 | 
			
		||||
		default.get_inventory_drops(pos, "src", drops)
 | 
			
		||||
		default.get_inventory_drops(pos, "fuel", drops)
 | 
			
		||||
		default.get_inventory_drops(pos, "dst", drops)
 | 
			
		||||
		drops[#drops+1] = "default:furnace"
 | 
			
		||||
		minetest.remove_node(pos)
 | 
			
		||||
		return drops
 | 
			
		||||
	end,
 | 
			
		||||
	allow_metadata_inventory_put = allow_metadata_inventory_put,
 | 
			
		||||
	allow_metadata_inventory_move = allow_metadata_inventory_move,
 | 
			
		||||
	allow_metadata_inventory_take = allow_metadata_inventory_take,
 | 
			
		||||
	on_receive_fields = function(pos, formname, fields, sender)
 | 
			
		||||
		if not pipeworks.may_configure(pos, sender) then return end
 | 
			
		||||
		fs_helpers.on_receive_fields(pos, fields)
 | 
			
		||||
		local meta = minetest.get_meta(pos)
 | 
			
		||||
		local formspec = inactive_formspec(pos, meta)
 | 
			
		||||
		meta:set_string("formspec", formspec)
 | 
			
		||||
	end,
 | 
			
		||||
	after_place_node = pipeworks.after_place,
 | 
			
		||||
	after_dig_node = pipeworks.after_dig
 | 
			
		||||
})
 | 
			
		||||
	after_dig_node = pipeworks.after_dig,
 | 
			
		||||
	on_rotate = pipeworks.on_rotate
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
minetest.register_node(":default:furnace_active", {
 | 
			
		||||
	description = "Furnace",
 | 
			
		||||
local override_active = {
 | 
			
		||||
	tiles = {
 | 
			
		||||
		"default_furnace_top.png"..tube_entry,
 | 
			
		||||
		"default_furnace_bottom.png"..tube_entry,
 | 
			
		||||
@@ -377,7 +85,7 @@ minetest.register_node(":default:furnace_active", {
 | 
			
		||||
			},
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	groups = {cracky = 2, tubedevice = 1, tubedevice_receiver = 1, not_in_creative_inventory = 1},
 | 
			
		||||
	groups = groups_active,
 | 
			
		||||
	tube = {
 | 
			
		||||
		insert_object = function(pos,node,stack,direction)
 | 
			
		||||
			local meta = minetest.get_meta(pos)
 | 
			
		||||
@@ -398,36 +106,23 @@ minetest.register_node(":default:furnace_active", {
 | 
			
		||||
			if direction.y == 1 then
 | 
			
		||||
				return inv:room_for_item("fuel", stack)
 | 
			
		||||
			else
 | 
			
		||||
				if meta:get_int("split_material_stacks") == 1 then
 | 
			
		||||
					stack = stack:peek_item(1)
 | 
			
		||||
				end
 | 
			
		||||
				return inv:room_for_item("src", stack)
 | 
			
		||||
			end
 | 
			
		||||
		end,
 | 
			
		||||
		input_inventory = "dst",
 | 
			
		||||
		connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
 | 
			
		||||
		connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1}
 | 
			
		||||
	},
 | 
			
		||||
	paramtype2 = "facedir",
 | 
			
		||||
	light_source = 8,
 | 
			
		||||
	drop = "default:furnace",
 | 
			
		||||
	legacy_facedir_simple = true,
 | 
			
		||||
	is_ground_content = false,
 | 
			
		||||
	sounds = default.node_sound_stone_defaults(),
 | 
			
		||||
	on_timer = furnace_node_timer,
 | 
			
		||||
 | 
			
		||||
	can_dig = can_dig,
 | 
			
		||||
 | 
			
		||||
	allow_metadata_inventory_put = allow_metadata_inventory_put,
 | 
			
		||||
	allow_metadata_inventory_move = allow_metadata_inventory_move,
 | 
			
		||||
	allow_metadata_inventory_take = allow_metadata_inventory_take,
 | 
			
		||||
	on_receive_fields = function(pos, formname, fields, sender)
 | 
			
		||||
		if not pipeworks.may_configure(pos, sender) then return end
 | 
			
		||||
		fs_helpers.on_receive_fields(pos, fields)
 | 
			
		||||
		local meta = minetest.get_meta(pos)
 | 
			
		||||
		local formspec = active_formspec(0, 0, pos, meta)
 | 
			
		||||
		meta:set_string("formspec", formspec)
 | 
			
		||||
	end,
 | 
			
		||||
	after_place_node = pipeworks.after_place,
 | 
			
		||||
	after_dig_node = pipeworks.after_dig
 | 
			
		||||
})
 | 
			
		||||
	after_dig_node = pipeworks.after_dig,
 | 
			
		||||
	on_rotate = pipeworks.on_rotate
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if minetest.get_modpath("default") then
 | 
			
		||||
	minetest.override_item("default:furnace", override)
 | 
			
		||||
	minetest.override_item("default:furnace_active", override_active)
 | 
			
		||||
elseif minetest.get_modpath("hades_furnaces") then
 | 
			
		||||
	minetest.override_item("hades_furnaces:furnace", override)
 | 
			
		||||
	minetest.override_item("hades_furnaces:furnace_active", override_active)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										466
									
								
								crafts.lua
									
									
									
									
									
								
							
							
						
						
									
										466
									
								
								crafts.lua
									
									
									
									
									
								
							@@ -1,172 +1,372 @@
 | 
			
		||||
local materials = {
 | 
			
		||||
	stone = "default:stone",
 | 
			
		||||
	desert_stone = "default:desert_stone",
 | 
			
		||||
	desert_sand = "default:desert_sand",
 | 
			
		||||
	chest = "default:chest",
 | 
			
		||||
	copper_ingot = "default:copper_ingot",
 | 
			
		||||
	steel_ingot = "default:steel_ingot",
 | 
			
		||||
	gold_ingot = "default:gold_ingot",
 | 
			
		||||
	mese = "default:mese",
 | 
			
		||||
	mese_crystal = "default:mese_crystal",
 | 
			
		||||
	mese_crystal_fragment = "default:mese_crystal_fragment",
 | 
			
		||||
	teleporter = "default:mese",
 | 
			
		||||
	glass = "default:glass",
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if minetest.get_modpath("mcl_core") then
 | 
			
		||||
	materials = {
 | 
			
		||||
		stone = "mcl_core:stone",
 | 
			
		||||
		desert_stone = "mcl_core:redsandstone",
 | 
			
		||||
		desert_sand = "mcl_core:sand",
 | 
			
		||||
		chest = "mcl_chests:chest",
 | 
			
		||||
		steel_ingot = "mcl_core:iron_ingot",
 | 
			
		||||
		gold_ingot = "mcl_core:gold_ingot",
 | 
			
		||||
		mese = "mesecons_torch:redstoneblock",
 | 
			
		||||
		mese_crystal = "mesecons:redstone",
 | 
			
		||||
		mese_crystal_fragment = "mesecons:redstone",
 | 
			
		||||
		teleporter = "mesecons_torch:redstoneblock",
 | 
			
		||||
		copper_ingot = "mcl_copper:copper_ingot",
 | 
			
		||||
		glass = "mcl_core:glass",
 | 
			
		||||
	}
 | 
			
		||||
elseif minetest.get_modpath("fl_ores") and minetest.get_modpath("fl_stone") then
 | 
			
		||||
	materials = {
 | 
			
		||||
		stone = "fl_stone:stone",
 | 
			
		||||
		desert_stone = "fl_stone:desert_stone",
 | 
			
		||||
		desert_sand = "fl_stone:desert_sand",
 | 
			
		||||
		chest = "fl_storage:wood_chest",
 | 
			
		||||
		steel_ingot = "fl_ores:iron_ingot",
 | 
			
		||||
		gold_ingot = "fl_ores:gold_ingot",
 | 
			
		||||
		mese = "fl_ores:iron_ingot",
 | 
			
		||||
		mese_crystal = "fl_ores:iron_ingot",
 | 
			
		||||
		mese_crystal_fragment = "fl_ores:iron_ingot",
 | 
			
		||||
		teleporter = "fl_ores:iron_ingot",
 | 
			
		||||
		copper_ingot = "fl_ores:copper_ingot",
 | 
			
		||||
		glass = "fl_glass:framed_glass",
 | 
			
		||||
	}
 | 
			
		||||
elseif minetest.get_modpath("hades_core") then
 | 
			
		||||
	materials = {
 | 
			
		||||
		stone = "hades_core:stone",
 | 
			
		||||
		desert_stone = "hades_core:stone_baked",
 | 
			
		||||
		desert_sand = "hades_core:volcanic_sand",
 | 
			
		||||
		chest = "hades_chests:chest";
 | 
			
		||||
		steel_ingot = "hades_core:steel_ingot",
 | 
			
		||||
		gold_ingot = "hades_core:gold_ingot",
 | 
			
		||||
		mese = "hades_core:mese",
 | 
			
		||||
		mese_crystal = "hades_core:mese_crystal",
 | 
			
		||||
		mese_crystal_fragment = "hades_core:mese_crystal_fragment",
 | 
			
		||||
		teleporter = "hades_materials:teleporter_device",
 | 
			
		||||
		copper_ingot = "hades_core:copper_ingot",
 | 
			
		||||
		tin_ingot = "hades_core:tin_ingot",
 | 
			
		||||
		glass = "hades_core:glass",
 | 
			
		||||
	}
 | 
			
		||||
  if minetest.get_modpath("hades_default") then
 | 
			
		||||
		materials.desert_sand = "hades_default:desert_sand"
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Crafting recipes for pipes
 | 
			
		||||
 | 
			
		||||
minetest.register_craft( {
 | 
			
		||||
        output = "pipeworks:pipe_1_empty 12",
 | 
			
		||||
        recipe = {
 | 
			
		||||
                { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" },
 | 
			
		||||
                { "", "", "" },
 | 
			
		||||
                { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }
 | 
			
		||||
        },
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
minetest.register_craft( {
 | 
			
		||||
        output = "pipeworks:straight_pipe_empty 3",
 | 
			
		||||
        recipe = {
 | 
			
		||||
                { "pipeworks:pipe_1_empty", "pipeworks:pipe_1_empty", "pipeworks:pipe_1_empty" },
 | 
			
		||||
        },
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
minetest.register_craft( {
 | 
			
		||||
        output = "pipeworks:spigot 3",
 | 
			
		||||
        recipe = {
 | 
			
		||||
                { "pipeworks:pipe_1_empty", "" },
 | 
			
		||||
                { "", "pipeworks:pipe_1_empty" },
 | 
			
		||||
        },
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
minetest.register_craft( {
 | 
			
		||||
	output = "pipeworks:entry_panel_empty 2",
 | 
			
		||||
	output = "pipeworks:pipe_1_empty 12",
 | 
			
		||||
	recipe = {
 | 
			
		||||
		{ "", "default:steel_ingot", "" },
 | 
			
		||||
		{ "", "pipeworks:pipe_1_empty", "" },
 | 
			
		||||
		{ "", "default:steel_ingot", "" },
 | 
			
		||||
			{ materials.steel_ingot, materials.steel_ingot, materials.steel_ingot },
 | 
			
		||||
			{ "", "", "" },
 | 
			
		||||
			{ materials.steel_ingot, materials.steel_ingot, materials.steel_ingot }
 | 
			
		||||
	},
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
minetest.register_craft( {
 | 
			
		||||
	output = "pipeworks:straight_pipe_empty 3",
 | 
			
		||||
	recipe = {
 | 
			
		||||
			{ "pipeworks:pipe_1_empty", "pipeworks:pipe_1_empty", "pipeworks:pipe_1_empty" },
 | 
			
		||||
	},
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
minetest.register_craft( {
 | 
			
		||||
	output = "pipeworks:spigot 3",
 | 
			
		||||
	recipe = {
 | 
			
		||||
			{ "pipeworks:pipe_1_empty", "" },
 | 
			
		||||
			{ "", "pipeworks:pipe_1_empty" },
 | 
			
		||||
	},
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
minetest.register_craft( {
 | 
			
		||||
output = "pipeworks:entry_panel_empty 2",
 | 
			
		||||
recipe = {
 | 
			
		||||
	{ "", materials.steel_ingot, "" },
 | 
			
		||||
	{ "", "pipeworks:pipe_1_empty", "" },
 | 
			
		||||
	{ "", materials.steel_ingot, "" },
 | 
			
		||||
},
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
-- Various ancillary pipe devices
 | 
			
		||||
 | 
			
		||||
minetest.register_craft( {
 | 
			
		||||
        output = "pipeworks:pump_off 2",
 | 
			
		||||
        recipe = {
 | 
			
		||||
                { "default:stone", "default:steel_ingot", "default:stone" },
 | 
			
		||||
                { "default:copper_ingot", "default:mese_crystal_fragment", "default:copper_ingot" },
 | 
			
		||||
                { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }
 | 
			
		||||
        },
 | 
			
		||||
	output = "pipeworks:pump_off 2",
 | 
			
		||||
	recipe = {
 | 
			
		||||
			{ materials.stone, materials.steel_ingot, materials.stone },
 | 
			
		||||
			{ materials.copper_ingot, materials.mese_crystal_fragment, materials.copper_ingot },
 | 
			
		||||
			{ materials.steel_ingot, materials.steel_ingot, materials.steel_ingot }
 | 
			
		||||
	},
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
minetest.register_craft( {
 | 
			
		||||
        output = "pipeworks:valve_off_empty 2",
 | 
			
		||||
        recipe = {
 | 
			
		||||
                { "", "group:stick", "" },
 | 
			
		||||
                { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" },
 | 
			
		||||
                { "", "default:steel_ingot", "" }
 | 
			
		||||
        },
 | 
			
		||||
	output = "pipeworks:valve_off_empty 2",
 | 
			
		||||
	recipe = {
 | 
			
		||||
			{ "", "group:stick", "" },
 | 
			
		||||
			{ materials.steel_ingot, materials.steel_ingot, materials.steel_ingot },
 | 
			
		||||
			{ "", materials.steel_ingot, "" }
 | 
			
		||||
	},
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
minetest.register_craft( {
 | 
			
		||||
        output = "pipeworks:storage_tank_0 2",
 | 
			
		||||
        recipe = {
 | 
			
		||||
                { "", "default:steel_ingot", "default:steel_ingot" },
 | 
			
		||||
                { "default:steel_ingot", "default:glass", "default:steel_ingot" },
 | 
			
		||||
                { "default:steel_ingot", "default:steel_ingot", "" }
 | 
			
		||||
        },
 | 
			
		||||
	output = "pipeworks:storage_tank_0 2",
 | 
			
		||||
	recipe = {
 | 
			
		||||
			{ "", materials.steel_ingot, materials.steel_ingot },
 | 
			
		||||
			{ materials.steel_ingot, materials.glass, materials.steel_ingot },
 | 
			
		||||
			{ materials.steel_ingot, materials.steel_ingot, "" }
 | 
			
		||||
	},
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
minetest.register_craft( {
 | 
			
		||||
        output = "pipeworks:grating 2",
 | 
			
		||||
        recipe = {
 | 
			
		||||
                { "default:steel_ingot", "", "default:steel_ingot" },
 | 
			
		||||
                { "", "pipeworks:pipe_1_empty", "" },
 | 
			
		||||
                { "default:steel_ingot", "", "default:steel_ingot" }
 | 
			
		||||
        },
 | 
			
		||||
	output = "pipeworks:grating 2",
 | 
			
		||||
	recipe = {
 | 
			
		||||
			{ materials.steel_ingot, "", materials.steel_ingot },
 | 
			
		||||
			{ "", "pipeworks:pipe_1_empty", "" },
 | 
			
		||||
			{ materials.steel_ingot, "", materials.steel_ingot }
 | 
			
		||||
	},
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
minetest.register_craft( {
 | 
			
		||||
        output = "pipeworks:flow_sensor_empty 2",
 | 
			
		||||
        recipe = {
 | 
			
		||||
                { "pipeworks:pipe_1_empty", "mesecons:mesecon", "pipeworks:pipe_1_empty" },
 | 
			
		||||
        },
 | 
			
		||||
	output = "pipeworks:flow_sensor_empty 2",
 | 
			
		||||
	recipe = {
 | 
			
		||||
			{ "pipeworks:pipe_1_empty", "mesecons:mesecon", "pipeworks:pipe_1_empty" },
 | 
			
		||||
	},
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
minetest.register_craft( {
 | 
			
		||||
        output = "pipeworks:fountainhead 2",
 | 
			
		||||
        recipe = {
 | 
			
		||||
                { "pipeworks:pipe_1_empty" },
 | 
			
		||||
				{ "pipeworks:pipe_1_empty" }
 | 
			
		||||
        },
 | 
			
		||||
	output = "pipeworks:fountainhead 2",
 | 
			
		||||
	recipe = {
 | 
			
		||||
			{ "pipeworks:pipe_1_empty" },
 | 
			
		||||
			{ "pipeworks:pipe_1_empty" }
 | 
			
		||||
	},
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
-- injectors
 | 
			
		||||
 | 
			
		||||
-- Crafting recipes for pneumatic tubes
 | 
			
		||||
minetest.register_craft( {
 | 
			
		||||
	output = "pipeworks:filter 2",
 | 
			
		||||
	recipe = {
 | 
			
		||||
			{ materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" },
 | 
			
		||||
			{ "group:stick", materials.mese_crystal, "basic_materials:plastic_sheet" },
 | 
			
		||||
			{ materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" }
 | 
			
		||||
	},
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
-- If homedecor is not installed, we need to register its crafting chain for
 | 
			
		||||
-- plastic sheeting so that pipeworks remains compatible with it.
 | 
			
		||||
minetest.register_craft( {
 | 
			
		||||
	output = "pipeworks:mese_filter 2",
 | 
			
		||||
	recipe = {
 | 
			
		||||
			{ materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" },
 | 
			
		||||
			{ "group:stick", materials.mese, "basic_materials:plastic_sheet" },
 | 
			
		||||
			{ materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" }
 | 
			
		||||
	},
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
if minetest.get_modpath("homedecor") == nil then
 | 
			
		||||
 | 
			
		||||
	minetest.register_craftitem(":homedecor:oil_extract", {
 | 
			
		||||
		    description = "Oil extract",
 | 
			
		||||
		    inventory_image = "homedecor_oil_extract.png",
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	minetest.register_craftitem(":homedecor:paraffin", {
 | 
			
		||||
		    description = "Unprocessed paraffin",
 | 
			
		||||
		    inventory_image = "homedecor_paraffin.png",
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	minetest.register_alias("homedecor:plastic_base", "homedecor:paraffin")
 | 
			
		||||
 | 
			
		||||
	minetest.register_craftitem(":homedecor:plastic_sheeting", {
 | 
			
		||||
		    description = "Plastic sheet",
 | 
			
		||||
		    inventory_image = "homedecor_plastic_sheeting.png",
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	minetest.register_craft({
 | 
			
		||||
		type = "shapeless",
 | 
			
		||||
		output = "homedecor:oil_extract 4",
 | 
			
		||||
if minetest.get_modpath("digilines") then
 | 
			
		||||
	minetest.register_craft( {
 | 
			
		||||
		output = "pipeworks:digiline_filter 2",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			"group:leaves",
 | 
			
		||||
			"group:leaves",
 | 
			
		||||
			"group:leaves",
 | 
			
		||||
			"group:leaves",
 | 
			
		||||
			"group:leaves",
 | 
			
		||||
			"group:leaves"
 | 
			
		||||
		}
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	minetest.register_craft({
 | 
			
		||||
		    type = "cooking",
 | 
			
		||||
		    output = "homedecor:paraffin",
 | 
			
		||||
		    recipe = "homedecor:oil_extract",
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	minetest.register_craft({
 | 
			
		||||
		    type = "cooking",
 | 
			
		||||
		    output = "homedecor:plastic_sheeting",
 | 
			
		||||
		    recipe = "homedecor:paraffin",
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	minetest.register_craft({
 | 
			
		||||
		    type = "fuel",
 | 
			
		||||
		    recipe = "homedecor:oil_extract",
 | 
			
		||||
		    burntime = 30,
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	minetest.register_craft({
 | 
			
		||||
		    type = "fuel",
 | 
			
		||||
		    recipe = "homedecor:paraffin",
 | 
			
		||||
		    burntime = 30,
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	minetest.register_craft({
 | 
			
		||||
		    type = "fuel",
 | 
			
		||||
		    recipe = "homedecor:plastic_sheeting",
 | 
			
		||||
		    burntime = 30,
 | 
			
		||||
			{ materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" },
 | 
			
		||||
			{ "group:stick", "digilines:wire_std_00000000", "basic_materials:plastic_sheet" },
 | 
			
		||||
			{ materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" }
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- crafting items for creating node breakers
 | 
			
		||||
minetest.register_craftitem("pipeworks:gear", {
 | 
			
		||||
	description = "Gear",
 | 
			
		||||
	inventory_image = "pipeworks_gear.png",
 | 
			
		||||
-- other
 | 
			
		||||
 | 
			
		||||
minetest.register_craft( {
 | 
			
		||||
	output = "pipeworks:autocrafter 2",
 | 
			
		||||
	recipe = {
 | 
			
		||||
			{ materials.steel_ingot, materials.mese_crystal, materials.steel_ingot },
 | 
			
		||||
			{ "basic_materials:plastic_sheet", materials.steel_ingot, "basic_materials:plastic_sheet" },
 | 
			
		||||
			{ materials.steel_ingot, materials.mese_crystal, materials.steel_ingot }
 | 
			
		||||
	},
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
minetest.register_craft( {
 | 
			
		||||
        output = "pipeworks:gear 6",
 | 
			
		||||
        recipe = {
 | 
			
		||||
                { "", 			"default:steel_ingot",	"" },
 | 
			
		||||
                { "default:steel_ingot","default:stone",	"default:steel_ingot" },
 | 
			
		||||
                { "",			"default:steel_ingot",	"" }
 | 
			
		||||
        },
 | 
			
		||||
	output = "pipeworks:steel_block_embedded_tube 1",
 | 
			
		||||
	recipe = {
 | 
			
		||||
		{ materials.steel_ingot, materials.steel_ingot, materials.steel_ingot },
 | 
			
		||||
		{ materials.steel_ingot, "pipeworks:tube_1", materials.steel_ingot },
 | 
			
		||||
		{ materials.steel_ingot, materials.steel_ingot, materials.steel_ingot }
 | 
			
		||||
	},
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
minetest.register_craft( {
 | 
			
		||||
	output = "pipeworks:steel_pane_embedded_tube 1",
 | 
			
		||||
	recipe = {
 | 
			
		||||
		{ "", materials.steel_ingot, "" },
 | 
			
		||||
		{ "", "pipeworks:tube_1", "" },
 | 
			
		||||
		{ "", materials.steel_ingot, "" }
 | 
			
		||||
	},
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
minetest.register_craft({
 | 
			
		||||
	output = "pipeworks:trashcan",
 | 
			
		||||
	recipe = {
 | 
			
		||||
		{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
 | 
			
		||||
		{ materials.steel_ingot, "", materials.steel_ingot },
 | 
			
		||||
		{ materials.steel_ingot, materials.steel_ingot, materials.steel_ingot },
 | 
			
		||||
	},
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
minetest.register_craft( {
 | 
			
		||||
	output = "pipeworks:teleport_tube_1 2",
 | 
			
		||||
	recipe = {
 | 
			
		||||
			{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
 | 
			
		||||
			{ materials.desert_stone, materials.teleporter, materials.desert_stone },
 | 
			
		||||
			{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
 | 
			
		||||
	},
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
if pipeworks.enable_priority_tube then
 | 
			
		||||
	minetest.register_craft( {
 | 
			
		||||
		output = "pipeworks:priority_tube_1 6",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
 | 
			
		||||
			{ materials.gold_ingot, "", materials.gold_ingot },
 | 
			
		||||
			{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if pipeworks.enable_accelerator_tube then
 | 
			
		||||
	minetest.register_craft( {
 | 
			
		||||
		output = "pipeworks:accelerator_tube_1 2",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
 | 
			
		||||
			{ materials.mese_crystal_fragment, materials.steel_ingot, materials.mese_crystal_fragment },
 | 
			
		||||
			{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if pipeworks.enable_crossing_tube then
 | 
			
		||||
	minetest.register_craft( {
 | 
			
		||||
		output = "pipeworks:crossing_tube_1 5",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			{ "", "pipeworks:tube_1", "" },
 | 
			
		||||
			{ "pipeworks:tube_1", "pipeworks:tube_1", "pipeworks:tube_1" },
 | 
			
		||||
			{ "", "pipeworks:tube_1", "" }
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if pipeworks.enable_one_way_tube then
 | 
			
		||||
	minetest.register_craft({
 | 
			
		||||
		output = "pipeworks:one_way_tube 2",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
 | 
			
		||||
			{ "group:stick", materials.mese_crystal, "basic_materials:plastic_sheet" },
 | 
			
		||||
			{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if pipeworks.enable_mese_tube then
 | 
			
		||||
	minetest.register_craft( {
 | 
			
		||||
		output = "pipeworks:mese_tube_000000 2",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
 | 
			
		||||
			{ "", materials.mese_crystal, "" },
 | 
			
		||||
			{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	minetest.register_craft( {
 | 
			
		||||
		type = "shapeless",
 | 
			
		||||
		output = "pipeworks:mese_tube_000000",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			"pipeworks:tube_1",
 | 
			
		||||
			materials.mese_crystal_fragment,
 | 
			
		||||
			materials.mese_crystal_fragment,
 | 
			
		||||
			materials.mese_crystal_fragment,
 | 
			
		||||
			materials.mese_crystal_fragment,
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if pipeworks.enable_sand_tube then
 | 
			
		||||
	minetest.register_craft( {
 | 
			
		||||
		output = "pipeworks:sand_tube_1 2",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			{"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet"},
 | 
			
		||||
			{"group:sand",                 "group:sand",                 "group:sand"},
 | 
			
		||||
			{"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet"}
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	minetest.register_craft( {
 | 
			
		||||
		output = "pipeworks:sand_tube_1",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			{"group:sand", "pipeworks:tube_1", "group:sand"},
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if pipeworks.enable_mese_sand_tube then
 | 
			
		||||
	minetest.register_craft( {
 | 
			
		||||
		output = "pipeworks:mese_sand_tube_1 2",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			{"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
 | 
			
		||||
			{"group:sand",				 materials.mese_crystal,	   "group:sand" },
 | 
			
		||||
			{"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	minetest.register_craft( {
 | 
			
		||||
		type = "shapeless",
 | 
			
		||||
		output = "pipeworks:mese_sand_tube_1",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			"pipeworks:sand_tube_1",
 | 
			
		||||
			materials.mese_crystal_fragment,
 | 
			
		||||
			materials.mese_crystal_fragment,
 | 
			
		||||
			materials.mese_crystal_fragment,
 | 
			
		||||
			materials.mese_crystal_fragment,
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if pipeworks.enable_deployer then
 | 
			
		||||
	minetest.register_craft({
 | 
			
		||||
		output = "pipeworks:deployer_off",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			{ "group:wood",	materials.chest,	"group:wood"	},
 | 
			
		||||
			{ materials.stone, "mesecons:piston",  materials.stone },
 | 
			
		||||
			{ materials.stone, "mesecons:mesecon", materials.stone },
 | 
			
		||||
		}
 | 
			
		||||
	})
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if pipeworks.enable_dispenser then
 | 
			
		||||
	minetest.register_craft({
 | 
			
		||||
		output = "pipeworks:dispenser_off",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			{ materials.desert_sand, materials.chest,	materials.desert_sand },
 | 
			
		||||
			{ materials.stone,	   "mesecons:piston",  materials.stone	   },
 | 
			
		||||
			{ materials.stone,	   "mesecons:mesecon", materials.stone	  },
 | 
			
		||||
		}
 | 
			
		||||
	})
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if pipeworks.enable_node_breaker then
 | 
			
		||||
	minetest.register_craft({
 | 
			
		||||
		output = "pipeworks:nodebreaker_off",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			{ "basic_materials:gear_steel", "basic_materials:gear_steel",   "basic_materials:gear_steel"	},
 | 
			
		||||
			{ materials.stone, "mesecons:piston",   materials.stone },
 | 
			
		||||
			{ "group:wood",	"mesecons:mesecon",  "group:wood" },
 | 
			
		||||
		}
 | 
			
		||||
	})
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,18 +1,25 @@
 | 
			
		||||
local S = minetest.get_translator("pipeworks")
 | 
			
		||||
 | 
			
		||||
local straight = function(pos, node, velocity, stack) return {velocity} end
 | 
			
		||||
local steel_tex = "[combine:16x16^[noalpha^[colorize:#D3D3D3"
 | 
			
		||||
if minetest.get_modpath("default") then steel_tex = "default_steel_block.png" end
 | 
			
		||||
 | 
			
		||||
minetest.register_node("pipeworks:steel_block_embedded_tube", {
 | 
			
		||||
	description = "Airtight steelblock embedded tube",
 | 
			
		||||
	description = S("Airtight steelblock embedded tube"),
 | 
			
		||||
	tiles = {
 | 
			
		||||
		"default_steel_block.png", "default_steel_block.png",
 | 
			
		||||
		"default_steel_block.png", "default_steel_block.png",
 | 
			
		||||
		"default_steel_block.png^pipeworks_tube_connection_metallic.png",
 | 
			
		||||
		"default_steel_block.png^pipeworks_tube_connection_metallic.png",
 | 
			
		||||
		steel_tex, steel_tex,
 | 
			
		||||
		steel_tex, steel_tex,
 | 
			
		||||
		steel_tex .. "^pipeworks_tube_connection_metallic.png",
 | 
			
		||||
		steel_tex .. "^pipeworks_tube_connection_metallic.png",
 | 
			
		||||
		},
 | 
			
		||||
	paramtype = "light",
 | 
			
		||||
	paramtype2 = "facedir",
 | 
			
		||||
	groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1},
 | 
			
		||||
	groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1, dig_glass = 2, pickaxey=1, handy=1},
 | 
			
		||||
	_mcl_hardness=0.8,
 | 
			
		||||
	legacy_facedir_simple = true,
 | 
			
		||||
	sounds = default.node_sound_stone_defaults(),
 | 
			
		||||
	_sound_def = {
 | 
			
		||||
        key = "node_sound_stone_defaults",
 | 
			
		||||
    },
 | 
			
		||||
	tube = {
 | 
			
		||||
		connect_sides = {front = 1, back = 1,},
 | 
			
		||||
		priority = 50,
 | 
			
		||||
@@ -24,16 +31,9 @@ minetest.register_node("pipeworks:steel_block_embedded_tube", {
 | 
			
		||||
	},
 | 
			
		||||
	after_place_node = pipeworks.after_place,
 | 
			
		||||
	after_dig_node = pipeworks.after_dig,
 | 
			
		||||
	on_rotate = pipeworks.on_rotate,
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
minetest.register_craft( {
 | 
			
		||||
	output = "pipeworks:steel_block_embedded_tube 1",
 | 
			
		||||
	recipe = {
 | 
			
		||||
		{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" },
 | 
			
		||||
		{ "default:steel_ingot", "pipeworks:tube_1", "default:steel_ingot" },
 | 
			
		||||
		{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }
 | 
			
		||||
	},
 | 
			
		||||
})
 | 
			
		||||
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:steel_block_embedded_tube"
 | 
			
		||||
 | 
			
		||||
local pane_box = {
 | 
			
		||||
	type = "fixed",
 | 
			
		||||
@@ -42,24 +42,33 @@ local pane_box = {
 | 
			
		||||
		{ -8/16, -8/16, -1/16, 8/16, 8/16, 1/16 } -- pane
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local texture_alpha_mode = minetest.features.use_texture_alpha_string_modes
 | 
			
		||||
	and "clip" or true
 | 
			
		||||
 | 
			
		||||
minetest.register_node("pipeworks:steel_pane_embedded_tube", {
 | 
			
		||||
	drawtype = "nodebox",
 | 
			
		||||
	description = "Airtight panel embedded tube ",
 | 
			
		||||
	description = S("Airtight panel embedded tube"),
 | 
			
		||||
	tiles = {
 | 
			
		||||
		"pipeworks_pane_embedded_tube_sides.png^[transformR90",
 | 
			
		||||
		"pipeworks_pane_embedded_tube_sides.png^[transformR90",
 | 
			
		||||
		"pipeworks_pane_embedded_tube_sides.png",
 | 
			
		||||
		"pipeworks_pane_embedded_tube_sides.png",
 | 
			
		||||
		"pipeworks_pane_embedded_tube_ends.png", "pipeworks_pane_embedded_tube_ends.png",
 | 
			
		||||
		},
 | 
			
		||||
		pipeworks.make_tube_tile("pipeworks_pane_embedded_tube_sides.png^[transformR90"),
 | 
			
		||||
		pipeworks.make_tube_tile("pipeworks_pane_embedded_tube_sides.png^[transformR90"),
 | 
			
		||||
		pipeworks.make_tube_tile("pipeworks_pane_embedded_tube_sides.png"),
 | 
			
		||||
		pipeworks.make_tube_tile("pipeworks_pane_embedded_tube_sides.png"),
 | 
			
		||||
		pipeworks.make_tube_tile("pipeworks_pane_embedded_tube_ends.png"),
 | 
			
		||||
		pipeworks.make_tube_tile("pipeworks_pane_embedded_tube_ends.png"),
 | 
			
		||||
	},
 | 
			
		||||
	use_texture_alpha = texture_alpha_mode,
 | 
			
		||||
	node_box = pane_box,
 | 
			
		||||
	selection_box = pane_box,
 | 
			
		||||
	collision_box = pane_box,
 | 
			
		||||
	paramtype = "light",
 | 
			
		||||
	paramtype2 = "facedir",
 | 
			
		||||
	groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1},
 | 
			
		||||
	groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1, dig_glass = 2, pickaxey=1, handy=1},
 | 
			
		||||
	_mcl_hardness=0.8,
 | 
			
		||||
	legacy_facedir_simple = true,
 | 
			
		||||
	sounds = default.node_sound_stone_defaults(),
 | 
			
		||||
	_sound_def = {
 | 
			
		||||
        key = "node_sound_stone_defaults",
 | 
			
		||||
    },
 | 
			
		||||
	tube = {
 | 
			
		||||
		connect_sides = {front = 1, back = 1,},
 | 
			
		||||
		priority = 50,
 | 
			
		||||
@@ -71,13 +80,6 @@ minetest.register_node("pipeworks:steel_pane_embedded_tube", {
 | 
			
		||||
	},
 | 
			
		||||
	after_place_node = pipeworks.after_place,
 | 
			
		||||
	after_dig_node = pipeworks.after_dig,
 | 
			
		||||
	on_rotate = pipeworks.on_rotate,
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
minetest.register_craft( {
 | 
			
		||||
	output = "pipeworks:steel_pane_embedded_tube 1",
 | 
			
		||||
	recipe = {
 | 
			
		||||
		{ "", "default:steel_ingot", "" },
 | 
			
		||||
		{ "", "pipeworks:tube_1", "" },
 | 
			
		||||
		{ "", "default:steel_ingot", "" }
 | 
			
		||||
	},
 | 
			
		||||
})
 | 
			
		||||
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:steel_pane_embedded_tube"
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,8 @@ local settings = {
 | 
			
		||||
	enable_cyclic_mode = true,
 | 
			
		||||
	drop_on_routing_fail = false,
 | 
			
		||||
	delete_item_on_clearobject = true,
 | 
			
		||||
	use_real_entities = true,
 | 
			
		||||
	entity_update_interval = 0,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pipeworks.toggles = {}
 | 
			
		||||
@@ -62,10 +64,9 @@ pipeworks.toggles.finite_water = nil
 | 
			
		||||
for name, value in pairs(settings) do
 | 
			
		||||
	local setting_type = type(value)
 | 
			
		||||
	if setting_type == "boolean" then
 | 
			
		||||
		pipeworks[name] = minetest.settings:get_bool(prefix..name)
 | 
			
		||||
		if pipeworks[name] == nil then
 | 
			
		||||
			pipeworks[name] = value
 | 
			
		||||
		end
 | 
			
		||||
		pipeworks[name] = minetest.settings:get_bool(prefix..name, value)
 | 
			
		||||
	elseif setting_type == "number" then
 | 
			
		||||
		pipeworks[name] = tonumber(minetest.settings:get(prefix..name) or value)
 | 
			
		||||
	else
 | 
			
		||||
		pipeworks[name] = value
 | 
			
		||||
	end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
default
 | 
			
		||||
mesecons
 | 
			
		||||
mesecons_mvps
 | 
			
		||||
digilines?
 | 
			
		||||
@@ -1 +0,0 @@
 | 
			
		||||
This mod uses mesh nodes and nodeboxes to supply a complete set of 3D pipes and tubes, along with devices that work with them.
 | 
			
		||||
							
								
								
									
										239
									
								
								devices.lua
									
									
									
									
									
								
							
							
						
						
									
										239
									
								
								devices.lua
									
									
									
									
									
								
							@@ -1,5 +1,8 @@
 | 
			
		||||
local S = minetest.get_translator("pipeworks")
 | 
			
		||||
local new_flow_logic_register = pipeworks.flowables.register
 | 
			
		||||
 | 
			
		||||
local texture_alpha_mode = minetest.features.use_texture_alpha_string_modes
 | 
			
		||||
 | 
			
		||||
local polys = ""
 | 
			
		||||
if pipeworks.enable_lowpoly then polys = "_lowpoly" end
 | 
			
		||||
 | 
			
		||||
@@ -9,7 +12,7 @@ function pipeworks.fix_after_rotation(pos, node, user, mode, new_param2)
 | 
			
		||||
 | 
			
		||||
	if string.find(node.name, "spigot") then new_param2 = new_param2 % 4 end
 | 
			
		||||
 | 
			
		||||
	newnode = string.gsub(node.name, "_on", "_off")
 | 
			
		||||
	local newnode = string.gsub(node.name, "_on", "_off")
 | 
			
		||||
	minetest.swap_node(pos, { name = newnode, param2 = new_param2 })
 | 
			
		||||
	pipeworks.scan_for_pipe_objects(pos)
 | 
			
		||||
 | 
			
		||||
@@ -19,7 +22,7 @@ end
 | 
			
		||||
function pipeworks.rotate_on_place(itemstack, placer, pointed_thing)
 | 
			
		||||
 | 
			
		||||
	local playername = placer:get_player_name()
 | 
			
		||||
	if not minetest.is_protected(pointed_thing.under, playername) 
 | 
			
		||||
	if not minetest.is_protected(pointed_thing.under, playername)
 | 
			
		||||
	   and not minetest.is_protected(pointed_thing.above, playername) then
 | 
			
		||||
 | 
			
		||||
		local node = minetest.get_node(pointed_thing.under)
 | 
			
		||||
@@ -27,17 +30,17 @@ function pipeworks.rotate_on_place(itemstack, placer, pointed_thing)
 | 
			
		||||
		if (not placer:get_player_control().sneak)
 | 
			
		||||
		  and minetest.registered_nodes[node.name]
 | 
			
		||||
		  and minetest.registered_nodes[node.name].on_rightclick then
 | 
			
		||||
			minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack)
 | 
			
		||||
			minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under,
 | 
			
		||||
				node, placer, itemstack, pointed_thing)
 | 
			
		||||
 | 
			
		||||
		else
 | 
			
		||||
 | 
			
		||||
			local pitch = placer:get_look_pitch()
 | 
			
		||||
			local pitch = -placer:get_look_vertical()
 | 
			
		||||
			local above = pointed_thing.above
 | 
			
		||||
			local under = pointed_thing.under
 | 
			
		||||
			local fdir = minetest.dir_to_facedir(placer:get_look_dir())
 | 
			
		||||
			local undernode = minetest.get_node(under)
 | 
			
		||||
			local abovenode = minetest.get_node(above)
 | 
			
		||||
			local uname = undernode.name
 | 
			
		||||
			local aname = abovenode.name
 | 
			
		||||
			local isabove = (above.x == under.x) and (above.z == under.z) and (pitch > 0)
 | 
			
		||||
			local pos1 = above
 | 
			
		||||
 | 
			
		||||
@@ -104,6 +107,7 @@ if minetest.get_modpath("mesecons") then
 | 
			
		||||
	}
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
--[[
 | 
			
		||||
local pipes_devicelist = {
 | 
			
		||||
	"pump",
 | 
			
		||||
	"valve",
 | 
			
		||||
@@ -119,30 +123,35 @@ local pipes_devicelist = {
 | 
			
		||||
	"storage_tank_9",
 | 
			
		||||
	"storage_tank_10"
 | 
			
		||||
}
 | 
			
		||||
--]]
 | 
			
		||||
 | 
			
		||||
-- Now define the nodes.
 | 
			
		||||
 | 
			
		||||
local states = { "on", "off" }
 | 
			
		||||
local dgroups = ""
 | 
			
		||||
 | 
			
		||||
for s in ipairs(states) do
 | 
			
		||||
 | 
			
		||||
	local dgroups
 | 
			
		||||
	if states[s] == "off" then
 | 
			
		||||
		dgroups = {snappy=3, pipe=1}
 | 
			
		||||
		dgroups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}
 | 
			
		||||
	else
 | 
			
		||||
		dgroups = {snappy=3, pipe=1, not_in_creative_inventory=1}
 | 
			
		||||
		dgroups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	local pumpname = "pipeworks:pump_"..states[s]
 | 
			
		||||
	minetest.register_node(pumpname, {
 | 
			
		||||
		description = "Pump/Intake Module",
 | 
			
		||||
		description = S("Pump/Intake Module"),
 | 
			
		||||
		drawtype = "mesh",
 | 
			
		||||
		mesh = "pipeworks_pump"..polys..".obj",
 | 
			
		||||
		tiles = { "pipeworks_pump_"..states[s]..".png" },
 | 
			
		||||
		use_texture_alpha = texture_alpha_mode and "clip" or true,
 | 
			
		||||
		paramtype = "light",
 | 
			
		||||
		paramtype2 = "facedir",
 | 
			
		||||
		groups = dgroups,
 | 
			
		||||
		sounds = default.node_sound_wood_defaults(),
 | 
			
		||||
		_mcl_hardness=0.8,
 | 
			
		||||
		_sound_def = {
 | 
			
		||||
			key = "node_sound_metal_defaults",
 | 
			
		||||
		},
 | 
			
		||||
		walkable = true,
 | 
			
		||||
		pipe_connections = { top = 1 },
 | 
			
		||||
		after_place_node = function(pos)
 | 
			
		||||
@@ -164,7 +173,7 @@ for s in ipairs(states) do
 | 
			
		||||
			local fdir = node.param2
 | 
			
		||||
			minetest.swap_node(pos, { name = "pipeworks:pump_"..states[3-s], param2 = fdir })
 | 
			
		||||
		end,
 | 
			
		||||
		on_rotate = screwdriver.rotate_simple
 | 
			
		||||
		on_rotate = screwdriver and screwdriver.rotate_simple or nil
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	-- FIXME: this currently assumes that pumps can only rotate around the fixed axis pointing Y+.
 | 
			
		||||
@@ -178,7 +187,7 @@ for s in ipairs(states) do
 | 
			
		||||
 | 
			
		||||
	local nodename_valve_empty = "pipeworks:valve_"..states[s].."_empty"
 | 
			
		||||
	minetest.register_node(nodename_valve_empty, {
 | 
			
		||||
		description = "Valve",
 | 
			
		||||
		description = S("Valve"),
 | 
			
		||||
		drawtype = "mesh",
 | 
			
		||||
		mesh = "pipeworks_valve_"..states[s]..polys..".obj",
 | 
			
		||||
		tiles = { "pipeworks_valve.png" },
 | 
			
		||||
@@ -186,15 +195,18 @@ for s in ipairs(states) do
 | 
			
		||||
		paramtype = "light",
 | 
			
		||||
		paramtype2 = "facedir",
 | 
			
		||||
		selection_box = {
 | 
			
		||||
	             	type = "fixed",
 | 
			
		||||
			type = "fixed",
 | 
			
		||||
			fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 }
 | 
			
		||||
		},
 | 
			
		||||
		collision_box = {
 | 
			
		||||
	             	type = "fixed",
 | 
			
		||||
			type = "fixed",
 | 
			
		||||
			fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 }
 | 
			
		||||
		},
 | 
			
		||||
		groups = dgroups,
 | 
			
		||||
		sounds = default.node_sound_wood_defaults(),
 | 
			
		||||
		_mcl_hardness=0.8,
 | 
			
		||||
		_sound_def = {
 | 
			
		||||
			key = "node_sound_metal_defaults",
 | 
			
		||||
		},
 | 
			
		||||
		walkable = true,
 | 
			
		||||
		on_place = pipeworks.rotate_on_place,
 | 
			
		||||
		after_dig_node = function(pos)
 | 
			
		||||
@@ -221,10 +233,12 @@ for s in ipairs(states) do
 | 
			
		||||
		new_flow_logic_register.directional_horizonal_rotate(nodename_valve_empty, true)
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:pump_off"
 | 
			
		||||
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:valve_off_empty"
 | 
			
		||||
 | 
			
		||||
local nodename_valve_loaded = "pipeworks:valve_on_loaded"
 | 
			
		||||
minetest.register_node(nodename_valve_loaded, {
 | 
			
		||||
	description = "Valve",
 | 
			
		||||
	description = S("Valve"),
 | 
			
		||||
	drawtype = "mesh",
 | 
			
		||||
	mesh = "pipeworks_valve_on"..polys..".obj",
 | 
			
		||||
	tiles = { "pipeworks_valve.png" },
 | 
			
		||||
@@ -232,15 +246,18 @@ minetest.register_node(nodename_valve_loaded, {
 | 
			
		||||
	paramtype = "light",
 | 
			
		||||
	paramtype2 = "facedir",
 | 
			
		||||
	selection_box = {
 | 
			
		||||
             	type = "fixed",
 | 
			
		||||
		type = "fixed",
 | 
			
		||||
		fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 }
 | 
			
		||||
	},
 | 
			
		||||
	collision_box = {
 | 
			
		||||
             	type = "fixed",
 | 
			
		||||
		type = "fixed",
 | 
			
		||||
		fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 }
 | 
			
		||||
	},
 | 
			
		||||
	groups = {snappy=3, pipe=1, not_in_creative_inventory=1},
 | 
			
		||||
	sounds = default.node_sound_wood_defaults(),
 | 
			
		||||
	groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
 | 
			
		||||
	_mcl_hardness=0.8,
 | 
			
		||||
	_sound_def = {
 | 
			
		||||
        key = "node_sound_metal_defaults",
 | 
			
		||||
    },
 | 
			
		||||
	walkable = true,
 | 
			
		||||
	on_place = pipeworks.rotate_on_place,
 | 
			
		||||
	after_dig_node = function(pos)
 | 
			
		||||
@@ -272,7 +289,7 @@ new_flow_logic_register.directional_horizonal_rotate(nodename_valve_loaded, true
 | 
			
		||||
 | 
			
		||||
-- FIXME: should this do anything useful in the new flow logic?
 | 
			
		||||
minetest.register_node("pipeworks:grating", {
 | 
			
		||||
	description = "Decorative grating",
 | 
			
		||||
	description = S("Decorative grating"),
 | 
			
		||||
	tiles = {
 | 
			
		||||
		"pipeworks_grating_top.png",
 | 
			
		||||
		"pipeworks_grating_sides.png",
 | 
			
		||||
@@ -281,6 +298,7 @@ minetest.register_node("pipeworks:grating", {
 | 
			
		||||
		"pipeworks_grating_sides.png",
 | 
			
		||||
		"pipeworks_grating_sides.png"
 | 
			
		||||
	},
 | 
			
		||||
	use_texture_alpha = texture_alpha_mode and "clip" or true,
 | 
			
		||||
	drawtype = "nodebox",
 | 
			
		||||
	node_box = {
 | 
			
		||||
		type = "fixed",
 | 
			
		||||
@@ -288,8 +306,11 @@ minetest.register_node("pipeworks:grating", {
 | 
			
		||||
	},
 | 
			
		||||
	sunlight_propagates = true,
 | 
			
		||||
	paramtype = "light",
 | 
			
		||||
	groups = {snappy=3, pipe=1},
 | 
			
		||||
	sounds = default.node_sound_wood_defaults(),
 | 
			
		||||
	groups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
 | 
			
		||||
	_mcl_hardness=0.8,
 | 
			
		||||
	_sound_def = {
 | 
			
		||||
        key = "node_sound_metal_defaults",
 | 
			
		||||
    },
 | 
			
		||||
	walkable = true,
 | 
			
		||||
	pipe_connections = { top = 1 },
 | 
			
		||||
	after_place_node = function(pos)
 | 
			
		||||
@@ -300,20 +321,24 @@ minetest.register_node("pipeworks:grating", {
 | 
			
		||||
	end,
 | 
			
		||||
	on_rotate = false
 | 
			
		||||
})
 | 
			
		||||
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:grating"
 | 
			
		||||
 | 
			
		||||
-- outlet spigot
 | 
			
		||||
 | 
			
		||||
local nodename_spigot_empty = "pipeworks:spigot"
 | 
			
		||||
minetest.register_node(nodename_spigot_empty, {
 | 
			
		||||
	description = "Spigot outlet",
 | 
			
		||||
	description = S("Spigot outlet"),
 | 
			
		||||
	drawtype = "mesh",
 | 
			
		||||
	mesh = "pipeworks_spigot"..polys..".obj",
 | 
			
		||||
	tiles = { "pipeworks_spigot.png" },
 | 
			
		||||
	sunlight_propagates = true,
 | 
			
		||||
	paramtype = "light",
 | 
			
		||||
	paramtype2 = "facedir",
 | 
			
		||||
	groups = {snappy=3, pipe=1},
 | 
			
		||||
	sounds = default.node_sound_wood_defaults(),
 | 
			
		||||
	groups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
 | 
			
		||||
	_mcl_hardness=0.8,
 | 
			
		||||
	_sound_def = {
 | 
			
		||||
        key = "node_sound_metal_defaults",
 | 
			
		||||
    },
 | 
			
		||||
	walkable = true,
 | 
			
		||||
	pipe_connections = { left=1, right=1, front=1, back=1,
 | 
			
		||||
						 left_param2 = 3, right_param2 = 1, front_param2 = 2, back_param2 = 0 },
 | 
			
		||||
@@ -336,26 +361,22 @@ minetest.register_node(nodename_spigot_empty, {
 | 
			
		||||
 | 
			
		||||
local nodename_spigot_loaded = "pipeworks:spigot_pouring"
 | 
			
		||||
minetest.register_node(nodename_spigot_loaded, {
 | 
			
		||||
	description = "Spigot outlet",
 | 
			
		||||
	description = S("Spigot outlet"),
 | 
			
		||||
	drawtype = "mesh",
 | 
			
		||||
	mesh = "pipeworks_spigot_pouring"..polys..".obj",
 | 
			
		||||
	tiles = {
 | 
			
		||||
		{
 | 
			
		||||
			name = "default_water_flowing_animated.png",
 | 
			
		||||
			animation = {
 | 
			
		||||
				type = "vertical_frames",
 | 
			
		||||
				aspect_w = 16,
 | 
			
		||||
				aspect_h = 16,
 | 
			
		||||
				length = 0.8,
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
		minetest.registered_nodes[pipeworks.liquids.water.source].tiles[1],
 | 
			
		||||
		{ name = "pipeworks_spigot.png" }
 | 
			
		||||
	},
 | 
			
		||||
	use_texture_alpha = texture_alpha_mode and "blend" or true,
 | 
			
		||||
	sunlight_propagates = true,
 | 
			
		||||
	paramtype = "light",
 | 
			
		||||
	paramtype2 = "facedir",
 | 
			
		||||
	groups = {snappy=3, pipe=1, not_in_creative_inventory=1},
 | 
			
		||||
	sounds = default.node_sound_wood_defaults(),
 | 
			
		||||
	groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
 | 
			
		||||
	_mcl_hardness=0.8,
 | 
			
		||||
	_sound_def = {
 | 
			
		||||
        key = "node_sound_metal_defaults",
 | 
			
		||||
    },
 | 
			
		||||
	walkable = true,
 | 
			
		||||
	pipe_connections = { left=1, right=1, front=1, back=1,
 | 
			
		||||
						 left_param2 = 3, right_param2 = 1, front_param2 = 2, back_param2 = 0 },
 | 
			
		||||
@@ -377,6 +398,8 @@ minetest.register_node(nodename_spigot_loaded, {
 | 
			
		||||
	drop = "pipeworks:spigot",
 | 
			
		||||
	on_rotate = pipeworks.fix_after_rotation
 | 
			
		||||
})
 | 
			
		||||
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:spigot"
 | 
			
		||||
 | 
			
		||||
-- new flow logic does not currently distinguish between these two visual states.
 | 
			
		||||
-- register both so existing flowing spigots continue to work (even if the visual doesn't match the spigot's behaviour).
 | 
			
		||||
new_flow_logic_register.directional_horizonal_rotate(nodename_spigot_empty, false)
 | 
			
		||||
@@ -402,14 +425,17 @@ local panel_cbox = {
 | 
			
		||||
 | 
			
		||||
local nodename_panel_empty = "pipeworks:entry_panel_empty"
 | 
			
		||||
minetest.register_node(nodename_panel_empty, {
 | 
			
		||||
	description = "Airtight Pipe entry/exit",
 | 
			
		||||
	description = S("Airtight Pipe entry/exit"),
 | 
			
		||||
	drawtype = "mesh",
 | 
			
		||||
	mesh = "pipeworks_entry_panel"..polys..".obj",
 | 
			
		||||
	tiles = { "pipeworks_entry_panel.png" },
 | 
			
		||||
	paramtype = "light",
 | 
			
		||||
	paramtype2 = "facedir",
 | 
			
		||||
	groups = {snappy=3, pipe=1},
 | 
			
		||||
	sounds = default.node_sound_wood_defaults(),
 | 
			
		||||
	groups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
 | 
			
		||||
	_mcl_hardness=0.8,
 | 
			
		||||
	_sound_def = {
 | 
			
		||||
        key = "node_sound_metal_defaults",
 | 
			
		||||
    },
 | 
			
		||||
	walkable = true,
 | 
			
		||||
	on_place = pipeworks.rotate_on_place,
 | 
			
		||||
	after_dig_node = function(pos)
 | 
			
		||||
@@ -422,14 +448,17 @@ minetest.register_node(nodename_panel_empty, {
 | 
			
		||||
 | 
			
		||||
local nodename_panel_loaded = "pipeworks:entry_panel_loaded"
 | 
			
		||||
minetest.register_node(nodename_panel_loaded, {
 | 
			
		||||
	description = "Airtight Pipe entry/exit",
 | 
			
		||||
	description = S("Airtight Pipe entry/exit"),
 | 
			
		||||
	drawtype = "mesh",
 | 
			
		||||
	mesh = "pipeworks_entry_panel"..polys..".obj",
 | 
			
		||||
	tiles = { "pipeworks_entry_panel.png" },
 | 
			
		||||
	paramtype = "light",
 | 
			
		||||
	paramtype2 = "facedir",
 | 
			
		||||
	groups = {snappy=3, pipe=1, not_in_creative_inventory=1},
 | 
			
		||||
	sounds = default.node_sound_wood_defaults(),
 | 
			
		||||
	groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
 | 
			
		||||
	_mcl_hardness=0.8,
 | 
			
		||||
	_sound_def = {
 | 
			
		||||
        key = "node_sound_metal_defaults",
 | 
			
		||||
    },
 | 
			
		||||
	walkable = true,
 | 
			
		||||
	on_place = pipeworks.rotate_on_place,
 | 
			
		||||
	after_dig_node = function(pos)
 | 
			
		||||
@@ -440,6 +469,9 @@ minetest.register_node(nodename_panel_loaded, {
 | 
			
		||||
	drop = "pipeworks:entry_panel_empty",
 | 
			
		||||
	on_rotate = pipeworks.fix_after_rotation
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:entry_panel_empty"
 | 
			
		||||
 | 
			
		||||
-- TODO: AFAIK the two panels have no visual difference, so are redundant under new flow logic - alias?
 | 
			
		||||
new_flow_logic_register.directional_horizonal_rotate(nodename_panel_empty, true)
 | 
			
		||||
new_flow_logic_register.directional_horizonal_rotate(nodename_panel_loaded, true)
 | 
			
		||||
@@ -448,15 +480,18 @@ new_flow_logic_register.directional_horizonal_rotate(nodename_panel_loaded, true
 | 
			
		||||
 | 
			
		||||
local nodename_sensor_empty = "pipeworks:flow_sensor_empty"
 | 
			
		||||
minetest.register_node(nodename_sensor_empty, {
 | 
			
		||||
	description = "Flow Sensor",
 | 
			
		||||
	description = S("Flow Sensor"),
 | 
			
		||||
	drawtype = "mesh",
 | 
			
		||||
	mesh = "pipeworks_flow_sensor"..polys..".obj",
 | 
			
		||||
	tiles = { "pipeworks_flow_sensor_off.png" },
 | 
			
		||||
	sunlight_propagates = true,
 | 
			
		||||
	paramtype = "light",
 | 
			
		||||
	paramtype2 = "facedir",
 | 
			
		||||
	groups = {snappy=3, pipe=1},
 | 
			
		||||
	sounds = default.node_sound_wood_defaults(),
 | 
			
		||||
	groups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
 | 
			
		||||
	_mcl_hardness=0.8,
 | 
			
		||||
	_sound_def = {
 | 
			
		||||
        key = "node_sound_metal_defaults",
 | 
			
		||||
    },
 | 
			
		||||
	walkable = true,
 | 
			
		||||
	on_place = pipeworks.rotate_on_place,
 | 
			
		||||
	after_dig_node = function(pos)
 | 
			
		||||
@@ -464,7 +499,7 @@ minetest.register_node(nodename_sensor_empty, {
 | 
			
		||||
	end,
 | 
			
		||||
	on_construct = function(pos)
 | 
			
		||||
		if mesecon then
 | 
			
		||||
			mesecon.receptor_off(pos, rules) 
 | 
			
		||||
			mesecon.receptor_off(pos, pipeworks.mesecons_rules)
 | 
			
		||||
		end
 | 
			
		||||
	end,
 | 
			
		||||
	selection_box = {
 | 
			
		||||
@@ -487,15 +522,18 @@ minetest.register_node(nodename_sensor_empty, {
 | 
			
		||||
 | 
			
		||||
local nodename_sensor_loaded = "pipeworks:flow_sensor_loaded"
 | 
			
		||||
minetest.register_node(nodename_sensor_loaded, {
 | 
			
		||||
	description = "Flow sensor (on)",
 | 
			
		||||
	description = S("Flow sensor (on)"),
 | 
			
		||||
	drawtype = "mesh",
 | 
			
		||||
	mesh = "pipeworks_flow_sensor"..polys..".obj",
 | 
			
		||||
	tiles = { "pipeworks_flow_sensor_on.png" },
 | 
			
		||||
	sunlight_propagates = true,
 | 
			
		||||
	paramtype = "light",
 | 
			
		||||
	paramtype2 = "facedir",
 | 
			
		||||
	groups = {snappy=3, pipe=1, not_in_creative_inventory=1},
 | 
			
		||||
	sounds = default.node_sound_wood_defaults(),
 | 
			
		||||
	groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
 | 
			
		||||
	_mcl_hardness=0.8,
 | 
			
		||||
	_sound_def = {
 | 
			
		||||
        key = "node_sound_metal_defaults",
 | 
			
		||||
    },
 | 
			
		||||
	walkable = true,
 | 
			
		||||
	on_place = pipeworks.rotate_on_place,
 | 
			
		||||
	after_dig_node = function(pos)
 | 
			
		||||
@@ -503,7 +541,7 @@ minetest.register_node(nodename_sensor_loaded, {
 | 
			
		||||
	end,
 | 
			
		||||
	on_construct = function(pos)
 | 
			
		||||
		if mesecon then
 | 
			
		||||
			mesecon.receptor_on(pos, rules) 
 | 
			
		||||
			mesecon.receptor_on(pos, pipeworks.mesecons_rules)
 | 
			
		||||
		end
 | 
			
		||||
	end,
 | 
			
		||||
	selection_box = {
 | 
			
		||||
@@ -524,6 +562,8 @@ minetest.register_node(nodename_sensor_loaded, {
 | 
			
		||||
	mesecons = pipereceptor_on,
 | 
			
		||||
	on_rotate = pipeworks.fix_after_rotation
 | 
			
		||||
})
 | 
			
		||||
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:flow_sensor_empty"
 | 
			
		||||
 | 
			
		||||
new_flow_logic_register.directional_horizonal_rotate(nodename_sensor_empty, true)
 | 
			
		||||
new_flow_logic_register.directional_horizonal_rotate(nodename_sensor_loaded, true)
 | 
			
		||||
-- activate flow sensor at roughly half the pressure pumps drive pipes
 | 
			
		||||
@@ -536,18 +576,18 @@ new_flow_logic_register.transition_simple_set(sensor_pressure_set, { mesecons=pi
 | 
			
		||||
 | 
			
		||||
-- TODO flow-logic-stub: these don't currently do anything under the new flow logic.
 | 
			
		||||
for fill = 0, 10 do
 | 
			
		||||
	local filldesc="empty"
 | 
			
		||||
	local sgroups = {snappy=3, pipe=1, tankfill=fill+1}
 | 
			
		||||
	local filldesc=S("empty")
 | 
			
		||||
	local sgroups = {snappy=3, pipe=1, tankfill=fill+1, dig_generic = 4, axey=1, handy=1, pickaxey=1}
 | 
			
		||||
	local image = nil
 | 
			
		||||
 | 
			
		||||
	if fill ~= 0 then
 | 
			
		||||
		filldesc=fill.."0% full"
 | 
			
		||||
		sgroups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1}
 | 
			
		||||
		filldesc=S("@1% full", 10*fill)
 | 
			
		||||
		sgroups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}
 | 
			
		||||
		image = "pipeworks_storage_tank_fittings.png"
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	minetest.register_node("pipeworks:expansion_tank_"..fill, {
 | 
			
		||||
		description = "Expansion Tank ("..filldesc..")... You hacker, you.",
 | 
			
		||||
		description = S("Expansion Tank (@1)", filldesc),
 | 
			
		||||
		tiles = {
 | 
			
		||||
			"pipeworks_storage_tank_fittings.png",
 | 
			
		||||
			"pipeworks_storage_tank_fittings.png",
 | 
			
		||||
@@ -559,8 +599,11 @@ for fill = 0, 10 do
 | 
			
		||||
		inventory_image = image,
 | 
			
		||||
		paramtype = "light",
 | 
			
		||||
		paramtype2 = "facedir",
 | 
			
		||||
		groups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1},
 | 
			
		||||
		sounds = default.node_sound_wood_defaults(),
 | 
			
		||||
		groups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
 | 
			
		||||
		_mcl_hardness=0.8,
 | 
			
		||||
		_sound_def = {
 | 
			
		||||
			key = "node_sound_metal_defaults",
 | 
			
		||||
		},
 | 
			
		||||
		walkable = true,
 | 
			
		||||
		drop = "pipeworks:storage_tank_0",
 | 
			
		||||
		pipe_connections = { top = 1, bottom = 1},
 | 
			
		||||
@@ -575,7 +618,7 @@ for fill = 0, 10 do
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	minetest.register_node("pipeworks:storage_tank_"..fill, {
 | 
			
		||||
		description = "Fluid Storage Tank ("..filldesc..")",
 | 
			
		||||
		description = S("Fluid Storage Tank (@1)", filldesc),
 | 
			
		||||
		tiles = {
 | 
			
		||||
			"pipeworks_storage_tank_fittings.png",
 | 
			
		||||
			"pipeworks_storage_tank_fittings.png",
 | 
			
		||||
@@ -588,7 +631,10 @@ for fill = 0, 10 do
 | 
			
		||||
		paramtype = "light",
 | 
			
		||||
		paramtype2 = "facedir",
 | 
			
		||||
		groups = sgroups,
 | 
			
		||||
		sounds = default.node_sound_wood_defaults(),
 | 
			
		||||
		_mcl_hardness=0.8,
 | 
			
		||||
		_sound_def = {
 | 
			
		||||
			key = "node_sound_metal_defaults",
 | 
			
		||||
		},
 | 
			
		||||
		walkable = true,
 | 
			
		||||
		drop = "pipeworks:storage_tank_0",
 | 
			
		||||
		pipe_connections = { top = 1, bottom = 1},
 | 
			
		||||
@@ -602,19 +648,23 @@ for fill = 0, 10 do
 | 
			
		||||
		on_rotate = false
 | 
			
		||||
	})
 | 
			
		||||
end
 | 
			
		||||
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:storage_tank_0"
 | 
			
		||||
 | 
			
		||||
-- fountainhead
 | 
			
		||||
 | 
			
		||||
local nodename_fountain_empty = "pipeworks:fountainhead"
 | 
			
		||||
minetest.register_node(nodename_fountain_empty, {
 | 
			
		||||
	description = "Fountainhead",
 | 
			
		||||
	description = S("Fountainhead"),
 | 
			
		||||
	drawtype = "mesh",
 | 
			
		||||
	mesh = "pipeworks_fountainhead"..polys..".obj",
 | 
			
		||||
	tiles = { "pipeworks_fountainhead.png" },
 | 
			
		||||
	sunlight_propagates = true,
 | 
			
		||||
	paramtype = "light",
 | 
			
		||||
	groups = {snappy=3, pipe=1},
 | 
			
		||||
	sounds = default.node_sound_wood_defaults(),
 | 
			
		||||
	groups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
 | 
			
		||||
	_mcl_hardness=0.8,
 | 
			
		||||
	_sound_def = {
 | 
			
		||||
        key = "node_sound_metal_defaults",
 | 
			
		||||
    },
 | 
			
		||||
	walkable = true,
 | 
			
		||||
	pipe_connections = { bottom = 1 },
 | 
			
		||||
	after_place_node = function(pos)
 | 
			
		||||
@@ -625,7 +675,7 @@ minetest.register_node(nodename_fountain_empty, {
 | 
			
		||||
	end,
 | 
			
		||||
	on_construct = function(pos)
 | 
			
		||||
		if mesecon then
 | 
			
		||||
			mesecon.receptor_on(pos, rules) 
 | 
			
		||||
			mesecon.receptor_on(pos, pipeworks.mesecons_rules)
 | 
			
		||||
		end
 | 
			
		||||
	end,
 | 
			
		||||
	selection_box = {
 | 
			
		||||
@@ -638,17 +688,21 @@ minetest.register_node(nodename_fountain_empty, {
 | 
			
		||||
	},
 | 
			
		||||
	on_rotate = false
 | 
			
		||||
})
 | 
			
		||||
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:fountainhead"
 | 
			
		||||
 | 
			
		||||
local nodename_fountain_loaded = "pipeworks:fountainhead_pouring"
 | 
			
		||||
minetest.register_node(nodename_fountain_loaded, {
 | 
			
		||||
	description = "Fountainhead",
 | 
			
		||||
	description = S("Fountainhead"),
 | 
			
		||||
	drawtype = "mesh",
 | 
			
		||||
	mesh = "pipeworks_fountainhead"..polys..".obj",
 | 
			
		||||
	tiles = { "pipeworks_fountainhead.png" },
 | 
			
		||||
	sunlight_propagates = true,
 | 
			
		||||
	paramtype = "light",
 | 
			
		||||
	groups = {snappy=3, pipe=1, not_in_creative_inventory=1},
 | 
			
		||||
	sounds = default.node_sound_wood_defaults(),
 | 
			
		||||
	groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
 | 
			
		||||
	_mcl_hardness=0.8,
 | 
			
		||||
	_sound_def = {
 | 
			
		||||
        key = "node_sound_metal_defaults",
 | 
			
		||||
    },
 | 
			
		||||
	walkable = true,
 | 
			
		||||
	pipe_connections = { bottom = 1 },
 | 
			
		||||
	after_place_node = function(pos)
 | 
			
		||||
@@ -660,7 +714,7 @@ minetest.register_node(nodename_fountain_loaded, {
 | 
			
		||||
	end,
 | 
			
		||||
	on_construct = function(pos)
 | 
			
		||||
		if mesecon then
 | 
			
		||||
			mesecon.receptor_on(pos, rules) 
 | 
			
		||||
			mesecon.receptor_on(pos, pipeworks.mesecons_rules)
 | 
			
		||||
		end
 | 
			
		||||
	end,
 | 
			
		||||
	selection_box = {
 | 
			
		||||
@@ -691,14 +745,17 @@ local sp_cbox = {
 | 
			
		||||
 | 
			
		||||
local nodename_sp_empty = "pipeworks:straight_pipe_empty"
 | 
			
		||||
minetest.register_node(nodename_sp_empty, {
 | 
			
		||||
	description = "Straight-only Pipe",
 | 
			
		||||
	description = S("Straight-only Pipe"),
 | 
			
		||||
	drawtype = "mesh",
 | 
			
		||||
	mesh = "pipeworks_straight_pipe"..polys..".obj",
 | 
			
		||||
	tiles = { "pipeworks_straight_pipe_empty.png" },
 | 
			
		||||
	paramtype = "light",
 | 
			
		||||
	paramtype2 = "facedir",
 | 
			
		||||
	groups = {snappy=3, pipe=1},
 | 
			
		||||
	sounds = default.node_sound_wood_defaults(),
 | 
			
		||||
	groups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
 | 
			
		||||
	_mcl_hardness=0.8,
 | 
			
		||||
	_sound_def = {
 | 
			
		||||
        key = "node_sound_metal_defaults",
 | 
			
		||||
    },
 | 
			
		||||
	walkable = true,
 | 
			
		||||
	on_place = pipeworks.rotate_on_place,
 | 
			
		||||
	after_dig_node = function(pos)
 | 
			
		||||
@@ -706,19 +763,24 @@ minetest.register_node(nodename_sp_empty, {
 | 
			
		||||
	end,
 | 
			
		||||
	selection_box = sp_cbox,
 | 
			
		||||
	collision_box = sp_cbox,
 | 
			
		||||
	on_rotate = pipeworks.fix_after_rotation
 | 
			
		||||
	on_rotate = pipeworks.fix_after_rotation,
 | 
			
		||||
	check_for_pole = pipeworks.check_for_vert_pipe,
 | 
			
		||||
	check_for_horiz_pole = pipeworks.check_for_horiz_pipe
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
local nodename_sp_loaded = "pipeworks:straight_pipe_loaded"
 | 
			
		||||
minetest.register_node(nodename_sp_loaded, {
 | 
			
		||||
	description = "Straight-only Pipe",
 | 
			
		||||
	description = S("Straight-only Pipe"),
 | 
			
		||||
	drawtype = "mesh",
 | 
			
		||||
	mesh = "pipeworks_straight_pipe"..polys..".obj",
 | 
			
		||||
	tiles = { "pipeworks_straight_pipe_loaded.png" },
 | 
			
		||||
	paramtype = "light",
 | 
			
		||||
	paramtype2 = "facedir",
 | 
			
		||||
	groups = {snappy=3, pipe=1, not_in_creative_inventory=1},
 | 
			
		||||
	sounds = default.node_sound_wood_defaults(),
 | 
			
		||||
	groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
 | 
			
		||||
	_mcl_hardness=0.8,
 | 
			
		||||
	_sound_def = {
 | 
			
		||||
        key = "node_sound_metal_defaults",
 | 
			
		||||
    },
 | 
			
		||||
	walkable = true,
 | 
			
		||||
	on_place = pipeworks.rotate_on_place,
 | 
			
		||||
	after_dig_node = function(pos)
 | 
			
		||||
@@ -727,8 +789,11 @@ minetest.register_node(nodename_sp_loaded, {
 | 
			
		||||
	selection_box = sp_cbox,
 | 
			
		||||
	collision_box = sp_cbox,
 | 
			
		||||
	drop = "pipeworks:straight_pipe_empty",
 | 
			
		||||
	on_rotate = pipeworks.fix_after_rotation
 | 
			
		||||
	on_rotate = pipeworks.fix_after_rotation,
 | 
			
		||||
	check_for_pole = pipeworks.check_for_vert_pipe,
 | 
			
		||||
	check_for_horiz_pole = pipeworks.check_for_horiz_pipe
 | 
			
		||||
})
 | 
			
		||||
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:straight_pipe_empty"
 | 
			
		||||
 | 
			
		||||
new_flow_logic_register.directional_horizonal_rotate(nodename_sp_empty, true)
 | 
			
		||||
new_flow_logic_register.directional_horizonal_rotate(nodename_sp_loaded, true)
 | 
			
		||||
@@ -738,21 +803,3 @@ new_flow_logic_register.directional_horizonal_rotate(nodename_sp_loaded, true)
 | 
			
		||||
minetest.register_alias("pipeworks:valve_off_loaded", "pipeworks:valve_off_empty")
 | 
			
		||||
minetest.register_alias("pipeworks:entry_panel", "pipeworks:entry_panel_empty")
 | 
			
		||||
 | 
			
		||||
minetest.register_lbm({
 | 
			
		||||
	name = "pipeworks:rotate_valves_flowsensors",
 | 
			
		||||
	label = "Flip pipeworks valves and flow sensors around X/Z",
 | 
			
		||||
	run_at_every_load = false,
 | 
			
		||||
	nodenames = {
 | 
			
		||||
		"pipeworks:flow_sensor_empty",
 | 
			
		||||
		"pipeworks:flow_sensor_loaded",
 | 
			
		||||
		"pipeworks:valve_off_empty",
 | 
			
		||||
		"pipeworks:valve_on_empty",
 | 
			
		||||
		"pipeworks:valve_off_loaded",
 | 
			
		||||
	},
 | 
			
		||||
	action = function(pos, node)
 | 
			
		||||
		local dir = minetest.facedir_to_dir(node.param2)
 | 
			
		||||
		local newdir = { x=dir.z, y=dir.y, z=dir.x }
 | 
			
		||||
		local newfdir = minetest.dir_to_facedir(newdir)
 | 
			
		||||
		minetest.swap_node(pos, { name = node.name, param2 = newfdir })
 | 
			
		||||
	end
 | 
			
		||||
})
 | 
			
		||||
 
 | 
			
		||||
@@ -1,168 +1,71 @@
 | 
			
		||||
local S = minetest.get_translator("pipeworks")
 | 
			
		||||
local fs_helpers = pipeworks.fs_helpers
 | 
			
		||||
 | 
			
		||||
local function delay(x)
 | 
			
		||||
	return (function() return x end)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function set_filter_infotext(data, meta)
 | 
			
		||||
	local infotext = data.wise_desc.." Filter-Injector"
 | 
			
		||||
	local infotext = S("@1 Filter-Injector", data.wise_desc)
 | 
			
		||||
	if meta:get_int("slotseq_mode") == 2 then
 | 
			
		||||
		infotext = infotext .. " (slot #"..meta:get_int("slotseq_index").." next)"
 | 
			
		||||
		infotext = infotext .. " "..S("(slot #@1 next)", meta:get_int("slotseq_index"))
 | 
			
		||||
	end
 | 
			
		||||
	meta:set_string("infotext", infotext)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function set_filter_formspec(data, meta)
 | 
			
		||||
	local itemname = data.wise_desc.." Filter-Injector"
 | 
			
		||||
	local itemname = S("@1 Filter-Injector", data.wise_desc)
 | 
			
		||||
 | 
			
		||||
	local formspec
 | 
			
		||||
	if data.digiline then
 | 
			
		||||
		formspec = "size[8,2.7]"..
 | 
			
		||||
			"item_image[0,0;1,1;pipeworks:"..data.name.."]"..
 | 
			
		||||
			"label[1,0;"..minetest.formspec_escape(itemname).."]"..
 | 
			
		||||
			"field[0.3,1.5;8.0,1;channel;Channel;${channel}]"..
 | 
			
		||||
			fs_helpers.cycling_button(meta, "button[0,2;4,1", "slotseq_mode",
 | 
			
		||||
				{"Sequence slots by Priority",
 | 
			
		||||
				 "Sequence slots Randomly",
 | 
			
		||||
				 "Sequence slots by Rotation"})..
 | 
			
		||||
			fs_helpers.cycling_button(meta, "button[4,2;4,1", "exmatch_mode",
 | 
			
		||||
				{"Exact match - off",
 | 
			
		||||
				 "Exact match - on "})
 | 
			
		||||
		formspec =
 | 
			
		||||
			"size[8.5,3]"..
 | 
			
		||||
			"item_image[0.2,0;1,1;pipeworks:"..data.name.."]"..
 | 
			
		||||
			"label[1.2,0.2;"..minetest.formspec_escape(itemname).."]"..
 | 
			
		||||
			"field[0.5,1.6;4.6,1;channel;"..S("Channel")..";${channel}]"..
 | 
			
		||||
			"button[4.8,1.3;1.5,1;set_channel;"..S("Set").."]"..
 | 
			
		||||
			fs_helpers.cycling_button(meta, "button[0.2,2.3;4.05,1", "slotseq_mode",
 | 
			
		||||
				{S("Sequence slots by Priority"),
 | 
			
		||||
				 S("Sequence slots Randomly"),
 | 
			
		||||
				 S("Sequence slots by Rotation")})..
 | 
			
		||||
			fs_helpers.cycling_button(meta, "button[4.25,2.3;4.05,1", "exmatch_mode",
 | 
			
		||||
				{S("Exact match - off"),
 | 
			
		||||
				 S("Exact match - on")})..
 | 
			
		||||
			"button_exit[6.3,1.3;2,1;close;"..S("Close").."]"
 | 
			
		||||
	else
 | 
			
		||||
		local exmatch_button = ""
 | 
			
		||||
		if data.stackwise then
 | 
			
		||||
			exmatch_button =
 | 
			
		||||
				fs_helpers.cycling_button(meta, "button[4,3.5;4,1", "exmatch_mode",
 | 
			
		||||
					{"Exact match - off",
 | 
			
		||||
					 "Exact match - on "})
 | 
			
		||||
				fs_helpers.cycling_button(meta, "button["..(10.2-(0.22)-4)..",4.5;4,1", "exmatch_mode",
 | 
			
		||||
					{S("Exact match - off"),
 | 
			
		||||
					 S("Exact match - on")})
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		formspec = "size[8,8.5]"..
 | 
			
		||||
			"item_image[0,0;1,1;pipeworks:"..data.name.."]"..
 | 
			
		||||
			"label[1,0;"..minetest.formspec_escape(itemname).."]"..
 | 
			
		||||
			"label[0,1;Prefer item types:]"..
 | 
			
		||||
			"list[context;main;0,1.5;8,2;]"..
 | 
			
		||||
			fs_helpers.cycling_button(meta, "button[0,3.5;4,1", "slotseq_mode",
 | 
			
		||||
				{"Sequence slots by Priority",
 | 
			
		||||
				 "Sequence slots Randomly",
 | 
			
		||||
				 "Sequence slots by Rotation"})..
 | 
			
		||||
		local size = "10.2,11"
 | 
			
		||||
		local list_backgrounds = ""
 | 
			
		||||
		if minetest.get_modpath("i3") or minetest.get_modpath("mcl_formspec") then
 | 
			
		||||
			list_backgrounds = "style_type[box;colors=#666]"
 | 
			
		||||
			for i=0, 7 do
 | 
			
		||||
				for j=0, 1 do
 | 
			
		||||
					list_backgrounds = list_backgrounds .. "box[".. 0.22+(i*1.25) ..",".. 1.75+(j*1.25) ..";1,1;]"
 | 
			
		||||
				end
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
		formspec =
 | 
			
		||||
			"formspec_version[2]"..
 | 
			
		||||
			"size["..size.."]"..
 | 
			
		||||
			pipeworks.fs_helpers.get_prepends(size)..
 | 
			
		||||
			"item_image[0.22,0.22;1,1;pipeworks:"..data.name.."]"..
 | 
			
		||||
			"label[1.22,0.72;"..minetest.formspec_escape(itemname).."]"..
 | 
			
		||||
			"label[0.22,1.5;"..S("Prefer item types:").."]"..
 | 
			
		||||
			list_backgrounds..
 | 
			
		||||
			"list[context;main;0.22,1.75;8,2;]"..
 | 
			
		||||
			fs_helpers.cycling_button(meta, "button[0.22,4.5;4,1", "slotseq_mode",
 | 
			
		||||
				{S("Sequence slots by Priority"),
 | 
			
		||||
				 S("Sequence slots Randomly"),
 | 
			
		||||
				 S("Sequence slots by Rotation")})..
 | 
			
		||||
			exmatch_button..
 | 
			
		||||
			"list[current_player;main;0,4.5;8,4;]" ..
 | 
			
		||||
			pipeworks.fs_helpers.get_inv(6)..
 | 
			
		||||
			"listring[]"
 | 
			
		||||
	end
 | 
			
		||||
	meta:set_string("formspec", formspec)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- todo SOON: this function has *way too many* parameters
 | 
			
		||||
local function grabAndFire(data,slotseq_mode,exmatch_mode,filtmeta,frominv,frominvname,frompos,fromnode,filterfor,fromtube,fromdef,dir,fakePlayer,all,digiline)
 | 
			
		||||
	local sposes = {}
 | 
			
		||||
	if not frominvname or not frominv:get_list(frominvname) then return end
 | 
			
		||||
	for spos,stack in ipairs(frominv:get_list(frominvname)) do
 | 
			
		||||
		local matches
 | 
			
		||||
		if filterfor == "" then
 | 
			
		||||
			matches = stack:get_name() ~= ""
 | 
			
		||||
		else
 | 
			
		||||
			local fname = filterfor.name
 | 
			
		||||
			local fgroup = filterfor.group
 | 
			
		||||
			local fwear = filterfor.wear
 | 
			
		||||
			local fmetadata = filterfor.metadata
 | 
			
		||||
			matches = (not fname                                             -- If there's a name filter,
 | 
			
		||||
			           or stack:get_name() == fname)                         --  it must match.
 | 
			
		||||
 | 
			
		||||
			          and (not fgroup                                        -- If there's a group filter,
 | 
			
		||||
			               or (type(fgroup) == "string"                      --  it must be a string
 | 
			
		||||
			                   and minetest.get_item_group(                  --  and it must match.
 | 
			
		||||
			                                stack:get_name(), fgroup) ~= 0))
 | 
			
		||||
 | 
			
		||||
			          and (not fwear                                         -- If there's a wear filter:
 | 
			
		||||
			               or (type(fwear) == "number"                       --  If it's a number,
 | 
			
		||||
			                   and stack:get_wear() == fwear)                --   it must match.
 | 
			
		||||
			               or (type(fwear) == "table"                        --  If it's a table:
 | 
			
		||||
			                   and (not fwear[1]                             --   If there's a lower bound,
 | 
			
		||||
			                        or (type(fwear[1]) == "number"           --    it must be a number
 | 
			
		||||
			                            and fwear[1] <= stack:get_wear()))   --    and it must be <= the actual wear.
 | 
			
		||||
			                   and (not fwear[2]                             --   If there's an upper bound
 | 
			
		||||
			                        or (type(fwear[2]) == "number"           --    it must be a number
 | 
			
		||||
			                            and stack:get_wear() < fwear[2]))))  --    and it must be > the actual wear.
 | 
			
		||||
			                                                                 --  If the wear filter is of any other type, fail.
 | 
			
		||||
			                                                                 --
 | 
			
		||||
			          and (not fmetadata                                     -- If there's a matadata filter,
 | 
			
		||||
			               or (type(fmetadata) == "string"                   --  it must be a string
 | 
			
		||||
			                   and stack:get_metadata() == fmetadata))       --  and it must match.
 | 
			
		||||
		end
 | 
			
		||||
		if matches then table.insert(sposes, spos) end
 | 
			
		||||
	end
 | 
			
		||||
	if #sposes == 0 then return false end
 | 
			
		||||
	if slotseq_mode == 1 then
 | 
			
		||||
		for i = #sposes, 2, -1 do
 | 
			
		||||
			local j = math.random(i)
 | 
			
		||||
			local t = sposes[j]
 | 
			
		||||
			sposes[j] = sposes[i]
 | 
			
		||||
			sposes[i] = t
 | 
			
		||||
		end
 | 
			
		||||
	elseif slotseq_mode == 2 then
 | 
			
		||||
		local headpos = filtmeta:get_int("slotseq_index")
 | 
			
		||||
		table.sort(sposes, function (a, b)
 | 
			
		||||
			if a >= headpos then
 | 
			
		||||
				if b < headpos then return true end
 | 
			
		||||
			else
 | 
			
		||||
				if b >= headpos then return false end
 | 
			
		||||
			end
 | 
			
		||||
			return a < b
 | 
			
		||||
		end)
 | 
			
		||||
	end
 | 
			
		||||
	for _, spos in ipairs(sposes) do
 | 
			
		||||
			local stack = frominv:get_stack(frominvname, spos)
 | 
			
		||||
			local doRemove = stack:get_count()
 | 
			
		||||
			if fromtube.can_remove then
 | 
			
		||||
				doRemove = fromtube.can_remove(frompos, fromnode, stack, dir, frominvname, spos)
 | 
			
		||||
			elseif fromdef.allow_metadata_inventory_take then
 | 
			
		||||
				doRemove = fromdef.allow_metadata_inventory_take(frompos, frominvname,spos, stack, fakePlayer)
 | 
			
		||||
			end
 | 
			
		||||
			-- stupid lack of continue statements grumble
 | 
			
		||||
			if doRemove > 0 then
 | 
			
		||||
				if slotseq_mode == 2 then
 | 
			
		||||
					local nextpos = spos + 1
 | 
			
		||||
					if nextpos > frominv:get_size(frominvname) then
 | 
			
		||||
						nextpos = 1
 | 
			
		||||
					end
 | 
			
		||||
					filtmeta:set_int("slotseq_index", nextpos)
 | 
			
		||||
					set_filter_infotext(data, filtmeta)
 | 
			
		||||
				end
 | 
			
		||||
				local item
 | 
			
		||||
				local count
 | 
			
		||||
				if all then
 | 
			
		||||
					count = math.min(stack:get_count(), doRemove)
 | 
			
		||||
					if filterfor.count and (filterfor.count > 1 or digiline) then
 | 
			
		||||
						if exmatch_mode ~= 0 and filterfor.count > count then
 | 
			
		||||
							return false -- not enough, fail
 | 
			
		||||
						else
 | 
			
		||||
							-- limit quantity to filter amount
 | 
			
		||||
							count = math.min(filterfor.count, count)
 | 
			
		||||
						end
 | 
			
		||||
					end
 | 
			
		||||
				else
 | 
			
		||||
					count = 1
 | 
			
		||||
				end
 | 
			
		||||
				if fromtube.remove_items then
 | 
			
		||||
					-- it could be the entire stack...
 | 
			
		||||
					item = fromtube.remove_items(frompos, fromnode, stack, dir, count, frominvname, spos)
 | 
			
		||||
				else
 | 
			
		||||
					item = stack:take_item(count)
 | 
			
		||||
					frominv:set_stack(frominvname, spos, stack)
 | 
			
		||||
					if fromdef.on_metadata_inventory_take then
 | 
			
		||||
						fromdef.on_metadata_inventory_take(frompos, frominvname, spos, item, fakePlayer)
 | 
			
		||||
					end
 | 
			
		||||
				end
 | 
			
		||||
				local pos = vector.add(frompos, vector.multiply(dir, 1.4))
 | 
			
		||||
				local start_pos = vector.add(frompos, dir)
 | 
			
		||||
				local item1 = pipeworks.tube_inject_item(pos, start_pos, dir, item, fakePlayer:get_player_name())
 | 
			
		||||
				return true-- only fire one item, please
 | 
			
		||||
			end
 | 
			
		||||
	end
 | 
			
		||||
	return false
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function punch_filter(data, filtpos, filtnode, msg)
 | 
			
		||||
	local filtmeta = minetest.get_meta(filtpos)
 | 
			
		||||
	local filtinv = filtmeta:get_inventory()
 | 
			
		||||
@@ -175,11 +78,9 @@ local function punch_filter(data, filtpos, filtnode, msg)
 | 
			
		||||
	local fromnode = minetest.get_node(frompos)
 | 
			
		||||
	if not fromnode then return end
 | 
			
		||||
	local fromdef = minetest.registered_nodes[fromnode.name]
 | 
			
		||||
	if not fromdef then return end
 | 
			
		||||
	local fromtube = fromdef.tube
 | 
			
		||||
	if not fromdef or not fromdef.tube then return end
 | 
			
		||||
	local fromtube = table.copy(fromdef.tube)
 | 
			
		||||
	local input_special_cases = {
 | 
			
		||||
		["technic:mv_furnace"] = "dst",
 | 
			
		||||
		["technic:mv_furnace_active"] = "dst",
 | 
			
		||||
		["technic:mv_electric_furnace"] = "dst",
 | 
			
		||||
		["technic:mv_electric_furnace_active"] = "dst",
 | 
			
		||||
		["technic:mv_alloy_furnace"] = "dst",
 | 
			
		||||
@@ -193,6 +94,14 @@ local function punch_filter(data, filtpos, filtnode, msg)
 | 
			
		||||
		["technic:mv_grinder"] = "dst",
 | 
			
		||||
		["technic:mv_grinder_active"] = "dst",
 | 
			
		||||
		["technic:tool_workshop"] = "src",
 | 
			
		||||
		["technic:mv_freezer"] = "dst",
 | 
			
		||||
		["technic:mv_freezer_active"] = "dst",
 | 
			
		||||
		["technic:hv_electric_furnace"] = "dst",
 | 
			
		||||
		["technic:hv_electric_furnace_active"] = "dst",
 | 
			
		||||
		["technic:hv_compressor"] = "dst",
 | 
			
		||||
		["technic:hv_compressor_active"] = "dst",
 | 
			
		||||
		["technic:hv_grinder"] = "dst",
 | 
			
		||||
		["technic:hv_grinder_active"] = "dst"
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	-- make sure there's something appropriate to inject the item into
 | 
			
		||||
@@ -212,7 +121,7 @@ local function punch_filter(data, filtpos, filtnode, msg)
 | 
			
		||||
	if not (fromtube and fromtube.input_inventory) then return end
 | 
			
		||||
 | 
			
		||||
	local slotseq_mode
 | 
			
		||||
	local exact_match
 | 
			
		||||
	local exmatch_mode
 | 
			
		||||
 | 
			
		||||
	local filters = {}
 | 
			
		||||
	if data.digiline then
 | 
			
		||||
@@ -249,10 +158,10 @@ local function punch_filter(data, filtpos, filtnode, msg)
 | 
			
		||||
 | 
			
		||||
			local exmatch = msg.exmatch
 | 
			
		||||
			local t_exmatch = type(exmatch)
 | 
			
		||||
			if t_exmatch == "number" and exmatch >= 0 and exmatch <= 1 then
 | 
			
		||||
				exact_match = exmatch
 | 
			
		||||
			if t_exmatch == "number" and (exmatch == 0 or exmatch == 1) then
 | 
			
		||||
				exmatch_mode = exmatch
 | 
			
		||||
			elseif t_exmatch == "boolean" then
 | 
			
		||||
				exact_match = exmatch and 1 or 0
 | 
			
		||||
				exmatch_mode = exmatch and 1 or 0
 | 
			
		||||
			end
 | 
			
		||||
 | 
			
		||||
			local slotseq_index = msg.slotseq_index
 | 
			
		||||
@@ -269,11 +178,11 @@ local function punch_filter(data, filtpos, filtnode, msg)
 | 
			
		||||
				filtmeta:set_int("slotseq_mode", slotseq_mode)
 | 
			
		||||
			end
 | 
			
		||||
 | 
			
		||||
			if exact_match ~= nil then
 | 
			
		||||
				filtmeta:set_int("exmatch_mode", exact_match)
 | 
			
		||||
			if exmatch_mode ~= nil then
 | 
			
		||||
				filtmeta:set_int("exmatch_mode", exmatch_mode)
 | 
			
		||||
			end
 | 
			
		||||
 | 
			
		||||
			if slotseq_mode ~= nil or exact_match ~= nil then
 | 
			
		||||
			if slotseq_mode ~= nil or exmatch_mode ~= nil then
 | 
			
		||||
				set_filter_formspec(data, filtmeta)
 | 
			
		||||
			end
 | 
			
		||||
 | 
			
		||||
@@ -311,8 +220,8 @@ local function punch_filter(data, filtpos, filtnode, msg)
 | 
			
		||||
		slotseq_mode = filtmeta:get_int("slotseq_mode")
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	if exact_match == nil then
 | 
			
		||||
		exact_match = filtmeta:get_int("exmatch_mode")
 | 
			
		||||
	if exmatch_mode == nil then
 | 
			
		||||
		exmatch_mode = filtmeta:get_int("exmatch_mode")
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	local frominv
 | 
			
		||||
@@ -326,10 +235,121 @@ local function punch_filter(data, filtpos, filtnode, msg)
 | 
			
		||||
		frominv = frommeta:get_inventory()
 | 
			
		||||
	end
 | 
			
		||||
	if fromtube.before_filter then fromtube.before_filter(frompos) end
 | 
			
		||||
 | 
			
		||||
	local function grabAndFire(frominvname, filterfor)
 | 
			
		||||
		local sposes = {}
 | 
			
		||||
		if not frominvname or not frominv:get_list(frominvname) then return end
 | 
			
		||||
		for spos,stack in ipairs(frominv:get_list(frominvname)) do
 | 
			
		||||
			local matches
 | 
			
		||||
			if filterfor == "" then
 | 
			
		||||
				matches = stack:get_name() ~= ""
 | 
			
		||||
			else
 | 
			
		||||
				local fname = filterfor.name
 | 
			
		||||
				local fgroup = filterfor.group
 | 
			
		||||
				local fwear = filterfor.wear
 | 
			
		||||
				local fmetadata = filterfor.metadata
 | 
			
		||||
				matches = (not fname                                             -- If there's a name filter,
 | 
			
		||||
				           or stack:get_name() == fname)                         --  it must match.
 | 
			
		||||
 | 
			
		||||
				          and (not fgroup                                        -- If there's a group filter,
 | 
			
		||||
				               or (type(fgroup) == "string"                      --  it must be a string
 | 
			
		||||
				                   and minetest.get_item_group(                  --  and it must match.
 | 
			
		||||
				                                stack:get_name(), fgroup) ~= 0))
 | 
			
		||||
 | 
			
		||||
				          and (not fwear                                         -- If there's a wear filter:
 | 
			
		||||
				               or (type(fwear) == "number"                       --  If it's a number,
 | 
			
		||||
				                   and stack:get_wear() == fwear)                --   it must match.
 | 
			
		||||
				               or (type(fwear) == "table"                        --  If it's a table:
 | 
			
		||||
				                   and (not fwear[1]                             --   If there's a lower bound,
 | 
			
		||||
				                        or (type(fwear[1]) == "number"           --    it must be a number
 | 
			
		||||
				                            and fwear[1] <= stack:get_wear()))   --    and it must be <= the actual wear.
 | 
			
		||||
				                   and (not fwear[2]                             --   If there's an upper bound
 | 
			
		||||
				                        or (type(fwear[2]) == "number"           --    it must be a number
 | 
			
		||||
				                            and stack:get_wear() < fwear[2]))))  --    and it must be > the actual wear.
 | 
			
		||||
				                                                                 --  If the wear filter is of any other type, fail.
 | 
			
		||||
 | 
			
		||||
				          and (not fmetadata                                     -- If there's a metadata filter,
 | 
			
		||||
				               or (type(fmetadata) == "string"                   --  it must be a string
 | 
			
		||||
				                   and stack:get_metadata() == fmetadata))       --  and it must match.
 | 
			
		||||
			end
 | 
			
		||||
			if matches then table.insert(sposes, spos) end
 | 
			
		||||
		end
 | 
			
		||||
		if #sposes == 0 then return false end
 | 
			
		||||
		if slotseq_mode == 1 then
 | 
			
		||||
			for i = #sposes, 2, -1 do
 | 
			
		||||
				local j = math.random(i)
 | 
			
		||||
				local t = sposes[j]
 | 
			
		||||
				sposes[j] = sposes[i]
 | 
			
		||||
				sposes[i] = t
 | 
			
		||||
			end
 | 
			
		||||
		elseif slotseq_mode == 2 then
 | 
			
		||||
			local headpos = filtmeta:get_int("slotseq_index")
 | 
			
		||||
			table.sort(sposes, function (a, b)
 | 
			
		||||
				if a >= headpos then
 | 
			
		||||
					if b < headpos then return true end
 | 
			
		||||
				else
 | 
			
		||||
					if b >= headpos then return false end
 | 
			
		||||
				end
 | 
			
		||||
				return a < b
 | 
			
		||||
			end)
 | 
			
		||||
		end
 | 
			
		||||
		for _, spos in ipairs(sposes) do
 | 
			
		||||
			local stack = frominv:get_stack(frominvname, spos)
 | 
			
		||||
			local doRemove = stack:get_count()
 | 
			
		||||
			if fromtube.can_remove then
 | 
			
		||||
				doRemove = fromtube.can_remove(frompos, fromnode, stack, dir, frominvname, spos)
 | 
			
		||||
			elseif fromdef.allow_metadata_inventory_take then
 | 
			
		||||
				doRemove = fromdef.allow_metadata_inventory_take(frompos, frominvname,spos, stack, fakePlayer)
 | 
			
		||||
			end
 | 
			
		||||
			-- stupid lack of continue statements grumble
 | 
			
		||||
			if doRemove > 0 then
 | 
			
		||||
				if slotseq_mode == 2 then
 | 
			
		||||
					local nextpos = spos + 1
 | 
			
		||||
					if nextpos > frominv:get_size(frominvname) then
 | 
			
		||||
						nextpos = 1
 | 
			
		||||
					end
 | 
			
		||||
					filtmeta:set_int("slotseq_index", nextpos)
 | 
			
		||||
					set_filter_infotext(data, filtmeta)
 | 
			
		||||
				end
 | 
			
		||||
				local item
 | 
			
		||||
				local count
 | 
			
		||||
				if data.stackwise then
 | 
			
		||||
					count = math.min(stack:get_count(), doRemove)
 | 
			
		||||
					if filterfor.count and (filterfor.count > 1 or data.digiline) then
 | 
			
		||||
						if exmatch_mode ~= 0 and filterfor.count > count then
 | 
			
		||||
							return false -- not enough, fail
 | 
			
		||||
						else
 | 
			
		||||
							-- limit quantity to filter amount
 | 
			
		||||
							count = math.min(filterfor.count, count)
 | 
			
		||||
						end
 | 
			
		||||
					end
 | 
			
		||||
				else
 | 
			
		||||
					count = 1
 | 
			
		||||
				end
 | 
			
		||||
				if fromtube.remove_items then
 | 
			
		||||
					-- it could be the entire stack...
 | 
			
		||||
					item = fromtube.remove_items(frompos, fromnode, stack, dir, count, frominvname, spos)
 | 
			
		||||
				else
 | 
			
		||||
					item = stack:take_item(count)
 | 
			
		||||
					frominv:set_stack(frominvname, spos, stack)
 | 
			
		||||
					if fromdef.on_metadata_inventory_take then
 | 
			
		||||
						fromdef.on_metadata_inventory_take(frompos, frominvname, spos, item, fakePlayer)
 | 
			
		||||
					end
 | 
			
		||||
				end
 | 
			
		||||
				local pos = vector.add(frompos, vector.multiply(dir, 1.4))
 | 
			
		||||
				local start_pos = vector.add(frompos, dir)
 | 
			
		||||
				pipeworks.tube_inject_item(pos, start_pos, dir, item,
 | 
			
		||||
					fakePlayer:get_player_name())
 | 
			
		||||
				return true -- only fire one item, please
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
		return false
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	for _, frominvname in ipairs(type(fromtube.input_inventory) == "table" and fromtube.input_inventory or {fromtube.input_inventory}) do
 | 
			
		||||
		local done = false
 | 
			
		||||
		for _, filterfor in ipairs(filters) do
 | 
			
		||||
			if grabAndFire(data, slotseq_mode, exact_match, filtmeta, frominv, frominvname, frompos, fromnode, filterfor, fromtube, fromdef, dir, fakePlayer, data.stackwise, data.digiline) then
 | 
			
		||||
			if grabAndFire(frominvname, filterfor) then
 | 
			
		||||
				done = true
 | 
			
		||||
				break
 | 
			
		||||
			end
 | 
			
		||||
@@ -342,23 +362,23 @@ end
 | 
			
		||||
for _, data in ipairs({
 | 
			
		||||
	{
 | 
			
		||||
		name = "filter",
 | 
			
		||||
		wise_desc = "Itemwise",
 | 
			
		||||
		wise_desc = S("Itemwise"),
 | 
			
		||||
		stackwise = false,
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		name = "mese_filter",
 | 
			
		||||
		wise_desc = "Stackwise",
 | 
			
		||||
		wise_desc = S("Stackwise"),
 | 
			
		||||
		stackwise = true,
 | 
			
		||||
	},
 | 
			
		||||
	{ -- register even if no digilines
 | 
			
		||||
		name = "digiline_filter",
 | 
			
		||||
		wise_desc = "Digiline",
 | 
			
		||||
		wise_desc = S("Digiline"),
 | 
			
		||||
		stackwise = true,
 | 
			
		||||
		digiline = true,
 | 
			
		||||
	},
 | 
			
		||||
}) do
 | 
			
		||||
	local node = {
 | 
			
		||||
		description = data.wise_desc.." Filter-Injector",
 | 
			
		||||
		description = S("@1 Filter-Injector", data.wise_desc),
 | 
			
		||||
		tiles = {
 | 
			
		||||
			"pipeworks_"..data.name.."_top.png",
 | 
			
		||||
			"pipeworks_"..data.name.."_top.png",
 | 
			
		||||
@@ -368,9 +388,12 @@ for _, data in ipairs({
 | 
			
		||||
			"pipeworks_"..data.name.."_top.png",
 | 
			
		||||
		},
 | 
			
		||||
		paramtype2 = "facedir",
 | 
			
		||||
		groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, mesecon = 2},
 | 
			
		||||
		groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, mesecon = 2, axey=1, handy=1, pickaxey=1},
 | 
			
		||||
		_mcl_hardness=0.8,
 | 
			
		||||
		legacy_facedir_simple = true,
 | 
			
		||||
		sounds = default.node_sound_wood_defaults(),
 | 
			
		||||
		_sound_def = {
 | 
			
		||||
			key = "node_sound_wood_defaults",
 | 
			
		||||
		},
 | 
			
		||||
		on_construct = function(pos)
 | 
			
		||||
			local meta = minetest.get_meta(pos)
 | 
			
		||||
			set_filter_formspec(data, meta)
 | 
			
		||||
@@ -383,6 +406,7 @@ for _, data in ipairs({
 | 
			
		||||
			pipeworks.after_place(pos)
 | 
			
		||||
		end,
 | 
			
		||||
		after_dig_node = pipeworks.after_dig,
 | 
			
		||||
		on_rotate = pipeworks.on_rotate,
 | 
			
		||||
		allow_metadata_inventory_put = function(pos, listname, index, stack, player)
 | 
			
		||||
			if not pipeworks.may_configure(pos, player) then
 | 
			
		||||
				return 0
 | 
			
		||||
@@ -420,10 +444,14 @@ for _, data in ipairs({
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		node.on_receive_fields = function(pos, formname, fields, sender)
 | 
			
		||||
			if not pipeworks.may_configure(pos, sender) then return end
 | 
			
		||||
			if (fields.quit and not fields.key_enter_field)
 | 
			
		||||
			or not pipeworks.may_configure(pos, sender) then
 | 
			
		||||
				return
 | 
			
		||||
			end
 | 
			
		||||
 | 
			
		||||
			fs_helpers.on_receive_fields(pos, fields)
 | 
			
		||||
 | 
			
		||||
			if fields.channel then
 | 
			
		||||
			if fields.channel and (fields.key_enter_field == "channel" or fields.set_channel) then
 | 
			
		||||
				minetest.get_meta(pos):set_string("channel", fields.channel)
 | 
			
		||||
			end
 | 
			
		||||
 | 
			
		||||
@@ -467,35 +495,7 @@ for _, data in ipairs({
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	minetest.register_node("pipeworks:"..data.name, node)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
minetest.register_craft( {
 | 
			
		||||
	output = "pipeworks:filter 2",
 | 
			
		||||
	recipe = {
 | 
			
		||||
	        { "default:steel_ingot", "default:steel_ingot", "homedecor:plastic_sheeting" },
 | 
			
		||||
	        { "group:stick", "default:mese_crystal", "homedecor:plastic_sheeting" },
 | 
			
		||||
	        { "default:steel_ingot", "default:steel_ingot", "homedecor:plastic_sheeting" }
 | 
			
		||||
	},
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
minetest.register_craft( {
 | 
			
		||||
	output = "pipeworks:mese_filter 2",
 | 
			
		||||
	recipe = {
 | 
			
		||||
	        { "default:steel_ingot", "default:steel_ingot", "homedecor:plastic_sheeting" },
 | 
			
		||||
	        { "group:stick", "default:mese", "homedecor:plastic_sheeting" },
 | 
			
		||||
	        { "default:steel_ingot", "default:steel_ingot", "homedecor:plastic_sheeting" }
 | 
			
		||||
	},
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
if minetest.get_modpath("digilines") then
 | 
			
		||||
	minetest.register_craft( {
 | 
			
		||||
		output = "pipeworks:digiline_filter 2",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			{ "default:steel_ingot", "default:steel_ingot", "homedecor:plastic_sheeting" },
 | 
			
		||||
			{ "group:stick", "digilines:wire_std_00000000", "homedecor:plastic_sheeting" },
 | 
			
		||||
			{ "default:steel_ingot", "default:steel_ingot", "homedecor:plastic_sheeting" }
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
	pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:"..data.name
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
--[[
 | 
			
		||||
 
 | 
			
		||||
@@ -60,8 +60,8 @@ pipeworks.check_for_inflows = function(pos,node)
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
	if newnode then 
 | 
			
		||||
		minetest.add_node(pos,{name=newnode, param2 = node.param2}) 
 | 
			
		||||
	if newnode then
 | 
			
		||||
		minetest.add_node(pos,{name=newnode, param2 = node.param2})
 | 
			
		||||
		minetest.get_meta(pos):set_string("source",minetest.pos_to_string(source))
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
@@ -75,15 +75,15 @@ pipeworks.check_sources = function(pos,node)
 | 
			
		||||
		newnode = string.gsub(node.name,"loaded","empty")
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	if newnode then 
 | 
			
		||||
		minetest.add_node(pos,{name=newnode, param2 = node.param2}) 
 | 
			
		||||
	if newnode then
 | 
			
		||||
		minetest.add_node(pos,{name=newnode, param2 = node.param2})
 | 
			
		||||
		minetest.get_meta(pos):set_string("source","")
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
pipeworks.spigot_check = function(pos, node)
 | 
			
		||||
	local belowname = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name
 | 
			
		||||
	if belowname and (belowname == "air" or belowname == "default:water_flowing" or belowname == "default:water_source") then 
 | 
			
		||||
	if belowname and (belowname == "air" or belowname == pipeworks.liquids.water.flowing or belowname == pipeworks.liquids.water.source) then
 | 
			
		||||
		local spigotname = minetest.get_node(pos).name
 | 
			
		||||
		local fdir=node.param2 % 4
 | 
			
		||||
		local check = {
 | 
			
		||||
@@ -96,14 +96,14 @@ pipeworks.spigot_check = function(pos, node)
 | 
			
		||||
		if near_node and string.find(near_node.name, "_loaded") then
 | 
			
		||||
			if spigotname and spigotname == "pipeworks:spigot" then
 | 
			
		||||
				minetest.add_node(pos,{name = "pipeworks:spigot_pouring", param2 = fdir})
 | 
			
		||||
				if finitewater or belowname ~= "default:water_source" then
 | 
			
		||||
					minetest.add_node({x=pos.x,y=pos.y-1,z=pos.z},{name = "default:water_source"})
 | 
			
		||||
				if finitewater or belowname ~= pipeworks.liquids.water.source then
 | 
			
		||||
					minetest.add_node({x=pos.x,y=pos.y-1,z=pos.z},{name = pipeworks.liquids.water.source})
 | 
			
		||||
				end
 | 
			
		||||
			end
 | 
			
		||||
		else
 | 
			
		||||
			if spigotname == "pipeworks:spigot_pouring" then
 | 
			
		||||
				minetest.add_node({x=pos.x,y=pos.y,z=pos.z},{name = "pipeworks:spigot", param2 = fdir})
 | 
			
		||||
				if belowname == "default:water_source" and not finitewater then
 | 
			
		||||
				if belowname == pipeworks.liquids.water.source and not finitewater then
 | 
			
		||||
					minetest.remove_node({x=pos.x,y=pos.y-1,z=pos.z})
 | 
			
		||||
				end
 | 
			
		||||
			end
 | 
			
		||||
@@ -113,20 +113,20 @@ end
 | 
			
		||||
 | 
			
		||||
pipeworks.fountainhead_check = function(pos, node)
 | 
			
		||||
	local abovename = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}).name
 | 
			
		||||
	if abovename and (abovename == "air" or abovename == "default:water_flowing" or abovename == "default:water_source") then 
 | 
			
		||||
	if abovename and (abovename == "air" or abovename == pipeworks.liquids.water.flowing or abovename == pipeworks.liquids.water.source) then
 | 
			
		||||
		local fountainhead_name = minetest.get_node(pos).name
 | 
			
		||||
		local near_node = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})
 | 
			
		||||
		if near_node and string.find(near_node.name, "_loaded") then
 | 
			
		||||
			if fountainhead_name and fountainhead_name == "pipeworks:fountainhead" then
 | 
			
		||||
				minetest.add_node(pos,{name = "pipeworks:fountainhead_pouring"})
 | 
			
		||||
				if finitewater or abovename ~= "default:water_source" then
 | 
			
		||||
					minetest.add_node({x=pos.x,y=pos.y+1,z=pos.z},{name = "default:water_source"})
 | 
			
		||||
				if finitewater or abovename ~= pipeworks.liquids.water.source then
 | 
			
		||||
					minetest.add_node({x=pos.x,y=pos.y+1,z=pos.z},{name = pipeworks.liquids.water.source})
 | 
			
		||||
				end
 | 
			
		||||
			end
 | 
			
		||||
		else
 | 
			
		||||
			if fountainhead_name == "pipeworks:fountainhead_pouring" then
 | 
			
		||||
				minetest.add_node({x=pos.x,y=pos.y,z=pos.z},{name = "pipeworks:fountainhead"})
 | 
			
		||||
				if abovename == "default:water_source" and not finitewater then
 | 
			
		||||
				if abovename == pipeworks.liquids.water.source and not finitewater then
 | 
			
		||||
					minetest.remove_node({x=pos.x,y=pos.y+1,z=pos.z})
 | 
			
		||||
				end
 | 
			
		||||
			end
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										106
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						
									
										106
									
								
								init.lua
									
									
									
									
									
								
							@@ -3,15 +3,23 @@
 | 
			
		||||
-- This mod supplies various steel pipes and plastic pneumatic tubes
 | 
			
		||||
-- and devices that they can connect to.
 | 
			
		||||
--
 | 
			
		||||
-- License: WTFPL
 | 
			
		||||
--
 | 
			
		||||
 | 
			
		||||
pipeworks = {}
 | 
			
		||||
 | 
			
		||||
local DEBUG = false
 | 
			
		||||
pipeworks.ui_cat_tube_list = {}
 | 
			
		||||
 | 
			
		||||
pipeworks.worldpath = minetest.get_worldpath()
 | 
			
		||||
pipeworks.modpath = minetest.get_modpath("pipeworks")
 | 
			
		||||
local S = minetest.get_translator("pipeworks")
 | 
			
		||||
 | 
			
		||||
pipeworks.liquids = {}
 | 
			
		||||
pipeworks.liquids.water = {
 | 
			
		||||
	source = minetest.registered_nodes["mapgen_water_source"].name,
 | 
			
		||||
	flowing = minetest.registered_nodes["mapgen_water_source"].liquid_alternative_flowing
 | 
			
		||||
}
 | 
			
		||||
pipeworks.liquids.river_water = {
 | 
			
		||||
	source = minetest.registered_nodes["mapgen_river_water_source"].name,
 | 
			
		||||
	flowing = minetest.registered_nodes["mapgen_river_water_source"].liquid_alternative_flowing
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
dofile(pipeworks.modpath.."/default_settings.lua")
 | 
			
		||||
-- Read the external config file if it exists.
 | 
			
		||||
@@ -24,6 +32,9 @@ end
 | 
			
		||||
if pipeworks.toggles.pipe_mode == "pressure" then
 | 
			
		||||
	minetest.log("warning", "pipeworks pressure logic mode comes with caveats and differences in behaviour, you have been warned!")
 | 
			
		||||
end
 | 
			
		||||
if pipeworks.entity_update_interval >= 0.2 and pipeworks.enable_accelerator_tube then
 | 
			
		||||
	minetest.log("warning", "pipeworks accelerator tubes will not entirely work with an entity update interval 0.2 or above.")
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Random variables
 | 
			
		||||
 | 
			
		||||
@@ -42,12 +53,13 @@ pipeworks.rules_all = {{x=0, y=0, z=1},{x=0, y=0, z=-1},{x=1, y=0, z=0},{x=-1, y
 | 
			
		||||
pipeworks.mesecons_rules={{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=1,y=0,z=0},{x=-1,y=0,z=0},{x=0,y=1,z=0},{x=0,y=-1,z=0}}
 | 
			
		||||
pipeworks.digilines_rules={{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=1,y=0,z=0},{x=-1,y=0,z=0},{x=0,y=1,z=0},{x=0,y=-1,z=0}}
 | 
			
		||||
 | 
			
		||||
pipeworks.liquid_texture = "default_water.png"
 | 
			
		||||
pipeworks.liquid_texture = minetest.registered_nodes[pipeworks.liquids.water.flowing].tiles[1]
 | 
			
		||||
if type(pipeworks.liquid_texture) == "table" then pipeworks.liquid_texture = pipeworks.liquid_texture.name end
 | 
			
		||||
 | 
			
		||||
pipeworks.button_off   = {text="", texture="pipeworks_button_off.png", addopts="false;false;pipeworks_button_interm.png"}
 | 
			
		||||
pipeworks.button_on    = {text="", texture="pipeworks_button_on.png",  addopts="false;false;pipeworks_button_interm.png"}
 | 
			
		||||
pipeworks.button_base  = "image_button[0,4.3;1,0.6"
 | 
			
		||||
pipeworks.button_label = "label[0.9,4.31;Allow splitting incoming stacks from tubes]"
 | 
			
		||||
pipeworks.button_label = "label[0.9,4.31;"..S("Allow splitting incoming stacks from tubes").."]"
 | 
			
		||||
 | 
			
		||||
-- Helper functions
 | 
			
		||||
 | 
			
		||||
@@ -60,6 +72,29 @@ function pipeworks.fix_image_names(table, replacement)
 | 
			
		||||
	return outtable
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function overlay_tube_texture(texture)
 | 
			
		||||
	-- The texture appears the first time to be colorized as the opaque background.
 | 
			
		||||
	return ("(%s)^[noalpha^[colorize:#dadada^(%s)"):format(texture, texture)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function pipeworks.make_tube_tile(tile)
 | 
			
		||||
	if pipeworks.use_real_entities then
 | 
			
		||||
		return tile
 | 
			
		||||
	elseif type(tile) == "string" then
 | 
			
		||||
		return overlay_tube_texture(tile)
 | 
			
		||||
	else
 | 
			
		||||
		tile = table.copy(tile)
 | 
			
		||||
		if tile.color then
 | 
			
		||||
			-- Won't work 100% of the time, but good enough.
 | 
			
		||||
			tile.name = tile.name .. "^[multiply:" .. minetest.colorspec_to_colorstring(tile.color)
 | 
			
		||||
			tile.color = nil
 | 
			
		||||
		end
 | 
			
		||||
		tile.name = overlay_tube_texture(tile.name)
 | 
			
		||||
		tile.backface_culling = nil -- The texture is opaque
 | 
			
		||||
		return tile
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function pipeworks.add_node_box(t, b)
 | 
			
		||||
	if not t or not b then return end
 | 
			
		||||
	for i in ipairs(b)
 | 
			
		||||
@@ -72,8 +107,8 @@ function pipeworks.may_configure(pos, player)
 | 
			
		||||
	local meta = minetest.get_meta(pos)
 | 
			
		||||
	local owner = meta:get_string("owner")
 | 
			
		||||
 | 
			
		||||
	if owner ~= "" then -- wielders and filters
 | 
			
		||||
		return owner == name
 | 
			
		||||
	if owner ~= "" and owner == name then -- wielders and filters
 | 
			
		||||
		return true
 | 
			
		||||
	end
 | 
			
		||||
	return not minetest.is_protected(pos, name)
 | 
			
		||||
end
 | 
			
		||||
@@ -93,7 +128,7 @@ function pipeworks.replace_name(tbl,tr,name)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
pipeworks.logger = function(msg)
 | 
			
		||||
	print("[pipeworks] "..msg)
 | 
			
		||||
	minetest.log("action", "[pipeworks] "..msg)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-------------------------------------------
 | 
			
		||||
@@ -104,6 +139,10 @@ if pipeworks.toggles.finite_water == nil then
 | 
			
		||||
	dofile(pipeworks.modpath.."/autodetect-finite-water.lua")
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if minetest.get_modpath("signs_lib") then
 | 
			
		||||
	dofile(pipeworks.modpath.."/signs_compat.lua")
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
dofile(pipeworks.modpath.."/common.lua")
 | 
			
		||||
dofile(pipeworks.modpath.."/models.lua")
 | 
			
		||||
dofile(pipeworks.modpath.."/autoplace_pipes.lua")
 | 
			
		||||
@@ -111,11 +150,9 @@ dofile(pipeworks.modpath.."/autoplace_tubes.lua")
 | 
			
		||||
dofile(pipeworks.modpath.."/luaentity.lua")
 | 
			
		||||
dofile(pipeworks.modpath.."/item_transport.lua")
 | 
			
		||||
dofile(pipeworks.modpath.."/flowing_logic.lua")
 | 
			
		||||
dofile(pipeworks.modpath.."/crafts.lua")
 | 
			
		||||
dofile(pipeworks.modpath.."/tube_registration.lua")
 | 
			
		||||
dofile(pipeworks.modpath.."/routing_tubes.lua")
 | 
			
		||||
dofile(pipeworks.modpath.."/sorting_tubes.lua")
 | 
			
		||||
dofile(pipeworks.modpath.."/vacuum_tubes.lua")
 | 
			
		||||
dofile(pipeworks.modpath.."/signal_tubes.lua")
 | 
			
		||||
dofile(pipeworks.modpath.."/decorative_tubes.lua")
 | 
			
		||||
dofile(pipeworks.modpath.."/filter-injector.lua")
 | 
			
		||||
@@ -132,18 +169,49 @@ dofile(pipeworks.modpath..logicdir.."abms.lua")
 | 
			
		||||
dofile(pipeworks.modpath..logicdir.."abm_register.lua")
 | 
			
		||||
dofile(pipeworks.modpath..logicdir.."flowable_node_registry_install.lua")
 | 
			
		||||
 | 
			
		||||
if pipeworks.enable_pipes then dofile(pipeworks.modpath.."/pipes.lua") end
 | 
			
		||||
if pipeworks.enable_teleport_tube then dofile(pipeworks.modpath.."/teleport_tube.lua") end
 | 
			
		||||
if pipeworks.enable_pipe_devices then dofile(pipeworks.modpath.."/devices.lua") end
 | 
			
		||||
 | 
			
		||||
if pipeworks.enable_redefines then
 | 
			
		||||
if pipeworks.enable_pipes then
 | 
			
		||||
	dofile(pipeworks.modpath.."/pipes.lua")
 | 
			
		||||
end
 | 
			
		||||
if pipeworks.enable_teleport_tube then
 | 
			
		||||
	dofile(pipeworks.modpath.."/teleport_tube.lua")
 | 
			
		||||
end
 | 
			
		||||
if pipeworks.enable_pipe_devices then
 | 
			
		||||
	dofile(pipeworks.modpath.."/devices.lua")
 | 
			
		||||
end
 | 
			
		||||
if pipeworks.enable_redefines and (minetest.get_modpath("default") or minetest.get_modpath("hades_core")) then
 | 
			
		||||
	dofile(pipeworks.modpath.."/compat-chests.lua")
 | 
			
		||||
	dofile(pipeworks.modpath.."/compat-furnaces.lua")
 | 
			
		||||
end
 | 
			
		||||
if pipeworks.enable_autocrafter then dofile(pipeworks.modpath.."/autocrafter.lua") end
 | 
			
		||||
if pipeworks.enable_lua_tube then dofile(pipeworks.modpath.."/lua_tube.lua") end
 | 
			
		||||
if pipeworks.enable_redefines and minetest.get_modpath("mcl_barrels") then
 | 
			
		||||
	dofile(pipeworks.modpath.."/mcl_barrels.lua")
 | 
			
		||||
end
 | 
			
		||||
if pipeworks.enable_redefines and minetest.get_modpath("mcl_furnaces") then
 | 
			
		||||
	dofile(pipeworks.modpath.."/mcl_furnaces.lua")
 | 
			
		||||
end
 | 
			
		||||
if pipeworks.enable_autocrafter then
 | 
			
		||||
	dofile(pipeworks.modpath.."/autocrafter.lua")
 | 
			
		||||
end
 | 
			
		||||
if pipeworks.enable_lua_tube and minetest.get_modpath("mesecons") then
 | 
			
		||||
	dofile(pipeworks.modpath.."/lua_tube.lua")
 | 
			
		||||
end
 | 
			
		||||
if pipeworks.enable_sand_tube or pipeworks.enable_mese_sand_tube then
 | 
			
		||||
	dofile(pipeworks.modpath.."/vacuum_tubes.lua")
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
dofile(pipeworks.modpath.."/crafts.lua")
 | 
			
		||||
 | 
			
		||||
minetest.register_alias("pipeworks:pipe", "pipeworks:pipe_110000_empty")
 | 
			
		||||
 | 
			
		||||
print("Pipeworks loaded!")
 | 
			
		||||
-- Unified Inventory categories integration
 | 
			
		||||
 | 
			
		||||
if minetest.get_modpath("unified_inventory") and unified_inventory.registered_categories then
 | 
			
		||||
	if not unified_inventory.registered_categories["automation"] then
 | 
			
		||||
		unified_inventory.register_category("automation", {
 | 
			
		||||
			symbol = "pipeworks:lua_tube000000",
 | 
			
		||||
			label = "Automation components"
 | 
			
		||||
		})
 | 
			
		||||
	end
 | 
			
		||||
	unified_inventory.add_category_items("automation", pipeworks.ui_cat_tube_list)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
minetest.log("info", "Pipeworks loaded!")
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
local luaentity = pipeworks.luaentity
 | 
			
		||||
local enable_max_limit = minetest.settings:get("pipeworks_enable_items_per_tube_limit")
 | 
			
		||||
local enable_max_limit = minetest.settings:get_bool("pipeworks_enable_items_per_tube_limit")
 | 
			
		||||
local max_tube_limit = tonumber(minetest.settings:get("pipeworks_max_items_per_tube")) or 30
 | 
			
		||||
if enable_max_limit == nil then enable_max_limit = true end
 | 
			
		||||
 | 
			
		||||
@@ -25,7 +25,7 @@ end
 | 
			
		||||
-- both optional w/ sensible defaults and fallback to normal allow_* function
 | 
			
		||||
-- XXX: possibly change insert_object to insert_item
 | 
			
		||||
 | 
			
		||||
local adjlist={{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=0,y=1,z=0},{x=0,y=-1,z=0},{x=1,y=0,z=0},{x=-1,y=0,z=0}}
 | 
			
		||||
local default_adjlist={{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=0,y=1,z=0},{x=0,y=-1,z=0},{x=1,y=0,z=0},{x=-1,y=0,z=0}}
 | 
			
		||||
 | 
			
		||||
function pipeworks.notvel(tbl, vel)
 | 
			
		||||
	local tbl2={}
 | 
			
		||||
@@ -42,7 +42,7 @@ minetest.register_globalstep(function(dtime)
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
	tube_item_count = {}
 | 
			
		||||
	for id, entity in pairs(luaentity.entities) do
 | 
			
		||||
	for _, entity in pairs(luaentity.entities) do
 | 
			
		||||
		if entity.name == "pipeworks:tubed_item" then
 | 
			
		||||
			local h = minetest.hash_node_position(vector.round(entity._pos))
 | 
			
		||||
			tube_item_count[h] = (tube_item_count[h] or 0) + 1
 | 
			
		||||
@@ -55,15 +55,22 @@ end)
 | 
			
		||||
-- tube overload mechanism:
 | 
			
		||||
-- when the tube's item count (tracked in the above tube_item_count table)
 | 
			
		||||
-- exceeds the limit configured per tube, replace it with a broken one.
 | 
			
		||||
 | 
			
		||||
function pipeworks.break_tube(pos)
 | 
			
		||||
	local node = minetest.get_node(pos)
 | 
			
		||||
	local meta = minetest.get_meta(pos)
 | 
			
		||||
	meta:set_string("the_tube_was", minetest.serialize(node))
 | 
			
		||||
	minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
 | 
			
		||||
	pipeworks.scan_for_tube_objects(pos)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local crunch_tube = function(pos, cnode, cmeta)
 | 
			
		||||
	if enable_max_limit then
 | 
			
		||||
		local h = minetest.hash_node_position(pos)
 | 
			
		||||
		local itemcount = tube_item_count[h] or 0
 | 
			
		||||
		if itemcount > max_tube_limit then
 | 
			
		||||
			cmeta:set_string("the_tube_was", minetest.serialize(cnode))
 | 
			
		||||
			print("[Pipeworks] Warning - a tube at "..minetest.pos_to_string(pos).." broke due to too many items ("..itemcount..")")
 | 
			
		||||
			minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
 | 
			
		||||
			pipeworks.scan_for_tube_objects(pos)
 | 
			
		||||
			pipeworks.logger("Warning - a tube at "..minetest.pos_to_string(pos).." broke due to too many items ("..itemcount..")")
 | 
			
		||||
			pipeworks.break_tube(pos)
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
@@ -80,6 +87,9 @@ local function go_next_compat(pos, cnode, cmeta, cycledir, vel, stack, owner)
 | 
			
		||||
	if minetest.registered_nodes[cnode.name] and minetest.registered_nodes[cnode.name].tube and minetest.registered_nodes[cnode.name].tube.can_go then
 | 
			
		||||
		can_go = minetest.registered_nodes[cnode.name].tube.can_go(pos, cnode, vel, stack)
 | 
			
		||||
	else
 | 
			
		||||
		local adjlist_string = minetest.get_meta(pos):get_string("adjlist")
 | 
			
		||||
		local adjlist = minetest.deserialize(adjlist_string) or default_adjlist -- backward compat: if not found, use old behavior: all directions
 | 
			
		||||
 | 
			
		||||
		can_go = pipeworks.notvel(adjlist, vel)
 | 
			
		||||
	end
 | 
			
		||||
	-- can_go() is expected to return an array-like table of candidate offsets.
 | 
			
		||||
@@ -191,6 +201,7 @@ minetest.register_entity("pipeworks:tubed_item", {
 | 
			
		||||
 | 
			
		||||
	from_data = function(self, itemstring)
 | 
			
		||||
		local stack = ItemStack(itemstring)
 | 
			
		||||
		--[[
 | 
			
		||||
		local itemtable = stack:to_table()
 | 
			
		||||
		local itemname = nil
 | 
			
		||||
		if itemtable then
 | 
			
		||||
@@ -202,6 +213,7 @@ minetest.register_entity("pipeworks:tubed_item", {
 | 
			
		||||
			item_texture = minetest.registered_items[itemname].inventory_image
 | 
			
		||||
			item_type = minetest.registered_items[itemname].type
 | 
			
		||||
		end
 | 
			
		||||
		--]]
 | 
			
		||||
		self.object:set_properties({
 | 
			
		||||
			is_visible = true,
 | 
			
		||||
			textures = {stack:get_name()}
 | 
			
		||||
@@ -299,8 +311,6 @@ luaentity.register_entity("pipeworks:tubed_item", {
 | 
			
		||||
			self:set_pos(pos)
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		local stack = ItemStack(self.itemstring)
 | 
			
		||||
 | 
			
		||||
		local velocity = self:get_velocity()
 | 
			
		||||
 | 
			
		||||
		local moved = false
 | 
			
		||||
@@ -317,9 +327,15 @@ luaentity.register_entity("pipeworks:tubed_item", {
 | 
			
		||||
			moved = true
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		if not moved then
 | 
			
		||||
			return
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		local stack = ItemStack(self.itemstring)
 | 
			
		||||
 | 
			
		||||
		pipeworks.load_position(self.start_pos)
 | 
			
		||||
		local node = minetest.get_node(self.start_pos)
 | 
			
		||||
		if moved and minetest.get_item_group(node.name, "tubedevice_receiver") == 1 then
 | 
			
		||||
		if minetest.get_item_group(node.name, "tubedevice_receiver") == 1 then
 | 
			
		||||
			local leftover
 | 
			
		||||
			if minetest.registered_nodes[node.name].tube and minetest.registered_nodes[node.name].tube.insert_object then
 | 
			
		||||
				leftover = minetest.registered_nodes[node.name].tube.insert_object(self.start_pos, node, stack, vel, self.owner)
 | 
			
		||||
@@ -337,43 +353,43 @@ luaentity.register_entity("pipeworks:tubed_item", {
 | 
			
		||||
			return
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		if moved then
 | 
			
		||||
			local found_next, new_velocity, multimode = go_next(self.start_pos, velocity, stack, self.owner) -- todo: color
 | 
			
		||||
			local rev_vel = vector.multiply(velocity, -1)
 | 
			
		||||
			local rev_dir = vector.direction(self.start_pos,vector.add(self.start_pos,rev_vel))
 | 
			
		||||
			local rev_node = minetest.get_node(vector.round(vector.add(self.start_pos,rev_dir)))
 | 
			
		||||
			local tube_present = minetest.get_item_group(rev_node.name,"tubedevice") == 1
 | 
			
		||||
			if not found_next then
 | 
			
		||||
				if pipeworks.drop_on_routing_fail or not tube_present or
 | 
			
		||||
						minetest.get_item_group(rev_node.name,"tube") ~= 1 then
 | 
			
		||||
					-- Using add_item instead of item_drop since this makes pipeworks backward
 | 
			
		||||
					-- compatible with Minetest 0.4.13.
 | 
			
		||||
					-- Using item_drop here makes Minetest 0.4.13 crash.
 | 
			
		||||
					local dropped_item = minetest.add_item(self.start_pos, stack)
 | 
			
		||||
		local found_next, new_velocity, multimode = go_next(self.start_pos, velocity, stack, self.owner) -- todo: color
 | 
			
		||||
		local rev_vel = vector.multiply(velocity, -1)
 | 
			
		||||
		local rev_dir = vector.direction(self.start_pos,vector.add(self.start_pos,rev_vel))
 | 
			
		||||
		local rev_node = minetest.get_node(vector.round(vector.add(self.start_pos,rev_dir)))
 | 
			
		||||
		local tube_present = minetest.get_item_group(rev_node.name,"tubedevice") == 1
 | 
			
		||||
		if not found_next then
 | 
			
		||||
			if pipeworks.drop_on_routing_fail or not tube_present or
 | 
			
		||||
					minetest.get_item_group(rev_node.name,"tube") ~= 1 then
 | 
			
		||||
				-- Using add_item instead of item_drop since this makes pipeworks backward
 | 
			
		||||
				-- compatible with Minetest 0.4.13.
 | 
			
		||||
				-- Using item_drop here makes Minetest 0.4.13 crash.
 | 
			
		||||
				local dropped_item = minetest.add_item(self.start_pos, stack)
 | 
			
		||||
				if dropped_item then
 | 
			
		||||
					dropped_item:set_velocity(vector.multiply(velocity, 5))
 | 
			
		||||
					self:remove()
 | 
			
		||||
					return
 | 
			
		||||
				else
 | 
			
		||||
					velocity = vector.multiply(velocity, -1)
 | 
			
		||||
					self:set_pos(vector.subtract(self.start_pos, vector.multiply(vel, moved_by - 1)))
 | 
			
		||||
					self:set_velocity(velocity)
 | 
			
		||||
				end
 | 
			
		||||
			elseif is_multimode(multimode) then
 | 
			
		||||
				-- create new stacks according to returned data.
 | 
			
		||||
				local s = self.start_pos
 | 
			
		||||
				for _, split in ipairs(multimode) do
 | 
			
		||||
					pipeworks.tube_inject_item(s, s, split.velocity, split.itemstack, self.owner)
 | 
			
		||||
				end
 | 
			
		||||
				-- remove ourself now the splits are sent
 | 
			
		||||
				self:remove()
 | 
			
		||||
				return
 | 
			
		||||
			else
 | 
			
		||||
				velocity = vector.multiply(velocity, -1)
 | 
			
		||||
				self:set_pos(vector.subtract(self.start_pos, vector.multiply(vel, moved_by - 1)))
 | 
			
		||||
				self:set_velocity(velocity)
 | 
			
		||||
			end
 | 
			
		||||
		elseif is_multimode(multimode) then
 | 
			
		||||
			-- create new stacks according to returned data.
 | 
			
		||||
			local s = self.start_pos
 | 
			
		||||
			for _, split in ipairs(multimode) do
 | 
			
		||||
				pipeworks.tube_inject_item(s, s, split.velocity, split.itemstack, self.owner)
 | 
			
		||||
			end
 | 
			
		||||
			-- remove ourself now the splits are sent
 | 
			
		||||
			self:remove()
 | 
			
		||||
			return
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
			if new_velocity and not vector.equals(velocity, new_velocity) then
 | 
			
		||||
				local nvelr = math.abs(new_velocity.x + new_velocity.y + new_velocity.z)
 | 
			
		||||
				self:set_pos(vector.add(self.start_pos, vector.multiply(new_velocity, (moved_by - 1) / nvelr)))
 | 
			
		||||
				self:set_velocity(new_velocity)
 | 
			
		||||
			end
 | 
			
		||||
		if new_velocity and not vector.equals(velocity, new_velocity) then
 | 
			
		||||
			local nvelr = math.abs(new_velocity.x + new_velocity.y + new_velocity.z)
 | 
			
		||||
			self:set_pos(vector.add(self.start_pos, vector.multiply(new_velocity, (moved_by - 1) / nvelr)))
 | 
			
		||||
			self:set_velocity(new_velocity)
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
})
 | 
			
		||||
@@ -386,7 +402,7 @@ if minetest.get_modpath("mesecons_mvps") then
 | 
			
		||||
		for _, n in ipairs(moved_nodes) do
 | 
			
		||||
			moved[minetest.hash_node_position(n.oldpos)] = vector.subtract(n.pos, n.oldpos)
 | 
			
		||||
		end
 | 
			
		||||
		for id, entity in pairs(luaentity.entities) do
 | 
			
		||||
		for _, entity in pairs(luaentity.entities) do
 | 
			
		||||
			if entity.name == "pipeworks:tubed_item" then
 | 
			
		||||
				local pos = entity:get_pos()
 | 
			
		||||
				local rpos = vector.round(pos)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										17
									
								
								legacy.lua
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								legacy.lua
									
									
									
									
									
								
							@@ -1,5 +1,6 @@
 | 
			
		||||
local S = minetest.get_translator("pipeworks")
 | 
			
		||||
 | 
			
		||||
if not minetest.get_modpath("auto_tree_tap") and 
 | 
			
		||||
if not minetest.get_modpath("auto_tree_tap") and
 | 
			
		||||
  minetest.get_modpath("technic") then
 | 
			
		||||
 | 
			
		||||
	minetest.register_abm({
 | 
			
		||||
@@ -20,13 +21,16 @@ if not minetest.get_modpath("auto_tree_tap") and
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	minetest.register_node(":auto_tree_tap:off", {
 | 
			
		||||
		description = "Auto-Tap",
 | 
			
		||||
		description = S("Auto-Tap"),
 | 
			
		||||
		tiles = {"pipeworks_nodebreaker_top_off.png","pipeworks_nodebreaker_bottom_off.png","pipeworks_nodebreaker_side2_off.png","pipeworks_nodebreaker_side1_off.png",
 | 
			
		||||
			"pipeworks_nodebreaker_back.png","pipeworks_nodebreaker_front_off.png"},
 | 
			
		||||
		is_ground_content = true,
 | 
			
		||||
		paramtype2 = "facedir",
 | 
			
		||||
		groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1, not_in_creative_inventory=1 },
 | 
			
		||||
		sounds = default.node_sound_stone_defaults(),
 | 
			
		||||
		groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1, not_in_creative_inventory=1, axey=1, handy=1, pickaxey=1},
 | 
			
		||||
		_mcl_hardness=0.8,
 | 
			
		||||
		_sound_def = {
 | 
			
		||||
			key = "node_sound_stone_defaults",
 | 
			
		||||
		},
 | 
			
		||||
		tube = {connect_sides={back=1}},
 | 
			
		||||
		on_construct = function(pos)
 | 
			
		||||
			local meta = minetest.get_meta(pos)
 | 
			
		||||
@@ -37,10 +41,10 @@ if not minetest.get_modpath("auto_tree_tap") and
 | 
			
		||||
		after_place_node = function (pos, placer)
 | 
			
		||||
			pipeworks.scan_for_tube_objects(pos, placer)
 | 
			
		||||
			local placer_pos = placer:get_pos()
 | 
			
		||||
		
 | 
			
		||||
 | 
			
		||||
			--correct for the player's height
 | 
			
		||||
			if placer:is_player() then placer_pos.y = placer_pos.y + 1.5 end
 | 
			
		||||
		
 | 
			
		||||
 | 
			
		||||
			--correct for 6d facedir
 | 
			
		||||
			if placer_pos then
 | 
			
		||||
				local dir = {
 | 
			
		||||
@@ -51,7 +55,6 @@ if not minetest.get_modpath("auto_tree_tap") and
 | 
			
		||||
				local node = minetest.get_node(pos)
 | 
			
		||||
				node.param2 = minetest.dir_to_facedir(dir, true)
 | 
			
		||||
				minetest.set_node(pos, node)
 | 
			
		||||
				minetest.log("action", "real (6d) facedir: " .. node.param2)
 | 
			
		||||
			end
 | 
			
		||||
		end,
 | 
			
		||||
		after_dig_node = pipeworks.scan_for_tube_objects,
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										119
									
								
								locale/pipeworks.fr.tr
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										119
									
								
								locale/pipeworks.fr.tr
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,119 @@
 | 
			
		||||
# textdomain: pipeworks
 | 
			
		||||
 | 
			
		||||
# License: CC-by-SA 4.0
 | 
			
		||||
# Author: Louis Royer <4259825-lroyer@users.noreply.gitlab.com>
 | 
			
		||||
 | 
			
		||||
## generic interaction
 | 
			
		||||
Set=Fixer
 | 
			
		||||
Close=Fermer
 | 
			
		||||
 | 
			
		||||
## digilines interfacing
 | 
			
		||||
Channel=Canal
 | 
			
		||||
 | 
			
		||||
## init
 | 
			
		||||
Allow splitting incoming stacks from tubes=Séparer les piles venant des tubes
 | 
			
		||||
 | 
			
		||||
## autocrafter
 | 
			
		||||
Unknown item=Item inconnu
 | 
			
		||||
unconfigured Autocrafter: unknown recipe=Autocrafteur non-configuré : recette inconnue
 | 
			
		||||
unconfigured Autocrafter=Autocrafteur non-configuré
 | 
			
		||||
'@1' Autocrafter (@2)=Autocrafteur de '@1' (@2)
 | 
			
		||||
Save=Valider
 | 
			
		||||
paused '@1' Autocrafter=Autocrafteur de '@1' en pause
 | 
			
		||||
Autocrafter=Autocrafteur
 | 
			
		||||
 | 
			
		||||
## compat-furnaces
 | 
			
		||||
Allow splitting incoming material (not fuel) stacks from tubes=Séparer les piles (sauf le carburant) venant des tubes
 | 
			
		||||
 | 
			
		||||
## decorative tubes
 | 
			
		||||
Airtight steelblock embedded tube=Tube hermétique intégré à un bloc d’acier
 | 
			
		||||
Airtight panel embedded tube=Tube hermétique intégré à un panneau
 | 
			
		||||
 | 
			
		||||
## devices
 | 
			
		||||
Pump/Intake Module=Module de pompage et d’admission
 | 
			
		||||
Valve=Vanne
 | 
			
		||||
Decorative grating=Grillage décoratif
 | 
			
		||||
Spigot outlet=Sortie de robinet
 | 
			
		||||
Airtight Pipe entry/exit=Extrémité de tube hermétique
 | 
			
		||||
Flow Sensor=Détecteur de débit
 | 
			
		||||
Flow sensor (on)=Détecteur de débit (actif)
 | 
			
		||||
empty=vide
 | 
			
		||||
@1% full=plein à @1 %
 | 
			
		||||
Expansion Tank (@1)=Réservoir d’expansion (@1)
 | 
			
		||||
Fluid Storage Tank (@1)=Réservoir de liquides (@1)
 | 
			
		||||
Fountainhead=Tête de fontaine
 | 
			
		||||
Straight-only Pipe=Tuyau droit
 | 
			
		||||
 | 
			
		||||
## filter-injector
 | 
			
		||||
(slot #@1 next)=(slot suivant : #@1)
 | 
			
		||||
@1 Filter-Injector=Filtre-injecteur @1
 | 
			
		||||
Sequence slots by Priority=Ordonner par priorité
 | 
			
		||||
Sequence slots Randomly=Ordonner aléatoirement
 | 
			
		||||
Sequence slots by Rotation=Ordonner en rotation
 | 
			
		||||
Exact match - off=Filtrage inactif
 | 
			
		||||
Exact match - on=Filtrage actif
 | 
			
		||||
Prefer item types:=Items à filtrer :
 | 
			
		||||
Itemwise=par item
 | 
			
		||||
Stackwise=par piles d’items
 | 
			
		||||
Digiline=digiline
 | 
			
		||||
 | 
			
		||||
## legacy
 | 
			
		||||
Auto-Tap=Robinet d’arbre automatique
 | 
			
		||||
 | 
			
		||||
## pipes
 | 
			
		||||
Pipe Segment=Segment de tuyau
 | 
			
		||||
Pipe Segment (legacy)=Segment de tuyau (obsolète)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## routing tubes
 | 
			
		||||
Pneumatic tube segment=Segment de tuyau pneumatique
 | 
			
		||||
Broken Tube=Tuyau cassé
 | 
			
		||||
High Priority Tube Segment=Segment de tuyau haute priorité
 | 
			
		||||
Accelerating Pneumatic Tube Segment=Segment de tuyau pneumatique accélérante
 | 
			
		||||
Crossing Pneumatic Tube Segment=Intersection de tuyau pneumatique
 | 
			
		||||
One way tube=Tuyau unidirectionnel
 | 
			
		||||
 | 
			
		||||
## signal tubes
 | 
			
		||||
Detecting Pneumatic Tube Segment on=Segment de tuyau pneumatique avec détecteur (actif)
 | 
			
		||||
Detecting Pneumatic Tube Segment=Segment de tuyau pneumatique avec détecteur
 | 
			
		||||
Digiline Detecting Pneumatic Tube Segment=Segment de tuyau pneumatique avec détecteur digiline
 | 
			
		||||
Digiline Detecting Tube=Tuyau avec détecteur digiline
 | 
			
		||||
Conducting Pneumatic Tube Segment=Segment de tuyau pneumatique conducteur
 | 
			
		||||
Conducting Pneumatic Tube Segment on=Segment de tuyau pneumatique conducteur actif
 | 
			
		||||
Digiline Conducting Pneumatic Tube Segment=Segment de tuyau pneumatique conducteur digiline
 | 
			
		||||
Mesecon and Digiline Conducting Pneumatic Tube Segment=Segment de tuyau pneumatique conducteur mesecon et digiline
 | 
			
		||||
Mesecon and Digiline Conducting Pneumatic Tube Segment on=Segment de tuyau pneumatique conducteur mesecon et digiline (actif)
 | 
			
		||||
 | 
			
		||||
## sorting tubes
 | 
			
		||||
Sorting Pneumatic Tube Segment=Segment de tuyau pneumatique triant
 | 
			
		||||
Sorting pneumatic tube=Tuyau pneumatique triant
 | 
			
		||||
 | 
			
		||||
## teleport tube
 | 
			
		||||
Receive=Reception
 | 
			
		||||
Channels are public by default=Les canaux sont publics par défaut
 | 
			
		||||
Use <player>:<channel> for fully private channels=Utilisez <joueur>:<canal> pour un canal entièrement privé
 | 
			
		||||
Use <player>;<channel> for private receivers=Utilisez <joueur>;<canal> pour une réception privée
 | 
			
		||||
Teleporting Pneumatic Tube Segment=Segment de tuyau pneumatique téléporteur
 | 
			
		||||
Teleporting Tube=Tuyau pneumatique téléporteur
 | 
			
		||||
Unconfigured Teleportation Tube=Tuyau téléporteur non-configuré
 | 
			
		||||
Sorry, channel '@1' is reserved for exclusive use by @2=Désolé, le canal '@1' est réservé exclusivement à l’utilisateur @2.
 | 
			
		||||
Sorry, receiving from channel '@1' is reserved for @2=Désolé, la réception depuis le canal '@1' est réservée pour @2.
 | 
			
		||||
Teleportation Tube @1 on '@2'=Tuyau de téléportation @1 sur '@2'
 | 
			
		||||
 | 
			
		||||
## trashcan
 | 
			
		||||
Trash Can=Poubelle
 | 
			
		||||
 | 
			
		||||
## tube registration
 | 
			
		||||
Pneumatic tube segment (legacy)=Segment de tuyau pneumatique (obsolète)
 | 
			
		||||
 | 
			
		||||
## vacuum tubes
 | 
			
		||||
Radius=Rayon
 | 
			
		||||
Vacuuming Pneumatic Tube Segment=Segment de tuyau pneumatique aspirant
 | 
			
		||||
Adjustable Vacuuming Tube=Tuyau pneumatique aspirant réglable
 | 
			
		||||
Adjustable Vacuuming Pneumatic Tube Segment=Segment de tuyau pneumatique aspirant réglable
 | 
			
		||||
Adjustable Vacuuming Pneumatic Tube Segment (@1m)=Segment de tuyau pneumatique aspirant réglable (@1 m)
 | 
			
		||||
 | 
			
		||||
## wielder
 | 
			
		||||
Node Breaker=Casseur de blocs
 | 
			
		||||
Deployer=Poseur de blocs
 | 
			
		||||
Dispenser=Distributeur
 | 
			
		||||
							
								
								
									
										117
									
								
								locale/pipeworks.zh_CN.tr
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										117
									
								
								locale/pipeworks.zh_CN.tr
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,117 @@
 | 
			
		||||
# textdomain: pipeworks
 | 
			
		||||
# License: CC-by-SA 4.0
 | 
			
		||||
# Author: pevernow <3450354617@qq.com>
 | 
			
		||||
 | 
			
		||||
## generic interaction
 | 
			
		||||
Set=
 | 
			
		||||
Cancel=
 | 
			
		||||
 | 
			
		||||
## digilines interfacing
 | 
			
		||||
Channel=频道
 | 
			
		||||
 | 
			
		||||
## init
 | 
			
		||||
Allow splitting incoming stacks from tubes=允许从管道中拆分传入堆栈
 | 
			
		||||
 | 
			
		||||
## autocrafter
 | 
			
		||||
Unknown item=通道
 | 
			
		||||
unconfigured Autocrafter: unknown recipe=未配置的自动工作台: 未知配方
 | 
			
		||||
unconfigured Autocrafter=未配置的自动工作台
 | 
			
		||||
'@1' Autocrafter (@2)=自动工作台 '@1' (@2)
 | 
			
		||||
Save=保存
 | 
			
		||||
paused '@1' Autocrafter=暂停的自动工作台
 | 
			
		||||
Autocrafter=自动工作台
 | 
			
		||||
 | 
			
		||||
## compat-furnaces
 | 
			
		||||
Allow splitting incoming material (not fuel) stacks from tubes=允许从管子中分离进来的材料(不是燃料)堆
 | 
			
		||||
 | 
			
		||||
## decorative tubes
 | 
			
		||||
Airtight steelblock embedded tube=密封嵌入式铁块管道
 | 
			
		||||
Airtight panel embedded tube=密封嵌入式片状管道
 | 
			
		||||
 | 
			
		||||
## devices
 | 
			
		||||
Pump/Intake Module=泵/进气模块
 | 
			
		||||
Valve=阀门
 | 
			
		||||
Decorative grating=Decorative grating
 | 
			
		||||
Spigot outlet=龙头
 | 
			
		||||
Airtight Pipe entry/exit=密闭管进/出
 | 
			
		||||
Flow Sensor=流量传感器
 | 
			
		||||
Flow sensor (on)=流量传感器(上)
 | 
			
		||||
empty=空的
 | 
			
		||||
@1% full=满的@1 %
 | 
			
		||||
Expansion Tank (@1)=扩展水箱 (@1)
 | 
			
		||||
Fluid Storage Tank (@1)=储液罐 (@1)
 | 
			
		||||
Fountainhead=源泉
 | 
			
		||||
Straight-only Pipe=直管
 | 
			
		||||
## filter-injector
 | 
			
		||||
(slot #@1 next)=(下一个插槽 : #@1)
 | 
			
		||||
@1 Filter-Injector=@1取物器
 | 
			
		||||
Sequence slots by Priority=优先顺序排列
 | 
			
		||||
Sequence slots Randomly=随机排列时隙
 | 
			
		||||
Sequence slots by Rotation=旋转顺序槽
 | 
			
		||||
Exact match - off=完全匹配-关闭
 | 
			
		||||
Exact match - on=完全匹配-开启
 | 
			
		||||
Prefer item types:=偏好物品类型 :
 | 
			
		||||
Itemwise=逐项
 | 
			
		||||
Stackwise=堆叠方式
 | 
			
		||||
Digiline=Digiline
 | 
			
		||||
 | 
			
		||||
## legacy
 | 
			
		||||
Auto-Tap=自动轴阀
 | 
			
		||||
 | 
			
		||||
## pipes
 | 
			
		||||
Pipe Segment=管道
 | 
			
		||||
Pipe Segment (legacy)=管道(旧版)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## routing tubes
 | 
			
		||||
Pneumatic tube segment=普通管道
 | 
			
		||||
Broken Tube=断管
 | 
			
		||||
High Priority Tube Segment=高优先级管段
 | 
			
		||||
Accelerating Pneumatic Tube Segment=加速管道
 | 
			
		||||
Crossing Pneumatic Tube Segment=定向管道
 | 
			
		||||
One way tube=单向管
 | 
			
		||||
 | 
			
		||||
## signal tubes
 | 
			
		||||
Detecting Pneumatic Tube Segment on=检测管道(运行中)
 | 
			
		||||
Detecting Pneumatic Tube Segment=检测管道
 | 
			
		||||
Digiline Detecting Pneumatic Tube Segment=Digiline检测管道
 | 
			
		||||
Digiline Detecting Tube=Digiline检测管
 | 
			
		||||
Conducting Pneumatic Tube Segment=传导管道
 | 
			
		||||
Conducting Pneumatic Tube Segment on=传导管道(运行中)
 | 
			
		||||
Digiline Conducting Pneumatic Tube Segment=Digiline传导式气动管道
 | 
			
		||||
Mesecon and Digiline Conducting Pneumatic Tube Segment=Mesecon和Digiline传导管道
 | 
			
		||||
Mesecon and Digiline Conducting Pneumatic Tube Segment on=Mesecon和Digiline传导管道(运行中)
 | 
			
		||||
 | 
			
		||||
## sorting tubes
 | 
			
		||||
Sorting Pneumatic Tube Segment=分类管道
 | 
			
		||||
Sorting pneumatic tube=分类管道
 | 
			
		||||
 | 
			
		||||
## teleport tube
 | 
			
		||||
Receive=接收
 | 
			
		||||
Channels are public by default=频道默认为公开
 | 
			
		||||
Use <player>:<channel> for fully private channels=将<player>:<channel>用于完全私人的频道
 | 
			
		||||
Use <player>;<channel> for private receivers=使用<player>;<channel>作为私人接收器
 | 
			
		||||
Teleporting Pneumatic Tube Segment=传送管道
 | 
			
		||||
Teleporting Tube=
 | 
			
		||||
Unconfigured Teleportation Tube=未配置的传送管道
 | 
			
		||||
Sorry, channel '@1' is reserved for exclusive use by @2=抱歉,频道‘@1’保留供‘@2’专用
 | 
			
		||||
Sorry, receiving from channel '@1' is reserved for @2=抱歉,从频道'@1'接收的内容已保留给'@2'
 | 
			
		||||
Teleportation Tube @1 on '@2'=传送管'@1'在'@2'上
 | 
			
		||||
 | 
			
		||||
## trashcan
 | 
			
		||||
Trash Can=垃圾箱
 | 
			
		||||
 | 
			
		||||
## tube registration
 | 
			
		||||
Pneumatic tube segment (legacy)=普通管道(旧式)
 | 
			
		||||
 | 
			
		||||
## vacuum tubes
 | 
			
		||||
Radius=
 | 
			
		||||
Vacuuming Pneumatic Tube Segment=拾取管道
 | 
			
		||||
Adjustable Vacuuming Tube=
 | 
			
		||||
Adjustable Vacuuming Pneumatic Tube Segment=高级拾取管道
 | 
			
		||||
Adjustable Vacuuming Pneumatic Tube Segment (@1m)=高级拾取管道(@1m)
 | 
			
		||||
 | 
			
		||||
## wielder
 | 
			
		||||
Node Breaker=方块破坏器
 | 
			
		||||
Deployer=放置器
 | 
			
		||||
Dispenser=投掷器
 | 
			
		||||
							
								
								
									
										119
									
								
								locale/template.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										119
									
								
								locale/template.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,119 @@
 | 
			
		||||
# textdomain: pipeworks
 | 
			
		||||
 | 
			
		||||
# License: CC-by-SA 4.0
 | 
			
		||||
# Author:
 | 
			
		||||
 | 
			
		||||
## generic interaction
 | 
			
		||||
Set=
 | 
			
		||||
Cancel=
 | 
			
		||||
 | 
			
		||||
## digilines interfacing
 | 
			
		||||
Channel=
 | 
			
		||||
 | 
			
		||||
## init
 | 
			
		||||
Allow splitting incoming stacks from tubes=
 | 
			
		||||
 | 
			
		||||
## autocrafter
 | 
			
		||||
Unknown item=
 | 
			
		||||
unconfigured Autocrafter: unknown recipe=
 | 
			
		||||
unconfigured Autocrafter=
 | 
			
		||||
'@1' Autocrafter (@2)=
 | 
			
		||||
Save=
 | 
			
		||||
paused '@1' Autocrafter=
 | 
			
		||||
Autocrafter=
 | 
			
		||||
 | 
			
		||||
## compat-furnaces
 | 
			
		||||
Allow splitting incoming material (not fuel) stacks from tubes=
 | 
			
		||||
 | 
			
		||||
## decorative tubes
 | 
			
		||||
Airtight steelblock embedded tube=
 | 
			
		||||
Airtight panel embedded tube=
 | 
			
		||||
 | 
			
		||||
## devices
 | 
			
		||||
Pump/Intake Module=
 | 
			
		||||
Valve=
 | 
			
		||||
Decorative grating=
 | 
			
		||||
Spigot outlet=
 | 
			
		||||
Airtight Pipe entry/exit=
 | 
			
		||||
Flow Sensor=
 | 
			
		||||
Flow sensor (on)=
 | 
			
		||||
empty=
 | 
			
		||||
@1% full=
 | 
			
		||||
Expansion Tank (@1)=
 | 
			
		||||
Fluid Storage Tank (@1)=
 | 
			
		||||
Fountainhead=
 | 
			
		||||
Straight-only Pipe=
 | 
			
		||||
 | 
			
		||||
## filter-injector
 | 
			
		||||
(slot #@1 next)=
 | 
			
		||||
@1 Filter-Injector=
 | 
			
		||||
Sequence slots by Priority=
 | 
			
		||||
Sequence slots Randomly=
 | 
			
		||||
Sequence slots by Rotation=
 | 
			
		||||
Exact match - off=
 | 
			
		||||
Exact match - on=
 | 
			
		||||
Prefer item types:=
 | 
			
		||||
Itemwise=
 | 
			
		||||
Stackwise=
 | 
			
		||||
Digiline=
 | 
			
		||||
 | 
			
		||||
## legacy
 | 
			
		||||
Auto-Tap=
 | 
			
		||||
 | 
			
		||||
## pipes
 | 
			
		||||
Pipe Segment=
 | 
			
		||||
Pipe Segment (legacy)=
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## routing tubes
 | 
			
		||||
Pneumatic tube segment=
 | 
			
		||||
Broken Tube=
 | 
			
		||||
High Priority Tube Segment=
 | 
			
		||||
Accelerating Pneumatic Tube Segment=
 | 
			
		||||
Crossing Pneumatic Tube Segment=
 | 
			
		||||
One way tube=
 | 
			
		||||
 | 
			
		||||
## signal tubes
 | 
			
		||||
Detecting Pneumatic Tube Segment on=
 | 
			
		||||
Detecting Pneumatic Tube Segment=
 | 
			
		||||
Digiline Detecting Pneumatic Tube Segment=
 | 
			
		||||
Digiline Detecting Tube=
 | 
			
		||||
Conducting Pneumatic Tube Segment=
 | 
			
		||||
Conducting Pneumatic Tube Segment on=
 | 
			
		||||
Digiline Conducting Pneumatic Tube Segment=
 | 
			
		||||
Mesecon and Digiline Conducting Pneumatic Tube Segment=
 | 
			
		||||
Mesecon and Digiline Conducting Pneumatic Tube Segment on=
 | 
			
		||||
 | 
			
		||||
## sorting tubes
 | 
			
		||||
Sorting Pneumatic Tube Segment=
 | 
			
		||||
Sorting pneumatic tube=
 | 
			
		||||
 | 
			
		||||
## teleport tube
 | 
			
		||||
Receive=
 | 
			
		||||
Channels are public by default=
 | 
			
		||||
Use <player>:<channel> for fully private channels=
 | 
			
		||||
Use <player>;<channel> for private receivers=
 | 
			
		||||
Teleporting Pneumatic Tube Segment=
 | 
			
		||||
Teleporting Tube=
 | 
			
		||||
Unconfigured Teleportation Tube=
 | 
			
		||||
Sorry, channel '@1' is reserved for exclusive use by @2=
 | 
			
		||||
Sorry, receiving from channel '@1' is reserved for @2=
 | 
			
		||||
Teleportation Tube @1 on '@2'=
 | 
			
		||||
 | 
			
		||||
## trashcan
 | 
			
		||||
Trash Can=
 | 
			
		||||
 | 
			
		||||
## tube registration
 | 
			
		||||
Pneumatic tube segment (legacy)=
 | 
			
		||||
 | 
			
		||||
## vacuum tubes
 | 
			
		||||
Radius=
 | 
			
		||||
Vacuuming Pneumatic Tube Segment=
 | 
			
		||||
Adjustable Vacuuming Tube=
 | 
			
		||||
Adjustable Vacuuming Pneumatic Tube Segment=
 | 
			
		||||
Adjustable Vacuuming Pneumatic Tube Segment (@1m)=
 | 
			
		||||
 | 
			
		||||
## wielder
 | 
			
		||||
Node Breaker=
 | 
			
		||||
Deployer=
 | 
			
		||||
Dispenser=
 | 
			
		||||
							
								
								
									
										514
									
								
								lua_tube.lua
									
									
									
									
									
								
							
							
						
						
									
										514
									
								
								lua_tube.lua
									
									
									
									
									
								
							@@ -13,8 +13,10 @@
 | 
			
		||||
-- newport = merge_port_states(state1, state2): just does result = state1 or state2 for every port
 | 
			
		||||
-- set_port(pos, rule, state): activates/deactivates the mesecons according to the port states
 | 
			
		||||
-- set_port_states(pos, ports): Applies new port states to a Luacontroller at pos
 | 
			
		||||
-- run(pos): runs the code in the controller at pos
 | 
			
		||||
-- reset_meta(pos, code, errmsg): performs a software-reset, installs new code and prints error messages
 | 
			
		||||
-- run_inner(pos, code, event): runs code on the controller at pos and event
 | 
			
		||||
-- reset_formspec(pos, code, errmsg): installs new code and prints error messages, without resetting LCID
 | 
			
		||||
-- reset_meta(pos, code, errmsg): performs a software-reset, installs new code and prints error message
 | 
			
		||||
-- run(pos, event): a wrapper for run_inner which gets code & handles errors via reset_meta
 | 
			
		||||
-- resetn(pos): performs a hardware reset, turns off all ports
 | 
			
		||||
--
 | 
			
		||||
-- The Sandbox
 | 
			
		||||
@@ -24,7 +26,7 @@
 | 
			
		||||
-- use too much memory from the sandbox.
 | 
			
		||||
-- You can add more functions to the environment
 | 
			
		||||
-- (see where local env is defined)
 | 
			
		||||
-- Something nice to play is is appending minetest.env to it.
 | 
			
		||||
-- Something nice to play is appending minetest.env to it.
 | 
			
		||||
 | 
			
		||||
local BASENAME = "pipeworks:lua_tube"
 | 
			
		||||
 | 
			
		||||
@@ -37,6 +39,23 @@ local rules = {
 | 
			
		||||
	white  = {x =  0, y =  0, z =  1, name = "white"},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local digiline_rules_luatube = {
 | 
			
		||||
	{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},
 | 
			
		||||
	-- vertical connectivity
 | 
			
		||||
	{x=0,  y=1,  z=0},
 | 
			
		||||
	{x=0,  y=-1, z=0},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
------------------
 | 
			
		||||
-- Action stuff --
 | 
			
		||||
@@ -60,7 +79,7 @@ local function update_real_port_states(pos, rule_name, new_state)
 | 
			
		||||
	if rule_name.x == nil then
 | 
			
		||||
		for _, rname in ipairs(rule_name) do
 | 
			
		||||
			local port = pos_to_side[rname.x + (2 * rname.y) + (3 * rname.z) + 4]
 | 
			
		||||
			L[port] = (newstate == "on") and 1 or 0
 | 
			
		||||
			L[port] = (new_state == "on") and 1 or 0
 | 
			
		||||
		end
 | 
			
		||||
	else
 | 
			
		||||
		local port = pos_to_side[rule_name.x + (2 * rule_name.y) + (3 * rule_name.z) + 4]
 | 
			
		||||
@@ -151,7 +170,7 @@ local function set_port_states(pos, ports)
 | 
			
		||||
		-- Solution / Workaround:
 | 
			
		||||
		-- Remember which output was turned off and ignore next "off" event.
 | 
			
		||||
		local meta = minetest.get_meta(pos)
 | 
			
		||||
		local ign = minetest.deserialize(meta:get_string("ignore_offevents")) or {}
 | 
			
		||||
		local ign = minetest.deserialize(meta:get_string("ignore_offevents"), true) or {}
 | 
			
		||||
		if ports.red    and not vports.red    and not mesecon.is_powered(pos, rules.red)    then ign.red    = true end
 | 
			
		||||
		if ports.blue   and not vports.blue   and not mesecon.is_powered(pos, rules.blue)   then ign.blue   = true end
 | 
			
		||||
		if ports.yellow and not vports.yellow and not mesecon.is_powered(pos, rules.yellow) then ign.yellow = true end
 | 
			
		||||
@@ -197,7 +216,7 @@ end
 | 
			
		||||
 | 
			
		||||
local function ignore_event(event, meta)
 | 
			
		||||
	if event.type ~= "off" then return false end
 | 
			
		||||
	local ignore_offevents = minetest.deserialize(meta:get_string("ignore_offevents")) or {}
 | 
			
		||||
	local ignore_offevents = minetest.deserialize(meta:get_string("ignore_offevents"), true) or {}
 | 
			
		||||
	if ignore_offevents[event.pin.name] then
 | 
			
		||||
		ignore_offevents[event.pin.name] = nil
 | 
			
		||||
		meta:set_string("ignore_offevents", minetest.serialize(ignore_offevents))
 | 
			
		||||
@@ -210,7 +229,11 @@ end
 | 
			
		||||
-------------------------
 | 
			
		||||
 | 
			
		||||
local function safe_print(param)
 | 
			
		||||
	local string_meta = getmetatable("")
 | 
			
		||||
	local sandbox = string_meta.__index
 | 
			
		||||
	string_meta.__index = string -- Leave string sandbox temporarily
 | 
			
		||||
	print(dump(param))
 | 
			
		||||
	string_meta.__index = sandbox -- Restore string sandbox
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function safe_date()
 | 
			
		||||
@@ -250,6 +273,7 @@ local function remove_functions(x)
 | 
			
		||||
	local seen = {}
 | 
			
		||||
 | 
			
		||||
	local function rfuncs(x)
 | 
			
		||||
		if x == nil then return end
 | 
			
		||||
		if seen[x] then return end
 | 
			
		||||
		seen[x] = true
 | 
			
		||||
		if type(x) ~= "table" then return end
 | 
			
		||||
@@ -273,51 +297,179 @@ local function remove_functions(x)
 | 
			
		||||
	return x
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function get_interrupt(pos)
 | 
			
		||||
	-- iid = interrupt id
 | 
			
		||||
	local function interrupt(time, iid)
 | 
			
		||||
		if type(time) ~= "number" then return end
 | 
			
		||||
		local luac_id = minetest.get_meta(pos):get_int("luac_id")
 | 
			
		||||
		mesecon.queue:add_action(pos, "pipeworks:lc_tube_interrupt", {luac_id, iid}, time, iid, 1)
 | 
			
		||||
-- The setting affects API so is not intended to be changeable at runtime
 | 
			
		||||
local get_interrupt
 | 
			
		||||
if mesecon.setting("luacontroller_lightweight_interrupts", false) then
 | 
			
		||||
	-- use node timer
 | 
			
		||||
	get_interrupt = function(pos, itbl, send_warning)
 | 
			
		||||
		return (function(time, iid)
 | 
			
		||||
			if type(time) ~= "number" then error("Delay must be a number") end
 | 
			
		||||
			if iid ~= nil then send_warning("Interrupt IDs are disabled on this server") end
 | 
			
		||||
			table.insert(itbl, function() minetest.get_node_timer(pos):start(time) end)
 | 
			
		||||
		end)
 | 
			
		||||
	end
 | 
			
		||||
else
 | 
			
		||||
	-- use global action queue
 | 
			
		||||
	-- itbl: Flat table of functions to run after sandbox cleanup, used to prevent various security hazards
 | 
			
		||||
	get_interrupt = function(pos, itbl, send_warning)
 | 
			
		||||
		-- iid = interrupt id
 | 
			
		||||
		local function interrupt(time, iid)
 | 
			
		||||
			-- NOTE: This runs within string metatable sandbox, so don't *rely* on anything of the form (""):y
 | 
			
		||||
			-- Hence the values get moved out. Should take less time than original, so totally compatible
 | 
			
		||||
			if type(time) ~= "number" then error("Delay must be a number") end
 | 
			
		||||
			table.insert(itbl, function ()
 | 
			
		||||
				-- Outside string metatable sandbox, can safely run this now
 | 
			
		||||
				local luac_id = minetest.get_meta(pos):get_int("luac_id")
 | 
			
		||||
				-- Check if IID is dodgy, so you can't use interrupts to store an infinite amount of data.
 | 
			
		||||
				-- Note that this is safe from alter-after-free because this code gets run after the sandbox has ended.
 | 
			
		||||
				-- This runs outside of the timer and *shouldn't* harm perf. unless dodgy data is being sent in the first place
 | 
			
		||||
				iid = remove_functions(iid)
 | 
			
		||||
				local msg_ser = minetest.serialize(iid)
 | 
			
		||||
				if #msg_ser <= mesecon.setting("luacontroller_interruptid_maxlen", 256) then
 | 
			
		||||
					mesecon.queue:add_action(pos, "pipeworks:lc_tube_interrupt", {luac_id, iid}, time, iid, 1)
 | 
			
		||||
				else
 | 
			
		||||
					send_warning("An interrupt ID was too large!")
 | 
			
		||||
				end
 | 
			
		||||
			end)
 | 
			
		||||
		end
 | 
			
		||||
		return interrupt
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Given a message object passed to digiline_send, clean it up into a form
 | 
			
		||||
-- which is safe to transmit over the network and compute its "cost" (a very
 | 
			
		||||
-- rough estimate of its memory usage).
 | 
			
		||||
--
 | 
			
		||||
-- The cleaning comprises the following:
 | 
			
		||||
-- 1. Functions (and userdata, though user scripts ought not to get hold of
 | 
			
		||||
--    those in the first place) are removed, because they break the model of
 | 
			
		||||
--    Digilines as a network that carries basic data, and they could exfiltrate
 | 
			
		||||
--    references to mutable objects from one Luacontroller to another, allowing
 | 
			
		||||
--    inappropriate high-bandwidth, no-wires communication.
 | 
			
		||||
-- 2. Tables are duplicated because, being mutable, they could otherwise be
 | 
			
		||||
--    modified after the send is complete in order to change what data arrives
 | 
			
		||||
--    at the recipient, perhaps in violation of the previous cleaning rule or
 | 
			
		||||
--    in violation of the message size limit.
 | 
			
		||||
--
 | 
			
		||||
-- The cost indication is only approximate; it’s not a perfect measurement of
 | 
			
		||||
-- the number of bytes of memory used by the message object.
 | 
			
		||||
--
 | 
			
		||||
-- Parameters:
 | 
			
		||||
-- msg -- the message to clean
 | 
			
		||||
-- back_references -- for internal use only; do not provide
 | 
			
		||||
--
 | 
			
		||||
-- Returns:
 | 
			
		||||
-- 1. The cleaned object.
 | 
			
		||||
-- 2. The approximate cost of the object.
 | 
			
		||||
local function clean_and_weigh_digiline_message(msg, back_references)
 | 
			
		||||
	local t = type(msg)
 | 
			
		||||
	if t == "string" then
 | 
			
		||||
		-- Strings are immutable so can be passed by reference, and cost their
 | 
			
		||||
		-- length plus the size of the Lua object header (24 bytes on a 64-bit
 | 
			
		||||
		-- platform) plus one byte for the NUL terminator.
 | 
			
		||||
		return msg, #msg + 25
 | 
			
		||||
	elseif t == "number" then
 | 
			
		||||
		-- Numbers are passed by value so need not be touched, and cost 8 bytes
 | 
			
		||||
		-- as all numbers in Lua are doubles.
 | 
			
		||||
		return msg, 8
 | 
			
		||||
	elseif t == "boolean" then
 | 
			
		||||
		-- Booleans are passed by value so need not be touched, and cost 1
 | 
			
		||||
		-- byte.
 | 
			
		||||
		return msg, 1
 | 
			
		||||
	elseif t == "table" then
 | 
			
		||||
		-- Tables are duplicated. Check if this table has been seen before
 | 
			
		||||
		-- (self-referential or shared table); if so, reuse the cleaned value
 | 
			
		||||
		-- of the previous occurrence, maintaining table topology and avoiding
 | 
			
		||||
		-- infinite recursion, and charge zero bytes for this as the object has
 | 
			
		||||
		-- already been counted.
 | 
			
		||||
		back_references = back_references or {}
 | 
			
		||||
		local bref = back_references[msg]
 | 
			
		||||
		if bref then
 | 
			
		||||
			return bref, 0
 | 
			
		||||
		end
 | 
			
		||||
		-- Construct a new table by cleaning all the keys and values and adding
 | 
			
		||||
		-- up their costs, plus 8 bytes as a rough estimate of table overhead.
 | 
			
		||||
		local cost = 8
 | 
			
		||||
		local ret = {}
 | 
			
		||||
		back_references[msg] = ret
 | 
			
		||||
		for k, v in pairs(msg) do
 | 
			
		||||
			local k_cost, v_cost
 | 
			
		||||
			k, k_cost = clean_and_weigh_digiline_message(k, back_references)
 | 
			
		||||
			v, v_cost = clean_and_weigh_digiline_message(v, back_references)
 | 
			
		||||
			if k ~= nil and v ~= nil then
 | 
			
		||||
				-- Only include an element if its key and value are of legal
 | 
			
		||||
				-- types.
 | 
			
		||||
				ret[k] = v
 | 
			
		||||
			end
 | 
			
		||||
			-- If we only counted the cost of a table element when we actually
 | 
			
		||||
			-- used it, we would be vulnerable to the following attack:
 | 
			
		||||
			-- 1. Construct a huge table (too large to pass the cost limit).
 | 
			
		||||
			-- 2. Insert it somewhere in a table, with a function as a key.
 | 
			
		||||
			-- 3. Insert it somewhere in another table, with a number as a key.
 | 
			
		||||
			-- 4. The first occurrence doesn’t pay the cost because functions
 | 
			
		||||
			--    are stripped and therefore the element is dropped.
 | 
			
		||||
			-- 5. The second occurrence doesn’t pay the cost because it’s in
 | 
			
		||||
			--    back_references.
 | 
			
		||||
			-- By counting the costs regardless of whether the objects will be
 | 
			
		||||
			-- included, we avoid this attack; it may overestimate the cost of
 | 
			
		||||
			-- some messages, but only those that won’t be delivered intact
 | 
			
		||||
			-- anyway because they contain illegal object types.
 | 
			
		||||
			cost = cost + k_cost + v_cost
 | 
			
		||||
		end
 | 
			
		||||
		return ret, cost
 | 
			
		||||
	else
 | 
			
		||||
		return nil, 0
 | 
			
		||||
	end
 | 
			
		||||
	return interrupt
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
local function get_digiline_send(pos)
 | 
			
		||||
	if not digiline then return end
 | 
			
		||||
-- itbl: Flat table of functions to run after sandbox cleanup, used to prevent various security hazards
 | 
			
		||||
local function get_digiline_send(pos, itbl, send_warning)
 | 
			
		||||
	if not minetest.get_modpath("digilines") then return end
 | 
			
		||||
	local chan_maxlen = mesecon.setting("luacontroller_digiline_channel_maxlen", 256)
 | 
			
		||||
	local maxlen = mesecon.setting("luacontroller_digiline_maxlen", 50000)
 | 
			
		||||
	return function(channel, msg)
 | 
			
		||||
		-- NOTE: This runs within string metatable sandbox, so don't *rely* on anything of the form (""):y
 | 
			
		||||
		--        or via anything that could.
 | 
			
		||||
		-- Make sure channel is string, number or boolean
 | 
			
		||||
		if (type(channel) ~= "string" and type(channel) ~= "number" and type(channel) ~= "boolean") then
 | 
			
		||||
		if type(channel) == "string" then
 | 
			
		||||
			if #channel > chan_maxlen then
 | 
			
		||||
				send_warning("Channel string too long.")
 | 
			
		||||
				return false
 | 
			
		||||
			end
 | 
			
		||||
		elseif (type(channel) ~= "string" and type(channel) ~= "number" and type(channel) ~= "boolean") then
 | 
			
		||||
			send_warning("Channel must be string, number or boolean.")
 | 
			
		||||
			return false
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		-- It is technically possible to send functions over the wire since
 | 
			
		||||
		-- the high performance impact of stripping those from the data has
 | 
			
		||||
		-- been decided to not be worth the added realism.
 | 
			
		||||
		-- Make sure serialized version of the data is not insanely long to
 | 
			
		||||
		-- prevent DoS-like attacks
 | 
			
		||||
		local msg_ser = minetest.serialize(msg)
 | 
			
		||||
		if #msg_ser > mesecon.setting("luacontroller_digiline_maxlen", 50000) then
 | 
			
		||||
		local msg_cost
 | 
			
		||||
		msg, msg_cost = clean_and_weigh_digiline_message(msg)
 | 
			
		||||
		if msg == nil or msg_cost > maxlen then
 | 
			
		||||
			send_warning("Message was too complex, or contained invalid data.")
 | 
			
		||||
			return false
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		minetest.after(0, function()
 | 
			
		||||
			digilines.receptor_send(pos, digiline.rules.default, channel, msg)
 | 
			
		||||
		table.insert(itbl, function ()
 | 
			
		||||
			-- Runs outside of string metatable sandbox
 | 
			
		||||
			local luac_id = minetest.get_meta(pos):get_int("luac_id")
 | 
			
		||||
			mesecon.queue:add_action(pos, "pipeworks:lt_digiline_relay", {channel, luac_id, msg})
 | 
			
		||||
		end)
 | 
			
		||||
		return true
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
local safe_globals = {
 | 
			
		||||
	-- Don't add pcall/xpcall unless willing to deal with the consequences (unless very careful, incredibly likely to allow killing server indirectly)
 | 
			
		||||
	"assert", "error", "ipairs", "next", "pairs", "select",
 | 
			
		||||
	"tonumber", "tostring", "type", "unpack", "_VERSION"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local function create_environment(pos, mem, event)
 | 
			
		||||
	-- Gather variables for the environment
 | 
			
		||||
local function create_environment(pos, mem, event, itbl, send_warning)
 | 
			
		||||
	-- Make sure the tube hasn't broken.
 | 
			
		||||
	local vports = minetest.registered_nodes[minetest.get_node(pos).name].virtual_portstates
 | 
			
		||||
	if not vports then return {} end
 | 
			
		||||
 | 
			
		||||
	-- Gather variables for the environment
 | 
			
		||||
	local vports_copy = {}
 | 
			
		||||
	for k, v in pairs(vports) do vports_copy[k] = v end
 | 
			
		||||
	local rports = get_real_port_states(pos)
 | 
			
		||||
@@ -332,8 +484,8 @@ local function create_environment(pos, mem, event)
 | 
			
		||||
		heat = mesecon.get_heat(pos),
 | 
			
		||||
		heat_max = mesecon.setting("overheat_max", 20),
 | 
			
		||||
		print = safe_print,
 | 
			
		||||
		interrupt = get_interrupt(pos),
 | 
			
		||||
		digiline_send = get_digiline_send(pos),
 | 
			
		||||
		interrupt = get_interrupt(pos, itbl, send_warning),
 | 
			
		||||
		digiline_send = get_digiline_send(pos, itbl, send_warning),
 | 
			
		||||
		string = {
 | 
			
		||||
			byte = string.byte,
 | 
			
		||||
			char = string.char,
 | 
			
		||||
@@ -421,10 +573,11 @@ local function create_sandbox(code, env)
 | 
			
		||||
		jit.off(f, true)
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	local maxevents = mesecon.setting("luacontroller_maxevents", 10000)
 | 
			
		||||
	return function(...)
 | 
			
		||||
		-- NOTE: This runs within string metatable sandbox, so the setting's been moved out for safety
 | 
			
		||||
		-- Use instruction counter to stop execution
 | 
			
		||||
		-- after luacontroller_maxevents
 | 
			
		||||
		local maxevents = mesecon.setting("luacontroller_maxevents", 10000)
 | 
			
		||||
		debug.sethook(timeout, "", maxevents)
 | 
			
		||||
		local ok, ret = pcall(f, ...)
 | 
			
		||||
		debug.sethook()  -- Clear hook
 | 
			
		||||
@@ -435,7 +588,7 @@ end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
local function load_memory(meta)
 | 
			
		||||
	return minetest.deserialize(meta:get_string("lc_memory")) or {}
 | 
			
		||||
	return minetest.deserialize(meta:get_string("lc_memory"), true) or {}
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -445,6 +598,7 @@ local function save_memory(pos, meta, mem)
 | 
			
		||||
 | 
			
		||||
	if (#memstring <= memsize_max) then
 | 
			
		||||
		meta:set_string("lc_memory", memstring)
 | 
			
		||||
		meta:mark_as_private("lc_memory")
 | 
			
		||||
	else
 | 
			
		||||
		print("Error: lua_tube memory overflow. "..memsize_max.." bytes available, "
 | 
			
		||||
				..#memstring.." required. Controller overheats.")
 | 
			
		||||
@@ -452,26 +606,42 @@ local function save_memory(pos, meta, mem)
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
local function run(pos, event)
 | 
			
		||||
-- Returns success (boolean), errmsg (string), retval(any, return value of the user supplied code)
 | 
			
		||||
-- run (as opposed to run_inner) is responsible for setting up meta according to this output
 | 
			
		||||
local function run_inner(pos, code, event)
 | 
			
		||||
	local meta = minetest.get_meta(pos)
 | 
			
		||||
	if overheat(pos) then return end
 | 
			
		||||
	if ignore_event(event, meta) then return end
 | 
			
		||||
	-- Note: These return success, presumably to avoid changing LC ID.
 | 
			
		||||
	if overheat(pos) then return true, "", nil end
 | 
			
		||||
	if ignore_event(event, meta) then return true, "", nil end
 | 
			
		||||
 | 
			
		||||
	-- Load code & mem from meta
 | 
			
		||||
	local mem  = load_memory(meta)
 | 
			
		||||
	local code = meta:get_string("code")
 | 
			
		||||
 | 
			
		||||
	-- 'Last warning' label.
 | 
			
		||||
	local warning = ""
 | 
			
		||||
	local function send_warning(str)
 | 
			
		||||
		warning = "Warning: " .. str
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	-- Create environment
 | 
			
		||||
	local env = create_environment(pos, mem, event)
 | 
			
		||||
	local itbl = {}
 | 
			
		||||
	local env = create_environment(pos, mem, event, itbl, send_warning)
 | 
			
		||||
 | 
			
		||||
	-- Create the sandbox and execute code
 | 
			
		||||
	local f, msg = create_sandbox(code, env)
 | 
			
		||||
	if not f then return false, msg end
 | 
			
		||||
	local succ, msg = pcall(f)
 | 
			
		||||
	if not succ then return false, msg end
 | 
			
		||||
	if not f then return false, msg, nil end
 | 
			
		||||
	-- Start string true sandboxing
 | 
			
		||||
	local onetruestring = getmetatable("")
 | 
			
		||||
	-- If a string sandbox is already up yet inconsistent, something is very wrong
 | 
			
		||||
	assert(onetruestring.__index == string)
 | 
			
		||||
	onetruestring.__index = env.string
 | 
			
		||||
	local success, msg = pcall(f)
 | 
			
		||||
	onetruestring.__index = string
 | 
			
		||||
	-- End string true sandboxing
 | 
			
		||||
	if not success then return false, msg, nil end
 | 
			
		||||
	if type(env.port) ~= "table" then
 | 
			
		||||
		return false, "Ports set are invalid."
 | 
			
		||||
		return false, "Ports set are invalid.", nil
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	-- Actually set the ports
 | 
			
		||||
@@ -480,35 +650,82 @@ local function run(pos, event)
 | 
			
		||||
	-- Save memory. This may burn the luacontroller if a memory overflow occurs.
 | 
			
		||||
	save_memory(pos, meta, env.mem)
 | 
			
		||||
 | 
			
		||||
	return succ, msg
 | 
			
		||||
	-- Execute deferred tasks
 | 
			
		||||
	for _, v in ipairs(itbl) do
 | 
			
		||||
		local failure = v()
 | 
			
		||||
		if failure then
 | 
			
		||||
			return false, failure, nil
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
	return true, warning, msg
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
mesecon.queue:add_function("pipeworks:lc_tube_interrupt", function (pos, luac_id, iid)
 | 
			
		||||
	-- There is no lua_tube anymore / it has been reprogrammed / replaced / burnt
 | 
			
		||||
	if (minetest.get_meta(pos):get_int("luac_id") ~= luac_id) then return end
 | 
			
		||||
	if (minetest.registered_nodes[minetest.get_node(pos).name].is_burnt) then return end
 | 
			
		||||
	run(pos, {type = "interrupt", iid = iid})
 | 
			
		||||
end)
 | 
			
		||||
local function reset_formspec(meta, code, errmsg)
 | 
			
		||||
	meta:set_string("code", code)
 | 
			
		||||
	meta:mark_as_private("code")
 | 
			
		||||
	code = minetest.formspec_escape(code or "")
 | 
			
		||||
	errmsg = minetest.formspec_escape(tostring(errmsg or ""))
 | 
			
		||||
	meta:set_string("formspec", "size[12,10]"
 | 
			
		||||
		.."style_type[label,textarea;font=mono]"
 | 
			
		||||
		.."background[-0.2,-0.25;12.4,10.75;jeija_luac_background.png]"
 | 
			
		||||
		.."label[0.1,8.3;"..errmsg.."]"
 | 
			
		||||
		.."textarea[0.2,0.2;12.2,9.5;code;;"..code.."]"
 | 
			
		||||
		.."image_button[4.75,8.75;2.5,1;jeija_luac_runbutton.png;program;]"
 | 
			
		||||
		.."image_button_exit[11.72,-0.25;0.425,0.4;jeija_close_window.png;exit;]"
 | 
			
		||||
		)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function reset_meta(pos, code, errmsg)
 | 
			
		||||
	local meta = minetest.get_meta(pos)
 | 
			
		||||
	meta:set_string("code", code)
 | 
			
		||||
	code = minetest.formspec_escape(code or "")
 | 
			
		||||
	errmsg = minetest.formspec_escape(tostring(errmsg or ""))
 | 
			
		||||
	meta:set_string("formspec", "size[12,10]"..
 | 
			
		||||
		"background[-0.2,-0.25;12.4,10.75;jeija_luac_background.png]"..
 | 
			
		||||
		"textarea[0.2,0.2;12.2,9.5;code;;"..code.."]"..
 | 
			
		||||
		"image_button[4.75,8.75;2.5,1;jeija_luac_runbutton.png;program;]"..
 | 
			
		||||
		"image_button_exit[11.72,-0.25;0.425,0.4;jeija_close_window.png;exit;]"..
 | 
			
		||||
		"label[0.1,9;"..errmsg.."]")
 | 
			
		||||
	reset_formspec(meta, code, errmsg)
 | 
			
		||||
	meta:set_int("luac_id", math.random(1, 65535))
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Wraps run_inner with LC-reset-on-error
 | 
			
		||||
local function run(pos, event)
 | 
			
		||||
	local meta = minetest.get_meta(pos)
 | 
			
		||||
	local code = meta:get_string("code")
 | 
			
		||||
	local ok, errmsg, retval = run_inner(pos, code, event)
 | 
			
		||||
	if not ok then
 | 
			
		||||
		reset_meta(pos, code, errmsg)
 | 
			
		||||
	else
 | 
			
		||||
		reset_formspec(meta, code, errmsg)
 | 
			
		||||
	end
 | 
			
		||||
	return ok, errmsg, retval
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function reset(pos)
 | 
			
		||||
	set_port_states(pos, {red = false, blue = false, yellow = false,
 | 
			
		||||
		green = false, black = false, white = false})
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function node_timer(pos)
 | 
			
		||||
	if minetest.registered_nodes[minetest.get_node(pos).name].is_burnt then
 | 
			
		||||
		return false
 | 
			
		||||
	end
 | 
			
		||||
	run(pos, {type="interrupt"})
 | 
			
		||||
	return false
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-----------------------
 | 
			
		||||
-- A.Queue callbacks --
 | 
			
		||||
-----------------------
 | 
			
		||||
 | 
			
		||||
mesecon.queue:add_function("pipeworks:lc_tube_interrupt", function (pos, luac_id, iid)
 | 
			
		||||
	-- There is no lua_tube anymore / it has been reprogrammed / replaced / burnt
 | 
			
		||||
	if (minetest.get_meta(pos):get_int("luac_id") ~= luac_id) then return end
 | 
			
		||||
	if (minetest.registered_nodes[minetest.get_node(pos).name].is_burnt) then return end
 | 
			
		||||
	run(pos, {type="interrupt", iid = iid})
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
mesecon.queue:add_function("pipeworks:lt_digiline_relay", function (pos, channel, luac_id, msg)
 | 
			
		||||
	if not digiline then return end
 | 
			
		||||
	-- This check is only really necessary because in case of server crash, old actions can be thrown into the future
 | 
			
		||||
	if (minetest.get_meta(pos):get_int("luac_id") ~= luac_id) then return end
 | 
			
		||||
	if (minetest.registered_nodes[minetest.get_node(pos).name].is_burnt) then return end
 | 
			
		||||
	-- The actual work
 | 
			
		||||
	digiline:receptor_send(pos, digiline_rules_luatube, channel, msg)
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
-----------------------
 | 
			
		||||
-- Node Registration --
 | 
			
		||||
@@ -538,10 +755,26 @@ local digiline = {
 | 
			
		||||
	receptor = {},
 | 
			
		||||
	effector = {
 | 
			
		||||
		action = function(pos, node, channel, msg)
 | 
			
		||||
			msg = clean_and_weigh_digiline_message(msg)
 | 
			
		||||
			run(pos, {type = "digiline", channel = channel, msg = msg})
 | 
			
		||||
		end
 | 
			
		||||
	}
 | 
			
		||||
	},
 | 
			
		||||
	wire = {
 | 
			
		||||
		rules = pipeworks.digilines_rules
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local function get_program(pos)
 | 
			
		||||
	local meta = minetest.get_meta(pos)
 | 
			
		||||
	return meta:get_string("code")
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function set_program(pos, code)
 | 
			
		||||
	reset(pos)
 | 
			
		||||
	reset_meta(pos, code)
 | 
			
		||||
	return run(pos, {type="program"})
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function on_receive_fields(pos, form_name, fields, sender)
 | 
			
		||||
	if not fields.program then
 | 
			
		||||
		return
 | 
			
		||||
@@ -551,12 +784,10 @@ local function on_receive_fields(pos, form_name, fields, sender)
 | 
			
		||||
		minetest.record_protection_violation(pos, name)
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
	reset(pos)
 | 
			
		||||
	reset_meta(pos, fields.code)
 | 
			
		||||
	local succ, err = run(pos, {type="program"})
 | 
			
		||||
	if not succ then
 | 
			
		||||
		print(err)
 | 
			
		||||
		reset_meta(pos, fields.code, err)
 | 
			
		||||
	local ok, err = set_program(pos, fields.code)
 | 
			
		||||
	if not ok then
 | 
			
		||||
		-- it's not an error from the server perspective
 | 
			
		||||
		minetest.log("action", "Lua controller programming error: " .. tostring(err))
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@@ -583,84 +814,58 @@ local tiles_base = {
 | 
			
		||||
	"pipeworks_mese_tube_plain_2.png", "pipeworks_mese_tube_plain_1.png",
 | 
			
		||||
	"pipeworks_mese_tube_plain_6.png", "pipeworks_mese_tube_plain_5.png"}
 | 
			
		||||
 | 
			
		||||
local tiles_on_off = {
 | 
			
		||||
	R__0   = "^pipeworks_lua_tube_port_%s.png",
 | 
			
		||||
	R_90  = "^(pipeworks_lua_tube_port_%s.png^[transformR90)",
 | 
			
		||||
	R180 = "^(pipeworks_lua_tube_port_%s.png^[transformR180)",
 | 
			
		||||
	R270 = "^(pipeworks_lua_tube_port_%s.png^[transformR270)"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local texture_alpha_mode = minetest.features.use_texture_alpha_string_modes
 | 
			
		||||
	and "clip" or true
 | 
			
		||||
 | 
			
		||||
for red    = 0, 1 do -- 0 = off  1 = on
 | 
			
		||||
for blue   = 0, 1 do
 | 
			
		||||
for yellow = 0, 1 do
 | 
			
		||||
for green  = 0, 1 do
 | 
			
		||||
for black  = 0, 1 do
 | 
			
		||||
for white  = 0, 1 do
 | 
			
		||||
	local cid = tostring(white)..tostring(black)..tostring(green)..
 | 
			
		||||
			tostring(yellow)..tostring(blue)..tostring(red)
 | 
			
		||||
	local cid = white..black..green..yellow..blue..red
 | 
			
		||||
	local node_name = BASENAME..cid
 | 
			
		||||
	local tiles = table.copy(tiles_base)
 | 
			
		||||
	if red == 1 then
 | 
			
		||||
		tiles[1] = tiles[1].."^(pipeworks_lua_tube_port_on.png^[transformR90)"
 | 
			
		||||
		tiles[2] = tiles[2].."^(pipeworks_lua_tube_port_on.png^[transformR90)"
 | 
			
		||||
		tiles[5] = tiles[5].."^(pipeworks_lua_tube_port_on.png^[transformR270)"
 | 
			
		||||
		tiles[6] = tiles[6].."^(pipeworks_lua_tube_port_on.png^[transformR90)"
 | 
			
		||||
	else
 | 
			
		||||
		tiles[1] = tiles[1].."^(pipeworks_lua_tube_port_off.png^[transformR90)"
 | 
			
		||||
		tiles[2] = tiles[2].."^(pipeworks_lua_tube_port_off.png^[transformR90)"
 | 
			
		||||
		tiles[5] = tiles[5].."^(pipeworks_lua_tube_port_off.png^[transformR270)"
 | 
			
		||||
		tiles[6] = tiles[6].."^(pipeworks_lua_tube_port_off.png^[transformR90)"
 | 
			
		||||
	end
 | 
			
		||||
	if blue == 1 then
 | 
			
		||||
		tiles[1] = tiles[1].."^(pipeworks_lua_tube_port_on.png^[transformR270)"
 | 
			
		||||
		tiles[2] = tiles[2].."^(pipeworks_lua_tube_port_on.png^[transformR270)"
 | 
			
		||||
		tiles[5] = tiles[5].."^(pipeworks_lua_tube_port_on.png^[transformR90)"
 | 
			
		||||
		tiles[6] = tiles[6].."^(pipeworks_lua_tube_port_on.png^[transformR270)"
 | 
			
		||||
	else
 | 
			
		||||
		tiles[1] = tiles[1].."^(pipeworks_lua_tube_port_off.png^[transformR270)"
 | 
			
		||||
		tiles[2] = tiles[2].."^(pipeworks_lua_tube_port_off.png^[transformR270)"
 | 
			
		||||
		tiles[5] = tiles[5].."^(pipeworks_lua_tube_port_off.png^[transformR90)"
 | 
			
		||||
		tiles[6] = tiles[6].."^(pipeworks_lua_tube_port_off.png^[transformR270)"
 | 
			
		||||
	end
 | 
			
		||||
	if yellow == 1 then
 | 
			
		||||
		tiles[3] = tiles[3].."^(pipeworks_lua_tube_port_on.png^[transformR180)"
 | 
			
		||||
		tiles[4] = tiles[4].."^(pipeworks_lua_tube_port_on.png^[transformR180)"
 | 
			
		||||
		tiles[5] = tiles[5].."^(pipeworks_lua_tube_port_on.png^[transformR180)"
 | 
			
		||||
		tiles[6] = tiles[6].."^(pipeworks_lua_tube_port_on.png^[transformR180)"
 | 
			
		||||
	else
 | 
			
		||||
		tiles[3] = tiles[3].."^(pipeworks_lua_tube_port_off.png^[transformR180)"
 | 
			
		||||
		tiles[4] = tiles[4].."^(pipeworks_lua_tube_port_off.png^[transformR180)"
 | 
			
		||||
		tiles[5] = tiles[5].."^(pipeworks_lua_tube_port_off.png^[transformR180)"
 | 
			
		||||
		tiles[6] = tiles[6].."^(pipeworks_lua_tube_port_off.png^[transformR180)"
 | 
			
		||||
	end
 | 
			
		||||
	if green == 1 then
 | 
			
		||||
		tiles[3] = tiles[3].."^pipeworks_lua_tube_port_on.png"
 | 
			
		||||
		tiles[4] = tiles[4].."^pipeworks_lua_tube_port_on.png"
 | 
			
		||||
		tiles[5] = tiles[5].."^pipeworks_lua_tube_port_on.png"
 | 
			
		||||
		tiles[6] = tiles[6].."^pipeworks_lua_tube_port_on.png"
 | 
			
		||||
	else
 | 
			
		||||
		tiles[3] = tiles[3].."^pipeworks_lua_tube_port_off.png"
 | 
			
		||||
		tiles[4] = tiles[4].."^pipeworks_lua_tube_port_off.png"
 | 
			
		||||
		tiles[5] = tiles[5].."^pipeworks_lua_tube_port_off.png"
 | 
			
		||||
		tiles[6] = tiles[6].."^pipeworks_lua_tube_port_off.png"
 | 
			
		||||
	end
 | 
			
		||||
	if black == 1 then
 | 
			
		||||
		tiles[1] = tiles[1].."^(pipeworks_lua_tube_port_on.png^[transformR180)"
 | 
			
		||||
		tiles[2] = tiles[2].."^pipeworks_lua_tube_port_on.png"
 | 
			
		||||
		tiles[3] = tiles[3].."^(pipeworks_lua_tube_port_on.png^[transformR90)"
 | 
			
		||||
		tiles[4] = tiles[4].."^(pipeworks_lua_tube_port_on.png^[transformR270)"
 | 
			
		||||
	else
 | 
			
		||||
		tiles[1] = tiles[1].."^(pipeworks_lua_tube_port_off.png^[transformR180)"
 | 
			
		||||
		tiles[2] = tiles[2].."^pipeworks_lua_tube_port_off.png"
 | 
			
		||||
		tiles[3] = tiles[3].."^(pipeworks_lua_tube_port_off.png^[transformR90)"
 | 
			
		||||
		tiles[4] = tiles[4].."^(pipeworks_lua_tube_port_off.png^[transformR270)"
 | 
			
		||||
	end
 | 
			
		||||
	if white == 1 then
 | 
			
		||||
		tiles[1] = tiles[1].."^pipeworks_lua_tube_port_on.png"
 | 
			
		||||
		tiles[2] = tiles[2].."^(pipeworks_lua_tube_port_on.png^[transformR180)"
 | 
			
		||||
		tiles[3] = tiles[3].."^(pipeworks_lua_tube_port_on.png^[transformR270)"
 | 
			
		||||
		tiles[4] = tiles[4].."^(pipeworks_lua_tube_port_on.png^[transformR90)"
 | 
			
		||||
	else
 | 
			
		||||
		tiles[1] = tiles[1].."^pipeworks_lua_tube_port_off.png"
 | 
			
		||||
		tiles[2] = tiles[2].."^(pipeworks_lua_tube_port_off.png^[transformR180)"
 | 
			
		||||
		tiles[3] = tiles[3].."^(pipeworks_lua_tube_port_off.png^[transformR270)"
 | 
			
		||||
		tiles[4] = tiles[4].."^(pipeworks_lua_tube_port_off.png^[transformR90)"
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	local groups = {snappy = 3, tube = 1, tubedevice = 1, overheat = 1}
 | 
			
		||||
	local tiles = table.copy(tiles_base)
 | 
			
		||||
	-- Red
 | 
			
		||||
	tiles[1] = tiles[1]..tiles_on_off.R_90:format(red == 1 and "on" or "off");
 | 
			
		||||
	tiles[2] = tiles[2]..tiles_on_off.R_90:format(red == 1 and "on" or "off");
 | 
			
		||||
	tiles[5] = tiles[5]..tiles_on_off.R270:format(red == 1 and "on" or "off");
 | 
			
		||||
	tiles[6] = tiles[6]..tiles_on_off.R_90:format(red == 1 and "on" or "off");
 | 
			
		||||
	-- Blue
 | 
			
		||||
	tiles[1] = tiles[1]..tiles_on_off.R270:format(blue == 1 and "on" or "off");
 | 
			
		||||
	tiles[2] = tiles[2]..tiles_on_off.R270:format(blue == 1 and "on" or "off");
 | 
			
		||||
	tiles[5] = tiles[5]..tiles_on_off.R_90:format(blue == 1 and "on" or "off");
 | 
			
		||||
	tiles[6] = tiles[6]..tiles_on_off.R270:format(blue == 1 and "on" or "off");
 | 
			
		||||
	-- Yellow
 | 
			
		||||
	tiles[1] = tiles[1]..tiles_on_off.R180:format(yellow == 1 and "on" or "off");
 | 
			
		||||
	tiles[2] = tiles[2]..tiles_on_off.R180:format(yellow == 1 and "on" or "off");
 | 
			
		||||
	tiles[5] = tiles[5]..tiles_on_off.R180:format(yellow == 1 and "on" or "off");
 | 
			
		||||
	tiles[6] = tiles[6]..tiles_on_off.R180:format(yellow == 1 and "on" or "off");
 | 
			
		||||
	-- Green
 | 
			
		||||
	tiles[3] = tiles[3]..tiles_on_off.R__0:format(green == 1 and "on" or "off");
 | 
			
		||||
	tiles[4] = tiles[4]..tiles_on_off.R__0:format(green == 1 and "on" or "off");
 | 
			
		||||
	tiles[5] = tiles[5]..tiles_on_off.R__0:format(green == 1 and "on" or "off");
 | 
			
		||||
	tiles[6] = tiles[6]..tiles_on_off.R__0:format(green == 1 and "on" or "off");
 | 
			
		||||
	-- Black
 | 
			
		||||
	tiles[1] = tiles[1]..tiles_on_off.R180:format(black == 1 and "on" or "off");
 | 
			
		||||
	tiles[2] = tiles[2]..tiles_on_off.R__0:format(black == 1 and "on" or "off");
 | 
			
		||||
	tiles[3] = tiles[3]..tiles_on_off.R_90:format(black == 1 and "on" or "off");
 | 
			
		||||
	tiles[4] = tiles[4]..tiles_on_off.R270:format(black == 1 and "on" or "off");
 | 
			
		||||
	-- White
 | 
			
		||||
	tiles[1] = tiles[1]..tiles_on_off.R__0:format(white == 1 and "on" or "off");
 | 
			
		||||
	tiles[2] = tiles[2]..tiles_on_off.R180:format(white == 1 and "on" or "off");
 | 
			
		||||
	tiles[3] = tiles[3]..tiles_on_off.R270:format(white == 1 and "on" or "off");
 | 
			
		||||
	tiles[4] = tiles[4]..tiles_on_off.R_90:format(white == 1 and "on" or "off");
 | 
			
		||||
 | 
			
		||||
	local groups = {snappy = 3, tube = 1, tubedevice = 1, overheat = 1, dig_generic = 4, axey=1, handy=1, pickaxey=1}
 | 
			
		||||
	if red + blue + yellow + green + black + white ~= 0 then
 | 
			
		||||
		groups.not_in_creative_inventory = 1
 | 
			
		||||
	end
 | 
			
		||||
@@ -692,22 +897,31 @@ for white  = 0, 1 do
 | 
			
		||||
		receptor = {
 | 
			
		||||
			state = mesecon.state.on,
 | 
			
		||||
			rules = output_rules[cid]
 | 
			
		||||
		}
 | 
			
		||||
		},
 | 
			
		||||
		luacontroller = {
 | 
			
		||||
			get_program = get_program,
 | 
			
		||||
			set_program = set_program,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	minetest.register_node(node_name, {
 | 
			
		||||
		description = "Lua controlled Tube",
 | 
			
		||||
		drawtype = "nodebox",
 | 
			
		||||
		tiles = tiles,
 | 
			
		||||
		use_texture_alpha = texture_alpha_mode,
 | 
			
		||||
		paramtype = "light",
 | 
			
		||||
		is_ground_content = false,
 | 
			
		||||
		groups = groups,
 | 
			
		||||
		_mcl_hardness=0.8,
 | 
			
		||||
		drop = BASENAME.."000000",
 | 
			
		||||
		sunlight_propagates = true,
 | 
			
		||||
		selection_box = selection_box,
 | 
			
		||||
		node_box = node_box,
 | 
			
		||||
		on_construct = reset_meta,
 | 
			
		||||
		on_receive_fields = on_receive_fields,
 | 
			
		||||
		sounds = default.node_sound_wood_defaults(),
 | 
			
		||||
		_sound_def = {
 | 
			
		||||
			key = "node_sound_wood_defaults",
 | 
			
		||||
		},
 | 
			
		||||
		mesecons = mesecons,
 | 
			
		||||
		digiline = digiline,
 | 
			
		||||
		-- Virtual portstates are the ports that
 | 
			
		||||
@@ -726,6 +940,7 @@ for white  = 0, 1 do
 | 
			
		||||
			pipeworks.after_dig(pos, node)
 | 
			
		||||
		end,
 | 
			
		||||
		is_luacontroller = true,
 | 
			
		||||
		on_timer = node_timer,
 | 
			
		||||
		tubelike = 1,
 | 
			
		||||
		tube = {
 | 
			
		||||
			connect_sides = {front = 1, back = 1, left = 1, right = 1, top = 1, bottom = 1},
 | 
			
		||||
@@ -733,13 +948,13 @@ for white  = 0, 1 do
 | 
			
		||||
			can_go = function(pos, node, velocity, stack)
 | 
			
		||||
				local src = {name = nil}
 | 
			
		||||
				-- add color of the incoming tube explicitly; referring to rules, in case they change later
 | 
			
		||||
				for color, rule in pairs(rules) do
 | 
			
		||||
				for _, rule in pairs(rules) do
 | 
			
		||||
					if (-velocity.x == rule.x and -velocity.y == rule.y and -velocity.z == rule.z) then
 | 
			
		||||
						src.name = rule.name
 | 
			
		||||
						break
 | 
			
		||||
					end
 | 
			
		||||
				end
 | 
			
		||||
				local succ, msg = run(pos, {
 | 
			
		||||
				local succ, _, msg = run(pos, {
 | 
			
		||||
					type = "item",
 | 
			
		||||
					pin = src,
 | 
			
		||||
					itemstring = stack:to_string(),
 | 
			
		||||
@@ -757,15 +972,7 @@ for white  = 0, 1 do
 | 
			
		||||
		on_blast = function(pos, intensity)
 | 
			
		||||
			if not intensity or intensity > 1 + 3^0.5 then
 | 
			
		||||
				minetest.remove_node(pos)
 | 
			
		||||
				return {string.format("%s_%s", name, dropname)}
 | 
			
		||||
			end
 | 
			
		||||
			minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
 | 
			
		||||
			pipeworks.scan_for_tube_objects(pos)
 | 
			
		||||
		end,
 | 
			
		||||
		on_blast = function(pos, intensity)
 | 
			
		||||
			if not intensity or intensity > 1 + 3^0.5 then
 | 
			
		||||
				minetest.remove_node(pos)
 | 
			
		||||
				return {string.format("%s_%s", name, dropname)}
 | 
			
		||||
				return
 | 
			
		||||
			end
 | 
			
		||||
			minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
 | 
			
		||||
			pipeworks.scan_for_tube_objects(pos)
 | 
			
		||||
@@ -778,6 +985,8 @@ end
 | 
			
		||||
end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = BASENAME.."000000"
 | 
			
		||||
 | 
			
		||||
------------------------------------
 | 
			
		||||
-- Overheated Lua controlled Tube --
 | 
			
		||||
------------------------------------
 | 
			
		||||
@@ -811,16 +1020,21 @@ tiles_burnt[4] = tiles_burnt[4].."^(pipeworks_lua_tube_port_burnt.png^[transform
 | 
			
		||||
minetest.register_node(BASENAME .. "_burnt", {
 | 
			
		||||
	drawtype = "nodebox",
 | 
			
		||||
	tiles = tiles_burnt,
 | 
			
		||||
	use_texture_alpha = texture_alpha_mode,
 | 
			
		||||
	is_burnt = true,
 | 
			
		||||
	paramtype = "light",
 | 
			
		||||
	groups = {snappy = 3, tube = 1, tubedevice = 1, not_in_creative_inventory=1},
 | 
			
		||||
	is_ground_content = false,
 | 
			
		||||
	groups = {snappy = 3, tube = 1, tubedevice = 1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
 | 
			
		||||
	_mcl_hardness=0.8,
 | 
			
		||||
	drop = BASENAME.."000000",
 | 
			
		||||
	sunlight_propagates = true,
 | 
			
		||||
	selection_box = selection_box,
 | 
			
		||||
	node_box = node_box,
 | 
			
		||||
	on_construct = reset_meta,
 | 
			
		||||
	on_receive_fields = on_receive_fields,
 | 
			
		||||
	sounds = default.node_sound_wood_defaults(),
 | 
			
		||||
	_sound_def = {
 | 
			
		||||
        key = "node_sound_wood_defaults",
 | 
			
		||||
    },
 | 
			
		||||
	virtual_portstates = {red = false, blue = false, yellow = false,
 | 
			
		||||
		green = false, black = false, white = false},
 | 
			
		||||
	mesecons = {
 | 
			
		||||
@@ -841,7 +1055,7 @@ minetest.register_node(BASENAME .. "_burnt", {
 | 
			
		||||
	on_blast = function(pos, intensity)
 | 
			
		||||
		if not intensity or intensity > 1 + 3^0.5 then
 | 
			
		||||
			minetest.remove_node(pos)
 | 
			
		||||
			return {string.format("%s_%s", name, dropname)}
 | 
			
		||||
			return
 | 
			
		||||
		end
 | 
			
		||||
		minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
 | 
			
		||||
		pipeworks.scan_for_tube_objects(pos)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										121
									
								
								luaentity.lua
									
									
									
									
									
								
							
							
						
						
									
										121
									
								
								luaentity.lua
									
									
									
									
									
								
							@@ -9,16 +9,16 @@ local filename = minetest.get_worldpath().."/luaentities"
 | 
			
		||||
local function read_file()
 | 
			
		||||
	local f = io.open(filename, "r")
 | 
			
		||||
	if f == nil then return {} end
 | 
			
		||||
    	local t = f:read("*all")
 | 
			
		||||
    	f:close()
 | 
			
		||||
	local t = f:read("*all")
 | 
			
		||||
	f:close()
 | 
			
		||||
	if t == "" or t == nil then return {} end
 | 
			
		||||
	return minetest.deserialize(t) or {}
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function write_file(tbl)
 | 
			
		||||
	local f = io.open(filename, "w")
 | 
			
		||||
    	f:write(minetest.serialize(tbl))
 | 
			
		||||
    	f:close()
 | 
			
		||||
	f:write(minetest.serialize(tbl))
 | 
			
		||||
	f:close()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function read_entities()
 | 
			
		||||
@@ -36,7 +36,7 @@ local function read_entities()
 | 
			
		||||
		y=math.min(30927,y)
 | 
			
		||||
		z=math.min(30927,z)
 | 
			
		||||
 | 
			
		||||
		entity.start_pos.x = x                 
 | 
			
		||||
		entity.start_pos.x = x
 | 
			
		||||
		entity.start_pos.y = y
 | 
			
		||||
		entity.start_pos.z = z
 | 
			
		||||
 | 
			
		||||
@@ -46,6 +46,11 @@ local function read_entities()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function write_entities()
 | 
			
		||||
	if not luaentity.entities then
 | 
			
		||||
		-- This can happen if crashing on startup, causing another error that
 | 
			
		||||
		-- masks the original one. Return gracefully in that case instead.
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
	for _, entity in pairs(luaentity.entities) do
 | 
			
		||||
		setmetatable(entity, nil)
 | 
			
		||||
		for _, attached in pairs(entity._attached_entities) do
 | 
			
		||||
@@ -68,31 +73,43 @@ local function get_blockpos(pos)
 | 
			
		||||
	        z = math.floor(pos.z / 16)}
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local active_blocks = {} -- These only contain active blocks near players (i.e., not forceloaded ones)
 | 
			
		||||
local move_entities_globalstep_part1
 | 
			
		||||
local is_active
 | 
			
		||||
 | 
			
		||||
local move_entities_globalstep_part1 = function(dtime)
 | 
			
		||||
	local active_block_range = tonumber(minetest.settings:get("active_block_range")) or 2
 | 
			
		||||
	local new_active_blocks = {}
 | 
			
		||||
	for _, player in ipairs(minetest.get_connected_players()) do
 | 
			
		||||
		local blockpos = get_blockpos(player:get_pos())
 | 
			
		||||
		local minp = vector.subtract(blockpos, active_block_range)
 | 
			
		||||
		local maxp = vector.add(blockpos, active_block_range)
 | 
			
		||||
if pipeworks.use_real_entities then
 | 
			
		||||
	local active_blocks = {} -- These only contain active blocks near players (i.e., not forceloaded ones)
 | 
			
		||||
 | 
			
		||||
		for x = minp.x, maxp.x do
 | 
			
		||||
		for y = minp.y, maxp.y do
 | 
			
		||||
		for z = minp.z, maxp.z do
 | 
			
		||||
			local pos = {x = x, y = y, z = z}
 | 
			
		||||
			new_active_blocks[minetest.hash_node_position(pos)] = pos
 | 
			
		||||
		end
 | 
			
		||||
		end
 | 
			
		||||
	move_entities_globalstep_part1 = function(dtime)
 | 
			
		||||
		local active_block_range = tonumber(minetest.settings:get("active_block_range")) or 2
 | 
			
		||||
		local new_active_blocks = {}
 | 
			
		||||
		for _, player in ipairs(minetest.get_connected_players()) do
 | 
			
		||||
			local blockpos = get_blockpos(player:get_pos())
 | 
			
		||||
			local minp = vector.subtract(blockpos, active_block_range)
 | 
			
		||||
			local maxp = vector.add(blockpos, active_block_range)
 | 
			
		||||
 | 
			
		||||
			for x = minp.x, maxp.x do
 | 
			
		||||
			for y = minp.y, maxp.y do
 | 
			
		||||
			for z = minp.z, maxp.z do
 | 
			
		||||
				local pos = {x = x, y = y, z = z}
 | 
			
		||||
				new_active_blocks[minetest.hash_node_position(pos)] = pos
 | 
			
		||||
			end
 | 
			
		||||
			end
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
		active_blocks = new_active_blocks
 | 
			
		||||
		-- todo: callbacks on block load/unload
 | 
			
		||||
	end
 | 
			
		||||
	active_blocks = new_active_blocks
 | 
			
		||||
	-- todo: callbacks on block load/unload
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function is_active(pos)
 | 
			
		||||
	return active_blocks[minetest.hash_node_position(get_blockpos(pos))] ~= nil
 | 
			
		||||
	is_active = function(pos)
 | 
			
		||||
		return active_blocks[minetest.hash_node_position(get_blockpos(pos))] ~= nil
 | 
			
		||||
	end
 | 
			
		||||
else
 | 
			
		||||
	move_entities_globalstep_part1 = function()
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	is_active = function()
 | 
			
		||||
		return false
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local entitydef_default = {
 | 
			
		||||
@@ -146,11 +163,15 @@ local entitydef_default = {
 | 
			
		||||
		if not is_active(entity_pos) then
 | 
			
		||||
			return
 | 
			
		||||
		end
 | 
			
		||||
		local ent = minetest.add_entity(entity_pos, entity.name):get_luaentity()
 | 
			
		||||
		local object = minetest.add_entity(entity_pos, entity.name)
 | 
			
		||||
		if not object then
 | 
			
		||||
			return
 | 
			
		||||
		end
 | 
			
		||||
		local ent = object:get_luaentity()
 | 
			
		||||
		ent:from_data(entity.data)
 | 
			
		||||
		ent.parent_id = self._id
 | 
			
		||||
		ent.attached_id = index
 | 
			
		||||
		entity.entity = ent.object
 | 
			
		||||
		entity.entity = object
 | 
			
		||||
		local master = self._attached_entities_master
 | 
			
		||||
		if master then
 | 
			
		||||
			self:_attach(index, master)
 | 
			
		||||
@@ -206,7 +227,7 @@ local entitydef_default = {
 | 
			
		||||
		end
 | 
			
		||||
	end,
 | 
			
		||||
	get_velocity = function(self)
 | 
			
		||||
		return vector.new(self._velocity)	
 | 
			
		||||
		return vector.new(self._velocity)
 | 
			
		||||
	end,
 | 
			
		||||
	set_velocity = function(self, velocity)
 | 
			
		||||
		self._velocity = vector.new(velocity)
 | 
			
		||||
@@ -284,7 +305,7 @@ function luaentity.add_entity(pos, name)
 | 
			
		||||
		_acceleration = {x = 0, y = 0, z = 0},
 | 
			
		||||
		_attached_entities = {},
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	local prototype = luaentity.registered_entities[name]
 | 
			
		||||
	setmetatable(entity, prototype) -- Default to prototype for other methods
 | 
			
		||||
	luaentity.entities[index] = entity
 | 
			
		||||
@@ -313,19 +334,20 @@ end
 | 
			
		||||
function luaentity.get_objects_inside_radius(pos, radius)
 | 
			
		||||
	local objects = {}
 | 
			
		||||
	local index = 1
 | 
			
		||||
	for id, entity in pairs(luaentity.entities) do
 | 
			
		||||
	for _, entity in pairs(luaentity.entities) do
 | 
			
		||||
		if vector.distance(pos, entity:get_pos()) <= radius then
 | 
			
		||||
			objects[index] = entity
 | 
			
		||||
			index = index + 1
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
	return objects
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local move_entities_globalstep_part2 = function(dtime)
 | 
			
		||||
	if not luaentity.entities then
 | 
			
		||||
		luaentity.entities = read_entities()
 | 
			
		||||
	end
 | 
			
		||||
	for id, entity in pairs(luaentity.entities) do
 | 
			
		||||
	for _, entity in pairs(luaentity.entities) do
 | 
			
		||||
		local master = entity._attached_entities_master
 | 
			
		||||
		local master_def = master and entity._attached_entities[master]
 | 
			
		||||
		local master_entity = master_def and master_def.entity
 | 
			
		||||
@@ -335,6 +357,8 @@ local move_entities_globalstep_part2 = function(dtime)
 | 
			
		||||
			entity._velocity = master_entity:get_velocity()
 | 
			
		||||
			entity._acceleration = master_entity:get_acceleration()
 | 
			
		||||
		else
 | 
			
		||||
			entity._velocity = entity._velocity or vector.new(0,0,0)
 | 
			
		||||
			entity._acceleration = entity._acceleration or vector.new(0,0,0)
 | 
			
		||||
			entity._pos = vector.add(vector.add(
 | 
			
		||||
				entity._pos,
 | 
			
		||||
				vector.multiply(entity._velocity, dtime)),
 | 
			
		||||
@@ -362,13 +386,36 @@ local move_entities_globalstep_part2 = function(dtime)
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local handle_active_blocks_timer = 0.1
 | 
			
		||||
-- dtime after which there is an update (or skip).
 | 
			
		||||
local dtime_threshold = pipeworks.entity_update_interval
 | 
			
		||||
-- Accumulated dtime since last update (or skip).
 | 
			
		||||
local dtime_accum = 0
 | 
			
		||||
-- Delayed dtime accumulated due to skipped updates.
 | 
			
		||||
local dtime_delayed = 0
 | 
			
		||||
local skip_update = false
 | 
			
		||||
 | 
			
		||||
minetest.register_globalstep(function(dtime)
 | 
			
		||||
	handle_active_blocks_timer = handle_active_blocks_timer + dtime
 | 
			
		||||
	if dtime < 0.2 or handle_active_blocks_timer >= (dtime * 3) then
 | 
			
		||||
		handle_active_blocks_timer = 0.1
 | 
			
		||||
		move_entities_globalstep_part1(dtime)
 | 
			
		||||
		move_entities_globalstep_part2(dtime)
 | 
			
		||||
	if dtime >= 0.2 and dtime_delayed < 1 then
 | 
			
		||||
		-- Reduce activity when the server is lagging.
 | 
			
		||||
		skip_update = true
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	dtime_accum = dtime_accum + dtime
 | 
			
		||||
	if dtime_accum < dtime_threshold then
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	if skip_update then
 | 
			
		||||
		dtime_delayed = dtime_delayed + dtime_accum
 | 
			
		||||
		skip_update = false
 | 
			
		||||
	else
 | 
			
		||||
		move_entities_globalstep_part1(dtime_accum + dtime_delayed)
 | 
			
		||||
		move_entities_globalstep_part2(dtime_accum + dtime_delayed)
 | 
			
		||||
		dtime_delayed = 0
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	-- Tune the threshold so that the average interval is pipeworks.entity_update_interval.
 | 
			
		||||
	dtime_threshold = math.max(dtime_threshold + (pipeworks.entity_update_interval - dtime_accum) / 10, 0)
 | 
			
		||||
 | 
			
		||||
	dtime_accum = 0
 | 
			
		||||
end)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										72
									
								
								mcl_barrels.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								mcl_barrels.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,72 @@
 | 
			
		||||
-- this bit of code modifies the mcl barrels to be compatible with
 | 
			
		||||
-- pipeworks.
 | 
			
		||||
 | 
			
		||||
-- Pipeworks Specific
 | 
			
		||||
local tube_entry = "^pipeworks_tube_connection_wooden.png"
 | 
			
		||||
 | 
			
		||||
-- Original Definitions
 | 
			
		||||
local old_barrel = table.copy(minetest.registered_items["mcl_barrels:barrel_closed"])
 | 
			
		||||
 | 
			
		||||
local groups = old_barrel.groups
 | 
			
		||||
groups["tubedevice"] = 1
 | 
			
		||||
groups["tubedevice_receiver"] = 1
 | 
			
		||||
local groups_open = table.copy(groups)
 | 
			
		||||
groups_open["not_in_creative_inventory"] = 1
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
-- Override Construction
 | 
			
		||||
local override_barrel = {}
 | 
			
		||||
 | 
			
		||||
override_barrel.tiles = {
 | 
			
		||||
   "mcl_barrels_barrel_top.png^[transformR270",
 | 
			
		||||
   "mcl_barrels_barrel_bottom.png"..tube_entry,
 | 
			
		||||
   "mcl_barrels_barrel_side.png"..tube_entry
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
override_barrel.after_place_node = function(pos, placer, itemstack, pointed_thing)
 | 
			
		||||
   old_barrel.after_place_node(pos, placer, itemstack, pointed_thing)
 | 
			
		||||
   pipeworks.after_place(pos, placer, itemstack, pointed_thing)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
override_barrel.tube = {
 | 
			
		||||
   insert_object = function(pos, node, stack, direction)
 | 
			
		||||
      local meta = minetest.get_meta(pos)
 | 
			
		||||
      local inv = meta:get_inventory()
 | 
			
		||||
      return inv:add_item("main", stack)
 | 
			
		||||
   end,
 | 
			
		||||
   can_insert = function(pos, node, stack, direction)
 | 
			
		||||
      local meta = minetest.get_meta(pos)
 | 
			
		||||
      local inv = meta:get_inventory()
 | 
			
		||||
      if meta:get_int("splitstacks") == 1 then
 | 
			
		||||
	 stack = stack:peek_item(1)
 | 
			
		||||
      end
 | 
			
		||||
      return inv:room_for_item("main", stack)
 | 
			
		||||
   end,
 | 
			
		||||
   input_inventory = "main",
 | 
			
		||||
   connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
override_barrel.after_dig_node = function(pos, oldnode, oldmetadata, digger)
 | 
			
		||||
   old_barrel.after_dig_node(pos, oldnode, oldmetadata, digger)
 | 
			
		||||
   pipeworks.after_dig(pos)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
override_barrel.groups = table.copy(old_barrel.groups)
 | 
			
		||||
 | 
			
		||||
override_barrel.on_rotate = pipeworks.on_rotate
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
local override_barrel_open = table.copy(override_barrel)
 | 
			
		||||
 | 
			
		||||
override_barrel_open.tiles = {
 | 
			
		||||
   "mcl_barrels_barrel_top_open.png",
 | 
			
		||||
   "mcl_barrels_barrel_bottom.png"..tube_entry,
 | 
			
		||||
   "mcl_barrels_barrel_side.png"..tube_entry
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
override_barrel_open.groups = groups_open
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
-- Override with the new modifications.
 | 
			
		||||
minetest.override_item("mcl_barrels:barrel_closed", override_barrel)
 | 
			
		||||
minetest.override_item("mcl_barrels:barrel_open", override_barrel_open)
 | 
			
		||||
							
								
								
									
										376
									
								
								mcl_furnaces.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										376
									
								
								mcl_furnaces.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,376 @@
 | 
			
		||||
 | 
			
		||||
local old_furnace = table.copy(minetest.registered_nodes["mcl_furnaces:furnace"])
 | 
			
		||||
local old_blast_furnace = table.copy(minetest.registered_nodes["mcl_blast_furnace:blast_furnace"])
 | 
			
		||||
local old_smoker = table.copy(minetest.registered_nodes["mcl_smoker:smoker"])
 | 
			
		||||
 | 
			
		||||
local tube_entry = "^pipeworks_tube_connection_stony.png"
 | 
			
		||||
 | 
			
		||||
-- groups
 | 
			
		||||
local furnace_groups = old_furnace.groups
 | 
			
		||||
furnace_groups["tubedevice"] = 1
 | 
			
		||||
furnace_groups["tubedevice_receiver"] = 1
 | 
			
		||||
local furnace_groups_active = table.copy(furnace_groups)
 | 
			
		||||
furnace_groups_active["not_in_creative_inventory"] = 1
 | 
			
		||||
 | 
			
		||||
local blast_furnace_groups = old_blast_furnace.groups
 | 
			
		||||
blast_furnace_groups["tubedevice"] = 1
 | 
			
		||||
blast_furnace_groups["tubedevice_receiver"] = 1
 | 
			
		||||
local blast_furnace_groups_active = table.copy(blast_furnace_groups)
 | 
			
		||||
blast_furnace_groups_active["not_in_creative_inventory"] = 1
 | 
			
		||||
 | 
			
		||||
local smoker_groups = old_smoker.groups
 | 
			
		||||
smoker_groups["tubedevice"] = 1
 | 
			
		||||
smoker_groups["tubedevice_receiver"] = 1
 | 
			
		||||
local smoker_groups_active = table.copy(smoker_groups)
 | 
			
		||||
smoker_groups_active["not_in_creative_inventory"] = 1
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
-- a hack to give the exp to fake players it's be dropped instead added to (fake) player inv
 | 
			
		||||
local function give_xp(pos, player)
 | 
			
		||||
   local meta = minetest.get_meta(pos)
 | 
			
		||||
   local dir = vector.divide(minetest.facedir_to_dir(minetest.get_node(pos).param2), -1.95)
 | 
			
		||||
   local xp = meta:get_int("xp")
 | 
			
		||||
   if xp > 0 then
 | 
			
		||||
      mcl_experience.throw_xp(vector.add(pos, dir), xp)
 | 
			
		||||
      meta:set_int("xp", 0)
 | 
			
		||||
   end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local override = {}
 | 
			
		||||
 | 
			
		||||
override.tiles = {
 | 
			
		||||
   "default_furnace_top.png"..tube_entry,
 | 
			
		||||
   "default_furnace_bottom.png"..tube_entry,
 | 
			
		||||
   "default_furnace_side.png"..tube_entry,
 | 
			
		||||
   "default_furnace_side.png"..tube_entry,
 | 
			
		||||
   "default_furnace_side.png"..tube_entry,
 | 
			
		||||
   "default_furnace_front.png"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
override.groups = furnace_groups
 | 
			
		||||
 | 
			
		||||
override.tube = {
 | 
			
		||||
   insert_object = function(pos, node, stack, direction)
 | 
			
		||||
      local meta = minetest.get_meta(pos)
 | 
			
		||||
      local inv = meta:get_inventory()
 | 
			
		||||
      local timer = minetest.get_node_timer(pos)
 | 
			
		||||
      if not timer:is_started() then
 | 
			
		||||
	 timer:start(1.0)
 | 
			
		||||
      end
 | 
			
		||||
      if direction.y == 1 then
 | 
			
		||||
	 return inv:add_item("fuel", stack)
 | 
			
		||||
      else
 | 
			
		||||
	 return inv:add_item("src", stack)
 | 
			
		||||
      end
 | 
			
		||||
   end,
 | 
			
		||||
   can_insert = function(pos,node,stack,direction)
 | 
			
		||||
      local meta = minetest.get_meta(pos)
 | 
			
		||||
      local inv = meta:get_inventory()
 | 
			
		||||
      if direction.y == 1 then
 | 
			
		||||
	 return inv:room_for_item("fuel", stack)
 | 
			
		||||
      else
 | 
			
		||||
	 if meta:get_int("split_material_stacks") == 1 then
 | 
			
		||||
	    stack = stack:peek_item(1)
 | 
			
		||||
	 end
 | 
			
		||||
	 return inv:room_for_item("src", stack)
 | 
			
		||||
      end
 | 
			
		||||
   end,
 | 
			
		||||
   input_inventory = "dst",
 | 
			
		||||
   connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
override.after_place_node = function(pos, placer, itemstack, pointed_thing)
 | 
			
		||||
   pipeworks.after_place(pos, placer, itemstack, pointed_thing)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
override.after_dig_node = function(pos, oldnode, oldmetadata, digger)
 | 
			
		||||
   old_furnace.after_dig_node(pos, oldnode, oldmetadata, digger)
 | 
			
		||||
   pipeworks.after_dig(pos)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
override.on_metadata_inventory_take = function(pos, listname, index, stack, player)
 | 
			
		||||
   if listname == "dst" then
 | 
			
		||||
      if stack:get_name() == "mcl_core:iron_ingot" then
 | 
			
		||||
	 awards.unlock(player:get_player_name(), "mcl:acquireIron")
 | 
			
		||||
      elseif stack:get_name() == "mcl_fishing:fish_cooked" then
 | 
			
		||||
	 awards.unlock(player:get_player_name(), "mcl:cookFish")
 | 
			
		||||
      end
 | 
			
		||||
      give_xp(pos, player)
 | 
			
		||||
   end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
override.on_rotate = pipeworks.on_rotate
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
local override_active = table.copy(override)
 | 
			
		||||
 | 
			
		||||
override_active.tiles = {
 | 
			
		||||
   "default_furnace_top.png"..tube_entry,
 | 
			
		||||
   "default_furnace_bottom.png"..tube_entry,
 | 
			
		||||
   "default_furnace_side.png"..tube_entry,
 | 
			
		||||
   "default_furnace_side.png"..tube_entry,
 | 
			
		||||
   "default_furnace_side.png"..tube_entry,
 | 
			
		||||
   "default_furnace_front_active.png",
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
override_active.groups = furnace_groups_active
 | 
			
		||||
 | 
			
		||||
override_active.tube = {
 | 
			
		||||
   insert_object = function(pos,node,stack,direction)
 | 
			
		||||
      local meta = minetest.get_meta(pos)
 | 
			
		||||
      local inv = meta:get_inventory()
 | 
			
		||||
      local timer = minetest.get_node_timer(pos)
 | 
			
		||||
      if not timer:is_started() then
 | 
			
		||||
	 timer:start(1.0)
 | 
			
		||||
      end
 | 
			
		||||
      if direction.y == 1 then
 | 
			
		||||
	 return inv:add_item("fuel", stack)
 | 
			
		||||
      else
 | 
			
		||||
	 return inv:add_item("src", stack)
 | 
			
		||||
      end
 | 
			
		||||
   end,
 | 
			
		||||
   can_insert = function(pos, node, stack, direction)
 | 
			
		||||
      local meta = minetest.get_meta(pos)
 | 
			
		||||
      local inv = meta:get_inventory()
 | 
			
		||||
      if direction.y == 1 then
 | 
			
		||||
	 return inv:room_for_item("fuel", stack)
 | 
			
		||||
      else
 | 
			
		||||
	 return inv:room_for_item("src", stack)
 | 
			
		||||
      end
 | 
			
		||||
   end,
 | 
			
		||||
   input_inventory = "dst",
 | 
			
		||||
   connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
--blast furnace
 | 
			
		||||
 | 
			
		||||
local override_blast_furnace = {}
 | 
			
		||||
 | 
			
		||||
override_blast_furnace.tiles = {
 | 
			
		||||
   "blast_furnace_top.png"..tube_entry,
 | 
			
		||||
   "blast_furnace_top.png"..tube_entry,
 | 
			
		||||
   "blast_furnace_side.png"..tube_entry,
 | 
			
		||||
   "blast_furnace_side.png"..tube_entry,
 | 
			
		||||
   "blast_furnace_side.png"..tube_entry,
 | 
			
		||||
   "blast_furnace_front.png"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
override_blast_furnace.groups = blast_furnace_groups
 | 
			
		||||
 | 
			
		||||
override_blast_furnace.tube = {
 | 
			
		||||
   insert_object = function(pos, node, stack, direction)
 | 
			
		||||
      local meta = minetest.get_meta(pos)
 | 
			
		||||
      local inv = meta:get_inventory()
 | 
			
		||||
      local timer = minetest.get_node_timer(pos)
 | 
			
		||||
      if not timer:is_started() then
 | 
			
		||||
	 timer:start(1.0)
 | 
			
		||||
      end
 | 
			
		||||
      if direction.y == 1 then
 | 
			
		||||
	 return inv:add_item("fuel", stack)
 | 
			
		||||
      else
 | 
			
		||||
	 return inv:add_item("src", stack)
 | 
			
		||||
      end
 | 
			
		||||
   end,
 | 
			
		||||
   can_insert = function(pos,node,stack,direction)
 | 
			
		||||
      local meta = minetest.get_meta(pos)
 | 
			
		||||
      local inv = meta:get_inventory()
 | 
			
		||||
      if direction.y == 1 then
 | 
			
		||||
	 return inv:room_for_item("fuel", stack)
 | 
			
		||||
      else
 | 
			
		||||
	 if meta:get_int("split_material_stacks") == 1 then
 | 
			
		||||
	    stack = stack:peek_item(1)
 | 
			
		||||
	 end
 | 
			
		||||
	 return inv:room_for_item("src", stack)
 | 
			
		||||
      end
 | 
			
		||||
   end,
 | 
			
		||||
   input_inventory = "dst",
 | 
			
		||||
   connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
override_blast_furnace.after_place_node = function(pos, placer, itemstack, pointed_thing)
 | 
			
		||||
   pipeworks.after_place(pos, placer, itemstack, pointed_thing)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
override_blast_furnace.after_dig_node = function(pos, oldnode, oldmetadata, digger)
 | 
			
		||||
   old_blast_furnace.after_dig_node(pos, oldnode, oldmetadata, digger)
 | 
			
		||||
   pipeworks.after_dig(pos)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
override_blast_furnace.on_metadata_inventory_take = function(pos, listname, index, stack, player)
 | 
			
		||||
   -- Award smelting achievements
 | 
			
		||||
   if listname == "dst" then
 | 
			
		||||
      if stack:get_name() == "mcl_core:iron_ingot" then
 | 
			
		||||
	 awards.unlock(player:get_player_name(), "mcl:acquireIron")
 | 
			
		||||
      end
 | 
			
		||||
      give_xp(pos, player)
 | 
			
		||||
   end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
override_blast_furnace.on_rotate = pipeworks.on_rotate
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
local override_blast_active = table.copy(override)
 | 
			
		||||
 | 
			
		||||
override_blast_active.tiles = {
 | 
			
		||||
   "blast_furnace_top.png"..tube_entry,
 | 
			
		||||
   "blast_furnace_top.png"..tube_entry,
 | 
			
		||||
   "blast_furnace_side.png"..tube_entry,
 | 
			
		||||
   "blast_furnace_side.png"..tube_entry,
 | 
			
		||||
   "blast_furnace_side.png"..tube_entry,
 | 
			
		||||
   {
 | 
			
		||||
      name = "blast_furnace_front_on.png",
 | 
			
		||||
      animation = { type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 48 }
 | 
			
		||||
   },
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
override_blast_active.groups = blast_furnace_groups_active
 | 
			
		||||
 | 
			
		||||
override_blast_active.tube = {
 | 
			
		||||
   insert_object = function(pos,node,stack,direction)
 | 
			
		||||
      local meta = minetest.get_meta(pos)
 | 
			
		||||
      local inv = meta:get_inventory()
 | 
			
		||||
      local timer = minetest.get_node_timer(pos)
 | 
			
		||||
      if not timer:is_started() then
 | 
			
		||||
	 timer:start(1.0)
 | 
			
		||||
      end
 | 
			
		||||
      if direction.y == 1 then
 | 
			
		||||
	 return inv:add_item("fuel", stack)
 | 
			
		||||
      else
 | 
			
		||||
	 return inv:add_item("src", stack)
 | 
			
		||||
      end
 | 
			
		||||
   end,
 | 
			
		||||
   can_insert = function(pos, node, stack, direction)
 | 
			
		||||
      local meta = minetest.get_meta(pos)
 | 
			
		||||
      local inv = meta:get_inventory()
 | 
			
		||||
      if direction.y == 1 then
 | 
			
		||||
	 return inv:room_for_item("fuel", stack)
 | 
			
		||||
      else
 | 
			
		||||
	 return inv:room_for_item("src", stack)
 | 
			
		||||
      end
 | 
			
		||||
   end,
 | 
			
		||||
   input_inventory = "dst",
 | 
			
		||||
   connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
-- smoker
 | 
			
		||||
 | 
			
		||||
local override_smoker = {}
 | 
			
		||||
 | 
			
		||||
override_smoker.tiles = {
 | 
			
		||||
   "smoker_top.png"..tube_entry,
 | 
			
		||||
   "smoker_bottom.png"..tube_entry,
 | 
			
		||||
   "smoker_side.png"..tube_entry,
 | 
			
		||||
   "smoker_side.png"..tube_entry,
 | 
			
		||||
   "smoker_side.png"..tube_entry,
 | 
			
		||||
   "smoker_front.png"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
override_smoker.groups = smoker_groups
 | 
			
		||||
 | 
			
		||||
override_smoker.tube = {
 | 
			
		||||
   insert_object = function(pos, node, stack, direction)
 | 
			
		||||
      local meta = minetest.get_meta(pos)
 | 
			
		||||
      local inv = meta:get_inventory()
 | 
			
		||||
      local timer = minetest.get_node_timer(pos)
 | 
			
		||||
      if not timer:is_started() then
 | 
			
		||||
	 timer:start(1.0)
 | 
			
		||||
      end
 | 
			
		||||
      if direction.y == 1 then
 | 
			
		||||
	 return inv:add_item("fuel", stack)
 | 
			
		||||
      else
 | 
			
		||||
	 return inv:add_item("src", stack)
 | 
			
		||||
      end
 | 
			
		||||
   end,
 | 
			
		||||
   can_insert = function(pos,node,stack,direction)
 | 
			
		||||
      local meta = minetest.get_meta(pos)
 | 
			
		||||
      local inv = meta:get_inventory()
 | 
			
		||||
      if direction.y == 1 then
 | 
			
		||||
	 return inv:room_for_item("fuel", stack)
 | 
			
		||||
      else
 | 
			
		||||
	 if meta:get_int("split_material_stacks") == 1 then
 | 
			
		||||
	    stack = stack:peek_item(1)
 | 
			
		||||
	 end
 | 
			
		||||
	 return inv:room_for_item("src", stack)
 | 
			
		||||
      end
 | 
			
		||||
   end,
 | 
			
		||||
   input_inventory = "dst",
 | 
			
		||||
   connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
override_smoker.after_place_node = function(pos, placer, itemstack, pointed_thing)
 | 
			
		||||
   pipeworks.after_place(pos, placer, itemstack, pointed_thing)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
override_smoker.after_dig_node = function(pos, oldnode, oldmetadata, digger)
 | 
			
		||||
   old_smoker.after_dig_node(pos, oldnode, oldmetadata, digger)
 | 
			
		||||
   pipeworks.after_dig(pos)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
override_smoker.on_metadata_inventory_take = function(pos, listname, index, stack, player)
 | 
			
		||||
   -- Award fish achievements
 | 
			
		||||
   if listname == "dst" then
 | 
			
		||||
      if stack:get_name() == "mcl_fishing:fish_cooked" then
 | 
			
		||||
	 awards.unlock(player:get_player_name(), "mcl:cookFish")
 | 
			
		||||
      end
 | 
			
		||||
      give_xp(pos, player)
 | 
			
		||||
   end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
override_smoker.on_rotate = pipeworks.on_rotate
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
local override_smoker_active = table.copy(override)
 | 
			
		||||
 | 
			
		||||
override_smoker_active.tiles = {
 | 
			
		||||
   "smoker_top.png"..tube_entry,
 | 
			
		||||
   "smoker_bottom.png"..tube_entry,
 | 
			
		||||
   "smoker_side.png"..tube_entry,
 | 
			
		||||
   "smoker_side.png"..tube_entry,
 | 
			
		||||
   "smoker_side.png"..tube_entry,
 | 
			
		||||
   {
 | 
			
		||||
      name = "smoker_front_on.png",
 | 
			
		||||
      animation = { type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 48 }
 | 
			
		||||
   },
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
override_smoker_active.groups = smoker_groups_active
 | 
			
		||||
 | 
			
		||||
override_smoker_active.tube = {
 | 
			
		||||
   insert_object = function(pos,node,stack,direction)
 | 
			
		||||
      local meta = minetest.get_meta(pos)
 | 
			
		||||
      local inv = meta:get_inventory()
 | 
			
		||||
      local timer = minetest.get_node_timer(pos)
 | 
			
		||||
      if not timer:is_started() then
 | 
			
		||||
	 timer:start(1.0)
 | 
			
		||||
      end
 | 
			
		||||
      if direction.y == 1 then
 | 
			
		||||
	 return inv:add_item("fuel", stack)
 | 
			
		||||
      else
 | 
			
		||||
	 return inv:add_item("src", stack)
 | 
			
		||||
      end
 | 
			
		||||
   end,
 | 
			
		||||
   can_insert = function(pos, node, stack, direction)
 | 
			
		||||
      local meta = minetest.get_meta(pos)
 | 
			
		||||
      local inv = meta:get_inventory()
 | 
			
		||||
      if direction.y == 1 then
 | 
			
		||||
	 return inv:room_for_item("fuel", stack)
 | 
			
		||||
      else
 | 
			
		||||
	 return inv:room_for_item("src", stack)
 | 
			
		||||
      end
 | 
			
		||||
   end,
 | 
			
		||||
   input_inventory = "dst",
 | 
			
		||||
   connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
-- override
 | 
			
		||||
minetest.override_item("mcl_furnaces:furnace", override)
 | 
			
		||||
minetest.override_item("mcl_furnaces:furnace_active", override_active)
 | 
			
		||||
 | 
			
		||||
minetest.override_item("mcl_blast_furnace:blast_furnace", override_blast_furnace)
 | 
			
		||||
minetest.override_item("mcl_blast_furnace:blast_furnace_active", override_blast_active)
 | 
			
		||||
 | 
			
		||||
minetest.override_item("mcl_smoker:smoker", override_smoker)
 | 
			
		||||
minetest.override_item("mcl_smoker:smoker_active", override_smoker_active)
 | 
			
		||||
							
								
								
									
										4
									
								
								mod.conf
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								mod.conf
									
									
									
									
									
								
							@@ -1 +1,5 @@
 | 
			
		||||
name = pipeworks
 | 
			
		||||
description = This mod uses mesh nodes and nodeboxes to supply a complete set of 3D pipes and tubes, along with devices that work with them.
 | 
			
		||||
depends = basic_materials
 | 
			
		||||
optional_depends = mesecons, mesecons_mvps, digilines, signs_lib, unified_inventory, default, screwdriver, fl_mapgen, sound_api, i3, hades_core, hades_furnaces, hades_chests, mcl_mapgen_core, mcl_barrels, mcl_furnaces, mcl_experience
 | 
			
		||||
min_minetest_version = 5.4.0
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										55
									
								
								pipes.lua
									
									
									
									
									
								
							
							
						
						
									
										55
									
								
								pipes.lua
									
									
									
									
									
								
							@@ -1,4 +1,5 @@
 | 
			
		||||
-- This file supplies the steel pipes
 | 
			
		||||
local S = minetest.get_translator("pipeworks")
 | 
			
		||||
 | 
			
		||||
local REGISTER_COMPATIBILITY = true
 | 
			
		||||
 | 
			
		||||
@@ -10,11 +11,11 @@ local new_flow_logic_register = pipeworks.flowables.register
 | 
			
		||||
local polys = ""
 | 
			
		||||
if pipeworks.enable_lowpoly then polys = "_lowpoly" end
 | 
			
		||||
 | 
			
		||||
local vti = {4, 3, 2, 1, 6, 5}
 | 
			
		||||
--~ local vti = {4, 3, 2, 1, 6, 5}
 | 
			
		||||
local cconnects = {{}, {1}, {1, 2}, {1, 3}, {1, 3, 5}, {1, 2, 3}, {1, 2, 3, 5}, {1, 2, 3, 4}, {1, 2, 3, 4, 5}, {1, 2, 3, 4, 5, 6}}
 | 
			
		||||
for index, connects in ipairs(cconnects) do
 | 
			
		||||
	local outsel = {}
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	local jx = 0
 | 
			
		||||
	local jy = 0
 | 
			
		||||
	local jz = 0
 | 
			
		||||
@@ -29,23 +30,25 @@ for index, connects in ipairs(cconnects) do
 | 
			
		||||
		table.insert(outsel, pipeworks.pipe_selectboxes[v])
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	--[[
 | 
			
		||||
	if #connects == 1 then
 | 
			
		||||
		local v = connects[1]
 | 
			
		||||
		v = v-1 + 2*(v%2) -- Opposite side
 | 
			
		||||
	end
 | 
			
		||||
	
 | 
			
		||||
	local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1}
 | 
			
		||||
	local pipedesc = "Pipe segement".." "..dump(connects).."... You hacker, you."
 | 
			
		||||
	--]]
 | 
			
		||||
 | 
			
		||||
	local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1, dig_generic = 4, axey=1, handy=1, pickaxey=1}
 | 
			
		||||
	local pipedesc = S("Pipe Segment").." "..dump(connects)
 | 
			
		||||
 | 
			
		||||
	if #connects == 0 then
 | 
			
		||||
		pgroups = {snappy = 3, tube = 1}
 | 
			
		||||
		pipedesc = "Pipe segment"
 | 
			
		||||
		pgroups = {snappy = 3, tube = 1, dig_generic = 4, axey=1, handy=1, pickaxey=1}
 | 
			
		||||
		pipedesc = S("Pipe Segment")
 | 
			
		||||
	end
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	local outimg_e = { "pipeworks_pipe_plain.png" }
 | 
			
		||||
	local outimg_l = { "pipeworks_pipe_plain.png" }
 | 
			
		||||
 | 
			
		||||
	if index == 3 then 
 | 
			
		||||
	if index == 3 then
 | 
			
		||||
		outimg_e = { "pipeworks_pipe_3_empty.png" }
 | 
			
		||||
		outimg_l = { "pipeworks_pipe_3_loaded.png" }
 | 
			
		||||
	end
 | 
			
		||||
@@ -73,7 +76,10 @@ for index, connects in ipairs(cconnects) do
 | 
			
		||||
			fixed = outsel
 | 
			
		||||
		},
 | 
			
		||||
		groups = pgroups,
 | 
			
		||||
		sounds = default.node_sound_wood_defaults(),
 | 
			
		||||
		_mcl_hardness=0.8,
 | 
			
		||||
		_sound_def = {
 | 
			
		||||
			key = "node_sound_metal_defaults",
 | 
			
		||||
		},
 | 
			
		||||
		walkable = true,
 | 
			
		||||
		drop = "pipeworks:pipe_1_empty",
 | 
			
		||||
		after_place_node = function(pos)
 | 
			
		||||
@@ -82,10 +88,13 @@ for index, connects in ipairs(cconnects) do
 | 
			
		||||
		after_dig_node = function(pos)
 | 
			
		||||
			pipeworks.scan_for_pipe_objects(pos)
 | 
			
		||||
		end,
 | 
			
		||||
		on_rotate = false
 | 
			
		||||
		on_rotate = false,
 | 
			
		||||
		check_for_pole = pipeworks.check_for_vert_pipe,
 | 
			
		||||
		check_for_horiz_pole = pipeworks.check_for_horiz_pipe,
 | 
			
		||||
		pipenumber = index
 | 
			
		||||
	})
 | 
			
		||||
	
 | 
			
		||||
	local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1}
 | 
			
		||||
 | 
			
		||||
	local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1, dig_generic = 4, axey=1, handy=1, pickaxey=1}
 | 
			
		||||
 | 
			
		||||
	minetest.register_node("pipeworks:pipe_"..index.."_loaded", {
 | 
			
		||||
		description = pipedesc,
 | 
			
		||||
@@ -104,7 +113,10 @@ for index, connects in ipairs(cconnects) do
 | 
			
		||||
			fixed = outsel
 | 
			
		||||
		},
 | 
			
		||||
		groups = pgroups,
 | 
			
		||||
		sounds = default.node_sound_wood_defaults(),
 | 
			
		||||
		_mcl_hardness=0.8,
 | 
			
		||||
		_sound_def = {
 | 
			
		||||
			key = "node_sound_metal_defaults",
 | 
			
		||||
		},
 | 
			
		||||
		walkable = true,
 | 
			
		||||
		drop = "pipeworks:pipe_1_empty",
 | 
			
		||||
		after_place_node = function(pos)
 | 
			
		||||
@@ -114,9 +126,12 @@ for index, connects in ipairs(cconnects) do
 | 
			
		||||
		after_dig_node = function(pos)
 | 
			
		||||
			pipeworks.scan_for_pipe_objects(pos)
 | 
			
		||||
		end,
 | 
			
		||||
		on_rotate = false
 | 
			
		||||
		on_rotate = false,
 | 
			
		||||
		check_for_pole = pipeworks.check_for_vert_pipe,
 | 
			
		||||
		check_for_horiz_pole = pipeworks.check_for_horiz_pipe,
 | 
			
		||||
		pipenumber = index
 | 
			
		||||
	})
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	local emptypipe = "pipeworks:pipe_"..index.."_empty"
 | 
			
		||||
	local fullpipe = "pipeworks:pipe_"..index.."_loaded"
 | 
			
		||||
	table.insert(pipes_empty_nodenames, emptypipe)
 | 
			
		||||
@@ -124,7 +139,7 @@ for index, connects in ipairs(cconnects) do
 | 
			
		||||
	new_flow_logic_register.simple(emptypipe)
 | 
			
		||||
	new_flow_logic_register.simple(fullpipe)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:pipe_1_empty"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if REGISTER_COMPATIBILITY then
 | 
			
		||||
@@ -134,7 +149,7 @@ if REGISTER_COMPATIBILITY then
 | 
			
		||||
		drawtype = "airlike",
 | 
			
		||||
		sunlight_propagates = true,
 | 
			
		||||
		paramtype = "light",
 | 
			
		||||
		description = "Pipe Segment (legacy)",
 | 
			
		||||
		description = S("Pipe Segment (legacy)"),
 | 
			
		||||
		groups = {not_in_creative_inventory = 1, pipe_to_update = 1},
 | 
			
		||||
		drop = "pipeworks:pipe_1_empty",
 | 
			
		||||
		after_place_node = function(pos)
 | 
			
		||||
@@ -232,7 +247,7 @@ minetest.register_abm({
 | 
			
		||||
	nodenames = {"pipeworks:spigot","pipeworks:spigot_pouring"},
 | 
			
		||||
	interval = 1,
 | 
			
		||||
	chance = 1,
 | 
			
		||||
	action = function(pos, node, active_object_count, active_object_count_wider) 
 | 
			
		||||
	action = function(pos, node, active_object_count, active_object_count_wider)
 | 
			
		||||
		pipeworks.spigot_check(pos,node)
 | 
			
		||||
	end
 | 
			
		||||
})
 | 
			
		||||
@@ -241,7 +256,7 @@ minetest.register_abm({
 | 
			
		||||
	nodenames = {"pipeworks:fountainhead","pipeworks:fountainhead_pouring"},
 | 
			
		||||
	interval = 1,
 | 
			
		||||
	chance = 1,
 | 
			
		||||
	action = function(pos, node, active_object_count, active_object_count_wider) 
 | 
			
		||||
	action = function(pos, node, active_object_count, active_object_count_wider)
 | 
			
		||||
		pipeworks.fountainhead_check(pos,node)
 | 
			
		||||
	end
 | 
			
		||||
})
 | 
			
		||||
 
 | 
			
		||||
@@ -29,7 +29,7 @@ end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
local formatvec = function(vec) local sep="," return "("..tostring(vec.x)..sep..tostring(vec.y)..sep..tostring(vec.z)..")" end
 | 
			
		||||
--~ local formatvec = function(vec) local sep="," return "("..tostring(vec.x)..sep..tostring(vec.y)..sep..tostring(vec.z)..")" end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -39,10 +39,10 @@ local formatvec = function(vec) local sep="," return "("..tostring(vec.x)..sep..
 | 
			
		||||
local check_for_liquids_v2 = function(pos, limit)
 | 
			
		||||
	local coords = make_coords_offsets(pos, false)
 | 
			
		||||
	local total = 0
 | 
			
		||||
	for index, tpos in ipairs(coords) do
 | 
			
		||||
	for _, tpos in ipairs(coords) do
 | 
			
		||||
		if total >= limit then break end
 | 
			
		||||
		local name = minetest.get_node(tpos).name
 | 
			
		||||
		if name == "default:water_source" then
 | 
			
		||||
		if name == pipeworks.liquids.water.source then
 | 
			
		||||
			minetest.remove_node(tpos)
 | 
			
		||||
			total = total + 1
 | 
			
		||||
		end
 | 
			
		||||
@@ -69,11 +69,13 @@ end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
-- logging is unreliable when something is crashing...
 | 
			
		||||
--[[
 | 
			
		||||
local nilexplode = function(caller, label, value)
 | 
			
		||||
	if value == nil then
 | 
			
		||||
		error(caller..": "..label.." was nil")
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
--]]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -151,7 +153,7 @@ local get_neighbour_positions = function(pos, node)
 | 
			
		||||
 | 
			
		||||
	-- then, check each possible neighbour to see if they can be reached from this node.
 | 
			
		||||
	local connections = {}
 | 
			
		||||
	for index, offset in ipairs(candidates) do
 | 
			
		||||
	for _, offset in ipairs(candidates) do
 | 
			
		||||
		local npos = vector.add(pos, offset)
 | 
			
		||||
		local neighbour = minetest.get_node(npos)
 | 
			
		||||
		local nodename = neighbour.name
 | 
			
		||||
@@ -185,13 +187,12 @@ flowlogic.balance_pressure = function(pos, node, currentpressure)
 | 
			
		||||
	-- local dname = "flowlogic.balance_pressure()@"..formatvec(pos).." "
 | 
			
		||||
	-- check the pressure of all nearby flowable nodes, and average it out.
 | 
			
		||||
 | 
			
		||||
	-- pressure handles to average over
 | 
			
		||||
	local connections = {}
 | 
			
		||||
	-- unconditionally include self in nodes to average over.
 | 
			
		||||
	-- result of averaging will be returned as new pressure for main flow logic callback
 | 
			
		||||
	local totalv = currentpressure
 | 
			
		||||
	local totalc = 1
 | 
			
		||||
 | 
			
		||||
	-- pressure handles to average over
 | 
			
		||||
	local connections = get_neighbour_positions(pos, node)
 | 
			
		||||
 | 
			
		||||
	-- for each neighbour, add neighbour's pressure to the total to balance out
 | 
			
		||||
@@ -246,9 +247,9 @@ flowlogic.helpers.make_neighbour_output_fixed = function(neighbours)
 | 
			
		||||
			-- in non-finite mode, pressure has to be sustained to keep the sources there.
 | 
			
		||||
			-- so in non-finite mode, placing water is dependent on the target node;
 | 
			
		||||
			-- draining pressure is not.
 | 
			
		||||
			local canplace = (name == "air") or (name == "default:water_flowing")
 | 
			
		||||
			local canplace = (name == "air") or (name == pipeworks.liquids.water.flowing)
 | 
			
		||||
			if canplace then
 | 
			
		||||
				minetest.swap_node(npos, {name="default:water_source"})
 | 
			
		||||
				minetest.swap_node(npos, {name=pipeworks.liquids.water.source})
 | 
			
		||||
			end
 | 
			
		||||
			if (not finitemode) or canplace then
 | 
			
		||||
				taken = taken + 1
 | 
			
		||||
@@ -267,7 +268,7 @@ flowlogic.helpers.make_neighbour_cleanup_fixed = function(neighbours)
 | 
			
		||||
		for _, offset in pairs(neighbours) do
 | 
			
		||||
			local npos = vector.add(pos, offset)
 | 
			
		||||
			local name = minetest.get_node(npos).name
 | 
			
		||||
			if (name == "default:water_source") then
 | 
			
		||||
			if (name == pipeworks.liquids.water.source) then
 | 
			
		||||
				--pipeworks.logger("neighbour_cleanup_fixed removing "..formatvec(npos))
 | 
			
		||||
				minetest.remove_node(npos)
 | 
			
		||||
			end
 | 
			
		||||
@@ -287,7 +288,7 @@ flowlogic.run_output = function(pos, node, currentpressure, oldpressure, outputd
 | 
			
		||||
	local upper = outputdef.upper
 | 
			
		||||
	local lower = outputdef.lower
 | 
			
		||||
	local result = currentpressure
 | 
			
		||||
	local threshold = nil
 | 
			
		||||
	local threshold
 | 
			
		||||
	if finitemode then threshold = lower else threshold = upper end
 | 
			
		||||
	if currentpressure > threshold then
 | 
			
		||||
		local takenpressure = outputdef.outputfn(pos, node, currentpressure, finitemode)
 | 
			
		||||
@@ -316,7 +317,7 @@ flowlogic.run_transition = function(node, currentpressure)
 | 
			
		||||
		local nodename_prev = simplesetdef[1].nodename
 | 
			
		||||
		local result_nodename = node.name
 | 
			
		||||
 | 
			
		||||
		for index, element in ipairs(simplesetdef) do
 | 
			
		||||
		for _, element in ipairs(simplesetdef) do
 | 
			
		||||
			-- find the highest element that is below the current pressure.
 | 
			
		||||
			local threshold = element.threshold
 | 
			
		||||
			if threshold > currentpressure then
 | 
			
		||||
@@ -338,7 +339,9 @@ flowlogic.run_transition = function(node, currentpressure)
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	if not found then
 | 
			
		||||
		pipeworks.logger("flowlogic.run_transition() BUG no transition definitions found! nodename="..nodename.." currentpressure="..tostring(currentpressure))
 | 
			
		||||
		pipeworks.logger("flowlogic.run_transition() BUG no transition " ..
 | 
			
		||||
			"definitions found! node.name=" .. node.name ..
 | 
			
		||||
			" currentpressure=" .. tostring(currentpressure))
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	return result
 | 
			
		||||
@@ -350,7 +353,7 @@ end
 | 
			
		||||
flowlogic.run_transition_post = function(pos, node)
 | 
			
		||||
	local mesecons_def = minetest.registered_nodes[node.name].mesecons
 | 
			
		||||
	local mesecons_rules = pipeworks.flowables.transitions.mesecons[node.name]
 | 
			
		||||
	if minetest.global_exists("mesecon") and (mesecons_def ~= nil) and mesecons_rules then
 | 
			
		||||
	if minetest.get_modpath("mesecons") and (mesecons_def ~= nil) and mesecons_rules then
 | 
			
		||||
		if type(mesecons_def) ~= "table" then
 | 
			
		||||
			pipeworks.logger("flowlogic.run_transition_post() BUG mesecons def for "..node.name.."not a table: got "..tostring(mesecons_def))
 | 
			
		||||
		else
 | 
			
		||||
 
 | 
			
		||||
@@ -26,8 +26,8 @@ local insertbase = function(nodename)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local regwarning = function(kind, nodename)
 | 
			
		||||
	local tail = ""
 | 
			
		||||
	if pipeworks.toggles.pipe_mode ~= "pressure" then tail = " but pressure logic not enabled" end
 | 
			
		||||
	--~ local tail = ""
 | 
			
		||||
	--~ if pipeworks.toggles.pipe_mode ~= "pressure" then tail = " but pressure logic not enabled" end
 | 
			
		||||
	--pipeworks.logger(kind.." flow logic registry requested for "..nodename..tail)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@@ -106,7 +106,7 @@ register.directional_horizonal_rotate = function(nodename, doubleended)
 | 
			
		||||
	end
 | 
			
		||||
	local directionfn = function(node, direction)
 | 
			
		||||
		local result = false
 | 
			
		||||
		for index, endvec in ipairs(getends(node)) do
 | 
			
		||||
		for _, endvec in ipairs(getends(node)) do
 | 
			
		||||
			if vector.equals(direction, endvec) then result = true end
 | 
			
		||||
		end
 | 
			
		||||
		return result
 | 
			
		||||
 
 | 
			
		||||
@@ -1,19 +1,48 @@
 | 
			
		||||
 | 
			
		||||
local S = minetest.get_translator("pipeworks")
 | 
			
		||||
-- the default tube and default textures
 | 
			
		||||
pipeworks.register_tube("pipeworks:tube", "Pneumatic tube segment")
 | 
			
		||||
pipeworks.register_tube("pipeworks:tube", S("Pneumatic tube segment"))
 | 
			
		||||
minetest.register_craft( {
 | 
			
		||||
	output = "pipeworks:tube_1 6",
 | 
			
		||||
	recipe = {
 | 
			
		||||
	        { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
 | 
			
		||||
	        { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
 | 
			
		||||
	        { "", "", "" },
 | 
			
		||||
	        { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
 | 
			
		||||
	        { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
 | 
			
		||||
	},
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
-- The hammers that can be used to break/repair tubes
 | 
			
		||||
local allowed_hammers = {
 | 
			
		||||
	"anvil:hammer",
 | 
			
		||||
	"cottages:hammer",
 | 
			
		||||
	"glooptest:hammer_steel",
 | 
			
		||||
	"glooptest:hammer_bronze",
 | 
			
		||||
	"glooptest:hammer_diamond",
 | 
			
		||||
	"glooptest:hammer_mese",
 | 
			
		||||
	"glooptest:hammer_alatro",
 | 
			
		||||
	"glooptest:hammer_arol"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
-- Convert the above list to a format that's easier to look up
 | 
			
		||||
for _,hammer in ipairs(allowed_hammers) do
 | 
			
		||||
	allowed_hammers[hammer] = true
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Check if the player is holding a suitable hammer or not - if they are, apply wear to it
 | 
			
		||||
function pipeworks.check_and_wear_hammer(player)
 | 
			
		||||
	local itemstack = player:get_wielded_item()
 | 
			
		||||
	local wieldname = itemstack:get_name()
 | 
			
		||||
	if allowed_hammers[wieldname] then
 | 
			
		||||
		itemstack:add_wear(1000)
 | 
			
		||||
		player:set_wielded_item(itemstack)
 | 
			
		||||
		return true
 | 
			
		||||
	end
 | 
			
		||||
	return false
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local nodecolor = 0xffff3030
 | 
			
		||||
 | 
			
		||||
pipeworks.register_tube("pipeworks:broken_tube", {
 | 
			
		||||
	description = "Broken Tube (you hacker you)",
 | 
			
		||||
	description = S("Broken Tube"),
 | 
			
		||||
	plain = { { name = "pipeworks_broken_tube_plain.png", backface_culling = false, color = nodecolor } },
 | 
			
		||||
	noctr = { { name = "pipeworks_broken_tube_plain.png", backface_culling = false, color = nodecolor } },
 | 
			
		||||
	ends  = { { name = "pipeworks_broken_tube_end.png",   color = nodecolor } },
 | 
			
		||||
@@ -35,31 +64,49 @@ pipeworks.register_tube("pipeworks:broken_tube", {
 | 
			
		||||
			local itemstack = puncher:get_wielded_item()
 | 
			
		||||
			local wieldname = itemstack:get_name()
 | 
			
		||||
			local playername = puncher:get_player_name()
 | 
			
		||||
			print("[Pipeworks] "..playername.." struck a broken tube at "..minetest.pos_to_string(pos))
 | 
			
		||||
			if   wieldname == "anvil:hammer"
 | 
			
		||||
			  or wieldname == "cottages:hammer"
 | 
			
		||||
			  or wieldname == "glooptest:hammer_steel"
 | 
			
		||||
			  or wieldname == "glooptest:hammer_bronze"
 | 
			
		||||
			  or wieldname == "glooptest:hammer_diamond"
 | 
			
		||||
			  or wieldname == "glooptest:hammer_mese"
 | 
			
		||||
			  or wieldname == "glooptest:hammer_alatro"
 | 
			
		||||
			  or wieldname == "glooptest:hammer_arol" then
 | 
			
		||||
				local meta = minetest.get_meta(pos)
 | 
			
		||||
				local was_node = minetest.deserialize(meta:get_string("the_tube_was"))
 | 
			
		||||
				if was_node and was_node ~= "" then
 | 
			
		||||
					print("            with "..wieldname.." to repair it.")
 | 
			
		||||
			local log_msg = playername.." struck a broken tube at "..minetest.pos_to_string(pos).."\n            "
 | 
			
		||||
			local meta = minetest.get_meta(pos)
 | 
			
		||||
			local was_node = minetest.deserialize(meta:get_string("the_tube_was"))
 | 
			
		||||
			if not was_node then
 | 
			
		||||
				pipeworks.logger(log_msg.."but it can't be repaired.")
 | 
			
		||||
				return
 | 
			
		||||
			end
 | 
			
		||||
			if not pipeworks.check_and_wear_hammer(puncher) then
 | 
			
		||||
				if wieldname == "" then
 | 
			
		||||
					pipeworks.logger(log_msg.."by hand. It's not very effective.")
 | 
			
		||||
					if minetest.settings:get_bool("enable_damage") then
 | 
			
		||||
						minetest.chat_send_player(playername,S("Broken tubes may be a bit sharp. Perhaps try with a hammer?"))
 | 
			
		||||
						puncher:set_hp(puncher:get_hp()-1)
 | 
			
		||||
					end
 | 
			
		||||
				else
 | 
			
		||||
					pipeworks.logger(log_msg.."with "..wieldname.." but that tool is too weak.")
 | 
			
		||||
				end
 | 
			
		||||
				return
 | 
			
		||||
			end
 | 
			
		||||
			log_msg = log_msg.."with "..wieldname.." to repair it"
 | 
			
		||||
			local nodedef = minetest.registered_nodes[was_node.name]
 | 
			
		||||
			if nodedef then
 | 
			
		||||
				pipeworks.logger(log_msg..".")
 | 
			
		||||
				if nodedef.tube and nodedef.tube.on_repair then
 | 
			
		||||
					nodedef.tube.on_repair(pos, was_node)
 | 
			
		||||
				else
 | 
			
		||||
					minetest.swap_node(pos, { name = was_node.name, param2 = was_node.param2 })
 | 
			
		||||
					pipeworks.scan_for_tube_objects(pos)
 | 
			
		||||
					itemstack:add_wear(1000)
 | 
			
		||||
					puncher:set_wielded_item(itemstack)
 | 
			
		||||
					return itemstack
 | 
			
		||||
				else
 | 
			
		||||
					print("            but it can't be repaired.")
 | 
			
		||||
				end
 | 
			
		||||
			else
 | 
			
		||||
				print("            with "..wieldname.." but that tool is too weak.")
 | 
			
		||||
				pipeworks.logger(log_msg.." but original node "..was_node.name.." is not registered anymore.")
 | 
			
		||||
				minetest.chat_send_player(playername, S("This tube cannot be repaired."))
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
		end,
 | 
			
		||||
		allow_metadata_inventory_put = function()
 | 
			
		||||
			return 0
 | 
			
		||||
		end,
 | 
			
		||||
		allow_metadata_inventory_move = function()
 | 
			
		||||
			return 0
 | 
			
		||||
		end,
 | 
			
		||||
		allow_metadata_inventory_take = function()
 | 
			
		||||
			return 0
 | 
			
		||||
		end,
 | 
			
		||||
	}
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
@@ -69,7 +116,7 @@ pipeworks.register_tube("pipeworks:broken_tube", {
 | 
			
		||||
if pipeworks.enable_priority_tube then
 | 
			
		||||
	local color = "#ff3030:128"
 | 
			
		||||
	pipeworks.register_tube("pipeworks:priority_tube", {
 | 
			
		||||
			description = "High Priority Tube Segment",
 | 
			
		||||
			description = S("High Priority Tube Segment"),
 | 
			
		||||
			inventory_image = "pipeworks_tube_inv.png^[colorize:" .. color,
 | 
			
		||||
			plain = { { name = "pipeworks_tube_plain.png", color = nodecolor } },
 | 
			
		||||
			noctr = { { name = "pipeworks_tube_noctr.png", color = nodecolor } },
 | 
			
		||||
@@ -79,19 +126,11 @@ if pipeworks.enable_priority_tube then
 | 
			
		||||
				tube = { priority = 150 } -- higher than tubedevices (100)
 | 
			
		||||
			},
 | 
			
		||||
	})
 | 
			
		||||
	minetest.register_craft( {
 | 
			
		||||
		output = "pipeworks:priority_tube_1 6",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
 | 
			
		||||
			{ "default:gold_ingot", "", "default:gold_ingot" },
 | 
			
		||||
			{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if pipeworks.enable_accelerator_tube then
 | 
			
		||||
	pipeworks.register_tube("pipeworks:accelerator_tube", {
 | 
			
		||||
			description = "Accelerating Pneumatic Tube Segment",
 | 
			
		||||
			description = S("Accelerating Pneumatic Tube Segment"),
 | 
			
		||||
			inventory_image = "pipeworks_accelerator_tube_inv.png",
 | 
			
		||||
			plain = { "pipeworks_accelerator_tube_plain.png" },
 | 
			
		||||
			noctr = { "pipeworks_accelerator_tube_noctr.png" },
 | 
			
		||||
@@ -104,19 +143,11 @@ if pipeworks.enable_accelerator_tube then
 | 
			
		||||
					end}
 | 
			
		||||
			},
 | 
			
		||||
	})
 | 
			
		||||
	minetest.register_craft( {
 | 
			
		||||
		output = "pipeworks:accelerator_tube_1 2",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
 | 
			
		||||
			{ "default:mese_crystal_fragment", "default:steel_ingot", "default:mese_crystal_fragment" },
 | 
			
		||||
			{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if pipeworks.enable_crossing_tube then
 | 
			
		||||
	pipeworks.register_tube("pipeworks:crossing_tube", {
 | 
			
		||||
			description = "Crossing Pneumatic Tube Segment",
 | 
			
		||||
			description = S("Crossing Pneumatic Tube Segment"),
 | 
			
		||||
			inventory_image = "pipeworks_crossing_tube_inv.png",
 | 
			
		||||
			plain = { "pipeworks_crossing_tube_plain.png" },
 | 
			
		||||
			noctr = { "pipeworks_crossing_tube_noctr.png" },
 | 
			
		||||
@@ -126,28 +157,31 @@ if pipeworks.enable_crossing_tube then
 | 
			
		||||
				tube = {can_go = function(pos, node, velocity, stack) return {velocity} end }
 | 
			
		||||
			},
 | 
			
		||||
	})
 | 
			
		||||
	minetest.register_craft( {
 | 
			
		||||
		output = "pipeworks:crossing_tube_1 5",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			{ "", "pipeworks:tube_1", "" },
 | 
			
		||||
			{ "pipeworks:tube_1", "pipeworks:tube_1", "pipeworks:tube_1" },
 | 
			
		||||
			{ "", "pipeworks:tube_1", "" }
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local texture_alpha_mode = minetest.features.use_texture_alpha_string_modes
 | 
			
		||||
	and "clip" or true
 | 
			
		||||
 | 
			
		||||
if pipeworks.enable_one_way_tube then
 | 
			
		||||
	local tiles = {"pipeworks_one_way_tube_top.png", "pipeworks_one_way_tube_top.png", "pipeworks_one_way_tube_output.png",
 | 
			
		||||
		"pipeworks_one_way_tube_input.png", "pipeworks_one_way_tube_side.png", "pipeworks_one_way_tube_top.png"}
 | 
			
		||||
	for i, tile in ipairs(tiles) do
 | 
			
		||||
		tiles[i] = pipeworks.make_tube_tile(tile)
 | 
			
		||||
	end
 | 
			
		||||
	minetest.register_node("pipeworks:one_way_tube", {
 | 
			
		||||
		description = "One way tube",
 | 
			
		||||
		tiles = {"pipeworks_one_way_tube_top.png", "pipeworks_one_way_tube_top.png", "pipeworks_one_way_tube_output.png",
 | 
			
		||||
			"pipeworks_one_way_tube_input.png", "pipeworks_one_way_tube_side.png", "pipeworks_one_way_tube_top.png"},
 | 
			
		||||
		description = S("One way tube"),
 | 
			
		||||
		tiles = tiles,
 | 
			
		||||
		use_texture_alpha = texture_alpha_mode,
 | 
			
		||||
		paramtype2 = "facedir",
 | 
			
		||||
		drawtype = "nodebox",
 | 
			
		||||
		paramtype = "light",
 | 
			
		||||
		node_box = {type = "fixed",
 | 
			
		||||
			fixed = {{-1/2, -9/64, -9/64, 1/2, 9/64, 9/64}}},
 | 
			
		||||
		groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, tubedevice = 1},
 | 
			
		||||
		sounds = default.node_sound_wood_defaults(),
 | 
			
		||||
		groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, tubedevice = 1, axey=1, handy=1, pickaxey=1},
 | 
			
		||||
		_mcl_hardness=0.8,
 | 
			
		||||
		_sound_def = {
 | 
			
		||||
			key = "node_sound_wood_defaults",
 | 
			
		||||
		},
 | 
			
		||||
		tube = {
 | 
			
		||||
			connect_sides = {left = 1, right = 1},
 | 
			
		||||
			can_go = function(pos, node, velocity, stack)
 | 
			
		||||
@@ -161,13 +195,9 @@ if pipeworks.enable_one_way_tube then
 | 
			
		||||
		},
 | 
			
		||||
		after_place_node = pipeworks.after_place,
 | 
			
		||||
		after_dig_node = pipeworks.after_dig,
 | 
			
		||||
		on_rotate = pipeworks.on_rotate,
 | 
			
		||||
		check_for_pole = pipeworks.check_for_vert_tube,
 | 
			
		||||
		check_for_horiz_pole = pipeworks.check_for_horiz_tube
 | 
			
		||||
	})
 | 
			
		||||
	minetest.register_craft({
 | 
			
		||||
		output = "pipeworks:one_way_tube 2",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
 | 
			
		||||
			{ "group:stick", "default:mese_crystal", "homedecor:plastic_sheeting" },
 | 
			
		||||
			{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
	pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:one_way_tube"
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -75,3 +75,15 @@ pipeworks_drop_on_routing_fail (Drop On Routing Fail) bool false
 | 
			
		||||
 | 
			
		||||
#Delete item on clearobject.
 | 
			
		||||
pipeworks_delete_item_on_clearobject (Delete Item On Clearobject) bool true
 | 
			
		||||
 | 
			
		||||
#Use real visible entities in tubes within active areas.
 | 
			
		||||
#When disabled, tubes are made opaque.
 | 
			
		||||
pipeworks_use_real_entities (Use Real Entities) bool true
 | 
			
		||||
 | 
			
		||||
#Target interval between tube entity steps.
 | 
			
		||||
#A high value may cause issues with tube entity visuals.
 | 
			
		||||
#A value 0.2 or above may cause issues with accelerator tubes.
 | 
			
		||||
pipeworks_entity_update_interval (Entity Update Interval) float 0 0 0.8
 | 
			
		||||
 | 
			
		||||
# if set to true, items passing through teleport tubes will log log where they came from and where they went.
 | 
			
		||||
pipeworks_log_teleport_tubes (Log Teleport Tubes) bool false
 | 
			
		||||
 
 | 
			
		||||
@@ -1,17 +1,29 @@
 | 
			
		||||
if pipeworks.enable_detector_tube then
 | 
			
		||||
	local detector_tube_step = 5 * tonumber(minetest.settings:get("dedicated_server_step"))
 | 
			
		||||
local S = minetest.get_translator("pipeworks")
 | 
			
		||||
 | 
			
		||||
-- the minetest.after() calls below can sometimes trigger after a tube
 | 
			
		||||
-- breaks, at which point item_exit() is no longer valid, so we have to make
 | 
			
		||||
-- sure that there even IS a callback to run, first.
 | 
			
		||||
 | 
			
		||||
local function after_break(pos)
 | 
			
		||||
	local name = minetest.get_node(pos).name
 | 
			
		||||
	if minetest.registered_nodes[name].item_exit then
 | 
			
		||||
		minetest.registered_nodes[name].item_exit(pos)
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if minetest.get_modpath("mesecons") and pipeworks.enable_detector_tube then
 | 
			
		||||
	local detector_tube_step = 5 * (tonumber(minetest.settings:get("dedicated_server_step")) or 0.09)
 | 
			
		||||
	pipeworks.register_tube("pipeworks:detector_tube_on", {
 | 
			
		||||
			description = "Detecting Pneumatic Tube Segment on (you hacker you)",
 | 
			
		||||
			description = S("Detecting Pneumatic Tube Segment on"),
 | 
			
		||||
			inventory_image = "pipeworks_detector_tube_inv.png",
 | 
			
		||||
			plain = { "pipeworks_detector_tube_plain.png" },
 | 
			
		||||
			node_def = {
 | 
			
		||||
				tube = {can_go = function(pos, node, velocity, stack)
 | 
			
		||||
						 local meta = minetest.get_meta(pos)
 | 
			
		||||
						 local name = minetest.get_node(pos).name
 | 
			
		||||
						 local nitems = meta:get_int("nitems")+1
 | 
			
		||||
						 meta:set_int("nitems", nitems)
 | 
			
		||||
						 local saved_pos = vector.new(pos)
 | 
			
		||||
						 minetest.after(detector_tube_step, minetest.registered_nodes[name].item_exit, saved_pos)
 | 
			
		||||
						 minetest.after(detector_tube_step, after_break, saved_pos)
 | 
			
		||||
						 return pipeworks.notvel(pipeworks.meseadjlist,velocity)
 | 
			
		||||
					end},
 | 
			
		||||
				groups = {mesecon = 2, not_in_creative_inventory = 1},
 | 
			
		||||
@@ -33,14 +45,12 @@ if pipeworks.enable_detector_tube then
 | 
			
		||||
				on_construct = function(pos)
 | 
			
		||||
					 local meta = minetest.get_meta(pos)
 | 
			
		||||
					 meta:set_int("nitems", 1)
 | 
			
		||||
					 local name = minetest.get_node(pos).name
 | 
			
		||||
					 local saved_pos = vector.new(pos)
 | 
			
		||||
					 minetest.after(detector_tube_step, minetest.registered_nodes[name].item_exit, saved_pos)
 | 
			
		||||
					 minetest.after(detector_tube_step, after_break, pos)
 | 
			
		||||
				end,
 | 
			
		||||
			},
 | 
			
		||||
	})
 | 
			
		||||
	pipeworks.register_tube("pipeworks:detector_tube_off", {
 | 
			
		||||
			description = "Detecting Pneumatic Tube Segment",
 | 
			
		||||
			description = S("Detecting Pneumatic Tube Segment"),
 | 
			
		||||
			inventory_image = "pipeworks_detector_tube_inv.png",
 | 
			
		||||
			plain = { "pipeworks_detector_tube_plain.png" },
 | 
			
		||||
			node_def = {
 | 
			
		||||
@@ -60,9 +70,9 @@ if pipeworks.enable_detector_tube then
 | 
			
		||||
	minetest.register_craft( {
 | 
			
		||||
		output = "pipeworks:detector_tube_off_1 2",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
 | 
			
		||||
			{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
 | 
			
		||||
			{ "mesecons:mesecon", "mesecons_materials:silicon", "mesecons:mesecon" },
 | 
			
		||||
			{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
 | 
			
		||||
			{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
end
 | 
			
		||||
@@ -70,7 +80,7 @@ end
 | 
			
		||||
local digiline_enabled = minetest.get_modpath("digilines") ~= nil
 | 
			
		||||
if digiline_enabled and pipeworks.enable_digiline_detector_tube then
 | 
			
		||||
	pipeworks.register_tube("pipeworks:digiline_detector_tube", {
 | 
			
		||||
			description = "Digiline Detecting Pneumatic Tube Segment",
 | 
			
		||||
			description = S("Digiline Detecting Pneumatic Tube Segment"),
 | 
			
		||||
			inventory_image = "pipeworks_digiline_detector_tube_inv.png",
 | 
			
		||||
			plain = { "pipeworks_digiline_detector_tube_plain.png" },
 | 
			
		||||
			node_def = {
 | 
			
		||||
@@ -79,20 +89,27 @@ if digiline_enabled and pipeworks.enable_digiline_detector_tube then
 | 
			
		||||
 | 
			
		||||
						local setchan = meta:get_string("channel")
 | 
			
		||||
 | 
			
		||||
						digiline:receptor_send(pos, digiline.rules.default, setchan, stack:to_string())
 | 
			
		||||
						digiline:receptor_send(pos, digiline.rules.default, setchan, stack:to_table())
 | 
			
		||||
 | 
			
		||||
						return pipeworks.notvel(pipeworks.meseadjlist, velocity)
 | 
			
		||||
					end},
 | 
			
		||||
				on_construct = function(pos)
 | 
			
		||||
					local meta = minetest.get_meta(pos)
 | 
			
		||||
					meta:set_string("formspec",
 | 
			
		||||
						"size[8.6,2.2]"..
 | 
			
		||||
						"field[0.6,0.6;8,1;channel;Channel:;${channel}]"..
 | 
			
		||||
						"image[0.3,1.3;1,1;pipeworks_digiline_detector_tube_inv.png]"..
 | 
			
		||||
						"label[1.6,1.2;Digiline Detecting Tube]"
 | 
			
		||||
						"size[8.5,2.2]"..
 | 
			
		||||
						"image[0.2,0;1,1;pipeworks_digiline_detector_tube_inv.png]"..
 | 
			
		||||
						"label[1.2,0.2;"..S("Digiline Detecting Tube").."]"..
 | 
			
		||||
						"field[0.5,1.6;4.6,1;channel;"..S("Channel")..";${channel}]"..
 | 
			
		||||
						"button[4.8,1.3;1.5,1;set_channel;"..S("Set").."]"..
 | 
			
		||||
						"button_exit[6.3,1.3;2,1;close;"..S("Close").."]"
 | 
			
		||||
					)
 | 
			
		||||
				end,
 | 
			
		||||
				on_receive_fields = function(pos, formname, fields, sender)
 | 
			
		||||
					if (fields.quit and not fields.key_enter_field)
 | 
			
		||||
					or (fields.key_enter_field ~= "channel" and not fields.set_channel)
 | 
			
		||||
					or not pipeworks.may_configure(pos, sender) then
 | 
			
		||||
						return
 | 
			
		||||
					end
 | 
			
		||||
					if fields.channel then
 | 
			
		||||
						minetest.get_meta(pos):set_string("channel", fields.channel)
 | 
			
		||||
					end
 | 
			
		||||
@@ -102,7 +119,10 @@ if digiline_enabled and pipeworks.enable_digiline_detector_tube then
 | 
			
		||||
					receptor = {},
 | 
			
		||||
					effector = {
 | 
			
		||||
						action = function(pos,node,channel,msg) end
 | 
			
		||||
					}
 | 
			
		||||
					},
 | 
			
		||||
					wire = {
 | 
			
		||||
						rules = pipeworks.digilines_rules
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
	})
 | 
			
		||||
@@ -110,16 +130,16 @@ if digiline_enabled and pipeworks.enable_digiline_detector_tube then
 | 
			
		||||
	minetest.register_craft( {
 | 
			
		||||
		output = "pipeworks:digiline_detector_tube_1 2",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
 | 
			
		||||
			{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
 | 
			
		||||
			{ "digilines:wire_std_00000000", "mesecons_materials:silicon", "digilines:wire_std_00000000" },
 | 
			
		||||
			{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
 | 
			
		||||
			{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if pipeworks.enable_conductor_tube then
 | 
			
		||||
if minetest.get_modpath("mesecons") and pipeworks.enable_conductor_tube then
 | 
			
		||||
	pipeworks.register_tube("pipeworks:conductor_tube_off", {
 | 
			
		||||
			description = "Conducting Pneumatic Tube Segment",
 | 
			
		||||
			description = S("Conducting Pneumatic Tube Segment"),
 | 
			
		||||
			inventory_image = "pipeworks_conductor_tube_inv.png",
 | 
			
		||||
			short = "pipeworks_conductor_tube_short.png",
 | 
			
		||||
			plain = { "pipeworks_conductor_tube_plain.png" },
 | 
			
		||||
@@ -133,7 +153,7 @@ if pipeworks.enable_conductor_tube then
 | 
			
		||||
			},
 | 
			
		||||
	})
 | 
			
		||||
	pipeworks.register_tube("pipeworks:conductor_tube_on", {
 | 
			
		||||
			description = "Conducting Pneumatic Tube Segment on (you hacker you)",
 | 
			
		||||
			description = S("Conducting Pneumatic Tube Segment on"),
 | 
			
		||||
			inventory_image = "pipeworks_conductor_tube_inv.png",
 | 
			
		||||
			short = "pipeworks_conductor_tube_short.png",
 | 
			
		||||
			plain = { "pipeworks_conductor_tube_on_plain.png" },
 | 
			
		||||
@@ -157,7 +177,7 @@ end
 | 
			
		||||
 | 
			
		||||
if digiline_enabled and pipeworks.enable_digiline_conductor_tube then
 | 
			
		||||
	pipeworks.register_tube("pipeworks:digiline_conductor_tube", {
 | 
			
		||||
		description = "Digiline Conducting Pneumatic Tube Segment",
 | 
			
		||||
		description = S("Digiline Conducting Pneumatic Tube Segment"),
 | 
			
		||||
		inventory_image = "pipeworks_tube_inv.png^pipeworks_digiline_conductor_tube_inv.png",
 | 
			
		||||
		short = "pipeworks_tube_short.png^pipeworks_digiline_conductor_tube_short.png",
 | 
			
		||||
		plain = {"pipeworks_tube_plain.png^pipeworks_digiline_conductor_tube_plain.png"},
 | 
			
		||||
@@ -175,7 +195,7 @@ end
 | 
			
		||||
if digiline_enabled and pipeworks.enable_digiline_conductor_tube and
 | 
			
		||||
		pipeworks.enable_conductor_tube then
 | 
			
		||||
	pipeworks.register_tube("pipeworks:mesecon_and_digiline_conductor_tube_off", {
 | 
			
		||||
		description = "Mesecon and Digiline Conducting Pneumatic Tube Segment",
 | 
			
		||||
		description = S("Mesecon and Digiline Conducting Pneumatic Tube Segment"),
 | 
			
		||||
		inventory_image = "pipeworks_conductor_tube_inv.png^pipeworks_digiline_conductor_tube_inv.png",
 | 
			
		||||
		short = "pipeworks_conductor_tube_short.png^pipeworks_digiline_conductor_tube_short.png",
 | 
			
		||||
		plain = {"pipeworks_conductor_tube_plain.png^pipeworks_digiline_conductor_tube_plain.png"},
 | 
			
		||||
@@ -192,7 +212,7 @@ if digiline_enabled and pipeworks.enable_digiline_conductor_tube and
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
	pipeworks.register_tube("pipeworks:mesecon_and_digiline_conductor_tube_on", {
 | 
			
		||||
		description = "Mesecon and Digiline Conducting Pneumatic Tube Segment on (you hacker you)",
 | 
			
		||||
		description = S("Mesecon and Digiline Conducting Pneumatic Tube Segment on"),
 | 
			
		||||
		inventory_image = "pipeworks_conductor_tube_inv.png^pipeworks_digiline_conductor_tube_inv.png",
 | 
			
		||||
		short = "pipeworks_conductor_tube_short.png^pipeworks_digiline_conductor_tube_short.png",
 | 
			
		||||
		plain = {"pipeworks_conductor_tube_on_plain.png^pipeworks_digiline_conductor_tube_plain.png"},
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										241
									
								
								signs_compat.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										241
									
								
								signs_compat.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,241 @@
 | 
			
		||||
-- This file adds placement rules for signs_lib, if present
 | 
			
		||||
 | 
			
		||||
local spv = {
 | 
			
		||||
	[4] = true,
 | 
			
		||||
	[6] = true,
 | 
			
		||||
	[8] = true,
 | 
			
		||||
	[10] = true,
 | 
			
		||||
	[13] = true,
 | 
			
		||||
	[15] = true,
 | 
			
		||||
	[17] = true,
 | 
			
		||||
	[19] = true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local sphns = {
 | 
			
		||||
	[1] = true,
 | 
			
		||||
	[3] = true,
 | 
			
		||||
	[5] = true,
 | 
			
		||||
	[7] = true,
 | 
			
		||||
	[9] = true,
 | 
			
		||||
	[11] = true,
 | 
			
		||||
	[21] = true,
 | 
			
		||||
	[23] = true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local sphew = {
 | 
			
		||||
	[0] = true,
 | 
			
		||||
	[2] = true,
 | 
			
		||||
	[12] = true,
 | 
			
		||||
	[14] = true,
 | 
			
		||||
	[16] = true,
 | 
			
		||||
	[18] = true,
 | 
			
		||||
	[20] = true,
 | 
			
		||||
	[22] = true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local owtv = {
 | 
			
		||||
	[5] = true,
 | 
			
		||||
	[7] = true,
 | 
			
		||||
	[9] = true,
 | 
			
		||||
	[11] = true,
 | 
			
		||||
	[12] = true,
 | 
			
		||||
	[14] = true,
 | 
			
		||||
	[16] = true,
 | 
			
		||||
	[18] = true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local owtns = {
 | 
			
		||||
	[0] = true,
 | 
			
		||||
	[2] = true,
 | 
			
		||||
	[4] = true,
 | 
			
		||||
	[6] = true,
 | 
			
		||||
	[8] = true,
 | 
			
		||||
	[10] = true,
 | 
			
		||||
	[20] = true,
 | 
			
		||||
	[22] = true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local owtew = {
 | 
			
		||||
	[1] = true,
 | 
			
		||||
	[3] = true,
 | 
			
		||||
	[13] = true,
 | 
			
		||||
	[15] = true,
 | 
			
		||||
	[17] = true,
 | 
			
		||||
	[19] = true,
 | 
			
		||||
	[21] = true,
 | 
			
		||||
	[23] = true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local vert_n = {
 | 
			
		||||
	[3] = {[5] = true},
 | 
			
		||||
	[6] = {[9] = true, [12] = true, [16] = true},
 | 
			
		||||
	[7] = {[9] = true, [11] = true},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local vert_e = {
 | 
			
		||||
	[3] = {[5] = true},
 | 
			
		||||
	[6] = {[5] = true, [9] = true, [16] = true},
 | 
			
		||||
	[7] = {[7] = true, [11] = true},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local vert_s = {
 | 
			
		||||
	[3] = {[5] = true},
 | 
			
		||||
	[6] = {[5] = true, [12] = true, [16] = true},
 | 
			
		||||
	[7] = {[5] = true, [7] = true},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local vert_w = {
 | 
			
		||||
	[3] = {[5] = true},
 | 
			
		||||
	[6] = {[5] = true, [9] = true, [12] = true},
 | 
			
		||||
	[7] = {[5] = true, [9] = true},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local horiz_n = {
 | 
			
		||||
	[3] = {[0] = true},
 | 
			
		||||
	[6] = {[0] = true, [4] = true, [20] = true},
 | 
			
		||||
	[7] = {[2] = true, [10] = true},
 | 
			
		||||
	[8] = {[0] = true},
 | 
			
		||||
	[9] = {[2] = true},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local horiz_e = {
 | 
			
		||||
	[3] = {[1] = true},
 | 
			
		||||
	[6] = {[1] = true, [17] = true, [21] = true},
 | 
			
		||||
	[7] = {[3] = true, [19] = true},
 | 
			
		||||
	[8] = {[1] = true},
 | 
			
		||||
	[9] = {[3] = true},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local horiz_s = {
 | 
			
		||||
	[3] = {[0] = true},
 | 
			
		||||
	[6] = {[0] = true, [8] = true, [20] = true},
 | 
			
		||||
	[7] = {[0] = true, [4] = true},
 | 
			
		||||
	[8] = {[0] = true},
 | 
			
		||||
	[9] = {[0] = true},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local horiz_w = {
 | 
			
		||||
	[3] = {[1] = true},
 | 
			
		||||
	[6] = {[1] = true, [13] = true, [21] = true},
 | 
			
		||||
	[7] = {[1] = true, [13] = true},
 | 
			
		||||
	[8] = {[1] = true},
 | 
			
		||||
	[9] = {[1] = true},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local function get_sign_dir(node, def)
 | 
			
		||||
	if (node.param2 == 4 and def.paramtype2 == "wallmounted")
 | 
			
		||||
	  or (node.param2 == 0 and def.paramtype2 ~= "wallmounted") then
 | 
			
		||||
		return {["N"] = true}
 | 
			
		||||
	elseif (node.param2 == 2 and def.paramtype2 == "wallmounted")
 | 
			
		||||
	  or (node.param2 == 1 and def.paramtype2 ~= "wallmounted") then
 | 
			
		||||
		return {["E"] = true}
 | 
			
		||||
	elseif (node.param2 == 5 and def.paramtype2 == "wallmounted")
 | 
			
		||||
	  or (node.param2 == 2 and def.paramtype2 ~= "wallmounted") then
 | 
			
		||||
		return {["S"] = true}
 | 
			
		||||
	elseif node.param2 == 3 then
 | 
			
		||||
		return {["W"] = true}
 | 
			
		||||
	end
 | 
			
		||||
	return {}
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
--[[
 | 
			
		||||
In the functions below:
 | 
			
		||||
 | 
			
		||||
 pos: the (real) position of the placed sign
 | 
			
		||||
 node: the sign node itself
 | 
			
		||||
 def: its definition
 | 
			
		||||
 | 
			
		||||
 ppos: the position of the pointed node (pipe/tube)
 | 
			
		||||
 pnode: the node itself
 | 
			
		||||
 pdef: its definition
 | 
			
		||||
 | 
			
		||||
--]]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
-- pipes
 | 
			
		||||
 | 
			
		||||
function pipeworks.check_for_vert_pipe(pos, node, def, ppos, pnode, pdef)
 | 
			
		||||
	local signdir = get_sign_dir(node, def)
 | 
			
		||||
	local pipenumber = pdef.pipenumber
 | 
			
		||||
	local pipedir = pnode.param2
 | 
			
		||||
	if string.find(pnode.name, "straight_pipe") and spv[pipedir] then
 | 
			
		||||
		return true
 | 
			
		||||
	elseif signdir["N"] and vert_n[pipenumber] and vert_n[pipenumber][pipedir] then
 | 
			
		||||
		return true
 | 
			
		||||
	elseif signdir["E"] and vert_e[pipenumber] and vert_e[pipenumber][pipedir] then
 | 
			
		||||
		return true
 | 
			
		||||
	elseif signdir["S"] and vert_s[pipenumber] and vert_s[pipenumber][pipedir] then
 | 
			
		||||
		return true
 | 
			
		||||
	elseif signdir["W"] and vert_w[pipenumber] and vert_w[pipenumber][pipedir] then
 | 
			
		||||
		return true
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function pipeworks.check_for_horiz_pipe(pos, node, def, ppos, pnode, pdef)
 | 
			
		||||
	local signdir = get_sign_dir(node, def)
 | 
			
		||||
	local pipenumber = pdef.pipenumber
 | 
			
		||||
	local pipedir = pnode.param2
 | 
			
		||||
	if string.find(pnode.name, "straight_pipe") then
 | 
			
		||||
		if (signdir["N"] or signdir["S"]) and sphns[pipedir] then
 | 
			
		||||
			return true
 | 
			
		||||
		elseif (signdir["E"] or signdir["W"]) and sphew[pipedir] then
 | 
			
		||||
			return true
 | 
			
		||||
		end
 | 
			
		||||
	elseif signdir["N"] and horiz_n[pipenumber] and horiz_n[pipenumber][pipedir] then
 | 
			
		||||
		return true
 | 
			
		||||
	elseif signdir["E"] and horiz_e[pipenumber] and horiz_e[pipenumber][pipedir] then
 | 
			
		||||
		return true
 | 
			
		||||
	elseif signdir["S"] and horiz_s[pipenumber] and horiz_s[pipenumber][pipedir] then
 | 
			
		||||
		return true
 | 
			
		||||
	elseif signdir["W"] and horiz_w[pipenumber] and horiz_w[pipenumber][pipedir] then
 | 
			
		||||
		return true
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- tubes
 | 
			
		||||
 | 
			
		||||
function pipeworks.check_for_vert_tube(pos, node, def, ppos, pnode, pdef)
 | 
			
		||||
	local signdir = get_sign_dir(node, def)
 | 
			
		||||
	local tubenumber = pdef.tubenumber
 | 
			
		||||
	local tubedir = pnode.param2
 | 
			
		||||
	if pnode.name == "pipeworks:one_way_tube" and owtv[tubedir] then
 | 
			
		||||
		return true
 | 
			
		||||
	elseif tubenumber == 2 and (tubedir == 5 or tubedir == 7) then -- it's a stub pointing up or down
 | 
			
		||||
		return true
 | 
			
		||||
	elseif signdir["N"] and vert_n[tubenumber] and vert_n[tubenumber][tubedir] then
 | 
			
		||||
		return true
 | 
			
		||||
	elseif signdir["E"] and vert_e[tubenumber] and vert_e[tubenumber][tubedir] then
 | 
			
		||||
		return true
 | 
			
		||||
	elseif signdir["S"] and vert_s[tubenumber] and vert_s[tubenumber][tubedir] then
 | 
			
		||||
		return true
 | 
			
		||||
	elseif signdir["W"] and vert_w[tubenumber] and vert_w[tubenumber][tubedir] then
 | 
			
		||||
		return true
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function pipeworks.check_for_horiz_tube(pos, node, def, ppos, pnode, pdef)
 | 
			
		||||
	local signdir = get_sign_dir(node, def)
 | 
			
		||||
	local tubenumber = pdef.tubenumber
 | 
			
		||||
	local tubedir = pnode.param2
 | 
			
		||||
	if tubenumber == 2 then -- it'a a stub pointing sideways
 | 
			
		||||
		if (tubedir == 0 or tubedir == 2) and (signdir["N"] or signdir["S"]) then
 | 
			
		||||
			return true
 | 
			
		||||
		elseif (tubedir == 1 or tubedir == 3) and (signdir["E"] or signdir["W"]) then
 | 
			
		||||
			return true
 | 
			
		||||
		end
 | 
			
		||||
	elseif pnode.name == "pipeworks:one_way_tube" then
 | 
			
		||||
		if (signdir["N"] or signdir["S"]) and owtns[tubedir] then
 | 
			
		||||
			return true
 | 
			
		||||
		elseif (signdir["E"] or signdir["W"]) and owtew[tubedir] then
 | 
			
		||||
			return true
 | 
			
		||||
		end
 | 
			
		||||
	elseif signdir["N"] and horiz_n[tubenumber] and horiz_n[tubenumber][tubedir] then
 | 
			
		||||
		return true
 | 
			
		||||
	elseif signdir["E"] and horiz_e[tubenumber] and horiz_e[tubenumber][tubedir] then
 | 
			
		||||
		return true
 | 
			
		||||
	elseif signdir["S"] and horiz_s[tubenumber] and horiz_s[tubenumber][tubedir] then
 | 
			
		||||
		return true
 | 
			
		||||
	elseif signdir["W"] and horiz_w[tubenumber] and horiz_w[tubenumber][tubedir] then
 | 
			
		||||
		return true
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
local S = minetest.get_translator("pipeworks")
 | 
			
		||||
local fs_helpers = pipeworks.fs_helpers
 | 
			
		||||
 | 
			
		||||
if pipeworks.enable_mese_tube then
 | 
			
		||||
@@ -15,29 +16,43 @@ if pipeworks.enable_mese_tube then
 | 
			
		||||
		local buttons_formspec = ""
 | 
			
		||||
		for i = 0, 5 do
 | 
			
		||||
			buttons_formspec = buttons_formspec .. fs_helpers.cycling_button(meta,
 | 
			
		||||
				"image_button[7,"..(i+0.2)..";1,0.6", "l"..(i+1).."s",
 | 
			
		||||
				"image_button[9,"..(i+(i*0.25)+0.5)..";1,0.6", "l"..(i+1).."s",
 | 
			
		||||
				{
 | 
			
		||||
					pipeworks.button_off,
 | 
			
		||||
					pipeworks.button_on
 | 
			
		||||
				}
 | 
			
		||||
			)
 | 
			
		||||
		end
 | 
			
		||||
		local list_backgrounds = ""
 | 
			
		||||
		if minetest.get_modpath("i3") or minetest.get_modpath("mcl_formspec") then
 | 
			
		||||
			list_backgrounds = "style_type[box;colors=#666]"
 | 
			
		||||
			for i=0, 5 do
 | 
			
		||||
				for j=0, 5 do
 | 
			
		||||
					list_backgrounds = list_backgrounds .. "box[".. 1.5+(i*1.25) ..",".. 0.25+(j*1.25) ..";1,1;]"
 | 
			
		||||
				end
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
		local size = "10.2,13"
 | 
			
		||||
		meta:set_string("formspec",
 | 
			
		||||
			"size[8,11]"..
 | 
			
		||||
			"list[context;line1;1,0;6,1;]"..
 | 
			
		||||
			"list[context;line2;1,1;6,1;]"..
 | 
			
		||||
			"list[context;line3;1,2;6,1;]"..
 | 
			
		||||
			"list[context;line4;1,3;6,1;]"..
 | 
			
		||||
			"list[context;line5;1,4;6,1;]"..
 | 
			
		||||
			"list[context;line6;1,5;6,1;]"..
 | 
			
		||||
			"image[0,0;1,1;pipeworks_white.png]"..
 | 
			
		||||
			"image[0,1;1,1;pipeworks_black.png]"..
 | 
			
		||||
			"image[0,2;1,1;pipeworks_green.png]"..
 | 
			
		||||
			"image[0,3;1,1;pipeworks_yellow.png]"..
 | 
			
		||||
			"image[0,4;1,1;pipeworks_blue.png]"..
 | 
			
		||||
			"image[0,5;1,1;pipeworks_red.png]"..
 | 
			
		||||
			"formspec_version[2]"..
 | 
			
		||||
			"size["..size.."]"..
 | 
			
		||||
			pipeworks.fs_helpers.get_prepends(size)..
 | 
			
		||||
			"list[context;line1;1.5,0.25;6,1;]"..
 | 
			
		||||
			"list[context;line2;1.5,1.50;6,1;]"..
 | 
			
		||||
			"list[context;line3;1.5,2.75;6,1;]"..
 | 
			
		||||
			"list[context;line4;1.5,4.00;6,1;]"..
 | 
			
		||||
			"list[context;line5;1.5,5.25;6,1;]"..
 | 
			
		||||
			"list[context;line6;1.5,6.50;6,1;]"..
 | 
			
		||||
			list_backgrounds..
 | 
			
		||||
			"image[0.22,0.25;1,1;pipeworks_white.png]"..
 | 
			
		||||
			"image[0.22,1.50;1,1;pipeworks_black.png]"..
 | 
			
		||||
			"image[0.22,2.75;1,1;pipeworks_green.png]"..
 | 
			
		||||
			"image[0.22,4.00;1,1;pipeworks_yellow.png]"..
 | 
			
		||||
			"image[0.22,5.25;1,1;pipeworks_blue.png]"..
 | 
			
		||||
			"image[0.22,6.50;1,1;pipeworks_red.png]"..
 | 
			
		||||
			buttons_formspec..
 | 
			
		||||
			"list[current_player;main;0,7;8,4;]" ..
 | 
			
		||||
			--"list[current_player;main;0,8;8,4;]" ..
 | 
			
		||||
			pipeworks.fs_helpers.get_inv(8)..
 | 
			
		||||
			"listring[current_player;main]" ..
 | 
			
		||||
			"listring[current_player;main]" ..
 | 
			
		||||
			"listring[context;line1]" ..
 | 
			
		||||
@@ -55,7 +70,7 @@ if pipeworks.enable_mese_tube then
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	pipeworks.register_tube("pipeworks:mese_tube", {
 | 
			
		||||
			description = "Sorting Pneumatic Tube Segment",
 | 
			
		||||
			description = S("Sorting Pneumatic Tube Segment"),
 | 
			
		||||
			inventory_image = "pipeworks_mese_tube_inv.png",
 | 
			
		||||
			noctr = {"pipeworks_mese_tube_noctr_1.png", "pipeworks_mese_tube_noctr_2.png", "pipeworks_mese_tube_noctr_3.png",
 | 
			
		||||
				"pipeworks_mese_tube_noctr_4.png", "pipeworks_mese_tube_noctr_5.png", "pipeworks_mese_tube_noctr_6.png"},
 | 
			
		||||
@@ -107,11 +122,24 @@ if pipeworks.enable_mese_tube then
 | 
			
		||||
						inv:set_size("line"..tostring(i), 6*1)
 | 
			
		||||
					end
 | 
			
		||||
					update_formspec(pos)
 | 
			
		||||
					meta:set_string("infotext", "Sorting pneumatic tube")
 | 
			
		||||
					meta:set_string("infotext", S("Sorting pneumatic tube"))
 | 
			
		||||
				end,
 | 
			
		||||
				after_place_node = function(pos, placer, itemstack, pointed_thing)
 | 
			
		||||
					if placer and placer:is_player() and placer:get_player_control().aux1 then
 | 
			
		||||
						local meta = minetest.get_meta(pos)
 | 
			
		||||
						for i = 1, 6 do
 | 
			
		||||
							meta:set_int("l"..tostring(i).."s", 0)
 | 
			
		||||
						end
 | 
			
		||||
						update_formspec(pos)
 | 
			
		||||
					end
 | 
			
		||||
					return pipeworks.after_place(pos, placer, itemstack, pointed_thing)
 | 
			
		||||
				end,
 | 
			
		||||
				on_punch = update_formspec,
 | 
			
		||||
				on_receive_fields = function(pos, formname, fields, sender)
 | 
			
		||||
					if not pipeworks.may_configure(pos, sender) then return end
 | 
			
		||||
					if (fields.quit and not fields.key_enter_field)
 | 
			
		||||
							or not pipeworks.may_configure(pos, sender) then
 | 
			
		||||
						return
 | 
			
		||||
					end
 | 
			
		||||
					fs_helpers.on_receive_fields(pos, fields)
 | 
			
		||||
					update_formspec(pos)
 | 
			
		||||
				end,
 | 
			
		||||
@@ -149,25 +177,4 @@ if pipeworks.enable_mese_tube then
 | 
			
		||||
				end,
 | 
			
		||||
			},
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	minetest.register_craft( {
 | 
			
		||||
		output = "pipeworks:mese_tube_000000 2",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
 | 
			
		||||
			{ "", "default:mese_crystal", "" },
 | 
			
		||||
			{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	minetest.register_craft( {
 | 
			
		||||
		type = "shapeless",
 | 
			
		||||
		output = "pipeworks:mese_tube_000000",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			"pipeworks:tube_1",
 | 
			
		||||
			"default:mese_crystal_fragment",
 | 
			
		||||
			"default:mese_crystal_fragment",
 | 
			
		||||
			"default:mese_crystal_fragment",
 | 
			
		||||
			"default:mese_crystal_fragment"
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,260 +1,373 @@
 | 
			
		||||
local filename=minetest.get_worldpath() .. "/teleport_tubes"
 | 
			
		||||
 | 
			
		||||
local tp_tube_db = nil -- nil forces a read
 | 
			
		||||
local tp_tube_db_version = 2.0
 | 
			
		||||
local S = minetest.get_translator("pipeworks")
 | 
			
		||||
local filename = minetest.get_worldpath().."/teleport_tubes"  -- Only used for backward-compat
 | 
			
		||||
local storage = minetest.get_mod_storage()
 | 
			
		||||
 | 
			
		||||
local function hash(pos)
 | 
			
		||||
	return string.format("%.30g", minetest.hash_node_position(pos))
 | 
			
		||||
local enable_logging = minetest.settings:get_bool("pipeworks_log_teleport_tubes", false)
 | 
			
		||||
 | 
			
		||||
local has_digilines = minetest.get_modpath("digilines")
 | 
			
		||||
 | 
			
		||||
-- V1: Serialized text file indexed by vector position.
 | 
			
		||||
-- V2: Serialized text file indexed by hash position.
 | 
			
		||||
-- V3: Mod storage using serialized tables.
 | 
			
		||||
-- V4: Mod storage using "<can_receive>:<channel>" format.
 | 
			
		||||
local tube_db_version = 4
 | 
			
		||||
local tube_db = {}
 | 
			
		||||
local receiver_cache = {}
 | 
			
		||||
 | 
			
		||||
local function hash_pos(pos)
 | 
			
		||||
	vector.round(pos)
 | 
			
		||||
	return string.format("%.0f", minetest.hash_node_position(pos))
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function serialize_tube(tube)
 | 
			
		||||
	return string.format("%d:%s", tube.cr, tube.channel)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function deserialize_tube(hash, str)
 | 
			
		||||
	local sep = str:sub(2, 2) == ":"
 | 
			
		||||
	local cr = tonumber(str:sub(1, 1))
 | 
			
		||||
	local channel = str:sub(3)
 | 
			
		||||
	if sep and cr and channel then
 | 
			
		||||
		local pos = minetest.get_position_from_hash(tonumber(hash))
 | 
			
		||||
		return {x = pos.x, y = pos.y, z = pos.z, cr = cr, channel = channel}
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function save_tube_db()
 | 
			
		||||
	local file, err = io.open(filename, "w")
 | 
			
		||||
	if file then
 | 
			
		||||
		tp_tube_db.version = tp_tube_db_version
 | 
			
		||||
		file:write(minetest.serialize(tp_tube_db))
 | 
			
		||||
		tp_tube_db.version = nil
 | 
			
		||||
		io.close(file)
 | 
			
		||||
	else
 | 
			
		||||
		error(err)
 | 
			
		||||
	receiver_cache = {}
 | 
			
		||||
	local fields = {version = tube_db_version}
 | 
			
		||||
	for key, val in pairs(tube_db) do
 | 
			
		||||
		fields[key] = serialize_tube(val)
 | 
			
		||||
	end
 | 
			
		||||
	storage:from_table({fields = fields})
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function save_tube(hash)
 | 
			
		||||
	local tube = tube_db[hash]
 | 
			
		||||
	receiver_cache[tube.channel] = nil
 | 
			
		||||
	storage:set_string(hash, serialize_tube(tube))
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function remove_tube(pos)
 | 
			
		||||
	local hash = hash_pos(pos)
 | 
			
		||||
	if tube_db[hash] then
 | 
			
		||||
		receiver_cache[tube_db[hash].channel] = nil
 | 
			
		||||
		tube_db[hash] = nil
 | 
			
		||||
		storage:set_string(hash, "")
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function migrate_tube_db()
 | 
			
		||||
		local tmp_db = {}
 | 
			
		||||
		tp_tube_db.version = nil
 | 
			
		||||
		for key, val in pairs(tp_tube_db) do
 | 
			
		||||
			if(val.channel ~= "") then -- skip unconfigured tubes
 | 
			
		||||
				tmp_db[hash(val)] = val
 | 
			
		||||
	if storage:get_int("version") == 3 then
 | 
			
		||||
		for key, val in pairs(storage:to_table().fields) do
 | 
			
		||||
			if tonumber(key) then
 | 
			
		||||
				tube_db[key] = minetest.deserialize(val)
 | 
			
		||||
			elseif key ~= "version" then
 | 
			
		||||
				error("Unknown field in teleport tube database: "..key)
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
		tp_tube_db = tmp_db
 | 
			
		||||
		save_tube_db()
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
	local file = io.open(filename, "r")
 | 
			
		||||
	if file then
 | 
			
		||||
		local content = file:read("*all")
 | 
			
		||||
		io.close(file)
 | 
			
		||||
		if content and content ~= "" then
 | 
			
		||||
			tube_db = minetest.deserialize(content)
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
	local version = tube_db.version or 0
 | 
			
		||||
	tube_db.version = nil
 | 
			
		||||
	if version < 2 then
 | 
			
		||||
		local tmp_db = {}
 | 
			
		||||
		for _, val in pairs(tube_db) do
 | 
			
		||||
			if val.channel ~= "" then  -- Skip unconfigured tubes
 | 
			
		||||
				tmp_db[hash_pos(val)] = val
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
		tube_db = tmp_db
 | 
			
		||||
	end
 | 
			
		||||
	save_tube_db()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function read_tube_db()
 | 
			
		||||
	local file = io.open(filename, "r")
 | 
			
		||||
	if file ~= nil then
 | 
			
		||||
		local file_content = file:read("*all")
 | 
			
		||||
		io.close(file)
 | 
			
		||||
 | 
			
		||||
		if file_content and file_content ~= "" then
 | 
			
		||||
			tp_tube_db = minetest.deserialize(file_content)
 | 
			
		||||
			if(not tp_tube_db.version or tonumber(tp_tube_db.version) < tp_tube_db_version) then
 | 
			
		||||
				migrate_tube_db()
 | 
			
		||||
	local version = storage:get_int("version")
 | 
			
		||||
	if version < tube_db_version then
 | 
			
		||||
		migrate_tube_db()
 | 
			
		||||
	elseif version > tube_db_version then
 | 
			
		||||
		error("Cannot read teleport tube database of version "..version)
 | 
			
		||||
	else
 | 
			
		||||
		for key, val in pairs(storage:to_table().fields) do
 | 
			
		||||
			if tonumber(key) then
 | 
			
		||||
				tube_db[key] = deserialize_tube(key, val)
 | 
			
		||||
			elseif key ~= "version" then
 | 
			
		||||
				error("Unknown field in teleport tube database: "..key)
 | 
			
		||||
			end
 | 
			
		||||
			tp_tube_db.version = nil -- we add it back when saving
 | 
			
		||||
			return tp_tube_db -- we read sucessfully
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
	tp_tube_db = {}
 | 
			
		||||
	return tp_tube_db
 | 
			
		||||
	tube_db.version = nil
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- debug formatter for coordinates used below
 | 
			
		||||
local fmt = function(pos)
 | 
			
		||||
	return pos.x..", "..pos.y..", "..pos.z
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- updates or adds a tube
 | 
			
		||||
local function set_tube(pos, channel, can_receive)
 | 
			
		||||
	local tubes = tp_tube_db or read_tube_db()
 | 
			
		||||
	local hash = hash(pos)
 | 
			
		||||
	local tube = tubes[hash]
 | 
			
		||||
local function set_tube(pos, channel, cr)
 | 
			
		||||
	local hash = hash_pos(pos)
 | 
			
		||||
	local tube = tube_db[hash]
 | 
			
		||||
	if tube then
 | 
			
		||||
		tube.channel = channel
 | 
			
		||||
		tube.cr = can_receive
 | 
			
		||||
		save_tube_db()
 | 
			
		||||
		return
 | 
			
		||||
		if tube.channel ~= channel or tube.cr ~= cr then
 | 
			
		||||
			tube.channel = channel
 | 
			
		||||
			tube.cr = cr
 | 
			
		||||
			save_tube(hash)
 | 
			
		||||
		end
 | 
			
		||||
	else
 | 
			
		||||
		tube_db[hash] = {x = pos.x, y = pos.y, z = pos.z, channel = channel, cr = cr}
 | 
			
		||||
		save_tube(hash)
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	-- we haven't found any tp tube to update, so lets add it
 | 
			
		||||
	-- but sanity check that the hash has not already been inserted.
 | 
			
		||||
	-- if so, complain very loudly and refuse the update so the player knows something is amiss.
 | 
			
		||||
	-- to catch regressions of https://github.com/minetest-mods/pipeworks/issues/166
 | 
			
		||||
	local existing = tp_tube_db[hash]
 | 
			
		||||
	if  existing ~= nil then
 | 
			
		||||
		local e = "error"
 | 
			
		||||
		minetest.log(e, "pipeworks teleport tube update refused due to position hash collision")
 | 
			
		||||
		minetest.log(e, "collided hash: "..hash)
 | 
			
		||||
		minetest.log(e, "tried-to-place tube: "..fmt(pos))
 | 
			
		||||
		minetest.log(e, "existing tube: "..fmt(existing))
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	tp_tube_db[hash] = {x=pos.x,y=pos.y,z=pos.z,channel=channel,cr=can_receive}
 | 
			
		||||
	save_tube_db()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function remove_tube(pos)
 | 
			
		||||
	local tubes = tp_tube_db or read_tube_db()
 | 
			
		||||
	tubes[hash(pos)] = nil
 | 
			
		||||
	save_tube_db()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function read_node_with_vm(pos)
 | 
			
		||||
	local vm = VoxelManip()
 | 
			
		||||
	local MinEdge, MaxEdge = vm:read_from_map(pos, pos)
 | 
			
		||||
	local data = vm:get_data()
 | 
			
		||||
	local area = VoxelArea:new({MinEdge = MinEdge, MaxEdge = MaxEdge})
 | 
			
		||||
	return minetest.get_name_from_content_id(data[area:index(pos.x, pos.y, pos.z)])
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function get_receivers(pos, channel)
 | 
			
		||||
	local tubes = tp_tube_db or read_tube_db()
 | 
			
		||||
	local hash = hash_pos(pos)
 | 
			
		||||
	local cache = receiver_cache[channel] or {}
 | 
			
		||||
	if cache[hash] then
 | 
			
		||||
		return cache[hash]
 | 
			
		||||
	end
 | 
			
		||||
	local receivers = {}
 | 
			
		||||
	local dirty = false
 | 
			
		||||
	for key, val in pairs(tubes) do
 | 
			
		||||
		-- skip all non-receivers and the tube that it came from as early as possible, as this is called often
 | 
			
		||||
		if (val.cr == 1 and val.channel == channel and (val.x ~= pos.x or val.y ~= pos.y or val.z ~= pos.z)) then
 | 
			
		||||
			local is_loaded = (minetest.get_node_or_nil(val) ~= nil)
 | 
			
		||||
			local node_name = is_loaded and minetest.get_node(pos).name or read_node_with_vm(val)
 | 
			
		||||
 | 
			
		||||
			if minetest.registered_nodes[node_name] and minetest.registered_nodes[node_name].is_teleport_tube then
 | 
			
		||||
	for key, val in pairs(tube_db) do
 | 
			
		||||
		if val.cr == 1 and val.channel == channel and not vector.equals(val, pos) then
 | 
			
		||||
			minetest.load_area(val)
 | 
			
		||||
			local node_name = minetest.get_node(val).name
 | 
			
		||||
			if node_name:find("pipeworks:teleport_tube") then
 | 
			
		||||
				table.insert(receivers, val)
 | 
			
		||||
			else
 | 
			
		||||
				tp_tube_db[key] = nil
 | 
			
		||||
				dirty = true
 | 
			
		||||
				remove_tube(val)
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
	if dirty then
 | 
			
		||||
		save_tube_db()
 | 
			
		||||
	end
 | 
			
		||||
	cache[hash] = receivers
 | 
			
		||||
	receiver_cache[channel] = cache
 | 
			
		||||
	return receivers
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function update_meta(meta, can_receive)
 | 
			
		||||
	meta:set_int("can_receive", can_receive and 1 or 0)
 | 
			
		||||
	local cr_state = can_receive and "on" or "off"
 | 
			
		||||
	meta:set_string("formspec","size[8.6,2.2]"..
 | 
			
		||||
			"field[0.6,0.6;7,1;channel;Channel:;${channel}]"..
 | 
			
		||||
			"label[7.3,0;Receive]"..
 | 
			
		||||
			"image_button[7.3,0.3;1,0.6;pipeworks_button_" .. cr_state .. ".png;cr" .. (can_receive and 0 or 1) .. ";;;false;pipeworks_button_interm.png]"..
 | 
			
		||||
			"image[0.3,1.3;1,1;pipeworks_teleport_tube_inv.png]"..
 | 
			
		||||
			"label[1.6,1.2;channels are public by default]" ..
 | 
			
		||||
			"label[1.6,1.5;use <player>:<channel> for fully private channels]" ..
 | 
			
		||||
			"label[1.6,1.8;use <player>\\;<channel> for private receivers]" ..
 | 
			
		||||
			default.gui_bg..
 | 
			
		||||
			default.gui_bg_img)
 | 
			
		||||
local help_text = minetest.formspec_escape(
 | 
			
		||||
	S("Channels are public by default").."\n"..
 | 
			
		||||
	S("Use <player>:<channel> for fully private channels").."\n"..
 | 
			
		||||
	S("Use <player>;<channel> for private receivers")
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
local size = has_digilines and "8,5.9" or "8,4.4"
 | 
			
		||||
 | 
			
		||||
local formspec = "formspec_version[2]size["..size.."]"..
 | 
			
		||||
	pipeworks.fs_helpers.get_prepends(size)..
 | 
			
		||||
	"image[0.5,0.3;1,1;pipeworks_teleport_tube_inv.png]"..
 | 
			
		||||
	"label[1.75,0.8;"..S("Teleporting Tube").."]"..
 | 
			
		||||
	"field[0.5,1.7;5,0.8;channel;"..S("Channel")..";${channel}]"..
 | 
			
		||||
	"button_exit[5.5,1.7;2,0.8;save;"..S("Save").."]"..
 | 
			
		||||
	"label[6.5,0.6;"..S("Receive").."]"..
 | 
			
		||||
	"label[0.5,2.8;"..help_text.."]"
 | 
			
		||||
 | 
			
		||||
if has_digilines then
 | 
			
		||||
	formspec = formspec..
 | 
			
		||||
		"field[0.5,4.6;5,0.8;digiline_channel;"..S("Digiline Channel")..";${digiline_channel}]"..
 | 
			
		||||
		"button_exit[5.5,4.6;2,0.8;save;"..S("Save").."]"
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function update_meta(meta)
 | 
			
		||||
	local channel = meta:get_string("channel")
 | 
			
		||||
	local cr = meta:get_int("can_receive") == 1
 | 
			
		||||
	if channel == "" then
 | 
			
		||||
		meta:set_string("infotext", S("Unconfigured Teleportation Tube"))
 | 
			
		||||
	else
 | 
			
		||||
		local desc = cr and "sending and receiving" or "sending"
 | 
			
		||||
		meta:set_string("infotext", S("Teleportation Tube @1 on '@2'", desc, channel))
 | 
			
		||||
	end
 | 
			
		||||
	local state = cr and "on" or "off"
 | 
			
		||||
	meta:set_string("formspec", formspec..
 | 
			
		||||
		"image_button[6.4,0.8;1,0.6;pipeworks_button_"..state..
 | 
			
		||||
		".png;cr_"..state..";;;false;pipeworks_button_interm.png]")
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function update_tube(pos, channel, cr, player_name)
 | 
			
		||||
	local meta = minetest.get_meta(pos)
 | 
			
		||||
	if meta:get_string("channel") == channel and meta:get_int("can_receive") == cr then
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
	if channel == "" then
 | 
			
		||||
		meta:set_string("channel", "")
 | 
			
		||||
		meta:set_int("can_receive", cr)
 | 
			
		||||
		remove_tube(pos)
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
	local name, mode = channel:match("^([^:;]+)([:;])")
 | 
			
		||||
	if name and mode and name ~= player_name then
 | 
			
		||||
		if mode == ":" then
 | 
			
		||||
			minetest.chat_send_player(player_name,
 | 
			
		||||
				S("Sorry, channel '@1' is reserved for exclusive use by @2", channel, name))
 | 
			
		||||
			return
 | 
			
		||||
		elseif mode == ";" and cr ~= 0 then
 | 
			
		||||
			minetest.chat_send_player(player_name,
 | 
			
		||||
				S("Sorry, receiving from channel '@1' is reserved for @2", channel, name))
 | 
			
		||||
			return
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
	meta:set_string("channel", channel)
 | 
			
		||||
	meta:set_int("can_receive", cr)
 | 
			
		||||
	set_tube(pos, channel, cr)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function receive_fields(pos, _, fields, sender)
 | 
			
		||||
	if not fields.channel or not pipeworks.may_configure(pos, sender) then
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
	local meta = minetest.get_meta(pos)
 | 
			
		||||
	local channel = fields.channel:trim()
 | 
			
		||||
	local cr = meta:get_int("can_receive")
 | 
			
		||||
	if fields.cr_on then
 | 
			
		||||
		cr = 0
 | 
			
		||||
	elseif fields.cr_off then
 | 
			
		||||
		cr = 1
 | 
			
		||||
	end
 | 
			
		||||
	if has_digilines and fields.digiline_channel then
 | 
			
		||||
		meta:set_string("digiline_channel", fields.digiline_channel)
 | 
			
		||||
	end
 | 
			
		||||
	update_tube(pos, channel, cr, sender:get_player_name())
 | 
			
		||||
	update_meta(meta)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function can_go(pos, node, velocity, stack)
 | 
			
		||||
	velocity.x = 0
 | 
			
		||||
	velocity.y = 0
 | 
			
		||||
	velocity.z = 0
 | 
			
		||||
	local src_meta = minetest.get_meta(pos)
 | 
			
		||||
	local channel = src_meta:get_string("channel")
 | 
			
		||||
	if channel == "" then
 | 
			
		||||
		return {}
 | 
			
		||||
	end
 | 
			
		||||
	local receivers = get_receivers(pos, channel)
 | 
			
		||||
	if #receivers == 0 then
 | 
			
		||||
		return {}
 | 
			
		||||
	end
 | 
			
		||||
	local target = receivers[math.random(1, #receivers)]
 | 
			
		||||
	if enable_logging then
 | 
			
		||||
		local src_owner = src_meta:get_string("owner")
 | 
			
		||||
		local dst_meta = minetest.get_meta(pos)
 | 
			
		||||
		local dst_owner = dst_meta:get_string("owner")
 | 
			
		||||
		minetest.log("action", string.format("[pipeworks] %s teleported from %s (owner=%s) to %s (owner=%s) via %s",
 | 
			
		||||
			stack:to_string(), minetest.pos_to_string(pos), src_owner, minetest.pos_to_string(target), dst_owner, channel
 | 
			
		||||
		))
 | 
			
		||||
	end
 | 
			
		||||
	pos.x = target.x
 | 
			
		||||
	pos.y = target.y
 | 
			
		||||
	pos.z = target.z
 | 
			
		||||
	return pipeworks.meseadjlist
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function repair_tube(pos, node)
 | 
			
		||||
	minetest.swap_node(pos, {name = node.name, param2 = node.param2})
 | 
			
		||||
	pipeworks.scan_for_tube_objects(pos)
 | 
			
		||||
	local meta = minetest.get_meta(pos)
 | 
			
		||||
	local channel = meta:get_string("channel")
 | 
			
		||||
	if channel ~= "" then
 | 
			
		||||
		set_tube(pos, channel, meta:get_int("can_receive"))
 | 
			
		||||
	end
 | 
			
		||||
	update_meta(meta)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function digiline_action(pos, _, digiline_channel, msg)
 | 
			
		||||
	local meta = minetest.get_meta(pos)
 | 
			
		||||
	if digiline_channel ~= meta:get_string("digiline_channel") then
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
	local channel = meta:get_string("channel")
 | 
			
		||||
	local can_receive = meta:get_int("can_receive")
 | 
			
		||||
	if type(msg) == "string" then
 | 
			
		||||
		channel = msg
 | 
			
		||||
	elseif type(msg) == "table" then
 | 
			
		||||
		if type(msg.channel) == "string" then
 | 
			
		||||
			channel = msg.channel
 | 
			
		||||
		end
 | 
			
		||||
		if msg.can_receive == 1 or msg.can_receive == true then
 | 
			
		||||
			can_receive = 1
 | 
			
		||||
		elseif msg.can_receive == 0 or msg.can_receive == false then
 | 
			
		||||
			can_receive = 0
 | 
			
		||||
		end
 | 
			
		||||
	else
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
	local player_name = meta:get_string("owner")
 | 
			
		||||
	update_tube(pos, channel, can_receive, player_name)
 | 
			
		||||
	update_meta(meta)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local def = {
 | 
			
		||||
	tube = {
 | 
			
		||||
		can_go = can_go,
 | 
			
		||||
		on_repair = repair_tube,
 | 
			
		||||
	},
 | 
			
		||||
	on_construct = function(pos)
 | 
			
		||||
		local meta = minetest.get_meta(pos)
 | 
			
		||||
		meta:set_int("can_receive", 1)  -- Enabled by default
 | 
			
		||||
		update_meta(meta)
 | 
			
		||||
	end,
 | 
			
		||||
	on_receive_fields = receive_fields,
 | 
			
		||||
	on_destruct = remove_tube,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if has_digilines then
 | 
			
		||||
	def.after_place_node = function(pos, placer)
 | 
			
		||||
		-- Set owner for digilines
 | 
			
		||||
		minetest.get_meta(pos):set_string("owner", placer:get_player_name())
 | 
			
		||||
		pipeworks.after_place(pos)
 | 
			
		||||
	end
 | 
			
		||||
	def.digiline = {
 | 
			
		||||
		receptor = {
 | 
			
		||||
			rules = pipeworks.digilines_rules,
 | 
			
		||||
		},
 | 
			
		||||
		effector = {
 | 
			
		||||
			rules = pipeworks.digilines_rules,
 | 
			
		||||
			action = digiline_action,
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
pipeworks.register_tube("pipeworks:teleport_tube", {
 | 
			
		||||
	description = "Teleporting Pneumatic Tube Segment",
 | 
			
		||||
	description = S("Teleporting Pneumatic Tube Segment"),
 | 
			
		||||
	inventory_image = "pipeworks_teleport_tube_inv.png",
 | 
			
		||||
	noctr = { "pipeworks_teleport_tube_noctr.png" },
 | 
			
		||||
	plain = { "pipeworks_teleport_tube_plain.png" },
 | 
			
		||||
	ends = { "pipeworks_teleport_tube_end.png" },
 | 
			
		||||
	short = "pipeworks_teleport_tube_short.png",
 | 
			
		||||
	node_def = {
 | 
			
		||||
		is_teleport_tube = true,
 | 
			
		||||
		tube = {
 | 
			
		||||
			can_go = function(pos,node,velocity,stack)
 | 
			
		||||
				velocity.x = 0
 | 
			
		||||
				velocity.y = 0
 | 
			
		||||
				velocity.z = 0
 | 
			
		||||
 | 
			
		||||
				local channel = minetest.get_meta(pos):get_string("channel")
 | 
			
		||||
				if channel == "" then return {} end
 | 
			
		||||
 | 
			
		||||
				local target = get_receivers(pos, channel)
 | 
			
		||||
				if target[1] == nil then return {} end
 | 
			
		||||
 | 
			
		||||
				local d = math.random(1,#target)
 | 
			
		||||
				pos.x = target[d].x
 | 
			
		||||
				pos.y = target[d].y
 | 
			
		||||
				pos.z = target[d].z
 | 
			
		||||
				return pipeworks.meseadjlist
 | 
			
		||||
			end
 | 
			
		||||
		},
 | 
			
		||||
		on_construct = function(pos)
 | 
			
		||||
			local meta = minetest.get_meta(pos)
 | 
			
		||||
			update_meta(meta, true)
 | 
			
		||||
			meta:set_string("infotext", "unconfigured Teleportation Tube")
 | 
			
		||||
		end,
 | 
			
		||||
		on_receive_fields = function(pos,formname,fields,sender)
 | 
			
		||||
			if not fields.channel -- ignore escaping or clientside manipulation of the form
 | 
			
		||||
			or not pipeworks.may_configure(pos, sender) then
 | 
			
		||||
				return
 | 
			
		||||
			end
 | 
			
		||||
			local new_channel = tostring(fields.channel):trim()
 | 
			
		||||
 | 
			
		||||
			local meta = minetest.get_meta(pos)
 | 
			
		||||
			local can_receive = meta:get_int("can_receive")
 | 
			
		||||
 | 
			
		||||
			-- check for private channels each time before actually changing anything
 | 
			
		||||
			-- to not even allow switching between can_receive states of private channels
 | 
			
		||||
			if new_channel ~= "" then
 | 
			
		||||
				local sender_name = sender:get_player_name()
 | 
			
		||||
				local name, mode = new_channel:match("^([^:;]+)([:;])")
 | 
			
		||||
				if name and mode and name ~= sender_name then
 | 
			
		||||
					--channels starting with '[name]:' can only be used by the named player
 | 
			
		||||
					if mode == ":" then
 | 
			
		||||
						minetest.chat_send_player(sender_name, "Sorry, channel '"..new_channel.."' is reserved for exclusive use by "..name)
 | 
			
		||||
						return
 | 
			
		||||
				
 | 
			
		||||
					--channels starting with '[name];' can be used by other players, but cannot be received from
 | 
			
		||||
					elseif mode == ";" and (fields.cr1 or (can_receive ~= 0 and not fields.cr0)) then
 | 
			
		||||
						minetest.chat_send_player(sender_name, "Sorry, receiving from channel '"..new_channel.."' is reserved for "..name)
 | 
			
		||||
						return
 | 
			
		||||
					end
 | 
			
		||||
				end
 | 
			
		||||
			end
 | 
			
		||||
 | 
			
		||||
			local dirty = false
 | 
			
		||||
 | 
			
		||||
			-- was the channel changed?
 | 
			
		||||
			local channel = meta:get_string("channel")
 | 
			
		||||
			if new_channel ~= channel then
 | 
			
		||||
				channel = new_channel
 | 
			
		||||
				meta:set_string("channel", channel)
 | 
			
		||||
				dirty = true
 | 
			
		||||
			end
 | 
			
		||||
 | 
			
		||||
			-- test if a can_receive button was pressed
 | 
			
		||||
			if fields.cr0 and can_receive ~= 0 then
 | 
			
		||||
				can_receive = 0
 | 
			
		||||
				update_meta(meta, false)
 | 
			
		||||
				dirty = true
 | 
			
		||||
			elseif fields.cr1 and can_receive ~= 1 then
 | 
			
		||||
				can_receive = 1
 | 
			
		||||
				update_meta(meta, true)
 | 
			
		||||
				dirty = true
 | 
			
		||||
			end
 | 
			
		||||
 | 
			
		||||
			-- save if we changed something, handle the empty channel while we're at it
 | 
			
		||||
			if dirty then
 | 
			
		||||
				if channel ~= "" then
 | 
			
		||||
					set_tube(pos, channel, can_receive)
 | 
			
		||||
					local cr_description = (can_receive == 1) and "sending and receiving" or "sending"
 | 
			
		||||
					meta:set_string("infotext", string.format("Teleportation Tube %s on '%s'", cr_description, channel))
 | 
			
		||||
				else
 | 
			
		||||
					-- remove empty channel tubes, to not have to search through them
 | 
			
		||||
					remove_tube(pos)
 | 
			
		||||
					meta:set_string("infotext", "unconfigured Teleportation Tube")
 | 
			
		||||
				end
 | 
			
		||||
			end
 | 
			
		||||
		end,
 | 
			
		||||
		on_destruct = function(pos)
 | 
			
		||||
			remove_tube(pos)
 | 
			
		||||
		end
 | 
			
		||||
	},
 | 
			
		||||
})
 | 
			
		||||
minetest.register_craft( {
 | 
			
		||||
	output = "pipeworks:teleport_tube_1 2",
 | 
			
		||||
	recipe = {
 | 
			
		||||
	        { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
 | 
			
		||||
	        { "default:desert_stone", "default:mese", "default:desert_stone" },
 | 
			
		||||
	        { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
 | 
			
		||||
	},
 | 
			
		||||
	node_def = def,
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
if minetest.get_modpath("mesecons_mvps") ~= nil then
 | 
			
		||||
if minetest.get_modpath("mesecons_mvps") then
 | 
			
		||||
	-- Update tubes when moved by pistons
 | 
			
		||||
	mesecon.register_on_mvps_move(function(moved_nodes)
 | 
			
		||||
		for _, n in ipairs(moved_nodes) do
 | 
			
		||||
			if string.find(n.node.name, "pipeworks:teleport_tube") ~= nil then
 | 
			
		||||
			if n.node.name:find("pipeworks:teleport_tube") then
 | 
			
		||||
				local meta = minetest.get_meta(n.pos)
 | 
			
		||||
				set_tube(n.pos, meta:get_string("channel"), meta:get_int("can_receive"))
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
	end)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Expose teleport tube database API for other mods
 | 
			
		||||
pipeworks.tptube = {
 | 
			
		||||
	version = tube_db_version,
 | 
			
		||||
	hash = hash_pos,
 | 
			
		||||
	get_db = function() return tube_db end,
 | 
			
		||||
	save_tube_db = save_tube_db,
 | 
			
		||||
	set_tube = set_tube,
 | 
			
		||||
	save_tube = save_tube,
 | 
			
		||||
	update_tube = update_tube,
 | 
			
		||||
	update_meta = function(meta, cr)
 | 
			
		||||
		-- Legacy behaviour
 | 
			
		||||
		if cr ~= nil then
 | 
			
		||||
			meta:set_int("can_receive", cr and 1 or 0)
 | 
			
		||||
		end
 | 
			
		||||
		update_meta(meta)
 | 
			
		||||
	end,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
-- Load the database
 | 
			
		||||
read_tube_db()
 | 
			
		||||
 
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 5.7 KiB  | 
							
								
								
									
										53
									
								
								trashcan.lua
									
									
									
									
									
								
							
							
						
						
									
										53
									
								
								trashcan.lua
									
									
									
									
									
								
							@@ -1,6 +1,7 @@
 | 
			
		||||
local S = minetest.get_translator("pipeworks")
 | 
			
		||||
minetest.register_node("pipeworks:trashcan", {
 | 
			
		||||
	description = "Trash Can", 
 | 
			
		||||
	drawtype = "normal", 
 | 
			
		||||
	description = S("Trash Can"),
 | 
			
		||||
	drawtype = "normal",
 | 
			
		||||
	tiles = {
 | 
			
		||||
		"pipeworks_trashcan_bottom.png",
 | 
			
		||||
		"pipeworks_trashcan_bottom.png",
 | 
			
		||||
@@ -8,43 +9,43 @@ minetest.register_node("pipeworks:trashcan", {
 | 
			
		||||
		"pipeworks_trashcan_side.png",
 | 
			
		||||
		"pipeworks_trashcan_side.png",
 | 
			
		||||
		"pipeworks_trashcan_side.png",
 | 
			
		||||
	}, 
 | 
			
		||||
	groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1}, 
 | 
			
		||||
	},
 | 
			
		||||
	groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
 | 
			
		||||
	_mcl_hardness=0.8,
 | 
			
		||||
	tube = {
 | 
			
		||||
		insert_object = function(pos, node, stack, direction)
 | 
			
		||||
			return ItemStack("")
 | 
			
		||||
		end,
 | 
			
		||||
		connect_sides = {left = 1, right = 1, front = 1, back = 1, top = 1, bottom = 1},
 | 
			
		||||
		priority = 1, -- Lower than anything else
 | 
			
		||||
	}, 
 | 
			
		||||
	},
 | 
			
		||||
	on_construct = function(pos)
 | 
			
		||||
		local meta = minetest.get_meta(pos)
 | 
			
		||||
		local size = "10.2,9"
 | 
			
		||||
		local list_background = ""
 | 
			
		||||
		if minetest.get_modpath("i3") or minetest.get_modpath("mcl_formspec") then
 | 
			
		||||
			list_background = "style_type[box;colors=#666]box[4.5,2;1,1;]"
 | 
			
		||||
		end
 | 
			
		||||
		meta:set_string("formspec",
 | 
			
		||||
				"size[8,7]"..
 | 
			
		||||
				"item_image[0,0;1,1;pipeworks:trashcan]"..
 | 
			
		||||
				"label[1,0;Trash Can]"..
 | 
			
		||||
				"list[context;trash;3.5,1;1,1;]"..
 | 
			
		||||
				default.gui_bg..
 | 
			
		||||
				default.gui_bg_img..
 | 
			
		||||
				default.gui_slots..
 | 
			
		||||
				default.get_hotbar_bg(0,3) ..
 | 
			
		||||
				"list[current_player;main;0,3;8,4;]" ..
 | 
			
		||||
				"listring[]")
 | 
			
		||||
		meta:set_string("infotext", "Trash Can")
 | 
			
		||||
			"formspec_version[2]" ..
 | 
			
		||||
			"size["..size.."]"..
 | 
			
		||||
			pipeworks.fs_helpers.get_prepends(size) ..
 | 
			
		||||
			"item_image[0.5,0.5;1,1;pipeworks:trashcan]"..
 | 
			
		||||
			"label[1.5,1;"..S("Trash Can").."]"..
 | 
			
		||||
			list_background..
 | 
			
		||||
			"list[context;trash;4.5,2;1,1;]"..
 | 
			
		||||
			--"list[current_player;main;0,3;8,4;]" ..
 | 
			
		||||
			pipeworks.fs_helpers.get_inv(4)..
 | 
			
		||||
			"listring[context;trash]"..
 | 
			
		||||
			"listring[current_player;main]"
 | 
			
		||||
		)
 | 
			
		||||
		meta:set_string("infotext", S("Trash Can"))
 | 
			
		||||
		meta:get_inventory():set_size("trash", 1)
 | 
			
		||||
	end, 
 | 
			
		||||
	end,
 | 
			
		||||
	after_place_node = pipeworks.after_place,
 | 
			
		||||
	after_dig_node = pipeworks.after_dig,
 | 
			
		||||
	on_metadata_inventory_put = function(pos, listname, index, stack, player)
 | 
			
		||||
		minetest.get_meta(pos):get_inventory():set_stack(listname, index, ItemStack(""))
 | 
			
		||||
	end,
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
minetest.register_craft({
 | 
			
		||||
	output = "pipeworks:trashcan",
 | 
			
		||||
	recipe = {
 | 
			
		||||
		{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
 | 
			
		||||
		{ "default:steel_ingot", "", "default:steel_ingot" },
 | 
			
		||||
		{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" },
 | 
			
		||||
	},
 | 
			
		||||
})
 | 
			
		||||
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:trashcan"
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,5 @@
 | 
			
		||||
-- This file supplies the various kinds of pneumatic tubes
 | 
			
		||||
local S = minetest.get_translator("pipeworks")
 | 
			
		||||
 | 
			
		||||
local tubenodes = {}
 | 
			
		||||
pipeworks.tubenodes = tubenodes
 | 
			
		||||
@@ -25,6 +26,11 @@ local texture_mt = {
 | 
			
		||||
	end
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
-- This will remove any semi-transparent pixels
 | 
			
		||||
-- because that is still buggy in Minetest, force this as default
 | 
			
		||||
local texture_alpha_mode = minetest.features.use_texture_alpha_string_modes
 | 
			
		||||
	and "clip" or true
 | 
			
		||||
 | 
			
		||||
local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, ends, short, inv, special, connects, style)
 | 
			
		||||
	noctrs = noctrs or default_noctrs
 | 
			
		||||
	setmetatable(noctrs, texture_mt)
 | 
			
		||||
@@ -55,13 +61,13 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e
 | 
			
		||||
		outimgs[vti[v]] = ends[v]
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	local tgroups = {snappy = 3, tube = 1, tubedevice = 1, not_in_creative_inventory = 1}
 | 
			
		||||
	local tubedesc = string.format("%s %s... You hacker, you.", desc, dump(connects))
 | 
			
		||||
	local iimg = plain[1]
 | 
			
		||||
	local tgroups = {snappy = 3, tube = 1, tubedevice = 1, not_in_creative_inventory = 1, dig_generic = 4, axey=1, handy=1, pickaxey=1}
 | 
			
		||||
	local tubedesc = string.format("%s %s", desc, dump(connects))
 | 
			
		||||
	local iimg = type(plain[1]) == "table" and plain[1].name or plain[1]
 | 
			
		||||
	local wscale = {x = 1, y = 1, z = 1}
 | 
			
		||||
 | 
			
		||||
	if #connects == 0 then
 | 
			
		||||
		tgroups = {snappy = 3, tube = 1, tubedevice = 1}
 | 
			
		||||
		tgroups = {snappy = 3, tube = 1, tubedevice = 1, dig_generic = 4, axey=1, handy=1, pickaxey=1}
 | 
			
		||||
		tubedesc = desc
 | 
			
		||||
		iimg=inv
 | 
			
		||||
		outimgs = {
 | 
			
		||||
@@ -74,6 +80,10 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e
 | 
			
		||||
		wscale = {x = 1, y = 1, z = 0.01}
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	for i, tile in ipairs(outimgs) do
 | 
			
		||||
		outimgs[i] = pipeworks.make_tube_tile(tile)
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	local rname = string.format("%s_%s", name, tname)
 | 
			
		||||
	table.insert(tubenodes, rname)
 | 
			
		||||
 | 
			
		||||
@@ -81,6 +91,7 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e
 | 
			
		||||
		description = tubedesc,
 | 
			
		||||
		drawtype = "nodebox",
 | 
			
		||||
		tiles = outimgs,
 | 
			
		||||
		use_texture_alpha = texture_alpha_mode,
 | 
			
		||||
		sunlight_propagates = true,
 | 
			
		||||
		inventory_image = iimg,
 | 
			
		||||
		wield_image = iimg,
 | 
			
		||||
@@ -95,7 +106,10 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e
 | 
			
		||||
			fixed = outboxes
 | 
			
		||||
		},
 | 
			
		||||
		groups = tgroups,
 | 
			
		||||
		sounds = default.node_sound_wood_defaults(),
 | 
			
		||||
		_mcl_hardness=0.8,
 | 
			
		||||
		_sound_def = {
 | 
			
		||||
			key = "node_sound_wood_defaults",
 | 
			
		||||
		},
 | 
			
		||||
		walkable = true,
 | 
			
		||||
		stack_max = 99,
 | 
			
		||||
		basename = name,
 | 
			
		||||
@@ -106,8 +120,21 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e
 | 
			
		||||
			connect_sides = {front = 1, back = 1, left = 1, right = 1, top = 1, bottom = 1},
 | 
			
		||||
			priority = 50
 | 
			
		||||
		},
 | 
			
		||||
		on_punch = function(pos, node, player, pointed)
 | 
			
		||||
			local playername = player:get_player_name()
 | 
			
		||||
			if minetest.is_protected(pos, playername) and not minetest.check_player_privs(playername, {protection_bypass=true}) then
 | 
			
		||||
				return minetest.node_punch(pos, node, player, pointed)
 | 
			
		||||
			end
 | 
			
		||||
			if pipeworks.check_and_wear_hammer(player) then
 | 
			
		||||
				local wieldname = player:get_wielded_item():get_name()
 | 
			
		||||
				pipeworks.logger(string.format("%s struck a tube at %s with %s to break it.", playername, minetest.pos_to_string(pos), wieldname))
 | 
			
		||||
				pipeworks.break_tube(pos)
 | 
			
		||||
			end
 | 
			
		||||
			return minetest.node_punch(pos, node, player, pointed)
 | 
			
		||||
		end,
 | 
			
		||||
		after_place_node = pipeworks.after_place,
 | 
			
		||||
		after_dig_node = pipeworks.after_dig,
 | 
			
		||||
		on_rotate = false,
 | 
			
		||||
		on_blast = function(pos, intensity)
 | 
			
		||||
			if not intensity or intensity > 1 + 3^0.5 then
 | 
			
		||||
				minetest.remove_node(pos)
 | 
			
		||||
@@ -115,7 +142,10 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e
 | 
			
		||||
			end
 | 
			
		||||
			minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
 | 
			
		||||
			pipeworks.scan_for_tube_objects(pos)
 | 
			
		||||
		end
 | 
			
		||||
		end,
 | 
			
		||||
		check_for_pole = pipeworks.check_for_vert_tube,
 | 
			
		||||
		check_for_horiz_pole = pipeworks.check_for_horiz_tube,
 | 
			
		||||
		tubenumber = tonumber(tname)
 | 
			
		||||
	}
 | 
			
		||||
	if style == "6d" then
 | 
			
		||||
		nodedef.paramtype2 = "facedir"
 | 
			
		||||
@@ -177,6 +207,7 @@ local register_all_tubes = function(name, desc, plain, noctrs, ends, short, inv,
 | 
			
		||||
		end
 | 
			
		||||
		end
 | 
			
		||||
		end
 | 
			
		||||
		pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = name.."_000000"
 | 
			
		||||
	else
 | 
			
		||||
		-- 6d tubes: uses only 10 nodes instead of 64, but the textures must be rotated
 | 
			
		||||
		local cconnects = {{}, {1}, {1, 2}, {1, 3}, {1, 3, 5}, {1, 2, 3}, {1, 2, 3, 5}, {1, 2, 3, 4}, {1, 2, 3, 4, 5}, {1, 2, 3, 4, 5, 6}}
 | 
			
		||||
@@ -193,12 +224,13 @@ local register_all_tubes = function(name, desc, plain, noctrs, ends, short, inv,
 | 
			
		||||
				wield_image = inv,
 | 
			
		||||
				paramtype = "light",
 | 
			
		||||
				sunlight_propagates = true,
 | 
			
		||||
				description = "Pneumatic tube segment (legacy)",
 | 
			
		||||
				description = S("Pneumatic tube segment (legacy)"),
 | 
			
		||||
				after_place_node = pipeworks.after_place,
 | 
			
		||||
				groups = {not_in_creative_inventory = 1, tube_to_update = 1, tube = 1},
 | 
			
		||||
				tube = {connect_sides = {front = 1, back = 1, left = 1, right = 1, top = 1, bottom = 1}},
 | 
			
		||||
				drop = name.."_1",
 | 
			
		||||
			})
 | 
			
		||||
			pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = name.."_1"
 | 
			
		||||
			table.insert(tubenodes, cname)
 | 
			
		||||
			for xm = 0, 1 do
 | 
			
		||||
			for xp = 0, 1 do
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										198
									
								
								vacuum_tubes.lua
									
									
									
									
									
								
							
							
						
						
									
										198
									
								
								vacuum_tubes.lua
									
									
									
									
									
								
							@@ -1,118 +1,102 @@
 | 
			
		||||
if pipeworks.enable_sand_tube then
 | 
			
		||||
	pipeworks.register_tube("pipeworks:sand_tube", {
 | 
			
		||||
		description = "Vacuuming Pneumatic Tube Segment",
 | 
			
		||||
		inventory_image = "pipeworks_sand_tube_inv.png",
 | 
			
		||||
		short = "pipeworks_sand_tube_short.png",
 | 
			
		||||
		noctr = {"pipeworks_sand_tube_noctr.png"},
 | 
			
		||||
		plain = {"pipeworks_sand_tube_plain.png"},
 | 
			
		||||
		ends  = {"pipeworks_sand_tube_end.png"},
 | 
			
		||||
		node_def = {groups = {vacuum_tube = 1}},
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	minetest.register_craft( {
 | 
			
		||||
		output = "pipeworks:sand_tube_1 2",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			{"homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting"},
 | 
			
		||||
			{"group:sand",                 "group:sand",                 "group:sand"},
 | 
			
		||||
			{"homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting"}
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
local S = minetest.get_translator("pipeworks")
 | 
			
		||||
 | 
			
		||||
	minetest.register_craft( {
 | 
			
		||||
		output = "pipeworks:sand_tube_1",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			{"group:sand", "pipeworks:tube_1", "group:sand"},
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if pipeworks.enable_mese_sand_tube then
 | 
			
		||||
	pipeworks.register_tube("pipeworks:mese_sand_tube", {
 | 
			
		||||
			description = "Adjustable Vacuuming Pneumatic Tube Segment",
 | 
			
		||||
			inventory_image = "pipeworks_mese_sand_tube_inv.png",
 | 
			
		||||
			short = "pipeworks_mese_sand_tube_short.png",
 | 
			
		||||
			noctr = {"pipeworks_mese_sand_tube_noctr.png"},
 | 
			
		||||
			plain = {"pipeworks_mese_sand_tube_plain.png"},
 | 
			
		||||
			ends  = {"pipeworks_mese_sand_tube_end.png"},
 | 
			
		||||
			node_def = {
 | 
			
		||||
				groups = {vacuum_tube = 1},
 | 
			
		||||
				on_construct = function(pos)
 | 
			
		||||
					local meta = minetest.get_meta(pos)
 | 
			
		||||
					meta:set_int("dist", 0)
 | 
			
		||||
					meta:set_string("formspec", "size[2.1,0.8]"..
 | 
			
		||||
							"image[0,0;1,1;pipeworks_mese_sand_tube_inv.png]"..
 | 
			
		||||
							"field[1.3,0.4;1,1;dist;radius;${dist}]"..
 | 
			
		||||
							default.gui_bg..
 | 
			
		||||
							default.gui_bg_img)
 | 
			
		||||
					meta:set_string("infotext", "Adjustable Vacuuming Pneumatic Tube Segment")
 | 
			
		||||
				end,
 | 
			
		||||
				on_receive_fields = function(pos,formname,fields,sender)
 | 
			
		||||
					if not pipeworks.may_configure(pos, sender) then return end
 | 
			
		||||
					local meta = minetest.get_meta(pos)
 | 
			
		||||
					local dist = tonumber(fields.dist)
 | 
			
		||||
					if dist then
 | 
			
		||||
						dist = math.max(0, dist)
 | 
			
		||||
						dist = math.min(8, dist)
 | 
			
		||||
						meta:set_int("dist", dist)
 | 
			
		||||
						meta:set_string("infotext", ("Adjustable Vacuuming Pneumatic Tube Segment (%dm)"):format(dist))
 | 
			
		||||
					end
 | 
			
		||||
				end,
 | 
			
		||||
			},
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	minetest.register_craft( {
 | 
			
		||||
		output = "pipeworks:mese_sand_tube_1 2",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			{"homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
 | 
			
		||||
			{"group:sand",                 "default:mese_crystal",       "group:sand" },
 | 
			
		||||
			{"homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	minetest.register_craft( {
 | 
			
		||||
		type = "shapeless",
 | 
			
		||||
		output = "pipeworks:mese_sand_tube_1",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			"pipeworks:sand_tube_1",
 | 
			
		||||
			"default:mese_crystal_fragment",
 | 
			
		||||
			"default:mese_crystal_fragment",
 | 
			
		||||
			"default:mese_crystal_fragment",
 | 
			
		||||
			"default:mese_crystal_fragment"
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
end
 | 
			
		||||
local enable_max = minetest.settings:get_bool("pipeworks_enable_items_per_tube_limit", true)
 | 
			
		||||
local max_items = tonumber(minetest.settings:get("pipeworks_max_items_per_tube")) or 30
 | 
			
		||||
max_items = math.ceil(max_items / 2)  -- Limit vacuuming to half the max limit
 | 
			
		||||
 | 
			
		||||
local function vacuum(pos, radius)
 | 
			
		||||
	radius = radius + 0.5
 | 
			
		||||
	for _, object in pairs(minetest.get_objects_inside_radius(pos, math.sqrt(3) * radius)) do
 | 
			
		||||
		local lua_entity = object:get_luaentity()
 | 
			
		||||
		if not object:is_player() and lua_entity and lua_entity.name == "__builtin:item" then
 | 
			
		||||
			local obj_pos = object:get_pos()
 | 
			
		||||
			local minpos = vector.subtract(pos, radius)
 | 
			
		||||
			local maxpos = vector.add(pos, radius)
 | 
			
		||||
			if  obj_pos.x >= minpos.x and obj_pos.x <= maxpos.x
 | 
			
		||||
			and obj_pos.y >= minpos.y and obj_pos.y <= maxpos.y
 | 
			
		||||
			and obj_pos.z >= minpos.z and obj_pos.z <= maxpos.z then
 | 
			
		||||
				if lua_entity.itemstring ~= "" then
 | 
			
		||||
					pipeworks.tube_inject_item(pos, pos, vector.new(0, 0, 0), lua_entity.itemstring)
 | 
			
		||||
					lua_entity.itemstring = ""
 | 
			
		||||
				end
 | 
			
		||||
				object:remove()
 | 
			
		||||
	local min_pos = vector.subtract(pos, radius)
 | 
			
		||||
	local max_pos = vector.add(pos, radius)
 | 
			
		||||
	local count = 0
 | 
			
		||||
	for _, obj in pairs(minetest.get_objects_in_area(min_pos, max_pos)) do
 | 
			
		||||
		local entity = obj:get_luaentity()
 | 
			
		||||
		if entity and entity.name == "__builtin:item" then
 | 
			
		||||
			if entity.itemstring ~= "" then
 | 
			
		||||
				pipeworks.tube_inject_item(pos, pos, vector.new(0, 0, 0), entity.itemstring)
 | 
			
		||||
				entity.itemstring = ""
 | 
			
		||||
				count = count + 1
 | 
			
		||||
			end
 | 
			
		||||
			obj:remove()
 | 
			
		||||
			if enable_max and count >= max_items then
 | 
			
		||||
				return  -- Don't break tube by vacuuming too many items
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
minetest.register_abm({nodenames = {"group:vacuum_tube"},
 | 
			
		||||
	interval = 1,
 | 
			
		||||
	chance = 1,
 | 
			
		||||
	label = "Vacuum tubes",
 | 
			
		||||
	action = function(pos, node, active_object_count, active_object_count_wider)
 | 
			
		||||
		if node.name:find("pipeworks:sand_tube") then
 | 
			
		||||
			vacuum(pos, 2)
 | 
			
		||||
		else
 | 
			
		||||
			local radius = minetest.get_meta(pos):get_int("dist")
 | 
			
		||||
			vacuum(pos, radius)
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
local function set_timer(pos)
 | 
			
		||||
	local timer = minetest.get_node_timer(pos)
 | 
			
		||||
	-- Randomize timer so not all tubes vacuum at the same time
 | 
			
		||||
	timer:start(math.random(10, 20) * 0.1)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if pipeworks.enable_sand_tube then
 | 
			
		||||
	pipeworks.register_tube("pipeworks:sand_tube", {
 | 
			
		||||
		description = S("Vacuuming Pneumatic Tube Segment"),
 | 
			
		||||
		inventory_image = "pipeworks_sand_tube_inv.png",
 | 
			
		||||
		short = "pipeworks_sand_tube_short.png",
 | 
			
		||||
		noctr = {"pipeworks_sand_tube_noctr.png"},
 | 
			
		||||
		plain = {"pipeworks_sand_tube_plain.png"},
 | 
			
		||||
		ends = {"pipeworks_sand_tube_end.png"},
 | 
			
		||||
		node_def = {
 | 
			
		||||
			groups = {vacuum_tube = 1},
 | 
			
		||||
			on_construct = set_timer,
 | 
			
		||||
			on_timer = function(pos, elapsed)
 | 
			
		||||
				vacuum(pos, 2)
 | 
			
		||||
				set_timer(pos)
 | 
			
		||||
			end,
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if pipeworks.enable_mese_sand_tube then
 | 
			
		||||
	local formspec = "formspec_version[2]size[8,3]"..
 | 
			
		||||
		pipeworks.fs_helpers.get_prepends("8,3")..
 | 
			
		||||
		"image[0.5,0.3;1,1;pipeworks_mese_sand_tube_inv.png]"..
 | 
			
		||||
		"label[1.75,0.8;"..S("Adjustable Vacuuming Tube").."]"..
 | 
			
		||||
		"field[0.5,1.7;5,0.8;dist;"..S("Radius")..";${dist}]"..
 | 
			
		||||
		"button_exit[5.5,1.7;2,0.8;save;"..S("Save").."]"
 | 
			
		||||
 | 
			
		||||
	pipeworks.register_tube("pipeworks:mese_sand_tube", {
 | 
			
		||||
		description = S("Adjustable Vacuuming Tube"),
 | 
			
		||||
		inventory_image = "pipeworks_mese_sand_tube_inv.png",
 | 
			
		||||
		short = "pipeworks_mese_sand_tube_short.png",
 | 
			
		||||
		noctr = {"pipeworks_mese_sand_tube_noctr.png"},
 | 
			
		||||
		plain = {"pipeworks_mese_sand_tube_plain.png"},
 | 
			
		||||
		ends = {"pipeworks_mese_sand_tube_end.png"},
 | 
			
		||||
		node_def = {
 | 
			
		||||
			groups = {vacuum_tube = 1},
 | 
			
		||||
			on_construct = function(pos)
 | 
			
		||||
				local meta = minetest.get_meta(pos)
 | 
			
		||||
				meta:set_int("dist", 2)
 | 
			
		||||
				meta:set_string("formspec", formspec)
 | 
			
		||||
				meta:set_string("infotext", S("Adjustable Vacuuming Tube (@1m)", 2))
 | 
			
		||||
				set_timer(pos)
 | 
			
		||||
			end,
 | 
			
		||||
			on_timer = function(pos, elapsed)
 | 
			
		||||
				local radius = minetest.get_meta(pos):get_int("dist")
 | 
			
		||||
				vacuum(pos, radius)
 | 
			
		||||
				set_timer(pos)
 | 
			
		||||
			end,
 | 
			
		||||
			on_receive_fields = function(pos, _, fields, sender)
 | 
			
		||||
				if not fields.dist or not pipeworks.may_configure(pos, sender) then
 | 
			
		||||
					return
 | 
			
		||||
				end
 | 
			
		||||
				local meta = minetest.get_meta(pos)
 | 
			
		||||
				local dist = math.min(math.max(tonumber(fields.dist) or 0, 0), 8)
 | 
			
		||||
				meta:set_int("dist", dist)
 | 
			
		||||
				meta:set_string("infotext", S("Adjustable Vacuuming Tube (@1m)", dist))
 | 
			
		||||
			end,
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
minetest.register_lbm({
 | 
			
		||||
	label = "Vacuum tube node timer starter",
 | 
			
		||||
	name = "pipeworks:vacuum_tube_start",
 | 
			
		||||
	nodenames = {"group:vacuum_tube"},
 | 
			
		||||
	run_at_every_load = false,
 | 
			
		||||
	action = set_timer,
 | 
			
		||||
})
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										109
									
								
								wielder.lua
									
									
									
									
									
								
							
							
						
						
									
										109
									
								
								wielder.lua
									
									
									
									
									
								
							@@ -1,21 +1,33 @@
 | 
			
		||||
local S = minetest.get_translator("pipeworks")
 | 
			
		||||
local assumed_eye_pos = vector.new(0, 1.5, 0)
 | 
			
		||||
 | 
			
		||||
local function vector_copy(v)
 | 
			
		||||
	return { x = v.x, y = v.y, z = v.z }
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function delay(x)
 | 
			
		||||
	return (function() return x end)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function set_wielder_formspec(data, meta)
 | 
			
		||||
	local size = "10.2,"..(7+data.wield_inv_height)
 | 
			
		||||
	local list_background = ""
 | 
			
		||||
	if minetest.get_modpath("i3") or minetest.get_modpath("mcl_formspec") then
 | 
			
		||||
		list_background = "style_type[box;colors=#666]"
 | 
			
		||||
		for i=0, data.wield_inv_height-1 do
 | 
			
		||||
			for j=0, data.wield_inv_width-1 do
 | 
			
		||||
				list_background = list_background .. "box[".. ((10-data.wield_inv_width)*0.5)+(i*1.25) ..",".. 1+(j*1.25) ..";1,1;]"
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
	meta:set_string("formspec",
 | 
			
		||||
			"invsize[8,"..(6+data.wield_inv_height)..";]"..
 | 
			
		||||
			"item_image[0,0;1,1;"..data.name_base.."_off]"..
 | 
			
		||||
			"label[1,0;"..minetest.formspec_escape(data.description).."]"..
 | 
			
		||||
			"list[current_name;"..minetest.formspec_escape(data.wield_inv_name)..";"..((8-data.wield_inv_width)*0.5)..",1;"..data.wield_inv_width..","..data.wield_inv_height..";]"..
 | 
			
		||||
			"list[current_player;main;0,"..(2+data.wield_inv_height)..";8,4;]" ..
 | 
			
		||||
			"listring[]")
 | 
			
		||||
		"formspec_version[2]" ..
 | 
			
		||||
		"size["..size.."]"..
 | 
			
		||||
		pipeworks.fs_helpers.get_prepends(size)..
 | 
			
		||||
		"item_image[0.5,0.5;1,1;"..data.name_base.."_off]"..
 | 
			
		||||
		"label[1.5,1;"..minetest.formspec_escape(data.description).."]"..
 | 
			
		||||
		list_background ..
 | 
			
		||||
		"list[context;"..minetest.formspec_escape(data.wield_inv_name)..";"..((10-data.wield_inv_width)*0.5)..",1;"..data.wield_inv_width..","..data.wield_inv_height..";]"..
 | 
			
		||||
		pipeworks.fs_helpers.get_inv((2+data.wield_inv_height)) ..
 | 
			
		||||
		"listring[context;"..minetest.formspec_escape(data.wield_inv_name).."]" ..
 | 
			
		||||
		"listring[current_player;main]"
 | 
			
		||||
	)
 | 
			
		||||
	meta:set_string("infotext", data.description)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@@ -39,7 +51,7 @@ local can_tool_dig_node = function(nodename, toolcaps, toolname)
 | 
			
		||||
		-- but a player holding one can - the game seems to fall back to the hand.
 | 
			
		||||
		-- fall back to checking the hand's properties if the tool isn't the correct one.
 | 
			
		||||
		local hand_caps = minetest.registered_items[""].tool_capabilities
 | 
			
		||||
		diggable = minetest.get_dig_params(nodegroups, hand_caps)
 | 
			
		||||
		diggable = minetest.get_dig_params(nodegroups, hand_caps).diggable
 | 
			
		||||
	end
 | 
			
		||||
	return diggable
 | 
			
		||||
end
 | 
			
		||||
@@ -134,7 +146,7 @@ local function register_wielder(data)
 | 
			
		||||
	data.fixup_node = data.fixup_node or function (pos, node) end
 | 
			
		||||
	data.fixup_oldmetadata = data.fixup_oldmetadata or function (m) return m end
 | 
			
		||||
	for _, state in ipairs({ "off", "on" }) do
 | 
			
		||||
		local groups = { snappy=2, choppy=2, oddly_breakable_by_hand=2, mesecon=2, tubedevice=1, tubedevice_receiver=1 }
 | 
			
		||||
		local groups = { snappy=2, choppy=2, oddly_breakable_by_hand=2, mesecon=2, tubedevice=1, tubedevice_receiver=1, axey=1, handy=1, pickaxey=1 }
 | 
			
		||||
		if state == "on" then groups.not_in_creative_inventory = 1 end
 | 
			
		||||
		local tile_images = {}
 | 
			
		||||
		for _, face in ipairs({ "top", "bottom", "side2", "side1", "back", "front" }) do
 | 
			
		||||
@@ -187,7 +199,10 @@ local function register_wielder(data)
 | 
			
		||||
			paramtype2 = "facedir",
 | 
			
		||||
			tubelike = 1,
 | 
			
		||||
			groups = groups,
 | 
			
		||||
			sounds = default.node_sound_stone_defaults(),
 | 
			
		||||
			_mcl_hardness=0.6,
 | 
			
		||||
			_sound_def = {
 | 
			
		||||
				key = "node_sound_stone_defaults",
 | 
			
		||||
			},
 | 
			
		||||
			drop = data.name_base.."_off",
 | 
			
		||||
			on_construct = function(pos)
 | 
			
		||||
				local meta = minetest.get_meta(pos)
 | 
			
		||||
@@ -210,7 +225,6 @@ local function register_wielder(data)
 | 
			
		||||
					local node = minetest.get_node(pos)
 | 
			
		||||
					node.param2 = minetest.dir_to_facedir(dir, true)
 | 
			
		||||
					minetest.set_node(pos, node)
 | 
			
		||||
					minetest.log("action", "real (6d) facedir: " .. node.param2)
 | 
			
		||||
				end
 | 
			
		||||
				minetest.get_meta(pos):set_string("owner", placer:get_player_name())
 | 
			
		||||
			end,
 | 
			
		||||
@@ -234,6 +248,7 @@ local function register_wielder(data)
 | 
			
		||||
				end
 | 
			
		||||
				pipeworks.scan_for_tube_objects(pos)
 | 
			
		||||
			end,
 | 
			
		||||
			on_rotate = pipeworks.on_rotate,
 | 
			
		||||
			on_punch = data.fixup_node,
 | 
			
		||||
			allow_metadata_inventory_put = function(pos, listname, index, stack, player)
 | 
			
		||||
				if not pipeworks.may_configure(pos, player) then return 0 end
 | 
			
		||||
@@ -258,7 +273,7 @@ if pipeworks.enable_node_breaker then
 | 
			
		||||
	local wield_inv_name = "pick"
 | 
			
		||||
	data = {
 | 
			
		||||
		name_base = name_base,
 | 
			
		||||
		description = "Node Breaker",
 | 
			
		||||
		description = S("Node Breaker"),
 | 
			
		||||
		texture_base = "pipeworks_nodebreaker",
 | 
			
		||||
		texture_stateful = { top = true, bottom = true, side2 = true, side1 = true, front = true },
 | 
			
		||||
		tube_connect_sides = { top=1, bottom=1, left=1, right=1, back=1 },
 | 
			
		||||
@@ -321,6 +336,10 @@ if pipeworks.enable_node_breaker then
 | 
			
		||||
		masquerade_as_owner = true,
 | 
			
		||||
		sneak = false,
 | 
			
		||||
		act = function(virtplayer, pointed_thing)
 | 
			
		||||
			if minetest.is_protected(vector.add(virtplayer:get_pos(), assumed_eye_pos), virtplayer:get_player_name()) then
 | 
			
		||||
				return
 | 
			
		||||
			end
 | 
			
		||||
 | 
			
		||||
			--local dname = "nodebreaker.act() "
 | 
			
		||||
			local wieldstack = virtplayer:get_wielded_item()
 | 
			
		||||
			local oldwieldstack = ItemStack(wieldstack)
 | 
			
		||||
@@ -331,14 +350,27 @@ if pipeworks.enable_node_breaker then
 | 
			
		||||
				virtplayer:set_wielded_item(wieldstack)
 | 
			
		||||
			else
 | 
			
		||||
				local under_node = minetest.get_node(pointed_thing.under)
 | 
			
		||||
				local on_dig = (minetest.registered_nodes[under_node.name] or {on_dig=minetest.node_dig}).on_dig
 | 
			
		||||
				-- check that the current tool is capable of destroying the target node.
 | 
			
		||||
				local def = minetest.registered_nodes[under_node.name]
 | 
			
		||||
				if not def then
 | 
			
		||||
					-- do not dig an unknown node
 | 
			
		||||
					return
 | 
			
		||||
				end
 | 
			
		||||
				-- check that the current tool is capable of destroying the
 | 
			
		||||
				-- target node.
 | 
			
		||||
				-- if we can't, don't dig, and leave the wield stack unchanged.
 | 
			
		||||
				-- note that wieldstack:get_tool_capabilities() returns hand properties if the item has none of it's own.
 | 
			
		||||
				if can_tool_dig_node(under_node.name, wieldstack:get_tool_capabilities(), wieldstack:get_name()) then
 | 
			
		||||
					on_dig(pointed_thing.under, under_node, virtplayer)
 | 
			
		||||
				-- note that wieldstack:get_tool_capabilities() returns hand
 | 
			
		||||
				-- properties if the item has none of it's own.
 | 
			
		||||
				if can_tool_dig_node(under_node.name,
 | 
			
		||||
						wieldstack:get_tool_capabilities(),
 | 
			
		||||
						wieldstack:get_name()) then
 | 
			
		||||
					def.on_dig(pointed_thing.under, under_node, virtplayer)
 | 
			
		||||
					local sound = def.sounds and def.sounds.dug
 | 
			
		||||
					if sound then
 | 
			
		||||
						minetest.sound_play(sound.name,
 | 
			
		||||
							{pos=pointed_thing.under, gain=sound.gain})
 | 
			
		||||
					end
 | 
			
		||||
					wieldstack = virtplayer:get_wielded_item()
 | 
			
		||||
				else
 | 
			
		||||
				--~ else
 | 
			
		||||
					--pipeworks.logger(dname.."couldn't dig node!")
 | 
			
		||||
				end
 | 
			
		||||
			end
 | 
			
		||||
@@ -360,14 +392,7 @@ if pipeworks.enable_node_breaker then
 | 
			
		||||
		eject_drops = true,
 | 
			
		||||
	}
 | 
			
		||||
	register_wielder(data)
 | 
			
		||||
	minetest.register_craft({
 | 
			
		||||
		output = "pipeworks:nodebreaker_off",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			{ "pipeworks:gear", "pipeworks:gear",   "pipeworks:gear"    },
 | 
			
		||||
			{ "default:stone", "mesecons:piston",   "default:stone" },
 | 
			
		||||
			{ "group:wood",    "mesecons:mesecon",  "group:wood" },
 | 
			
		||||
		}
 | 
			
		||||
	})
 | 
			
		||||
	pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:nodebreaker_off"
 | 
			
		||||
	-- aliases for when someone had technic installed, but then uninstalled it but not pipeworks
 | 
			
		||||
	minetest.register_alias("technic:nodebreaker_off", "pipeworks:nodebreaker_off")
 | 
			
		||||
	minetest.register_alias("technic:nodebreaker_on", "pipeworks:nodebreaker_on")
 | 
			
		||||
@@ -394,7 +419,7 @@ end
 | 
			
		||||
if pipeworks.enable_deployer then
 | 
			
		||||
	register_wielder({
 | 
			
		||||
		name_base = "pipeworks:deployer",
 | 
			
		||||
		description = "Deployer",
 | 
			
		||||
		description = S("Deployer"),
 | 
			
		||||
		texture_base = "pipeworks_deployer",
 | 
			
		||||
		texture_stateful = { front = true },
 | 
			
		||||
		tube_connect_sides = { back=1 },
 | 
			
		||||
@@ -406,19 +431,16 @@ if pipeworks.enable_deployer then
 | 
			
		||||
		masquerade_as_owner = true,
 | 
			
		||||
		sneak = false,
 | 
			
		||||
		act = function(virtplayer, pointed_thing)
 | 
			
		||||
			if minetest.is_protected(vector.add(virtplayer:get_pos(), assumed_eye_pos), virtplayer:get_player_name()) then
 | 
			
		||||
				return
 | 
			
		||||
			end
 | 
			
		||||
 | 
			
		||||
			local wieldstack = virtplayer:get_wielded_item()
 | 
			
		||||
			virtplayer:set_wielded_item((minetest.registered_items[wieldstack:get_name()] or {on_place=minetest.item_place}).on_place(wieldstack, virtplayer, pointed_thing) or wieldstack)
 | 
			
		||||
		end,
 | 
			
		||||
		eject_drops = false,
 | 
			
		||||
	})
 | 
			
		||||
	minetest.register_craft({
 | 
			
		||||
		output = "pipeworks:deployer_off",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			{ "group:wood",    "default:chest",    "group:wood"    },
 | 
			
		||||
			{ "default:stone", "mesecons:piston",  "default:stone" },
 | 
			
		||||
			{ "default:stone", "mesecons:mesecon", "default:stone" },
 | 
			
		||||
		}
 | 
			
		||||
	})
 | 
			
		||||
	pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:deployer_off"
 | 
			
		||||
	-- aliases for when someone had technic installed, but then uninstalled it but not pipeworks
 | 
			
		||||
	minetest.register_alias("technic:deployer_off", "pipeworks:deployer_off")
 | 
			
		||||
	minetest.register_alias("technic:deployer_on", "pipeworks:deployer_on")
 | 
			
		||||
@@ -427,7 +449,7 @@ end
 | 
			
		||||
if pipeworks.enable_dispenser then
 | 
			
		||||
	register_wielder({
 | 
			
		||||
		name_base = "pipeworks:dispenser",
 | 
			
		||||
		description = "Dispenser",
 | 
			
		||||
		description = S("Dispenser"),
 | 
			
		||||
		texture_base = "pipeworks_dispenser",
 | 
			
		||||
		texture_stateful = { front = true },
 | 
			
		||||
		tube_connect_sides = { back=1 },
 | 
			
		||||
@@ -446,12 +468,5 @@ if pipeworks.enable_dispenser then
 | 
			
		||||
		end,
 | 
			
		||||
		eject_drops = false,
 | 
			
		||||
	})
 | 
			
		||||
	minetest.register_craft({
 | 
			
		||||
		output = "pipeworks:dispenser_off",
 | 
			
		||||
		recipe = {
 | 
			
		||||
			{ "default:desert_sand", "default:chest",    "default:desert_sand" },
 | 
			
		||||
			{ "default:stone",       "mesecons:piston",  "default:stone"       },
 | 
			
		||||
			{ "default:stone",       "mesecons:mesecon", "default:stone"       },
 | 
			
		||||
		}
 | 
			
		||||
	})
 | 
			
		||||
	pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:dispenser_off"
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user