Add chips, craftguide, and shop crafting

master
rubenwardy 2018-12-10 02:38:20 +00:00
parent 78a32abea9
commit f3478486a7
219 changed files with 78 additions and 5720 deletions

3
.gitmodules vendored
View File

@ -10,3 +10,6 @@
[submodule "mods/content/oil"]
path = mods/content/oil
url = https://github.com/rubenwardy/oil
[submodule "mods/content/craftguide"]
path = mods/content/craftguide
url = git@github.com:minetest-mods/craftguide.git

View File

@ -1,19 +1 @@
pipeworks_enable_autocrafter = false
pipeworks_enable_deployer = false
pipeworks_enable_dispenser = false
pipeworks_enable_node_breaker = false
pipeworks_enable_teleport_tube = false
pipeworks_enable_redefines = false
pipeworks_enable_teleport_tube = false
pipeworks_enable_mese_tube = false
pipeworks_enable_detector_tube = false
pipeworks_enable_digiline_detector_tube = false
pipeworks_enable_conductor_tube = false
pipeworks_enable_digiline_conductor_tube = false
pipeworks_enable_accelerator_tube = false
pipeworks_enable_crossing_tube = false
pipeworks_enable_sand_tube = false
pipeworks_enable_mese_sand_tube = false
pipeworks_enable_priority_tube = false
pipeworks_enable_one_way_tube = false
pipeworks_enable_lua_tube = false
craftguide_sfinv_only = true

View File

@ -1,2 +1,2 @@
name = shop
depends = company, banking, land, lib_utils, lib_underscore, lib_quickfs
depends = company, banking, land, lib_utils, lib_underscore, lib_quickfs, oil, chips

View File

@ -132,3 +132,28 @@ minetest.register_node("shop:chest", _.extend(chest_template, {
"shop_chest_side.png"
},
}))
minetest.register_craft({
output = "shop:counter",
recipe = {
{"oil:plastic_sheet", "default:glass", "oil:plastic_sheet"},
{"default:stick", "chips:chip", "default:stick" },
{"default:stick", "", "default:stick" },
},
})
minetest.register_craft({
output = "shop:chest",
recipe = {
{"default:wood", "default:wood", "default:wood"},
{"default:wood", "oil:plastic_sheet", "default:wood"},
{"default:wood", "default:wood", "default:wood"},
},
})
minetest.register_craft({
output = "shop:chest",
type = "shapeless",
recipe = { "default:chest", "oil:plastic_sheet"},
})

View File

@ -0,0 +1,9 @@
# Chips
Chip manufacturing and use
## Licenses
RealBadAngel (WTFPL):
* chips_chip.png

View File

@ -0,0 +1,35 @@
minetest.register_craftitem("chips:silicon", {
description = "Silicon",
inventory_image = "chips_silicon.png",
})
minetest.register_craftitem("chips:wafer", {
description = "Silicon Wafer",
inventory_image = "chips_wafer.png",
})
minetest.register_craftitem("chips:chip", {
description = "Chip",
inventory_image = "chips_chip.png"
})
minetest.register_craft({
output = "chips:silicon",
type = "shapeless",
recipe = {"default:sand 5"},
})
minetest.register_craft({
output = "chips:wafer",
recipe = {
{"chips:silicon", "default:gold_ingot", "chips:silicon" },
{"default:gold_ingot", "chips:silicon", "default:gold_ingot"},
{"chips:silicon", "default:gold_ingot", "chips:silicon" },
}
})
minetest.register_craft({
output = "chips:chip",
type = "shapeless",
recipe = {"chips:wafer"},
})

View File

@ -0,0 +1,2 @@
name = chips
depends = default

Binary file not shown.

After

Width:  |  Height:  |  Size: 652 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 913 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B

@ -0,0 +1 @@
Subproject commit 0b4f202ffb2d1a4f3d1e2c5ffcad299a388b39ed

@ -1 +1 @@
Subproject commit 8f17300c64f5803c5a6385073fec1c02ac5838c7
Subproject commit daaf11949f705edafdfd80967b5e5dd84c321fc0

View File

@ -1,22 +0,0 @@
## Files related to minetest development cycle
/*.patch
# GNU Patch reject file
*.rej
## Editors and Development environments
*~
*.swp
*.bak*
*.orig
# Vim
*.vim
# Kate
.*.kate-swp
.swp.*
# Eclipse (LDT)
.project
.settings/
.buildpath
.metadata
# Idea IDE
.idea/*

View File

@ -1,600 +0,0 @@
License for code: LGPL 3.0
License for media and all other assets: CC-by-SA 4.0
###############################################################################
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
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.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
###############################################################################
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.

View File

@ -1,22 +0,0 @@
This mod uses nodeboxes to supply a complete set of 3D pipes and tubes,
along devices that work with them.
See https://gitlab.com/VanessaE/pipeworks/wikis/ 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
or horizontally, and there are enough nodes defined to allow for all possible
connections. Valves and pumps can only be placed horizontally, and will
automatically rotate and join with neighboring pipes as objects are added, as
well as joining with each other under certain circumstances.
Pipes come in two variants: one type bears one or more dark windows on each
pipe, suggesting they're empty, while the other type bears green-tinted
windows, as if full (the two colors should also be easy to select if you want
to change them in a paint program). These windows only appear on straight
lengths and on certain junctions.
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.

View File

@ -1,226 +0,0 @@
--[[
autorouting for pipes
To connect pipes to some node, include this in the node def...
pipe_connections = {
pattern = <string>, -- if supplied, search for this pattern instead of the exact node name
left = <bool>, -- true (or 1) if the left side of the node needs to connect to a pipe
right = <bool>, -- or from the right side, etc.
top = <bool>,
bottom = <bool>,
front = <bool>,
back = <bool>,
left_param2 = <num>, -- the node must have this param2 to connect from the left
right_param2 = <num>, -- or right, etc.
top_param2 = <num>, -- Omit some or all of these to skip checking param2 for those sides
bottom_param2 = <num>,
front_param2 = <num>,
back_param2 = <num>,
},
...then add, pipeworks.scan_for_pipe_objects(pos)
to your node's after_dig_node and after_place_node callbacks.
]]--
-- get the axis dir (just 6 faces) of target node, assumes the pipe is the axis
function pipeworks.get_axis_dir(nodetable, pattern)
local pxm,pxp,pym,pyp,pzm,pzp
if string.find(nodetable.nxm.name, pattern)
and minetest.facedir_to_dir(nodetable.nxm.param2).x ~= 0 then
pxm=1
end
if string.find(nodetable.nxp.name, pattern)
and minetest.facedir_to_dir(nodetable.nxp.param2).x ~= 0 then
pxp=1
end
if string.find(nodetable.nzm.name, pattern)
and minetest.facedir_to_dir(nodetable.nzm.param2).z ~= 0 then
pzm=1
end
if string.find(nodetable.nzp.name, pattern)
and minetest.facedir_to_dir(nodetable.nzp.param2).z ~= 0 then
pzp=1
end
if string.find(nodetable.nym.name, pattern)
and minetest.facedir_to_dir(nodetable.nym.param2).y ~= 0 then
pym=1
end
if string.find(nodetable.nyp.name, pattern)
and minetest.facedir_to_dir(nodetable.nyp.param2).y ~= 0 then
pyp=1
end
local match = pxm or pxp or pym or pyp or pzm or pzp
return match,pxm,pxp,pym,pyp,pzm,pzp
end
local tube_table = {[0] = 1, 2, 2, 4, 2, 4, 4, 5, 2, 3, 4, 6, 4, 6, 5, 7, 2, 4, 3, 6, 4, 5, 6, 7, 4, 6, 6, 8, 5, 7, 7, 9, 2, 4, 4, 5, 3, 6, 6, 7, 4, 6, 5, 7, 6, 8, 7, 9, 4, 5, 6, 7, 6, 7, 8, 9, 5, 7, 7, 9, 7, 9, 9, 10}
local tube_table_facedirs = {[0] = 0, 0, 5, 0, 3, 4, 3, 0, 2, 0, 2, 0, 6, 4, 3, 0, 7, 12, 5, 12, 7, 4, 5, 5, 18, 20, 16, 0, 7, 4, 7, 0, 1, 8, 1, 1, 1, 13, 1, 1, 10, 8, 2, 2, 17, 4, 3, 6, 9, 9, 9, 9, 21, 13, 1, 1, 10, 10, 11, 2, 19, 4, 3, 0}
local function autoroute_pipes(pos)
local nctr = minetest.get_node(pos)
local state = "_empty"
if (string.find(nctr.name, "pipeworks:pipe_") == nil) then return end
if (string.find(nctr.name, "_loaded") ~= nil) then state = "_loaded" end
local nsurround = pipeworks.scan_pipe_surroundings(pos)
if nsurround == 0 then nsurround = 9 end
minetest.swap_node(pos, {name = "pipeworks:pipe_"..tube_table[nsurround]..state,
param2 = tube_table_facedirs[nsurround]})
end
function pipeworks.scan_for_pipe_objects(pos)
autoroute_pipes({ x=pos.x-1, y=pos.y , z=pos.z })
autoroute_pipes({ x=pos.x+1, y=pos.y , z=pos.z })
autoroute_pipes({ x=pos.x , y=pos.y-1, z=pos.z })
autoroute_pipes({ x=pos.x , y=pos.y+1, z=pos.z })
autoroute_pipes({ x=pos.x , y=pos.y , z=pos.z-1 })
autoroute_pipes({ x=pos.x , y=pos.y , z=pos.z+1 })
autoroute_pipes(pos)
end
-- auto-rotation code for various devices the pipes attach to
function pipeworks.scan_pipe_surroundings(pos)
local pxm=0
local pxp=0
local pym=0
local pyp=0
local pzm=0
local pzp=0
local nxm = minetest.get_node({ x=pos.x-1, y=pos.y , z=pos.z })
local nxp = minetest.get_node({ x=pos.x+1, y=pos.y , z=pos.z })
local nym = minetest.get_node({ x=pos.x , y=pos.y-1, z=pos.z })
local nyp = minetest.get_node({ x=pos.x , y=pos.y+1, z=pos.z })
local nzm = minetest.get_node({ x=pos.x , y=pos.y , z=pos.z-1 })
local nzp = minetest.get_node({ x=pos.x , y=pos.y , z=pos.z+1 })
local nodetable = {
nxm = nxm,
nxp = nxp,
nym = nym,
nyp = nyp,
nzm = nzm,
nzp = nzp
}
-- standard handling for pipes...
if string.find(nxm.name, "pipeworks:pipe_") then pxm=1 end
if string.find(nxp.name, "pipeworks:pipe_") then pxp=1 end
if string.find(nym.name, "pipeworks:pipe_") then pym=1 end
if string.find(nyp.name, "pipeworks:pipe_") then pyp=1 end
if string.find(nzm.name, "pipeworks:pipe_") then pzm=1 end
if string.find(nzp.name, "pipeworks:pipe_") then pzp=1 end
-- Special handling for valves...
local match,a,b,c,d,e,f = pipeworks.get_axis_dir(nodetable, "pipeworks:valve")
if match then
pxm = a or pxm
pxp = b or pxp
pym = c or pym
pyp = d or pyp
pzm = e or pzm
pzp = f or pzp
end
-- ...flow sensors...
local match,a,b,c,d,e,f = pipeworks.get_axis_dir(nodetable, "pipeworks:flow_sensor")
if match then
pxm = a or pxm
pxp = b or pxp
pym = c or pym
pyp = d or pyp
pzm = e or pzm
pzp = f or pzp
end
-- ...sealed pipe entry/exit...
local match,a,b,c,d,e,f = pipeworks.get_axis_dir(nodetable, "pipeworks:entry_panel")
if match then
pxm = a or pxm
pxp = b or pxp
pym = c or pym
pyp = d or pyp
pzm = e or pzm
pzp = f or pzp
end
-- ...straight-only pipe...
local match,a,b,c,d,e,f = pipeworks.get_axis_dir(nodetable, "pipeworks:straight_pipe")
if match then
pxm = a or pxm
pxp = b or pxp
pym = c or pym
pyp = d or pyp
pzm = e or pzm
pzp = f or pzp
end
-- ... other nodes
local def_left = minetest.registered_nodes[nxp.name] -- the node that {pos} is to the left of (not the
local def_right = minetest.registered_nodes[nxm.name] -- ...note that is AT the left!), etc.
local def_bottom = minetest.registered_nodes[nyp.name]
local def_top = minetest.registered_nodes[nym.name]
local def_front = minetest.registered_nodes[nzp.name]
local def_back = minetest.registered_nodes[nzm.name]
if def_left and def_left.pipe_connections and def_left.pipe_connections.left
and (not def_left.pipe_connections.pattern or string.find(nxp.name, def_left.pipe_connections.pattern))
and (not def_left.pipe_connections.left_param2 or (nxp.param2 == def_left.pipe_connections.left_param2)) then
pxp = 1
end
if def_right and def_right.pipe_connections and def_right.pipe_connections.right
and (not def_right.pipe_connections.pattern or string.find(nxm.name, def_right.pipe_connections.pattern))
and (not def_right.pipe_connections.right_param2 or (nxm.param2 == def_right.pipe_connections.right_param2)) then
pxm = 1
end
if def_top and def_top.pipe_connections and def_top.pipe_connections.top
and (not def_top.pipe_connections.pattern or string.find(nym.name, def_top.pipe_connections.pattern))
and (not def_top.pipe_connections.top_param2 or (nym.param2 == def_top.pipe_connections.top_param2)) then
pym = 1
end
if def_bottom and def_bottom.pipe_connections and def_bottom.pipe_connections.bottom
and (not def_bottom.pipe_connections.pattern or string.find(nyp.name, def_bottom.pipe_connections.pattern))
and (not def_bottom.pipe_connections.bottom_param2 or (nyp.param2 == def_bottom.pipe_connections.bottom_param2)) then
pyp = 1
end
if def_front and def_front.pipe_connections and def_front.pipe_connections.front
and (not def_front.pipe_connections.pattern or string.find(nzp.name, def_front.pipe_connections.pattern))
and (not def_front.pipe_connections.front_param2 or (nzp.param2 == def_front.pipe_connections.front_param2)) then
pzp = 1
end
if def_back and def_back.pipe_connections and def_back.pipe_connections.back
and (not def_back.pipe_connections.pattern or string.find(nzm.name, def_back.pipe_connections.pattern))
and (not def_back.pipe_connections.back_param2 or (nzm.param2 == def_back.pipe_connections.back_param2)) then
pzm = 1
end
print("stage 2 returns "..pxm+8*pxp+2*pym+16*pyp+4*pzm+32*pzp..
" for nodes surrounding "..minetest.get_node(pos).name.." at "..minetest.pos_to_string(pos))
return pxm+8*pxp+2*pym+16*pyp+4*pzm+32*pzp
end
function pipeworks.look_for_stackable_tanks(pos)
local tym = minetest.get_node({ x=pos.x , y=pos.y-1, z=pos.z })
if string.find(tym.name, "pipeworks:storage_tank_") ~= nil or
string.find(tym.name, "pipeworks:expansion_tank_") ~= nil then
minetest.add_node(pos, { name = "pipeworks:expansion_tank_0", param2 = tym.param2})
end
end

View File

@ -1,138 +0,0 @@
-- autorouting for pneumatic tubes
local function is_tube(nodename)
return pipeworks.table_contains(pipeworks.tubenodes, nodename)
end
--a function for determining which side of the node we are on
local function nodeside(node, tubedir)
if node.param2 < 0 or node.param2 > 23 then
node.param2 = 0
end
local backdir = minetest.facedir_to_dir(node.param2)
local back = pipeworks.vector_dot(backdir, tubedir)
if back == 1 then
return "back"
elseif back == -1 then
return "front"
end
local topdir = pipeworks.facedir_to_top_dir(node.param2)
local top = pipeworks.vector_dot(topdir, tubedir)
if top == 1 then
return "top"
elseif top == -1 then
return "bottom"
end
local rightdir = pipeworks.facedir_to_right_dir(node.param2)
local right = pipeworks.vector_dot(rightdir, tubedir)
if right == 1 then
return "right"
else
return "left"
end
end
local vts = {0, 3, 1, 4, 2, 5}
local tube_table = {[0] = 1, 2, 2, 4, 2, 4, 4, 5, 2, 3, 4, 6, 4, 6, 5, 7, 2, 4, 3, 6, 4, 5, 6, 7, 4, 6, 6, 8, 5, 7, 7, 9, 2, 4, 4, 5, 3, 6, 6, 7, 4, 6, 5, 7, 6, 8, 7, 9, 4, 5, 6, 7, 6, 7, 8, 9, 5, 7, 7, 9, 7, 9, 9, 10}
local tube_table_facedirs = {[0] = 0, 0, 5, 0, 3, 4, 3, 0, 2, 0, 2, 0, 6, 4, 3, 0, 7, 12, 5, 12, 7, 4, 5, 5, 18, 20, 16, 0, 7, 4, 7, 0, 1, 8, 1, 1, 1, 13, 1, 1, 10, 8, 2, 2, 17, 4, 3, 6, 9, 9, 9, 9, 21, 13, 1, 1, 10, 10, 11, 2, 19, 4, 3, 0}
local function tube_autoroute(pos)
local active = {0, 0, 0, 0, 0, 0}
local nctr = minetest.get_node(pos)
if not is_tube(nctr.name) then return end
local adjustments = {
{x = -1, y = 0, z = 0},
{x = 1, y = 0, z = 0},
{x = 0, y = -1, z = 0},
{x = 0, y = 1, z = 0},
{x = 0, y = 0, z = -1},
{x = 0, y = 0, z = 1}
}
-- 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
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
-- 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
active[i] = 1
end
end
end
-- 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
nsurround = nsurround..n
end
nctr.name = basename.."_"..nsurround
elseif nodedef.style == "6d" then
local s = 0
for i, n in ipairs(active) do
if n == 1 then
s = s + 2^vts[i]
end
end
nctr.name = basename.."_"..tube_table[s]
nctr.param2 = tube_table_facedirs[s]
end
minetest.swap_node(pos, nctr)
end
function pipeworks.scan_for_tube_objects(pos)
for side = 0, 6 do
tube_autoroute(vector.add(pos, pipeworks.directions.side_to_dir(side)))
end
end
function pipeworks.after_place(pos)
pipeworks.scan_for_tube_objects(pos)
end
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
pipeworks.scan_for_tube_objects(n.pos)
pipeworks.scan_for_tube_objects(n.oldpos)
end
end)
end

View File

@ -1,142 +0,0 @@
Changelog
---------
2017-10-19 (thetaepsilon)
Directional flowables are now implemented.
All devices for which it is relevant (valve, flow sensor etc.) have been converted so that they only flow on their connecting sides, so pressure propogation now works as expected for these devices when pressure logic is enabled.
Classic mode continues to be preserved by default as before.
2017-10-14 (thetaepsilon, VanessaE)
Node breakers have been updated to not have a tool by default, and determine if the node that they are trying to break can be dug with the tool in it's inventory slot.
The crafting recipe for the node breakers has been updated, using a new gear crafting item that requires iron instead of mese, which should be a more accessible cost in most cases.
Existing node breakers in worlds will get their mese pick back if their slot is empty via LBM - the mese pick will show up in the inventory slot so you can reclaim your hard-earned mese crystals.
Gear item texture and updated node breaker textures provided by VanessaE.
2017-10-08 (thetaepsilon)
A lot more of the new flow logic work.
There are two sub-modes of this now, non-finite and finite mode.
Non-finite mode most closely resembles "classic mode", whereas finite mode is more intended for use with mods such as dynamic_liquids which enable water sources to move themselves.
Everything that was functional in classic mode more or less works correctly now.
Still TODO:
+ Flow directionality - things like flow sensors and airtight panels will flow in directions that don't make sense from their visuals.
Possible feature requests:
+ Making tanks and gratings do something useful.
2017-09-27 (thetaepsilon)
Start of new flow logic re-implementation.
This mode is current *very* incomplete, and requires a per-world setting to enable.
Adds a pressure value stored in all pipe node metadata, and a mechanism to balance it out with nearby nodes on ABM trigger.
Currently, this inhibits the old behaviour when enabled, and (again WHEN ENABLED) breaks pretty much everything but normal pipes, spigots and pumps.
For this reason it is far from being intended as the default for some time to come yet.
What *does* work:
+ Pumps will try to take in water (and removes it!) as long as internal pressure does not exceed a threshold.
- a TODO is to make this pressure threshold configurable.
+ Pipes will balance this pressure between themselves, and will slowly average out over time.
+ Spigots will try to make the node beneath them a water source if the pressure is great enough and the existing node is flowing water or air.
- This is admittedly of fairly limited use with default water mechanics; those looking for more realistic mechanics might want to look at the dynamic_liquid mod, though that mod comes with it's own caveats (most notably drastic changes to previous worlds...).
What *does not* work:
+ Flow sensors, valves. Valves in particular currently do not function as a barrier to water's path under the experimental logic.
- TODO: internal code to allow this to be overriden.
*seems this hasn't been updated in a while*
2013-01-13: Tubes can transport items now! Namely, I added Novatux/Nore's item
transport mod as a default part of this mod, to make tubes do something useful!
Thanks to Nore and RealBadAngel for the code contributions!
2013-01-05: made storage tanks connect from top/bottom, made storage tank and
pipe textures use the ^ combine operator so they can show the actual liquid
going through the pipes/tanks.
2013-01-04 (a bit later): Made pipes able to carry water! It was just a minor
logic error resulting from moving the water flowing code into it's own file
when I originally imported it. Many thanks to Mauvebic for writing it!
2013-01-04: First stage of integrating Mauvebic's water flowing code. This is
experimental and doesn't move water yet - but at least it doesn't break
anything :-)
2013-01-01: Various minor tweaks to textures, facedir settings, some other
stuff. Changed crafting recipes to account for revamped pumps, valves, etc.
Now requires the moreores mod and most recent git (for mese crystal fragments)
to craft a pump. Added a "sealed" entry/exit panel (really just a horizontal
pipe with a metal panel overlayed into the middle). Also, tweaked pipes to
always drop the empty ones. Revamped pumps so that now they should sit in/on
liquid and be connected only from the top, relegated grates to decorational-
only, added outlet spigot. Got rid of a few obsolete textures. Got rid of
that whole _x and _z naming thing - now all directional devices (pumps, valves,
spigots, tanks) use facedir. Valves, spigots no longer auto-rotate to find
nearby pipes.
2012-09-17: Added test object for pneumatic tube autorouting code, made tubes
connect to it and any object that bears groups={tubedevice=1} (connects to any
side)
2012-09-05: All recipes doubled except for junglegrass -> plastic sheet (since
that is derived from home decor)
2012-09-02: Fixed plastic sheeting recipe. Added crafting recipes for various
objects, with options: If homedecor is installed, use the plastic sheeting
therein. If not, we define it manually. If the Technic mod is installed,
don't define any recipes at all. Also removed the extra "loaded!" messages and
tweaked the default pipe alias to point to something that is actually visible
:-)
2012-09-01: flattened wielded pipe segment.
2012-08-24: Added square-ish pneumatic tubes with their own autoplace code
(does not connect to steel pipes or pipe-oriented devices), then revised their
textures shortly after. Fixed a recursion bug that sometimes caused a stack
overflow. Old pipes were overriding the pipeworks:pipe defintion that belongs
with the new pipes.
2012-08-22: Added outlet grate, made it participate in autoplace algorithm.
Extended storage tank to show fill level in 10% steps (0% to 100%). Added
"expansion tank" that appears if the user stacks tanks upwards. (Downwards is
not checked).
2012-08-21: Made storage tank participate in autoplace algorithm. Tuned API a
little to allow for more flexible placement. Re-organized code a bit to allow
for some upcoming rules changes. Made storage tanks' upper/lower fittins and
intake grate participate in autoplace algorithm.
2012-08-20: Added temporary nodes for storage tank and intake grating, but
without autoplace.
2012-08-19: Pumps and valves now fully participate in the
auto-rotate/auto-place algorithm.
2012-08-18: Total rewrite again. All pipes are now nice and round-looking, and
they auto-connect! Also added temporary nodes for pump and valve (each with an
on/off setting - punch to change). No crafting recipes yet and the pipes still
don't do anything useful yet. Soon.
2012-08-06: Moved this changelog off the forum post and into a separate file.
2012-08-05 (multiple updates): Rewrote pipeworks to use loops and tables to
create the nodes. Requires far less code now. Added -X, +X, -Y, +Y, -Z, +Z
capped stubs and a short centered horizontal segment. Changed node definitions
so that the aforementioned "short centered" segment is given on dig/drop.
Renamed it to just "pipeworks:pipe" (and pipe_loaded). Added empty/loaded
indicator images to the capped ends, removed some redundant comments. Made the
empty/loaded indication at the capped end more prominent.
2012-07-21: Added screenshot showing pipes as they look now that nodebox
texture rotation is fixed.
2012-07-18: Changed the mod name and all internals to 'pipeworks' instead of
'pipes'... after a couple of mistakes :-)
2012-07-12: moved project to github.
2012-06-23: Initial release, followed by reworking the textures a bit.

View File

@ -1,290 +0,0 @@
----------------------
-- Vector functions --
----------------------
function pipeworks.vector_cross(a, b)
return {
x = a.y * b.z - a.z * b.y,
y = a.z * b.x - a.x * b.z,
z = a.x * b.y - a.y * b.x
}
end
function pipeworks.vector_dot(a, b)
return a.x * b.x + a.y * b.y + a.z * b.z
end
-----------------------
-- Facedir functions --
-----------------------
function pipeworks.facedir_to_top_dir(facedir)
return ({[0] = {x = 0, y = 1, z = 0},
{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}})
[math.floor(facedir / 4)]
end
function pipeworks.facedir_to_right_dir(facedir)
return pipeworks.vector_cross(
pipeworks.facedir_to_top_dir(facedir),
minetest.facedir_to_dir(facedir)
)
end
local directions = {}
pipeworks.directions = directions
function directions.side_to_dir(side)
return ({[0] = vector.new(),
vector.new( 0, 1, 0),
vector.new( 0, -1, 0),
vector.new( 1, 0, 0),
vector.new(-1, 0, 0),
vector.new( 0, 0, 1),
vector.new( 0, 0, -1)
})[side]
end
function directions.dir_to_side(dir)
local c = pipeworks.vector_dot(dir, vector.new(1, 2, 3)) + 4
return ({6, 2, 4, 0, 3, 1, 5})[c]
end
----------------------
-- String functions --
----------------------
--[[function pipeworks.string_split(str, sep)
local fields = {}
local index = 1
local expr = "([^"..sep.."])+"
string.gsub(str, expr, function(substring)
fields[index] = substring
index = index + 1
end)
return fields
end]]
function pipeworks.string_startswith(str, substr)
return str:sub(1, substr:len()) == substr
end
---------------------
-- Table functions --
---------------------
function pipeworks.table_contains(tbl, element)
for _, elt in pairs(tbl) do
if elt == element then
return true
end
end
return false
end
function pipeworks.table_extend(tbl, tbl2)
local index = #tbl + 1
for _, elt in ipairs(tbl2) do
tbl[index] = elt
index = index + 1
end
end
function pipeworks.table_recursive_replace(tbl, pattern, replace_with)
if type(tbl) == "table" then
local tbl2 = {}
for key, value in pairs(tbl) do
tbl2[key] = pipeworks.table_recursive_replace(value, pattern, replace_with)
end
return tbl2
elseif type(tbl) == "string" then
return tbl:gsub(pattern, replace_with)
else
return tbl
end
end
------------------------
-- Formspec functions --
------------------------
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
if pipeworks.string_startswith(field, "fs_helpers_cycling:") then
local l = field:split(":")
local new_value = tonumber(l[2])
local meta_name = l[3]
meta:set_int(meta_name, new_value)
end
end
end
function fs_helpers.cycling_button(meta, base, meta_name, values)
local current_value = meta:get_int(meta_name)
local new_value = (current_value + 1) % (#values)
local val = values[current_value + 1]
local text
local texture_name = nil
local addopts = nil
--when we get a table, we know the caller wants an image_button
if type(val) == "table" then
text = val["text"]
texture_name = val["texture"]
addopts = val["addopts"]
else
text = val
end
local field = "fs_helpers_cycling:"..new_value..":"..meta_name
return base..";"..(texture_name and texture_name..";" or "")..field..";"..minetest.formspec_escape(text)..(addopts and ";"..addopts or "").."]"
end
---------
-- Env --
---------
function pipeworks.load_position(pos)
if pos.x < -30912 or pos.y < -30912 or pos.z < -30912 or
pos.x > 30927 or pos.y > 30927 or pos.z > 30927 then return end
if minetest.get_node_or_nil(pos) then
return
end
local vm = minetest.get_voxel_manip()
vm:read_from_map(pos, pos)
end
local function delay(...)
local args = {...}
return (function() return unpack(args) end)
end
local function get_set_wrap(name, is_dynamic)
return (function(self)
return self["_" .. name]
end), (function(self, value)
if is_dynamic then
self["_" .. name] = type(value) == "table"
and table.copy(value) or value
end
end)
end
function pipeworks.create_fake_player(def, is_dynamic)
local wielded_item = ItemStack("")
if def.inventory and def.wield_list then
wielded_item = def.inventory:get_stack(def.wield_list, def.wield_index or 1)
end
local p = {
get_player_name = delay(def.name),
is_player = delay(true),
is_fake_player = true,
_formspec = def.formspec or default.gui_survival_form,
_hp = def.hp or 20,
_breath = 11,
_pos = def.position and table.copy(def.position) or vector.new(),
_properties = def.properties or { eye_height = def.eye_height or 1.47 },
_inventory = def.inventory,
_wield_index = def.wield_index or 1,
_wielded_item = wielded_item,
-- Model and view
_eye_offset1 = vector.new(),
_eye_offset3 = vector.new(),
set_eye_offset = function(self, first, third)
self._eye_offset1 = table.copy(first)
self._eye_offset3 = table.copy(third)
end,
get_eye_offset = function(self)
return self._eye_offset1, self._eye_offset3
end,
get_look_dir = delay(def.look_dir or {x=0, y=0, z=1}),
get_look_pitch = delay(def.look_pitch or 0),
get_look_yaw = delay(def.look_yaw or 0),
get_look_horizontal = delay(def.look_yaw or 0),
get_look_vertical = delay(-(def.look_pitch or 0)),
set_animation = delay(),
-- Controls
get_player_control = delay({
jump=false, right=false, left=false, LMB=false, RMB=false,
sneak=def.sneak, aux1=false, down=false, up=false
}),
get_player_control_bits = delay(def.sneak and 64 or 0),
-- Inventory and ItemStacks
get_inventory = delay(def.inventory),
set_wielded_item = function(self, item)
if self._inventory and def.wield_list then
return self._inventory:set_stack(def.wield_list,
self._wield_index, item)
end
_wielded_item = ItemStack(item)
end,
get_wielded_item = function(self, item)
if self._inventory and def.wield_list then
return self._inventory:get_stack(def.wield_list,
self._wield_index)
end
return ItemStack(self._wielded_item)
end,
get_wield_list = delay(def.wield_list),
punch = delay(),
remove = delay(),
right_click = delay(),
set_attach = delay(),
set_detach = delay(),
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)
-- Backwards compatibilty
p.getpos = p.get_pos
p.setpos = p.set_pos
p.moveto = p.move_to
-- TODO "implement" all these
-- set_armor_groups
-- get_armor_groups
-- get_animation
-- get_bone_position
-- get_player_velocity
-- set_look_pitch
-- set_look_yaw
-- set_physics_override
-- get_physics_override
-- hud_add
-- hud_remove
-- hud_get
-- hud_set_flags
-- hud_get_flags
-- hud_set_hotbar_itemcount
-- hud_get_hotbar_itemcount
-- hud_set_hotbar_image
-- hud_get_hotbar_image
-- hud_set_hotbar_selected_image
-- hud_get_hotbar_selected_image
-- hud_replace_builtin
-- set_sky
-- get_sky
-- override_day_night_ratio
-- get_day_night_ratio
-- set_local_animation
return p
end

View File

@ -1,87 +0,0 @@
-- 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",
recipe = {
{ "", "default:steel_ingot", "" },
{ "", "pipeworks:pipe_1_empty", "" },
{ "", "default: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" }
},
})
minetest.register_craft( {
output = "pipeworks:valve_off_empty 2",
recipe = {
{ "", "group:stick", "" },
{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" },
{ "", "default: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", "" }
},
})
minetest.register_craft( {
output = "pipeworks:grating 2",
recipe = {
{ "default:steel_ingot", "", "default:steel_ingot" },
{ "", "pipeworks:pipe_1_empty", "" },
{ "default:steel_ingot", "", "default:steel_ingot" }
},
})
minetest.register_craft( {
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" }
},
})

View File

@ -1,72 +0,0 @@
-- Various settings
local prefix = "pipeworks_"
local settings = {
enable_pipes = true,
enable_lowpoly = false,
enable_autocrafter = true,
enable_deployer = true,
enable_dispenser = true,
enable_node_breaker = true,
enable_teleport_tube = true,
enable_pipe_devices = true,
enable_redefines = true,
enable_mese_tube = true,
enable_detector_tube = true,
enable_digiline_detector_tube = true,
enable_conductor_tube = true,
enable_digiline_conductor_tube = true,
enable_accelerator_tube = true,
enable_crossing_tube = true,
enable_sand_tube = true,
enable_mese_sand_tube = true,
enable_one_way_tube = true,
enable_priority_tube = true,
enable_lua_tube = true,
enable_cyclic_mode = true,
drop_on_routing_fail = false,
delete_item_on_clearobject = true,
}
pipeworks.toggles = {}
-- documentation for toggles controlling pressure logic features.
-- do not edit this file directly;
-- instead, create pipeworks_settings.txt in your world directory,
-- and copy the uncommented lines from the block comments below into it.
--[[
-- flow logic implementation.
-- set to one of the following strings.
-- "classic": classic mode written by VanessaE
-- "pressure": pressure metadata based, written by thetaepsilon.
-- has caveats such as water speed issues though.
-- setting to nil inhibits all flow logic, useful for debugging ABM crashes,
-- or for rendering the pipes purely decorative.
]]
pipeworks.toggles.pipe_mode = "classic"
--[[
-- force-enable finite water handling mode.
-- this changes the way that water node placement is handled;
-- volume will always be preserved,
-- and water is assumed to move itself downwards.
-- nil (the default) means autodetect from installed finite liquid mods,
-- true is force-on, false is force-off.
-- note that you should NOT normally explicitly set this to true/false,
-- unless the mod you want this for is not covered by auto-detection
-- (please see autodetect-finite-water.lua).
-- please file an issue if you have a finite water mod not covered there,
-- and feel it necessary to explicitly set this toggle
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
else
pipeworks[name] = value
end
end

View File

@ -1 +0,0 @@
default

View File

@ -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.

View File

@ -1,678 +0,0 @@
local new_flow_logic_register = pipeworks.flowables.register
local polys = ""
if pipeworks.enable_lowpoly then polys = "_lowpoly" end
-- rotation handlers
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")
minetest.swap_node(pos, { name = newnode, param2 = new_param2 })
pipeworks.scan_for_pipe_objects(pos)
return true
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)
and not minetest.is_protected(pointed_thing.above, playername) then
local node = minetest.get_node(pointed_thing.under)
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)
else
local pitch = placer:get_look_pitch()
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
-- check if the object should be turned vertically
if above.x == under.x
and above.z == under.z
and (
string.find(uname, "pipeworks:pipe_")
or string.find(uname, "pipeworks:storage_")
or string.find(uname, "pipeworks:expansion_")
or ( string.find(uname, "pipeworks:grating") and not isabove )
or ( string.find(uname, "pipeworks:pump_") and not isabove )
or (
( string.find(uname, "pipeworks:valve")
or string.find(uname, "pipeworks:entry_panel")
or string.find(uname, "pipeworks:flow_sensor") )
and minetest.facedir_to_dir(undernode.param2).y ~= 0 )
)
then
fdir = 17
end
if minetest.registered_nodes[uname]
and minetest.registered_nodes[uname]["buildable_to"] then
pos1 = under
end
if minetest.registered_nodes[minetest.get_node(pos1).name]
and not minetest.registered_nodes[minetest.get_node(pos1).name]["buildable_to"] then return end
local placednode = string.gsub(itemstack:get_name(), "_loaded", "_empty")
placednode = string.gsub(placednode, "_on", "_off")
minetest.swap_node(pos1, {name = placednode, param2 = fdir })
pipeworks.scan_for_pipe_objects(pos1)
if not pipeworks.expect_infinite_stacks then
itemstack:take_item()
end
end
end
return itemstack
end
-- List of devices that should participate in the autoplace algorithm
local pipereceptor_on = nil
local pipereceptor_off = nil
local pipes_devicelist = {
"pump",
"valve",
"storage_tank_0",
"storage_tank_1",
"storage_tank_2",
"storage_tank_3",
"storage_tank_4",
"storage_tank_5",
"storage_tank_6",
"storage_tank_7",
"storage_tank_8",
"storage_tank_9",
"storage_tank_10"
}
-- Now define the nodes.
local states = { "on", "off" }
local dgroups = ""
for s in ipairs(states) do
if states[s] == "off" then
dgroups = {snappy=3, pipe=1}
else
dgroups = {snappy=3, pipe=1, not_in_creative_inventory=1}
end
local pumpname = "pipeworks:pump_"..states[s]
minetest.register_node(pumpname, {
description = "Pump/Intake Module",
drawtype = "mesh",
mesh = "pipeworks_pump"..polys..".obj",
tiles = { "pipeworks_pump_"..states[s]..".png" },
paramtype = "light",
paramtype2 = "facedir",
groups = dgroups,
sounds = default.node_sound_wood_defaults(),
walkable = true,
pipe_connections = { top = 1 },
after_place_node = function(pos)
pipeworks.scan_for_pipe_objects(pos)
end,
after_dig_node = function(pos)
pipeworks.scan_for_pipe_objects(pos)
end,
drop = "pipeworks:pump_off",
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
local fdir = node.param2
minetest.swap_node(pos, { name = "pipeworks:pump_"..states[3-s], param2 = fdir })
end,
on_rotate = screwdriver.rotate_simple
})
-- FIXME: this currently assumes that pumps can only rotate around the fixed axis pointing Y+.
new_flow_logic_register.directional_vertical_fixed(pumpname, true)
local pump_drive = 4
if states[s] ~= "off" then
new_flow_logic_register.intake_simple(pumpname, pump_drive)
end
local nodename_valve_empty = "pipeworks:valve_"..states[s].."_empty"
minetest.register_node(nodename_valve_empty, {
description = "Valve",
drawtype = "mesh",
mesh = "pipeworks_valve_"..states[s]..polys..".obj",
tiles = { "pipeworks_valve.png" },
sunlight_propagates = true,
paramtype = "light",
paramtype2 = "facedir",
selection_box = {
type = "fixed",
fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 }
},
collision_box = {
type = "fixed",
fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 }
},
groups = dgroups,
sounds = default.node_sound_wood_defaults(),
walkable = true,
on_place = pipeworks.rotate_on_place,
after_dig_node = function(pos)
pipeworks.scan_for_pipe_objects(pos)
end,
drop = "pipeworks:valve_off_empty",
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
local fdir = node.param2
minetest.swap_node(pos, { name = "pipeworks:valve_"..states[3-s].."_empty", param2 = fdir })
end,
on_rotate = pipeworks.fix_after_rotation
})
-- only register flow logic for the "on" ABM.
-- this means that the off state automatically blocks flow by not participating in the balancing operation.
if states[s] ~= "off" then
new_flow_logic_register.directional_horizonal_rotate(nodename_valve_empty, true)
end
end
local nodename_valve_loaded = "pipeworks:valve_on_loaded"
minetest.register_node(nodename_valve_loaded, {
description = "Valve",
drawtype = "mesh",
mesh = "pipeworks_valve_on"..polys..".obj",
tiles = { "pipeworks_valve.png" },
sunlight_propagates = true,
paramtype = "light",
paramtype2 = "facedir",
selection_box = {
type = "fixed",
fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 }
},
collision_box = {
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(),
walkable = true,
on_place = pipeworks.rotate_on_place,
after_dig_node = function(pos)
pipeworks.scan_for_pipe_objects(pos)
end,
drop = "pipeworks:valve_off_empty",
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
local fdir = node.param2
minetest.swap_node(pos, { name = "pipeworks:valve_off_empty", param2 = fdir })
end,
on_rotate = pipeworks.fix_after_rotation
})
-- register this the same as the on-but-empty variant, so existing nodes of this type work also.
-- note that as new_flow_logic code does not distinguish empty/full in node states,
-- right-clicking a "loaded" valve (becoming an off valve) then turning it on again will yield a on-but-empty valve,
-- but the flow logic will still function.
-- thus under new_flow_logic this serves as a kind of migration.
new_flow_logic_register.directional_horizonal_rotate(nodename_valve_loaded, true)
-- grating
-- FIXME: should this do anything useful in the new flow logic?
minetest.register_node("pipeworks:grating", {
description = "Decorative grating",
tiles = {
"pipeworks_grating_top.png",
"pipeworks_grating_sides.png",
"pipeworks_grating_sides.png",
"pipeworks_grating_sides.png",
"pipeworks_grating_sides.png",
"pipeworks_grating_sides.png"
},
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = { -0.49, -0.49, -0.49, 0.49, 0.5, 0.49 }
},
sunlight_propagates = true,
paramtype = "light",
groups = {snappy=3, pipe=1},
sounds = default.node_sound_wood_defaults(),
walkable = true,
pipe_connections = { top = 1 },
after_place_node = function(pos)
pipeworks.scan_for_pipe_objects(pos)
end,
after_dig_node = function(pos)
pipeworks.scan_for_pipe_objects(pos)
end,
on_rotate = false
})
-- outlet spigot
local nodename_spigot_empty = "pipeworks:spigot"
minetest.register_node(nodename_spigot_empty, {
description = "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(),
walkable = true,
pipe_connections = { left=1, right=1, front=1, back=1,
left_param2 = 3, right_param2 = 1, front_param2 = 2, back_param2 = 0 },
after_place_node = function(pos)
pipeworks.scan_for_pipe_objects(pos)
end,
after_dig_node = function(pos)
pipeworks.scan_for_pipe_objects(pos)
end,
selection_box = {
type = "fixed",
fixed = { -2/16, -6/16, -2/16, 2/16, 2/16, 8/16 }
},
collision_box = {
type = "fixed",
fixed = { -2/16, -6/16, -2/16, 2/16, 2/16, 8/16 }
},
on_rotate = pipeworks.fix_after_rotation
})
local nodename_spigot_loaded = "pipeworks:spigot_pouring"
minetest.register_node(nodename_spigot_loaded, {
description = "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,
},
},
{ name = "pipeworks_spigot.png" }
},
sunlight_propagates = true,
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy=3, pipe=1, not_in_creative_inventory=1},
sounds = default.node_sound_wood_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 },
after_place_node = function(pos)
minetest.set_node(pos, { name = "pipeworks:spigot", param2 = minetest.get_node(pos).param2 })
pipeworks.scan_for_pipe_objects(pos)
end,
after_dig_node = function(pos)
pipeworks.scan_for_pipe_objects(pos)
end,
selection_box = {
type = "fixed",
fixed = { -2/16, -6/16, -2/16, 2/16, 2/16, 8/16 }
},
collision_box = {
type = "fixed",
fixed = { -2/16, -6/16, -2/16, 2/16, 2/16, 8/16 }
},
drop = "pipeworks:spigot",
on_rotate = pipeworks.fix_after_rotation
})
-- 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)
new_flow_logic_register.directional_horizonal_rotate(nodename_spigot_loaded, false)
local spigot_upper = 1.0
local spigot_lower = 1.0
local spigot_neighbours={{x=0, y=-1, z=0}}
new_flow_logic_register.output_simple(nodename_spigot_empty, spigot_upper, spigot_lower, spigot_neighbours)
new_flow_logic_register.output_simple(nodename_spigot_loaded, spigot_upper, spigot_lower, spigot_neighbours)
-- sealed pipe entry/exit (horizontal pipe passing through a metal
-- wall, for use in places where walls should look like they're airtight)
local panel_cbox = {
type = "fixed",
fixed = {
{ -2/16, -2/16, -8/16, 2/16, 2/16, 8/16 },
{ -8/16, -8/16, -1/16, 8/16, 8/16, 1/16 }
}
}
local nodename_panel_empty = "pipeworks:entry_panel_empty"
minetest.register_node(nodename_panel_empty, {
description = "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(),
walkable = true,
on_place = pipeworks.rotate_on_place,
after_dig_node = function(pos)
pipeworks.scan_for_pipe_objects(pos)
end,
selection_box = panel_cbox,
collision_box = panel_cbox,
on_rotate = pipeworks.fix_after_rotation
})
local nodename_panel_loaded = "pipeworks:entry_panel_loaded"
minetest.register_node(nodename_panel_loaded, {
description = "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(),
walkable = true,
on_place = pipeworks.rotate_on_place,
after_dig_node = function(pos)
pipeworks.scan_for_pipe_objects(pos)
end,
selection_box = panel_cbox,
collision_box = panel_cbox,
drop = "pipeworks:entry_panel_empty",
on_rotate = pipeworks.fix_after_rotation
})
-- 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)
local nodename_sensor_empty = "pipeworks:flow_sensor_empty"
minetest.register_node(nodename_sensor_empty, {
description = "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(),
walkable = true,
on_place = pipeworks.rotate_on_place,
after_dig_node = function(pos)
pipeworks.scan_for_pipe_objects(pos)
end,
selection_box = {
type = "fixed",
fixed = {
{ -2/16, -2/16, -8/16, 2/16, 2/16, 8/16 },
{ -3/16, -3/16, -4/16, 3/16, 3/16, 4/16 },
}
},
collision_box = {
type = "fixed",
fixed = {
{ -2/16, -2/16, -8/16, 2/16, 2/16, 8/16 },
{ -3/16, -3/16, -4/16, 3/16, 3/16, 4/16 },
}
},
on_rotate = pipeworks.fix_after_rotation
})
local nodename_sensor_loaded = "pipeworks:flow_sensor_loaded"
minetest.register_node(nodename_sensor_loaded, {
description = "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(),
walkable = true,
on_place = pipeworks.rotate_on_place,
after_dig_node = function(pos)
pipeworks.scan_for_pipe_objects(pos)
end,
selection_box = {
type = "fixed",
fixed = {
{ -2/16, -2/16, -8/16, 2/16, 2/16, 8/16 },
{ -3/16, -3/16, -4/16, 3/16, 3/16, 4/16 },
}
},
collision_box = {
type = "fixed",
fixed = {
{ -2/16, -2/16, -8/16, 2/16, 2/16, 8/16 },
{ -3/16, -3/16, -4/16, 3/16, 3/16, 4/16 },
}
},
drop = "pipeworks:flow_sensor_empty",
on_rotate = pipeworks.fix_after_rotation
})
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
local sensor_pressure_set = { { nodename_sensor_empty, 0.0 }, { nodename_sensor_loaded, 1.0 } }
new_flow_logic_register.transition_simple_set(sensor_pressure_set, { mesecons=pipeworks.mesecons_rules })
-- tanks
-- 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 image = nil
if fill ~= 0 then
filldesc=fill.."0% full"
sgroups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1}
image = "pipeworks_storage_tank_fittings.png"
end
minetest.register_node("pipeworks:expansion_tank_"..fill, {
description = "Expansion Tank ("..filldesc..")... You hacker, you.",
tiles = {
"pipeworks_storage_tank_fittings.png",
"pipeworks_storage_tank_fittings.png",
"pipeworks_storage_tank_back.png",
"pipeworks_storage_tank_back.png",
"pipeworks_storage_tank_back.png",
pipeworks.liquid_texture.."^pipeworks_storage_tank_front_"..fill..".png"
},
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(),
walkable = true,
drop = "pipeworks:storage_tank_0",
pipe_connections = { top = 1, bottom = 1},
after_place_node = function(pos)
pipeworks.look_for_stackable_tanks(pos)
pipeworks.scan_for_pipe_objects(pos)
end,
after_dig_node = function(pos)
pipeworks.scan_for_pipe_objects(pos)
end,
on_rotate = false
})
minetest.register_node("pipeworks:storage_tank_"..fill, {
description = "Fluid Storage Tank ("..filldesc..")",
tiles = {
"pipeworks_storage_tank_fittings.png",
"pipeworks_storage_tank_fittings.png",
"pipeworks_storage_tank_back.png",
"pipeworks_storage_tank_back.png",
"pipeworks_storage_tank_back.png",
pipeworks.liquid_texture.."^pipeworks_storage_tank_front_"..fill..".png"
},
inventory_image = image,
paramtype = "light",
paramtype2 = "facedir",
groups = sgroups,
sounds = default.node_sound_wood_defaults(),
walkable = true,
drop = "pipeworks:storage_tank_0",
pipe_connections = { top = 1, bottom = 1},
after_place_node = function(pos)
pipeworks.look_for_stackable_tanks(pos)
pipeworks.scan_for_pipe_objects(pos)
end,
after_dig_node = function(pos)
pipeworks.scan_for_pipe_objects(pos)
end,
on_rotate = false
})
end
-- fountainhead
local nodename_fountain_empty = "pipeworks:fountainhead"
minetest.register_node(nodename_fountain_empty, {
description = "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(),
walkable = true,
pipe_connections = { bottom = 1 },
after_place_node = function(pos)
pipeworks.scan_for_pipe_objects(pos)
end,
after_dig_node = function(pos)
pipeworks.scan_for_pipe_objects(pos)
end,
selection_box = {
type = "fixed",
fixed = { -2/16, -8/16, -2/16, 2/16, 8/16, 2/16 }
},
collision_box = {
type = "fixed",
fixed = { -2/16, -8/16, -2/16, 2/16, 8/16, 2/16 }
},
on_rotate = false
})
local nodename_fountain_loaded = "pipeworks:fountainhead_pouring"
minetest.register_node(nodename_fountain_loaded, {
description = "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(),
walkable = true,
pipe_connections = { bottom = 1 },
after_place_node = function(pos)
minetest.set_node(pos, { name = "pipeworks:fountainhead", param2 = minetest.get_node(pos).param2 })
pipeworks.scan_for_pipe_objects(pos)
end,
after_dig_node = function(pos)
pipeworks.scan_for_pipe_objects(pos)
end,
selection_box = {
type = "fixed",
fixed = { -2/16, -8/16, -2/16, 2/16, 8/16, 2/16 }
},
collision_box = {
type = "fixed",
fixed = { -2/16, -8/16, -2/16, 2/16, 8/16, 2/16 }
},
drop = "pipeworks:fountainhead",
on_rotate = false
})
new_flow_logic_register.directional_vertical_fixed(nodename_fountain_empty, false)
new_flow_logic_register.directional_vertical_fixed(nodename_fountain_loaded, false)
local fountain_upper = 1.0
local fountain_lower = 1.0
local fountain_neighbours={{x=0, y=1, z=0}}
new_flow_logic_register.output_simple(nodename_fountain_empty, fountain_upper, fountain_lower, fountain_neighbours)
new_flow_logic_register.output_simple(nodename_fountain_loaded, fountain_upper, fountain_lower, fountain_neighbours)
local sp_cbox = {
type = "fixed",
fixed = {
{ -2/16, -2/16, -8/16, 2/16, 2/16, 8/16 }
}
}
local nodename_sp_empty = "pipeworks:straight_pipe_empty"
minetest.register_node(nodename_sp_empty, {
description = "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(),
walkable = true,
on_place = pipeworks.rotate_on_place,
after_dig_node = function(pos)
pipeworks.scan_for_pipe_objects(pos)
end,
selection_box = sp_cbox,
collision_box = sp_cbox,
on_rotate = pipeworks.fix_after_rotation
})
local nodename_sp_loaded = "pipeworks:straight_pipe_loaded"
minetest.register_node(nodename_sp_loaded, {
description = "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(),
walkable = true,
on_place = pipeworks.rotate_on_place,
after_dig_node = function(pos)
pipeworks.scan_for_pipe_objects(pos)
end,
selection_box = sp_cbox,
collision_box = sp_cbox,
drop = "pipeworks:straight_pipe_empty",
on_rotate = pipeworks.fix_after_rotation
})
new_flow_logic_register.directional_horizonal_rotate(nodename_sp_empty, true)
new_flow_logic_register.directional_horizonal_rotate(nodename_sp_loaded, true)
-- Other misc stuff
minetest.register_alias("pipeworks:valve_off_loaded", "pipeworks:valve_off_empty")
minetest.register_alias("pipeworks:entry_panel", "pipeworks:entry_panel_empty")

View File

@ -1,561 +0,0 @@
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"
if meta:get_int("slotseq_mode") == 2 then
infotext = infotext .. " (slot #"..meta:get_int("slotseq_index").." next)"
end
meta:set_string("infotext", infotext)
end
local function set_filter_formspec(data, meta)
local itemname = data.wise_desc.." Filter-Injector"
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 "})
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 "})
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"})..
exmatch_button..
"list[current_player;main;0,4.5;8,4;]" ..
"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()
local owner = filtmeta:get_string("owner")
local fakePlayer = pipeworks.create_fake_player({
name = owner
})
local dir = pipeworks.facedir_to_right_dir(filtnode.param2)
local frompos = vector.subtract(filtpos, dir)
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
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",
["technic:mv_alloy_furnace_active"] = "dst",
["technic:mv_centrifuge"] = "dst",
["technic:mv_centrifuge_active"] = "dst",
["technic:mv_compressor"] = "dst",
["technic:mv_compressor_active"] = "dst",
["technic:mv_extractor"] = "dst",
["technic:mv_extractor_active"] = "dst",
["technic:mv_grinder"] = "dst",
["technic:mv_grinder_active"] = "dst",
["technic:tool_workshop"] = "src",
}
-- make sure there's something appropriate to inject the item into
local todir = pipeworks.facedir_to_right_dir(filtnode.param2)
local topos = vector.add(filtpos, todir)
local tonode = minetest.get_node(topos)
local todef = minetest.registered_nodes[tonode.name]
if not todef
or not (minetest.get_item_group(tonode.name, "tube") == 1
or minetest.get_item_group(tonode.name, "tubedevice") == 1
or minetest.get_item_group(tonode.name, "tubedevice_receiver") == 1) then
return
end
if fromtube then fromtube.input_inventory = input_special_cases[fromnode.name] or fromtube.input_inventory end
if not (fromtube and fromtube.input_inventory) then return end
local slotseq_mode
local exact_match
local filters = {}
if data.digiline then
local function add_filter(name, group, count, wear, metadata)
table.insert(filters, {name = name, group = group, count = tonumber(count), wear = wear, metadata = metadata})
end
local function add_itemstring_filter(filter)
local filterstack = ItemStack(filter)
local filtername = filterstack:get_name()
local filtercount = filterstack:get_count()
local filterwear = string.match(filter, "%S*:%S*%s%d%s(%d)") and filterstack:get_wear()
local filtermetadata = string.match(filter, "%S*:%S*%s%d%s%d(%s.*)") and filterstack:get_metadata()
add_filter(filtername, nil, filtercount, filterwear, filtermetadata)
end
local t_msg = type(msg)
if t_msg == "table" then
local slotseq = msg.slotseq
local t_slotseq = type(slotseq)
if t_slotseq == "number" and slotseq >= 0 and slotseq <= 2 then
slotseq_mode = slotseq
elseif t_slotseq == "string" then
slotseq = string.lower(slotseq)
if slotseq == "priority" then
slotseq_mode = 0
elseif slotseq == "random" then
slotseq_mode = 1
elseif slotseq == "rotation" then
slotseq_mode = 2
end
end
local exmatch = msg.exmatch
local t_exmatch = type(exmatch)
if t_exmatch == "number" and exmatch >= 0 and exmatch <= 1 then
exact_match = exmatch
elseif t_exmatch == "boolean" then
exact_match = exmatch and 1 or 0
end
local slotseq_index = msg.slotseq_index
if type(slotseq_index) == "number" then
-- This should allow any valid index, but I'm not completely sure what
-- constitutes a valid index, so I'm only allowing resetting it to 1.
if slotseq_index == 1 then
filtmeta:set_int("slotseq_index", slotseq_index)
set_filter_infotext(data, filtmeta)
end
end
if slotseq_mode ~= nil then
filtmeta:set_int("slotseq_mode", slotseq_mode)
end
if exact_match ~= nil then
filtmeta:set_int("exmatch_mode", exact_match)
end
if slotseq_mode ~= nil or exact_match ~= nil then
set_filter_formspec(data, filtmeta)
end
if msg.nofire then
return
end
if msg.name or msg.group or msg.count or msg.wear or msg.metadata then
add_filter(msg.name, msg.group, msg.count, msg.wear, msg.metadata)
else
for _, filter in ipairs(msg) do
local t_filter = type(filter)
if t_filter == "table" then
if filter.name or filter.group or filter.count or filter.wear or filter.metadata then
add_filter(filter.name, filter.group, filter.count, filter.wear, filter.metadata)
end
elseif t_filter == "string" then
add_itemstring_filter(filter)
end
end
end
elseif t_msg == "string" then
add_itemstring_filter(msg)
end
else
for _, filterstack in ipairs(filtinv:get_list("main")) do
local filtername = filterstack:get_name()
local filtercount = filterstack:get_count()
if filtername ~= "" then table.insert(filters, {name = filtername, count = filtercount}) end
end
end
if #filters == 0 then table.insert(filters, "") end
if slotseq_mode == nil then
slotseq_mode = filtmeta:get_int("slotseq_mode")
end
if exact_match == nil then
exact_match = filtmeta:get_int("exmatch_mode")
end
local frominv
if fromtube.return_input_invref then
frominv = fromtube.return_input_invref(frompos, fromnode, dir, owner)
if not frominv then
return
end
else
local frommeta = minetest.get_meta(frompos)
frominv = frommeta:get_inventory()
end
if fromtube.before_filter then fromtube.before_filter(frompos) 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
done = true
break
end
end
if done then break end
end
if fromtube.after_filter then fromtube.after_filter(frompos) end
end
for _, data in ipairs({
{
name = "filter",
wise_desc = "Itemwise",
stackwise = false,
},
{
name = "mese_filter",
wise_desc = "Stackwise",
stackwise = true,
},
{ -- register even if no digilines
name = "digiline_filter",
wise_desc = "Digiline",
stackwise = true,
digiline = true,
},
}) do
local node = {
description = data.wise_desc.." Filter-Injector",
tiles = {
"pipeworks_"..data.name.."_top.png",
"pipeworks_"..data.name.."_top.png",
"pipeworks_"..data.name.."_output.png",
"pipeworks_"..data.name.."_input.png",
"pipeworks_"..data.name.."_side.png",
"pipeworks_"..data.name.."_top.png",
},
paramtype2 = "facedir",
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, mesecon = 2},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
set_filter_formspec(data, meta)
set_filter_infotext(data, meta)
local inv = meta:get_inventory()
inv:set_size("main", 8*2)
end,
after_place_node = function (pos, placer)
minetest.get_meta(pos):set_string("owner", placer:get_player_name())
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
end
local inv = minetest.get_meta(pos):get_inventory()
inv:set_stack("main", index, stack)
return 0
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
if not pipeworks.may_configure(pos, player) then
return 0
end
local inv = minetest.get_meta(pos):get_inventory()
local fake_stack = inv:get_stack("main", index)
fake_stack:take_item(stack:get_count())
inv:set_stack("main", index, fake_stack)
return 0
end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
if not pipeworks.may_configure(pos, player) then return 0 end
return count
end,
can_dig = function(pos, player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return inv:is_empty("main")
end,
tube = {connect_sides = {right = 1}},
}
if data.digiline then
node.groups.mesecon = nil
if not minetest.get_modpath("digilines") then
node.groups.not_in_creative_inventory = 1
end
node.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)
if fields.channel then
minetest.get_meta(pos):set_string("channel", fields.channel)
end
local meta = minetest.get_meta(pos)
--meta:set_int("slotseq_index", 1)
set_filter_formspec(data, meta)
set_filter_infotext(data, meta)
end
node.digiline = {
effector = {
action = function(pos, node, channel, msg)
local meta = minetest.get_meta(pos)
local setchan = meta:get_string("channel")
if setchan ~= channel then return end
punch_filter(data, pos, node, msg)
end,
},
}
else
node.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)
meta:set_int("slotseq_index", 1)
set_filter_formspec(data, meta)
set_filter_infotext(data, meta)
end
node.mesecons = {
effector = {
action_on = function(pos, node)
punch_filter(data, pos, node)
end,
},
}
node.on_punch = function (pos, node, puncher)
punch_filter(data, pos, node)
end
end
minetest.register_node("pipeworks:"..data.name, node)
end
minetest.register_craft( {
output = "pipeworks:filter 2",
recipe = {
{ "default:steel_ingot", "default:steel_ingot", "basic_materials:plastic_sheet" },
{ "group:stick", "default:mese_crystal", "basic_materials:plastic_sheet" },
{ "default:steel_ingot", "default:steel_ingot", "basic_materials:plastic_sheet" }
},
})
minetest.register_craft( {
output = "pipeworks:mese_filter 2",
recipe = {
{ "default:steel_ingot", "default:steel_ingot", "basic_materials:plastic_sheet" },
{ "group:stick", "default:mese", "basic_materials:plastic_sheet" },
{ "default:steel_ingot", "default:steel_ingot", "basic_materials:plastic_sheet" }
},
})
if minetest.get_modpath("digilines") then
minetest.register_craft( {
output = "pipeworks:digiline_filter 2",
recipe = {
{ "default:steel_ingot", "default:steel_ingot", "basic_materials:plastic_sheet" },
{ "group:stick", "digilines:wire_std_00000000", "basic_materials:plastic_sheet" },
{ "default:steel_ingot", "default:steel_ingot", "basic_materials:plastic_sheet" }
},
})
end
--[[
In the past the filter-injectors had real items in their inventories. This code
puts them to the input to the filter-injector if possible. Else the items are
dropped.
]]
local function put_to_inputinv(pos, node, filtmeta, list)
local dir = pipeworks.facedir_to_right_dir(node.param2)
local frompos = vector.subtract(pos, dir)
local fromnode = minetest.get_node(frompos)
local fromdef = minetest.registered_nodes[fromnode.name]
if not fromdef or not fromdef.tube then
return
end
local fromtube = fromdef.tube
local frominv
if fromtube.return_input_invref then
local owner = filtmeta:get_string("owner")
frominv = fromtube.return_input_invref(frompos, fromnode, dir, owner)
if not frominv then
return
end
else
frominv = minetest.get_meta(frompos):get_inventory()
end
local listname = type(fromtube.input_inventory) == "table" and
fromtube.input_inventory[1] or fromtube.input_inventory
if not listname then
return
end
for i = 1, #list do
local item = list[i]
if not item:is_empty() then
local leftover = frominv:add_item(listname, item)
if not leftover:is_empty() then
minetest.add_item(pos, leftover)
end
end
end
return true
end
minetest.register_lbm({
label = "Give back items of old filters that had real inventories",
name = "pipeworks:give_back_old_filter_items",
nodenames = {"pipeworks:filter", "pipeworks:mese_filter"},
run_at_every_load = false,
action = function(pos, node)
local meta = minetest.get_meta(pos)
local list = meta:get_inventory():get_list("main")
if put_to_inputinv(pos, node, meta, list) then
return
end
pos.y = pos.y + 1
for i = 1, #list do
local item = list[i]
if not item:is_empty() then
minetest.add_item(pos, item)
end
end
end,
})

View File

@ -1,135 +0,0 @@
-- This file provides the actual flow and pathfinding logic that makes water
-- move through the pipes.
--
-- Contributed by mauvebic, 2013-01-03, rewritten a bit by Vanessa Ezekowitz
--
local finitewater = minetest.settings:get_bool("liquid_finite")
pipeworks.check_for_liquids = function(pos)
local coords = {
{x=pos.x,y=pos.y-1,z=pos.z},
{x=pos.x,y=pos.y+1,z=pos.z},
{x=pos.x-1,y=pos.y,z=pos.z},
{x=pos.x+1,y=pos.y,z=pos.z},
{x=pos.x,y=pos.y,z=pos.z-1},
{x=pos.x,y=pos.y,z=pos.z+1}, }
for i =1,6 do
local name = minetest.get_node(coords[i]).name
if name and string.find(name,"water") then
if finitewater then minetest.remove_node(coords[i]) end
return true
end
end
return false
end
pipeworks.check_for_inflows = function(pos,node)
local coords = {
{x=pos.x,y=pos.y-1,z=pos.z},
{x=pos.x,y=pos.y+1,z=pos.z},
{x=pos.x-1,y=pos.y,z=pos.z},
{x=pos.x+1,y=pos.y,z=pos.z},
{x=pos.x,y=pos.y,z=pos.z-1},
{x=pos.x,y=pos.y,z=pos.z+1},
}
local newnode = false
local source = false
for i = 1, 6 do
if newnode then break end
local testnode = minetest.get_node(coords[i])
local name = testnode.name
if name and (name == "pipeworks:pump_on" and pipeworks.check_for_liquids(coords[i])) or string.find(name,"_loaded") then
if string.find(name,"_loaded") then
source = minetest.get_meta(coords[i]):get_string("source")
if source == minetest.pos_to_string(pos) then break end
end
if string.find(name, "valve") or string.find(name, "sensor")
or string.find(name, "straight_pipe") or string.find(name, "panel") then
if ((i == 3 or i == 4) and minetest.facedir_to_dir(testnode.param2).x ~= 0)
or ((i == 5 or i == 6) and minetest.facedir_to_dir(testnode.param2).z ~= 0)
or ((i == 1 or i == 2) and minetest.facedir_to_dir(testnode.param2).y ~= 0) then
newnode = string.gsub(node.name,"empty","loaded")
source = {x=coords[i].x,y=coords[i].y,z=coords[i].z}
end
else
newnode = string.gsub(node.name,"empty","loaded")
source = {x=coords[i].x,y=coords[i].y,z=coords[i].z}
end
end
end
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
pipeworks.check_sources = function(pos,node)
local sourcepos = minetest.string_to_pos(minetest.get_meta(pos):get_string("source"))
if not sourcepos then return end
local source = minetest.get_node(sourcepos).name
local newnode = false
if source and not ((source == "pipeworks:pump_on" and pipeworks.check_for_liquids(sourcepos)) or string.find(source,"_loaded") or source == "ignore" ) then
newnode = string.gsub(node.name,"loaded","empty")
end
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
local spigotname = minetest.get_node(pos).name
local fdir=node.param2 % 4
local check = {
{x=pos.x,y=pos.y,z=pos.z+1},
{x=pos.x+1,y=pos.y,z=pos.z},
{x=pos.x,y=pos.y,z=pos.z-1},
{x=pos.x-1,y=pos.y,z=pos.z}
}
local near_node = minetest.get_node(check[fdir+1])
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"})
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
minetest.remove_node({x=pos.x,y=pos.y-1,z=pos.z})
end
end
end
end
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
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"})
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
minetest.remove_node({x=pos.x,y=pos.y+1,z=pos.z})
end
end
end
end
end

View File

@ -1,126 +0,0 @@
-- Pipeworks mod by Vanessa Ezekowitz - 2013-07-13
--
-- This mod supplies various steel pipes and plastic pneumatic tubes
-- and devices that they can connect to.
--
pipeworks = {}
local DEBUG = false
pipeworks.worldpath = minetest.get_worldpath()
pipeworks.modpath = minetest.get_modpath("pipeworks")
dofile(pipeworks.modpath.."/default_settings.lua")
-- Read the external config file if it exists.
local worldsettingspath = pipeworks.worldpath.."/pipeworks_settings.txt"
local worldsettingsfile = io.open(worldsettingspath, "r")
if worldsettingsfile then
worldsettingsfile:close()
dofile(worldsettingspath)
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
-- Random variables
pipeworks.expect_infinite_stacks = true
if minetest.get_modpath("unified_inventory") or not minetest.settings:get_bool("creative_mode") then
pipeworks.expect_infinite_stacks = false
end
pipeworks.meseadjlist={{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}}
pipeworks.rules_all = {{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=1},{x=0, y=1, z=-1},{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=1, y=-1, z=0},{x=-1, y=-1, z=0},
{x=0, y=1, z=0}, {x=0, y=-1, z=0}}
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.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]"
-- Helper functions
function pipeworks.fix_image_names(table, replacement)
local outtable={}
for i in ipairs(table) do
outtable[i]=string.gsub(table[i], "_XXXXX", replacement)
end
return outtable
end
function pipeworks.add_node_box(t, b)
if not t or not b then return end
for i in ipairs(b)
do table.insert(t, b[i])
end
end
function pipeworks.may_configure(pos, player)
local name = player:get_player_name()
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
if owner ~= "" then -- wielders and filters
return owner == name
end
return not minetest.is_protected(pos, name)
end
function pipeworks.replace_name(tbl,tr,name)
local ntbl={}
for key,i in pairs(tbl) do
if type(i)=="string" then
ntbl[key]=string.gsub(i,tr,name)
elseif type(i)=="table" then
ntbl[key]=pipeworks.replace_name(i,tr,name)
else
ntbl[key]=i
end
end
return ntbl
end
pipeworks.logger = function(msg)
print("[pipeworks] "..msg)
end
-------------------------------------------
-- Load the various other parts of the mod
dofile(pipeworks.modpath.."/common.lua")
dofile(pipeworks.modpath.."/models.lua")
dofile(pipeworks.modpath.."/autoplace_pipes.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.."/filter-injector.lua")
dofile(pipeworks.modpath.."/trashcan.lua")
dofile(pipeworks.modpath.."/wielder.lua")
local logicdir = "/pressure_logic/"
-- note that even with these files the new flow logic is not yet default.
-- registration will take place but no actual ABMs/node logic will be installed,
-- unless the toggle flag is specifically enabled in the per-world settings flag.
dofile(pipeworks.modpath..logicdir.."flowable_node_registry.lua")
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_pipe_devices then dofile(pipeworks.modpath.."/devices.lua") end
minetest.register_alias("pipeworks:pipe", "pipeworks:pipe_110000_empty")
print("Pipeworks loaded!")

View File

@ -1,381 +0,0 @@
local luaentity = pipeworks.luaentity
local enable_max_limit = minetest.settings:get("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
function pipeworks.tube_item(pos, item)
error("obsolete pipeworks.tube_item() called; change caller to use pipeworks.tube_inject_item() instead")
end
function pipeworks.tube_inject_item(pos, start_pos, velocity, item, owner)
-- Take item in any format
local stack = ItemStack(item)
local obj = luaentity.add_entity(pos, "pipeworks:tubed_item")
obj:set_item(stack:to_string())
obj.start_pos = vector.new(start_pos)
obj:set_velocity(velocity)
obj.owner = owner
--obj:set_color("red") -- todo: this is test-only code
return obj
end
-- adding two tube functions
-- can_remove(pos,node,stack,dir) returns the maximum number of items of that stack that can be removed
-- remove_items(pos,node,stack,dir,count) removes count items and returns them
-- 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}}
function pipeworks.notvel(tbl, vel)
local tbl2={}
for _,val in ipairs(tbl) do
if val.x ~= -vel.x or val.y ~= -vel.y or val.z ~= -vel.z then table.insert(tbl2, val) end
end
return tbl2
end
local tube_item_count = {}
minetest.register_globalstep(function(dtime)
if not luaentity.entities then
return
end
tube_item_count = {}
for id, 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
end
end
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.
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)
end
end
end
-- compatibility behaviour for the existing can_go() callbacks,
-- which can only specify a list of possible positions.
local function go_next_compat(pos, cnode, cmeta, cycledir, vel, stack, owner)
local next_positions = {}
local max_priority = 0
local can_go
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
can_go = pipeworks.notvel(adjlist, vel)
end
-- can_go() is expected to return an array-like table of candidate offsets.
-- for each one, look at the node at that offset and determine if it can accept the item.
-- also note the prioritisation:
-- if any tube is found with a greater priority than previously discovered,
-- then the valid positions are reset and and subsequent positions under this are skipped.
-- this has the effect of allowing only equal priorities to co-exist.
for _, vect in ipairs(can_go) do
local npos = vector.add(pos, vect)
pipeworks.load_position(npos)
local node = minetest.get_node(npos)
local reg_node = minetest.registered_nodes[node.name]
if reg_node then
local tube_def = reg_node.tube
local tubedevice = minetest.get_item_group(node.name, "tubedevice")
local tube_priority = (tube_def and tube_def.priority) or 100
if tubedevice > 0 and tube_priority >= max_priority then
if not tube_def or not tube_def.can_insert or
tube_def.can_insert(npos, node, stack, vect, owner) then
if tube_priority > max_priority then
max_priority = tube_priority
next_positions = {}
end
next_positions[#next_positions + 1] = {pos = npos, vect = vect}
end
end
end
end
-- indicate not found if no valid rules were picked up,
-- and don't change the counter.
if not next_positions[1] then
return cycledir, false, nil, nil
end
-- otherwise rotate to the next output direction and return that
local n = (cycledir % (#next_positions)) + 1
local new_velocity = vector.multiply(next_positions[n].vect, vel.speed)
return n, true, new_velocity, nil
end
-- function called by the on_step callback of the pipeworks tube luaentity.
-- the routine is passed the current node position, velocity, itemstack,
-- and owner name.
-- returns three values:
-- * a boolean "found destination" status;
-- * a new velocity vector that the tubed item should use, or nil if not found;
-- * a "multi-mode" data table (or nil if N/A) where a stack was split apart.
-- if this is not nil, the luaentity spawns new tubed items for each new fragment stack,
-- then deletes itself (i.e. the original item stack).
local function go_next(pos, velocity, stack, owner)
local cnode = minetest.get_node(pos)
local cmeta = minetest.get_meta(pos)
local speed = math.abs(velocity.x + velocity.y + velocity.z)
if speed == 0 then
speed = 1
end
local vel = {x = velocity.x/speed, y = velocity.y/speed, z = velocity.z/speed,speed=speed}
if speed >= 4.1 then
speed = 4
elseif speed >= 1.1 then
speed = speed - 0.1
else
speed = 1
end
vel.speed = speed
crunch_tube(pos, cnode, cmeta)
-- cycling of outputs:
-- an integer counter is kept in each pipe's metadata,
-- which allows tracking which output was previously chosen.
-- note reliance on get_int returning 0 for uninitialised.
local cycledir = cmeta:get_int("tubedir")
-- pulled out and factored out into go_next_compat() above.
-- n is the new value of the cycle counter.
-- XXX: this probably needs cleaning up after being split out,
-- seven args is a bit too many
local n, found, new_velocity, multimode = go_next_compat(pos, cnode, cmeta, cycledir, vel, stack, owner)
-- if not using output cycling,
-- don't update the field so it stays the same for the next item.
if pipeworks.enable_cyclic_mode then
cmeta:set_int("tubedir", n)
end
return found, new_velocity, multimode
end
minetest.register_entity("pipeworks:tubed_item", {
initial_properties = {
hp_max = 1,
physical = false,
collisionbox = {0.1, 0.1, 0.1, 0.1, 0.1, 0.1},
visual = "wielditem",
visual_size = {x = 0.15, y = 0.15},
textures = {""},
spritediv = {x = 1, y = 1},
initial_sprite_basepos = {x = 0, y = 0},
is_visible = false,
},
physical_state = false,
from_data = function(self, itemstring)
local stack = ItemStack(itemstring)
local itemtable = stack:to_table()
local itemname = nil
if itemtable then
itemname = stack:to_table().name
end
local item_texture = nil
local item_type = ""
if minetest.registered_items[itemname] then
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()}
})
local def = stack:get_definition()
self.object:set_yaw((def and def.type == "node") and 0 or math.pi * 0.25)
end,
get_staticdata = luaentity.get_staticdata,
on_activate = function(self, staticdata) -- Legacy code, should be replaced later by luaentity.on_activate
if staticdata == "" or staticdata == nil then
return
end
if staticdata == "toremove" then
self.object:remove()
return
end
local item = minetest.deserialize(staticdata)
pipeworks.tube_inject_item(self.object:get_pos(), item.start_pos, item.velocity, item.itemstring)
self.object:remove()
end,
})
minetest.register_entity("pipeworks:color_entity", {
initial_properties = {
hp_max = 1,
physical = false,
collisionbox = {0.1, 0.1, 0.1, 0.1, 0.1, 0.1},
visual = "cube",
visual_size = {x = 3.5, y = 3.5, z = 3.5}, -- todo: find correct size
textures = {""},
is_visible = false,
},
physical_state = false,
from_data = function(self, color)
local t = "pipeworks_color_"..color..".png"
local prop = {
is_visible = true,
visual = "cube",
textures = {t, t, t, t, t, t} -- todo: textures
}
self.object:set_properties(prop)
end,
get_staticdata = luaentity.get_staticdata,
on_activate = luaentity.on_activate,
})
-- see below for usage:
-- determine if go_next returned a multi-mode set.
local is_multimode = function(v)
return (type(v) == "table") and (v.__multimode)
end
luaentity.register_entity("pipeworks:tubed_item", {
itemstring = '',
item_entity = nil,
color_entity = nil,
color = nil,
start_pos = nil,
set_item = function(self, item)
local itemstring = ItemStack(item):to_string() -- Accept any input format
if self.itemstring == itemstring then
return
end
if self.item_entity then
self:remove_attached_entity(self.item_entity)
end
self.itemstring = itemstring
self.item_entity = self:add_attached_entity("pipeworks:tubed_item", itemstring)
end,
set_color = function(self, color)
if self.color == color then
return
end
self.color = color
if self.color_entity then
self:remove_attached_entity(self.color_entity)
end
if color then
self.color_entity = self:add_attached_entity("pipeworks:color_entity", color)
else
self.color_entity = nil
end
end,
on_step = function(self, dtime)
local pos = self:get_pos()
if self.start_pos == nil then
self.start_pos = vector.round(pos)
self:set_pos(pos)
end
local stack = ItemStack(self.itemstring)
local velocity = self:get_velocity()
local moved = false
local speed = math.abs(velocity.x + velocity.y + velocity.z)
if speed == 0 then
speed = 1
moved = true
end
local vel = {x = velocity.x / speed, y = velocity.y / speed, z = velocity.z / speed, speed = speed}
local moved_by = vector.distance(pos, self.start_pos)
if moved_by >= 1 then
self.start_pos = vector.add(self.start_pos, vel)
moved = true
end
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
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)
else
leftover = stack
end
if leftover:is_empty() then
self:remove()
return
end
velocity = vector.multiply(velocity, -1)
self:set_pos(vector.subtract(self.start_pos, vector.multiply(vel, moved_by - 1)))
self:set_velocity(velocity)
self:set_item(leftover:to_string())
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)
if dropped_item then
dropped_item:set_velocity(vector.multiply(velocity, 5))
self:remove()
end
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
end
end
})

View File

@ -1,59 +0,0 @@
if not minetest.get_modpath("auto_tree_tap") and
minetest.get_modpath("technic") then
minetest.register_abm({
nodenames = { "auto_tree_tap:off", "auto_tree_tap:on" },
chance = 1,
interval = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local fdir = node.param2
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
inv:set_size("pick", 1)
inv:set_size("ghost_pick", 1)
inv:set_size("main", 100)
minetest.set_node(pos, {name = "pipeworks:nodebreaker_off", param2 = fdir})
minetest.registered_nodes["pipeworks:nodebreaker_off"].on_punch(pos, node)
inv:set_stack("pick", 1, ItemStack("technic:treetap"))
end
})
minetest.register_node(":auto_tree_tap:off", {
description = "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(),
tube = {connect_sides={back=1}},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
inv:set_size("pick", 1)
inv:set_stack("pick", 1, ItemStack("default:pick_mese"))
end,
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 = {
x = pos.x - placer_pos.x,
y = pos.y - placer_pos.y,
z = pos.z - placer_pos.z
}
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,
})
end

View File

@ -1,374 +0,0 @@
local max_entity_id = 1000000000000 -- If you need more, there's a problem with your code
local luaentity = {}
pipeworks.luaentity = luaentity
luaentity.registered_entities = {}
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()
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()
end
local function read_entities()
local t = read_file()
for _, entity in pairs(t) do
local x=entity.start_pos.x
local y=entity.start_pos.y
local z=entity.start_pos.z
x=math.max(-30912,x)
y=math.max(-30912,y)
z=math.max(-30912,z)
x=math.min(30927,x)
y=math.min(30927,y)
z=math.min(30927,z)
entity.start_pos.x = x
entity.start_pos.y = y
entity.start_pos.z = z
setmetatable(entity, luaentity.registered_entities[entity.name])
end
return t
end
local function write_entities()
for _, entity in pairs(luaentity.entities) do
setmetatable(entity, nil)
for _, attached in pairs(entity._attached_entities) do
if attached.entity then
attached.entity:remove()
attached.entity = nil
end
end
entity._attached_entities_master = nil
end
write_file(luaentity.entities)
end
minetest.register_on_shutdown(write_entities)
luaentity.entities_index = 0
local function get_blockpos(pos)
return {x = math.floor(pos.x / 16),
y = math.floor(pos.y / 16),
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 = 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
local function is_active(pos)
return active_blocks[minetest.hash_node_position(get_blockpos(pos))] ~= nil
end
local entitydef_default = {
_attach = function(self, attached, attach_to)
local attached_def = self._attached_entities[attached]
local attach_to_def = self._attached_entities[attach_to]
attached_def.entity:set_attach(
attach_to_def.entity, "",
vector.subtract(attached_def.offset, attach_to_def.offset), -- todo: Does not work because is object space
vector.new(0, 0, 0)
)
end,
_set_master = function(self, index)
self._attached_entities_master = index
if not index then
return
end
local def = self._attached_entities[index]
if not def.entity then
return
end
def.entity:set_pos(vector.add(self._pos, def.offset))
def.entity:set_velocity(self._velocity)
def.entity:set_acceleration(self._acceleration)
end,
_attach_all = function(self)
local master = self._attached_entities_master
if not master then
return
end
for id, entity in pairs(self._attached_entities) do
if id ~= master and entity.entity then
self:_attach(id, master)
end
end
end,
_detach_all = function(self)
local master = self._attached_entities_master
for id, entity in pairs(self._attached_entities) do
if id ~= master and entity.entity then
entity.entity:set_detach()
end
end
end,
_add_attached = function(self, index)
local entity = self._attached_entities[index]
if entity.entity then
return
end
local entity_pos = vector.add(self._pos, entity.offset)
if not is_active(entity_pos) then
return
end
local ent = minetest.add_entity(entity_pos, entity.name):get_luaentity()
ent:from_data(entity.data)
ent.parent_id = self._id
ent.attached_id = index
entity.entity = ent.object
local master = self._attached_entities_master
if master then
self:_attach(index, master)
else
self:_set_master(index)
end
end,
_remove_attached = function(self, index)
local master = self._attached_entities_master
local entity = self._attached_entities[index]
local ent = entity and entity.entity
if entity then entity.entity = nil end
if index == master then
self:_detach_all()
local newmaster
for id, attached in pairs(self._attached_entities) do
if id ~= master and attached.entity then
newmaster = id
break
end
end
self:_set_master(newmaster)
self:_attach_all()
elseif master and ent then
ent:set_detach()
end
if ent then
ent:remove()
end
end,
_add_loaded = function(self)
for id, _ in pairs(self._attached_entities) do
self:_add_attached(id)
end
end,
get_id = function(self)
return self._id
end,
get_pos = function(self)
return vector.new(self._pos)
end,
set_pos = function(self, pos)
self._pos = vector.new(pos)
--for _, entity in pairs(self._attached_entities) do
-- if entity.entity then
-- entity.entity:set_pos(vector.add(self._pos, entity.offset))
-- end
--end
local master = self._attached_entities_master
if master then
local master_def = self._attached_entities[master]
master_def.entity:set_pos(vector.add(self._pos, master_def.offset))
end
end,
get_velocity = function(self)
return vector.new(self._velocity)
end,
set_velocity = function(self, velocity)
self._velocity = vector.new(velocity)
local master = self._attached_entities_master
if master then
self._attached_entities[master].entity:set_velocity(self._velocity)
end
end,
get_acceleration = function(self)
return vector.new(self._acceleration)
end,
set_acceleration = function(self, acceleration)
self._acceleration = vector.new(acceleration)
local master = self._attached_entities_master
if master then
self._attached_entities[master].entity:set_acceleration(self._acceleration)
end
end,
remove = function(self)
self:_detach_all()
for _, entity in pairs(self._attached_entities) do
if entity.entity then
entity.entity:remove()
end
end
luaentity.entities[self._id] = nil
end,
add_attached_entity = function(self, name, data, offset)
local index = #self._attached_entities + 1
self._attached_entities[index] = {
name = name,
data = data,
offset = vector.new(offset),
}
self:_add_attached(index)
return index
end,
remove_attached_entity = function(self, index)
self:_remove_attached(index)
self._attached_entities[index] = nil
end,
}
function luaentity.register_entity(name, prototype)
-- name = check_modname_prefix(name)
prototype.name = name
setmetatable(prototype, {__index = entitydef_default})
prototype.__index = prototype -- Make it possible to use it as metatable
luaentity.registered_entities[name] = prototype
end
-- function luaentity.get_entity_definition(entity)
-- return luaentity.registered_entities[entity.name]
-- end
function luaentity.add_entity(pos, name)
if not luaentity.entities then
minetest.after(0, luaentity.add_entity, vector.new(pos), name)
return
end
local index = luaentity.entities_index
while luaentity.entities[index] do
index = index + 1
if index >= max_entity_id then
index = 0
end
end
luaentity.entities_index = index
local entity = {
name = name,
_id = index,
_pos = vector.new(pos),
_velocity = {x = 0, y = 0, z = 0},
_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
if entity.on_activate then
entity:on_activate()
end
return entity
end
-- todo: check if remove in get_staticdata works
function luaentity.get_staticdata(self)
local parent = luaentity.entities[self.parent_id]
if parent and parent._remove_attached then
parent:_remove_attached(self.attached_id)
end
return "toremove"
end
function luaentity.on_activate(self, staticdata)
if staticdata == "toremove" then
self.object:remove()
end
end
function luaentity.get_objects_inside_radius(pos, radius)
local objects = {}
local index = 1
for id, entity in pairs(luaentity.entities) do
if vector.distance(pos, entity:get_pos()) <= radius then
objects[index] = entity
index = index + 1
end
end
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
local master = entity._attached_entities_master
local master_def = master and entity._attached_entities[master]
local master_entity = master_def and master_def.entity
local master_entity_pos = master_entity and master_entity:get_pos()
if master_entity_pos then
entity._pos = vector.subtract(master_entity_pos, master_def.offset)
entity._velocity = master_entity:get_velocity()
entity._acceleration = master_entity:get_acceleration()
else
entity._pos = vector.add(vector.add(
entity._pos,
vector.multiply(entity._velocity, dtime)),
vector.multiply(entity._acceleration, 0.5 * dtime * dtime))
entity._velocity = vector.add(
entity._velocity,
vector.multiply(entity._acceleration, dtime))
end
if master and not master_entity_pos then -- The entity has somehow been cleared
if pipeworks.delete_item_on_clearobject then
entity:remove()
else
entity:_remove_attached(master)
entity:_add_loaded()
if entity.on_step then
entity:on_step(dtime)
end
end
else
entity:_add_loaded()
if entity.on_step then
entity:on_step(dtime)
end
end
end
end
local handle_active_blocks_timer = 0.1
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)
end
end)

View File

@ -1 +0,0 @@
name = pipeworks

View File

@ -1,49 +0,0 @@
-----------------------------------
-- The various pipe select boxes
pipeworks.pipe_selectboxes = {
{ -32/64, -8/64, -8/64, 8/64, 8/64, 8/64 },
{ -8/64 , -8/64, -8/64, 32/64, 8/64, 8/64 },
{ -8/64 , -32/64, -8/64, 8/64, 8/64, 8/64 },
{ -8/64 , -8/64, -8/64, 8/64, 32/64, 8/64 },
{ -8/64 , -8/64, -32/64, 8/64, 8/64, 8/64 },
{ -8/64 , -8/64, -8/64, 8/64, 8/64, 32/64 }
}
-- Tube models
pipeworks.tube_leftstub = {
{ -32/64, -9/64, -9/64, 9/64, 9/64, 9/64 }, -- tube segment against -X face
}
pipeworks.tube_rightstub = {
{ -9/64, -9/64, -9/64, 32/64, 9/64, 9/64 }, -- tube segment against +X face
}
pipeworks.tube_bottomstub = {
{ -9/64, -32/64, -9/64, 9/64, 9/64, 9/64 }, -- tube segment against -Y face
}
pipeworks.tube_topstub = {
{ -9/64, -9/64, -9/64, 9/64, 32/64, 9/64 }, -- tube segment against +Y face
}
pipeworks.tube_frontstub = {
{ -9/64, -9/64, -32/64, 9/64, 9/64, 9/64 }, -- tube segment against -Z face
}
pipeworks.tube_backstub = {
{ -9/64, -9/64, -9/64, 9/64, 9/64, 32/64 }, -- tube segment against +Z face
}
pipeworks.tube_boxes = {pipeworks.tube_leftstub, pipeworks.tube_rightstub, pipeworks.tube_bottomstub, pipeworks.tube_topstub, pipeworks.tube_frontstub, pipeworks.tube_backstub}
pipeworks.tube_selectboxes = {
{ -32/64, -10/64, -10/64, 10/64, 10/64, 10/64 },
{ -10/64 , -10/64, -10/64, 32/64, 10/64, 10/64 },
{ -10/64 , -32/64, -10/64, 10/64, 10/64, 10/64 },
{ -10/64 , -10/64, -10/64, 10/64, 32/64, 10/64 },
{ -10/64 , -10/64, -32/64, 10/64, 10/64, 10/64 },
{ -10/64 , -10/64, -10/64, 10/64, 10/64, 32/64 }
}

View File

@ -1,251 +0,0 @@
-- This file supplies the steel pipes
local REGISTER_COMPATIBILITY = true
local pipes_empty_nodenames = {}
local pipes_full_nodenames = {}
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 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
for _, v in ipairs(connects) do
if v == 1 or v == 2 then
jx = jx + 1
elseif v == 3 or v == 4 then
jy = jy + 1
else
jz = jz + 1
end
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."
if #connects == 0 then
pgroups = {snappy = 3, tube = 1}
pipedesc = "Pipe segment"
end
local outimg_e = { "pipeworks_pipe_plain.png" }
local outimg_l = { "pipeworks_pipe_plain.png" }
if index == 3 then
outimg_e = { "pipeworks_pipe_3_empty.png" }
outimg_l = { "pipeworks_pipe_3_loaded.png" }
end
local mesh = "pipeworks_pipe_"..index..polys..".obj"
if index == 1 then
mesh = "pipeworks_pipe_3"..polys..".obj"
end
minetest.register_node("pipeworks:pipe_"..index.."_empty", {
description = pipedesc,
drawtype = "mesh",
mesh = mesh,
tiles = outimg_e,
sunlight_propagates = true,
paramtype = "light",
paramtype2 = "facedir",
selection_box = {
type = "fixed",
fixed = outsel
},
collision_box = {
type = "fixed",
fixed = outsel
},
groups = pgroups,
sounds = default.node_sound_wood_defaults(),
walkable = true,
drop = "pipeworks:pipe_1_empty",
after_place_node = function(pos)
pipeworks.scan_for_pipe_objects(pos)
end,
after_dig_node = function(pos)
pipeworks.scan_for_pipe_objects(pos)
end,
on_rotate = false
})
local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1}
minetest.register_node("pipeworks:pipe_"..index.."_loaded", {
description = pipedesc,
drawtype = "mesh",
mesh = mesh,
tiles = outimg_l,
sunlight_propagates = true,
paramtype = "light",
paramtype2 = "facedir",
selection_box = {
type = "fixed",
fixed = outsel
},
collision_box = {
type = "fixed",
fixed = outsel
},
groups = pgroups,
sounds = default.node_sound_wood_defaults(),
walkable = true,
drop = "pipeworks:pipe_1_empty",
after_place_node = function(pos)
minetest.set_node(pos, { name = "pipeworks:pipe_"..index.."_empty" })
pipeworks.scan_for_pipe_objects(pos)
end,
after_dig_node = function(pos)
pipeworks.scan_for_pipe_objects(pos)
end,
on_rotate = false
})
local emptypipe = "pipeworks:pipe_"..index.."_empty"
local fullpipe = "pipeworks:pipe_"..index.."_loaded"
table.insert(pipes_empty_nodenames, emptypipe)
table.insert(pipes_full_nodenames, fullpipe)
new_flow_logic_register.simple(emptypipe)
new_flow_logic_register.simple(fullpipe)
end
if REGISTER_COMPATIBILITY then
local cempty = "pipeworks:pipe_compatibility_empty"
local cloaded = "pipeworks:pipe_compatibility_loaded"
minetest.register_node(cempty, {
drawtype = "airlike",
sunlight_propagates = true,
paramtype = "light",
description = "Pipe Segment (legacy)",
groups = {not_in_creative_inventory = 1, pipe_to_update = 1},
drop = "pipeworks:pipe_1_empty",
after_place_node = function(pos)
pipeworks.scan_for_pipe_objects(pos)
end,
on_rotate = false
})
minetest.register_node(cloaded, {
drawtype = "airlike",
sunlight_propagates = true,
paramtype = "light",
groups = {not_in_creative_inventory = 1, pipe_to_update = 1},
drop = "pipeworks:pipe_1_empty",
after_place_node = function(pos)
pipeworks.scan_for_pipe_objects(pos)
end,
on_rotate = false
})
for xm = 0, 1 do
for xp = 0, 1 do
for ym = 0, 1 do
for yp = 0, 1 do
for zm = 0, 1 do
for zp = 0, 1 do
local pname = xm..xp..ym..yp..zm..zp
minetest.register_alias("pipeworks:pipe_"..pname.."_empty", cempty)
minetest.register_alias("pipeworks:pipe_"..pname.."_loaded", cloaded)
end
end
end
end
end
end
minetest.register_abm({
nodenames = {"group:pipe_to_update"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local minp = {x = pos.x-1, y = pos.y-1, z = pos.z-1}
local maxp = {x = pos.x+1, y = pos.y+1, z = pos.z+1}
if table.getn(minetest.find_nodes_in_area(minp, maxp, "ignore")) == 0 then
pipeworks.scan_for_pipe_objects(pos)
end
end
})
end
local valve_on = "pipeworks:valve_on_empty"
local valve_off = "pipeworks:valve_off_empty"
local entry_panel_empty = "pipeworks:entry_panel_empty"
local flow_sensor_empty = "pipeworks:flow_sensor_empty"
local sp_empty = "pipeworks:straight_pipe_empty"
-- XXX: why aren't these in devices.lua!?
table.insert(pipes_empty_nodenames, valve_on)
table.insert(pipes_empty_nodenames, valve_off)
table.insert(pipes_empty_nodenames, entry_panel_empty)
table.insert(pipes_empty_nodenames, flow_sensor_empty)
table.insert(pipes_empty_nodenames, sp_empty)
local valve_on_loaded = "pipeworks:valve_on_loaded"
local entry_panel_loaded = "pipeworks:entry_panel_loaded"
local flow_sensor_loaded = "pipeworks:flow_sensor_loaded"
local sp_loaded = "pipeworks:straight_pipe_loaded"
table.insert(pipes_full_nodenames, valve_on_loaded)
table.insert(pipes_full_nodenames, entry_panel_loaded)
table.insert(pipes_full_nodenames, flow_sensor_loaded)
table.insert(pipes_full_nodenames, sp_loaded)
pipeworks.pipes_full_nodenames = pipes_full_nodenames
pipeworks.pipes_empty_nodenames = pipes_empty_nodenames
if pipeworks.toggles.pipe_mode == "classic" then
minetest.register_abm({
nodenames = pipes_empty_nodenames,
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
pipeworks.check_for_inflows(pos,node)
end
})
minetest.register_abm({
nodenames = pipes_full_nodenames,
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
pipeworks.check_sources(pos,node)
end
})
minetest.register_abm({
nodenames = {"pipeworks:spigot","pipeworks:spigot_pouring"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
pipeworks.spigot_check(pos,node)
end
})
minetest.register_abm({
nodenames = {"pipeworks:fountainhead","pipeworks:fountainhead_pouring"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
pipeworks.fountainhead_check(pos,node)
end
})
end

View File

@ -1,27 +0,0 @@
-- register new flow logic ABMs
-- written 2017 by thetaepsilon
local register = {}
pipeworks.flowlogic.abmregister = register
local flowlogic = pipeworks.flowlogic
-- register node list for the main logic function.
-- see flowlogic.run() in abms.lua.
local register_flowlogic_abm = function(nodename)
if pipeworks.toggles.pipe_mode == "pressure" then
minetest.register_abm({
label = "pipeworks new_flow_logic run",
nodenames = { nodename },
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
flowlogic.run(pos, node)
end
})
else
minetest.log("warning", "pipeworks pressure_logic not enabled but register.flowlogic() requested")
end
end
register.flowlogic = register_flowlogic_abm

View File

@ -1,368 +0,0 @@
-- reimplementation of new_flow_logic branch: processing functions
-- written 2017 by thetaepsilon
local flowlogic = {}
flowlogic.helpers = {}
pipeworks.flowlogic = flowlogic
-- borrowed from above: might be useable to replace the above coords tables
local make_coords_offsets = function(pos, include_base)
local coords = {
{x=pos.x,y=pos.y-1,z=pos.z},
{x=pos.x,y=pos.y+1,z=pos.z},
{x=pos.x-1,y=pos.y,z=pos.z},
{x=pos.x+1,y=pos.y,z=pos.z},
{x=pos.x,y=pos.y,z=pos.z-1},
{x=pos.x,y=pos.y,z=pos.z+1},
}
if include_base then table.insert(coords, pos) end
return coords
end
-- local debuglog = function(msg) print("## "..msg) end
local formatvec = function(vec) local sep="," return "("..tostring(vec.x)..sep..tostring(vec.y)..sep..tostring(vec.z)..")" end
-- new version of liquid check
-- accepts a limit parameter to only delete water blocks that the receptacle can accept,
-- and returns it so that the receptacle can update it's pressure values.
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
if total >= limit then break end
local name = minetest.get_node(tpos).name
if name == "default:water_source" then
minetest.remove_node(tpos)
total = total + 1
end
end
--pipeworks.logger("check_for_liquids_v2@"..formatvec(pos).." total "..total)
return total
end
flowlogic.check_for_liquids_v2 = check_for_liquids_v2
local label_pressure = "pipeworks.water_pressure"
local get_pressure_access = function(pos)
local metaref = minetest.get_meta(pos)
return {
get = function()
return metaref:get_float(label_pressure)
end,
set = function(v)
metaref:set_float(label_pressure, v)
end
}
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
local finitemode = pipeworks.toggles.finite_water
flowlogic.run = function(pos, node)
local nodename = node.name
-- get the current pressure value.
local nodepressure = get_pressure_access(pos)
local currentpressure = nodepressure.get()
local oldpressure = currentpressure
-- if node is an input: run intake phase
local inputdef = pipeworks.flowables.inputs.list[nodename]
if inputdef then
currentpressure = flowlogic.run_input(pos, node, currentpressure, inputdef)
--debuglog("post-intake currentpressure is "..currentpressure)
--nilexplode("run()", "currentpressure", currentpressure)
end
-- balance pressure with neighbours
currentpressure = flowlogic.balance_pressure(pos, node, currentpressure)
-- if node is an output: run output phase
local outputdef = pipeworks.flowables.outputs.list[nodename]
if outputdef then
currentpressure = flowlogic.run_output(
pos,
node,
currentpressure,
oldpressure,
outputdef,
finitemode)
end
-- if node has pressure transitions: determine new node
if pipeworks.flowables.transitions.list[nodename] then
local newnode = flowlogic.run_transition(node, currentpressure)
--pipeworks.logger("flowlogic.run()@"..formatvec(pos).." transition, new node name = "..dump(newnode).." pressure "..tostring(currentpressure))
minetest.swap_node(pos, newnode)
flowlogic.run_transition_post(pos, newnode)
end
-- set the new pressure
nodepressure.set(currentpressure)
end
local simple_neighbour_offsets = {
{x=0, y=-1,z= 0},
{x=0, y= 1,z= 0},
{x=-1,y= 0,z= 0},
{x= 1,y= 0,z= 0},
{x= 0,y= 0,z=-1},
{x= 0,y= 0,z= 1},
}
local get_neighbour_positions = function(pos, node)
-- local dname = "get_neighbour_positions@"..formatvec(pos).." "
-- get list of node neighbours.
-- if this node is directional and only flows on certain sides,
-- invoke the callback to retrieve the set.
-- for simple flowables this is just an auto-gen'd list of all six possible neighbours.
local candidates = {}
if pipeworks.flowables.list.simple[node.name] then
candidates = simple_neighbour_offsets
else
-- directional flowables: call the callback to get the list
local directional = pipeworks.flowables.list.directional[node.name]
if directional then
--pipeworks.logger(dname.."invoking neighbourfn")
local offsets = directional.neighbourfn(node)
candidates = offsets
end
end
-- then, check each possible neighbour to see if they can be reached from this node.
local connections = {}
for index, offset in ipairs(candidates) do
local npos = vector.add(pos, offset)
local neighbour = minetest.get_node(npos)
local nodename = neighbour.name
local is_simple = (pipeworks.flowables.list.simple[nodename])
if is_simple then
local n = get_pressure_access(npos)
table.insert(connections, n)
else
-- if target node is also directional, check if it agrees it can flow in that direction
local directional = pipeworks.flowables.list.directional[nodename]
if directional then
--pipeworks.logger(dname.."directionality test for offset "..formatvec(offset))
local towards_origin = vector.multiply(offset, -1)
--pipeworks.logger(dname.."vector passed to directionfn: "..formatvec(towards_origin))
local result = directional.directionfn(neighbour, towards_origin)
--pipeworks.logger(dname.."result: "..tostring(result))
if result then
local n = get_pressure_access(npos)
table.insert(connections, n)
end
end
end
end
return connections
end
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
local connections = get_neighbour_positions(pos, node)
-- for each neighbour, add neighbour's pressure to the total to balance out
for _, neighbour in ipairs(connections) do
local n = neighbour.get()
totalv = totalv + n
totalc = totalc + 1
end
local average = totalv / totalc
for _, target in ipairs(connections) do
target.set(average)
end
return average
end
flowlogic.run_input = function(pos, node, currentpressure, inputdef)
-- intakefn allows a given input node to define it's own intake logic.
-- this function will calculate the maximum amount of water that can be taken in;
-- the intakefn will be given this and is expected to return the actual absorption amount.
local maxpressure = inputdef.maxpressure
local intake_limit = maxpressure - currentpressure
if intake_limit <= 0 then return currentpressure end
local actual_intake = inputdef.intakefn(pos, intake_limit)
--pipeworks.logger("run_input@"..formatvec(pos).." oldpressure "..currentpressure.." intake_limit "..intake_limit.." actual_intake "..actual_intake)
if actual_intake <= 0 then return currentpressure end
local newpressure = actual_intake + currentpressure
--debuglog("run_input() end, oldpressure "..currentpressure.." intake_limit "..intake_limit.." actual_intake "..actual_intake.." newpressure "..newpressure)
return newpressure
end
-- flowlogic output helper implementation:
-- outputs water by trying to place water nodes nearby in the world.
-- neighbours is a list of node offsets to try placing water in.
-- this is a constructor function, returning another function which satisfies the output helper requirements.
-- note that this does *not* take rotation into account.
flowlogic.helpers.make_neighbour_output_fixed = function(neighbours)
return function(pos, node, currentpressure, finitemode)
local taken = 0
for _, offset in pairs(neighbours) do
local npos = vector.add(pos, offset)
local name = minetest.get_node(npos).name
if currentpressure < 1 then break end
-- take pressure anyway in non-finite mode, even if node is water source already.
-- 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")
if canplace then
minetest.swap_node(npos, {name="default:water_source"})
end
if (not finitemode) or canplace then
taken = taken + 1
currentpressure = currentpressure - 1
end
end
return taken
end
end
-- complementary function to the above when using non-finite mode:
-- removes water sources from neighbor positions when the output is "off" due to lack of pressure.
flowlogic.helpers.make_neighbour_cleanup_fixed = function(neighbours)
return function(pos, node, currentpressure)
--pipeworks.logger("neighbour_cleanup_fixed@"..formatvec(pos))
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
--pipeworks.logger("neighbour_cleanup_fixed removing "..formatvec(npos))
minetest.remove_node(npos)
end
end
end
end
flowlogic.run_output = function(pos, node, currentpressure, oldpressure, outputdef, finitemode)
-- processing step for water output devices.
-- takes care of checking a minimum pressure value and updating the resulting pressure level
-- the outputfn is provided the current pressure and returns the pressure "taken".
-- as an example, using this with the above spigot function,
-- the spigot function tries to output a water source if it will fit in the world.
--pipeworks.logger("flowlogic.run_output() pos "..formatvec(pos).." old -> currentpressure "..tostring(oldpressure).." "..tostring(currentpressure).." finitemode "..tostring(finitemode))
local upper = outputdef.upper
local lower = outputdef.lower
local result = currentpressure
local threshold = nil
if finitemode then threshold = lower else threshold = upper end
if currentpressure > threshold then
local takenpressure = outputdef.outputfn(pos, node, currentpressure, finitemode)
local newpressure = currentpressure - takenpressure
if newpressure < 0 then newpressure = 0 end
result = newpressure
end
if (not finitemode) and (currentpressure < lower) and (oldpressure < lower) then
--pipeworks.logger("flowlogic.run_output() invoking cleanup currentpressure="..tostring(currentpressure))
outputdef.cleanupfn(pos, node, currentpressure)
end
return result
end
-- determine which node to switch to based on current pressure
flowlogic.run_transition = function(node, currentpressure)
local simplesetdef = pipeworks.flowables.transitions.simple[node.name]
local result = node
local found = false
-- simple transition sets: assumes all nodes in the set share param values.
if simplesetdef then
-- assumes that the set has been checked to contain at least one element...
local nodename_prev = simplesetdef[1].nodename
local result_nodename = node.name
for index, element in ipairs(simplesetdef) do
-- find the highest element that is below the current pressure.
local threshold = element.threshold
if threshold > currentpressure then
result_nodename = nodename_prev
found = true
break
end
nodename_prev = element.nodename
end
-- use last element if no threshold is greater than current pressure
if not found then
result_nodename = nodename_prev
found = true
end
-- preserve param1/param2 values
result = { name=result_nodename, param1=node.param1, param2=node.param2 }
end
if not found then
pipeworks.logger("flowlogic.run_transition() BUG no transition definitions found! nodename="..nodename.." currentpressure="..tostring(currentpressure))
end
return result
end
-- post-update hook for run_transition
-- among other things, updates mesecons if present.
-- node here means the new node, returned from run_transition() above
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 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
local receptor = mesecons_def.receptor
if receptor then
local state = receptor.state
if state == mesecon.state.on then
mesecon.receptor_on(pos, mesecons_rules)
elseif state == mesecon.state.off then
mesecon.receptor_off(pos, mesecons_rules)
end
end
end
end
end

View File

@ -1,53 +0,0 @@
-- registry of flowable node behaviours in new flow logic
-- written 2017 by thetaepsilon
-- the actual registration functions which edit these tables can be found in flowable_node_registry_install.lua
-- this is because the ABM code needs to inspect these tables,
-- but the registration code needs to reference said ABM code.
-- so those functions were split out to resolve a circular dependency.
pipeworks.flowables = {}
pipeworks.flowables.list = {}
pipeworks.flowables.list.all = {}
-- pipeworks.flowables.list.nodenames = {}
-- simple flowables - balance pressure in any direction
pipeworks.flowables.list.simple = {}
pipeworks.flowables.list.simple_nodenames = {}
-- directional flowables - can only flow on certain sides
-- format per entry is a table with the following fields:
-- neighbourfn: function(node),
-- called to determine which nodes to consider as neighbours.
-- can be used to e.g. inspect the node's param values for facedir etc.
-- returns: array of vector offsets to look for possible neighbours in
-- directionfn: function(node, vector):
-- can this node flow in this direction?
-- called in the context of another node to check the matching entry returned by neighbourfn.
-- for every offset vector returned by neighbourfn,
-- the node at that absolute position is checked.
-- if that node is also a directional flowable,
-- then that node's vector is passed to that node's directionfn
-- (inverted, so that directionfn sees a vector pointing out from it back to the origin node).
-- if directionfn agrees that the neighbour node can currently flow in that direction,
-- the neighbour is to participate in pressure balancing.
pipeworks.flowables.list.directional = {}
-- simple intakes - try to absorb any adjacent water nodes
pipeworks.flowables.inputs = {}
pipeworks.flowables.inputs.list = {}
pipeworks.flowables.inputs.nodenames = {}
-- outputs - takes pressure from pipes and update world to do something with it
pipeworks.flowables.outputs = {}
pipeworks.flowables.outputs.list = {}
-- not currently any nodenames arraylist for this one as it's not currently needed.
-- nodes with registered node transitions
-- nodes will be switched depending on pressure level
pipeworks.flowables.transitions = {}
pipeworks.flowables.transitions.list = {} -- master list
pipeworks.flowables.transitions.simple = {} -- nodes that change based purely on pressure
pipeworks.flowables.transitions.mesecons = {} -- table of mesecons rules to apply on transition

View File

@ -1,263 +0,0 @@
-- flowable node registry: add entries and install ABMs if new flow logic is enabled
-- written 2017 by thetaepsilon
-- use for hooking up ABMs as nodes are registered
local abmregister = pipeworks.flowlogic.abmregister
-- registration functions
pipeworks.flowables.register = {}
local register = pipeworks.flowables.register
-- some sanity checking for passed args, as this could potentially be made an external API eventually
local checkexists = function(nodename)
if type(nodename) ~= "string" then error("pipeworks.flowables nodename must be a string!") end
return pipeworks.flowables.list.all[nodename]
end
local insertbase = function(nodename)
if checkexists(nodename) then error("pipeworks.flowables duplicate registration!") end
pipeworks.flowables.list.all[nodename] = true
-- table.insert(pipeworks.flowables.list.nodenames, nodename)
if pipeworks.toggles.pipe_mode == "pressure" then
abmregister.flowlogic(nodename)
end
end
local regwarning = function(kind, nodename)
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
-- Register a node as a simple flowable.
-- Simple flowable nodes have no considerations for direction of flow;
-- A cluster of adjacent simple flowables will happily average out in any direction.
register.simple = function(nodename)
insertbase(nodename)
pipeworks.flowables.list.simple[nodename] = true
table.insert(pipeworks.flowables.list.simple_nodenames, nodename)
regwarning("simple", nodename)
end
-- Register a node as a directional flowable:
-- has a helper function which determines which nodes to consider valid neighbours.
register.directional = function(nodename, neighbourfn, directionfn)
insertbase(nodename)
pipeworks.flowables.list.directional[nodename] = {
neighbourfn = neighbourfn,
directionfn = directionfn
}
regwarning("directional", nodename)
end
-- register a node as a directional flowable that can only flow through either the top or bottom side.
-- used for fountainheads (bottom side) and pumps (top side).
-- this is in world terms, not facedir relative!
register.directional_vertical_fixed = function(nodename, topside)
local y
if topside then y = 1 else y = -1 end
local side = { x=0, y=y, z=0 }
local neighbourfn = function(node) return { side } end
local directionfn = function(node, direction)
return vector.equals(direction, side)
end
register.directional(nodename, neighbourfn, directionfn)
end
-- register a node as a directional flowable whose accepting sides depends upon param2 rotation.
-- used for entry panels, valves, flow sensors and spigots.
-- this is mostly for legacy reasons and SHOULD NOT BE USED IN NEW CODE.
register.directional_horizonal_rotate = function(nodename, doubleended)
local rotations = {
{x= 0,y= 0,z= 1},
{x= 1,y= 0,z= 0},
{x= 0,y= 0,z=-1},
{x=-1,y= 0,z= 0},
}
local getends = function(node)
--local dname = "horizontal rotate getends() "
local param2 = node.param2
-- the pipeworks nodes use a fixed value for vertical facing nodes
-- if that is detected, just return that directly.
if param2 == 17 then
return {{x=0,y=1,z=0}, {x=0,y=-1,z=0}}
end
-- the sole end of the spigot points in the direction the rotation bits suggest
-- also note to self: lua arrays start at one...
local mainend = (param2 % 4) + 1
-- use modulus wrap-around to find other end for straight-run devices like the valve
local otherend = ((param2 + 2) % 4) + 1
local mainrot = rotations[mainend]
--pipeworks.logger(dname.."mainrot: "..dump(mainrot))
local result
if doubleended then
result = { mainrot, rotations[otherend] }
else
result = { mainrot }
end
--pipeworks.logger(dname.."result: "..dump(result))
return result
end
local neighbourfn = function(node)
return getends(node)
end
local directionfn = function(node, direction)
local result = false
for index, endvec in ipairs(getends(node)) do
if vector.equals(direction, endvec) then result = true end
end
return result
end
register.directional(nodename, neighbourfn, directionfn)
end
local checkbase = function(nodename)
if not checkexists(nodename) then error("pipeworks.flowables node doesn't exist as a flowable!") end
end
local duplicateerr = function(kind, nodename) error(kind.." duplicate registration for "..nodename) end
-- Registers a node as a fluid intake.
-- intakefn is used to determine the water that can be taken in a node-specific way.
-- Expects node to be registered as a flowable (is present in flowables.list.all),
-- so that water can move out of it.
-- maxpressure is the maximum pipeline pressure that this node can drive;
-- if the input's node exceeds this the callback is not run.
-- possible WISHME here: technic-driven high-pressure pumps
register.intake = function(nodename, maxpressure, intakefn)
-- check for duplicate registration of this node
local list = pipeworks.flowables.inputs.list
checkbase(nodename)
if list[nodename] then duplicateerr("pipeworks.flowables.inputs", nodename) end
list[nodename] = { maxpressure=maxpressure, intakefn=intakefn }
regwarning("intake", nodename)
end
-- Register a node as a simple intake:
-- tries to absorb water source nodes from it's surroundings.
-- may exceed limit slightly due to needing to absorb whole nodes.
register.intake_simple = function(nodename, maxpressure)
register.intake(nodename, maxpressure, pipeworks.flowlogic.check_for_liquids_v2)
end
-- Register a node as an output.
-- Expects node to already be a flowable.
-- upper and lower thresholds have different meanings depending on whether finite liquid mode is in effect.
-- if not (the default unless auto-detected),
-- nodes above their upper threshold have their outputfn invoked (and pressure deducted),
-- nodes between upper and lower are left idle,
-- and nodes below lower have their cleanup fn invoked (to say remove water sources).
-- the upper and lower difference acts as a hysteresis to try and avoid "gaps" in the flow.
-- if finite mode is on, upper is ignored and lower is used to determine whether to run outputfn;
-- cleanupfn is ignored in this mode as finite mode assumes something causes water to move itself.
register.output = function(nodename, upper, lower, outputfn, cleanupfn)
if pipeworks.flowables.outputs.list[nodename] then
error("pipeworks.flowables.outputs duplicate registration!")
end
checkbase(nodename)
pipeworks.flowables.outputs.list[nodename] = {
upper=upper,
lower=lower,
outputfn=outputfn,
cleanupfn=cleanupfn,
}
-- output ABM now part of main flow logic ABM to preserve ordering.
-- note that because outputs have to be a flowable first
-- (and the installation of the flow logic ABM is conditional),
-- registered output nodes for new_flow_logic is also still conditional on the enable flag.
regwarning("output node", nodename)
end
-- register a simple output:
-- drains pressure by attempting to place water in nearby nodes,
-- which can be set by passing a list of offset vectors.
-- will attempt to drain as many whole nodes as there are positions in the offset list.
-- for meanings of upper and lower, see register.output() above.
-- non-finite mode:
-- above upper pressure: places water sources as appropriate, keeps draining pressure.
-- below lower presssure: removes it's neighbour water sources.
-- finite mode:
-- same as for above pressure in non-finite mode,
-- but only drains pressure when water source nodes are actually placed.
register.output_simple = function(nodename, upper, lower, neighbours)
local outputfn = pipeworks.flowlogic.helpers.make_neighbour_output_fixed(neighbours)
local cleanupfn = pipeworks.flowlogic.helpers.make_neighbour_cleanup_fixed(neighbours)
register.output(nodename, upper, lower, outputfn, cleanupfn)
end
-- common base checking for transition nodes
-- ensures the node has only been registered once as a transition.
local transition_list = pipeworks.flowables.transitions.list
local insert_transition_base = function(nodename)
checkbase(nodename)
if transition_list[nodename] then duplicateerr("base transition", nodename) end
transition_list[nodename] = true
end
-- register a simple transition set.
-- expects a table with nodenames as keys and threshold pressures as values.
-- internally, the table is sorted by value, and when one of these nodes needs to transition,
-- the table is searched starting from the lowest (even if it's value is non-zero),
-- until a value is found which is higher than or equal to the current node pressure.
-- ex. nodeset = { ["mod:level_0"] = 0, ["mod:level_1"] = 1, --[[ ... ]] }
local simpleseterror = function(msg)
error("register.transition_simple_set(): "..msg)
end
local simple_transitions = pipeworks.flowables.transitions.simple
register.transition_simple_set = function(nodeset, extras)
local set = {}
if extras == nil then extras = {} end
local length = #nodeset
if length < 2 then simpleseterror("nodeset needs at least two elements!") end
for index, element in ipairs(nodeset) do
if type(element) ~= "table" then simpleseterror("element "..tostring(index).." in nodeset was not table!") end
local nodename = element[1]
local value = element[2]
if type(nodename) ~= "string" then simpleseterror("nodename "..tostring(nodename).."was not a string!") end
if type(value) ~= "number" then simpleseterror("pressure value "..tostring(value).."was not a number!") end
insert_transition_base(nodename)
if simple_transitions[nodename] then duplicateerr("simple transition set", nodename) end
-- assigning set to table is done separately below
table.insert(set, { nodename=nodename, threshold=value })
end
-- sort pressure values, smallest first
local smallest_first = function(a, b)
return a.threshold < b.threshold
end
table.sort(set, smallest_first)
-- individual registration of each node, all sharing this set,
-- so each node in the set will transition to the correct target node.
for _, element in ipairs(set) do
--pipeworks.logger("register.transition_simple_set() after sort: nodename "..element.nodename.." value "..tostring(element.threshold))
simple_transitions[element.nodename] = set
end
-- handle extra options
-- if mesecons rules table was passed, set for each node
if extras.mesecons then
local mesecons_rules = pipeworks.flowables.transitions.mesecons
for _, element in ipairs(set) do
mesecons_rules[element.nodename] = extras.mesecons
end
end
end

View File

@ -1,174 +0,0 @@
-- the default tube and default textures
pipeworks.register_tube("pipeworks:tube", "Pneumatic tube segment")
minetest.register_craft( {
output = "pipeworks:tube_1 6",
recipe = {
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
{ "", "", "" },
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
},
})
local nodecolor = 0xffff3030
pipeworks.register_tube("pipeworks:broken_tube", {
description = "Broken Tube (you hacker you)",
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 } },
short = { name = "pipeworks_broken_tube_short.png", color = nodecolor },
node_def = {
drop = "pipeworks:tube_1",
groups = {not_in_creative_inventory = 1, tubedevice_receiver = 1},
tube = {
insert_object = function(pos, node, stack, direction)
minetest.item_drop(stack, nil, pos)
return ItemStack("")
end,
can_insert = function(pos,node,stack,direction)
return true
end,
priority = 50,
},
on_punch = function(pos, node, puncher, pointed_thing)
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.")
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.")
end
end
}
})
-- the high priority tube is a low-cpu replacement for sorting tubes in situations
-- where players would use them for simple routing (turning off paths)
-- without doing actual sorting, like at outputs of tubedevices that might both accept and eject items
if pipeworks.enable_priority_tube then
local color = "#ff3030:128"
pipeworks.register_tube("pipeworks:priority_tube", {
description = "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 } },
ends = { { name = "pipeworks_tube_end.png", color = nodecolor } },
short = { name = "pipeworks_tube_short.png", color = nodecolor },
node_def = {
tube = { priority = 150 } -- higher than tubedevices (100)
},
})
minetest.register_craft( {
output = "pipeworks:priority_tube_1 6",
recipe = {
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
{ "default:gold_ingot", "", "default:gold_ingot" },
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
},
})
end
if pipeworks.enable_accelerator_tube then
pipeworks.register_tube("pipeworks:accelerator_tube", {
description = "Accelerating Pneumatic Tube Segment",
inventory_image = "pipeworks_accelerator_tube_inv.png",
plain = { "pipeworks_accelerator_tube_plain.png" },
noctr = { "pipeworks_accelerator_tube_noctr.png" },
ends = { "pipeworks_accelerator_tube_end.png" },
short = "pipeworks_accelerator_tube_short.png",
node_def = {
tube = {can_go = function(pos, node, velocity, stack)
velocity.speed = velocity.speed+1
return pipeworks.notvel(pipeworks.meseadjlist, velocity)
end}
},
})
minetest.register_craft( {
output = "pipeworks:accelerator_tube_1 2",
recipe = {
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
{ "default:mese_crystal_fragment", "default:steel_ingot", "default:mese_crystal_fragment" },
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
},
})
end
if pipeworks.enable_crossing_tube then
pipeworks.register_tube("pipeworks:crossing_tube", {
description = "Crossing Pneumatic Tube Segment",
inventory_image = "pipeworks_crossing_tube_inv.png",
plain = { "pipeworks_crossing_tube_plain.png" },
noctr = { "pipeworks_crossing_tube_noctr.png" },
ends = { "pipeworks_crossing_tube_end.png" },
short = "pipeworks_crossing_tube_short.png",
node_def = {
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
if pipeworks.enable_one_way_tube then
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"},
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(),
tube = {
connect_sides = {left = 1, right = 1},
can_go = function(pos, node, velocity, stack)
return {velocity}
end,
can_insert = function(pos, node, stack, direction)
local dir = pipeworks.facedir_to_right_dir(node.param2)
return vector.equals(dir, direction)
end,
priority = 75 -- Higher than normal tubes, but lower than receivers
},
after_place_node = pipeworks.after_place,
after_dig_node = pipeworks.after_dig,
on_rotate = pipeworks.on_rotate,
})
minetest.register_craft({
output = "pipeworks:one_way_tube 2",
recipe = {
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
{ "group:stick", "default:mese_crystal", "basic_materials:plastic_sheet" },
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
},
})
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

View File

@ -1,77 +0,0 @@
#Enable pipes.
pipeworks_enable_pipes (Enable Pipes) bool true
#Enable autocrafter.
pipeworks_enable_autocrafter (Enable Autocrafter) bool true
#Enable deployer.
pipeworks_enable_deployer (Enable Deployer) bool true
#Enable dispenser.
pipeworks_enable_dispenser (Enable Dispenser) bool true
#Enable node breaker.
pipeworks_enable_node_breaker (Enable Node Breaker) bool true
#Enable teleport tube.
pipeworks_enable_teleport_tube (Enable Teleport Tube) bool true
#Enable pipe devices.
pipeworks_enable_pipe_devices (Enable Pipe Devices) bool true
#Enable redefines.
pipeworks_enable_redefines (Enable Node Redefines) bool true
#Enable sorting tube.
pipeworks_enable_mese_tube (Enable Sorting Tube) bool true
#Enable detector tube.
pipeworks_enable_detector_tube (Enable Detector Tube) bool true
#Enable digiline detector tube.
pipeworks_enable_digiline_detector_tube (Enable Digiline Detector Tube) bool true
#Enable mesecon signal conducting tube.
pipeworks_enable_conductor_tube (Enable Conductor Tube) bool true
#Enable digiline signal conducting tube.
pipeworks_enable_digiline_conductor_tube (Enable Digiline Conductor Tube) bool true
#Enable accelerator tube.
pipeworks_enable_accelerator_tube (Enable Accelerator Tube) bool true
#Enable crossing tube.
#It sends all incoming items to the other side, or if there is no other tube, it sends them back.
pipeworks_enable_crossing_tube (Enable Crossing Tube) bool true
#Enable vacuum tube.
#It picks up all items that lay around next to it.
pipeworks_enable_sand_tube (Enable Vacuum Tube) bool true
#Enable mese vacuum tube.
#It's like the normal vacuum tube with the
#differance that you can set the radius up to 8 nodes.
pipeworks_enable_mese_sand_tube (Enable Mese Vacuum Tube) bool true
#Enable one way tube.
#It sends items only in one direction.
#Use it to drop items out of tubes.
pipeworks_enable_one_way_tube (Enable One Way Tube) bool true
#Enable high priority tube.
#It has a very high priority and so, on crossings, the items will
#always go to it if there are multible ways.
pipeworks_enable_priority_tube (Enable High Priority Tube) bool true
#Enable lua controlled tube.
#It is comparable with mesecons luacontroller.
pipeworks_enable_lua_tube (Enable Lua controlled Tube) bool true
#Enable cyclic mode.
pipeworks_enable_cyclic_mode (Enable Cyclic Mode) bool true
#Drop on routing fail.
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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 345 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 665 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 661 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 923 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 830 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 839 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 535 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1005 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 575 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 275 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 801 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 669 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 543 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 823 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 823 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 823 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 800 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 795 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 892 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 526 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 337 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 179 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 169 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 162 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 765 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 892 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 526 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Some files were not shown because too many files have changed in this diff Show More