pax_global_header00006660000000000000000000000064121372650150014514gustar00rootroot0000000000000052 comment=522edf1cd4f30b580c92b2951192f63a10b21682 MineTest-WorldEdit-0.6/000077500000000000000000000000001213726501500150045ustar00rootroot00000000000000MineTest-WorldEdit-0.6/Chat Commands.md000066400000000000000000000147571213726501500177450ustar00rootroot00000000000000Chat Commands ------------- For more information, see the [README](README.md). ### //reset Reset the region so that it is empty. //reset ### //mark Show markers at the region positions. //mark ### //pos1 Set WorldEdit region position 1 to the player's location. //pos1 ### //pos2 Set WorldEdit region position 2 to the player's location. //pos2 ### //p set/set1/set2/get Set WorldEdit region, WorldEdit position 1, or WorldEdit position 2 by punching nodes, or display the current WorldEdit region. //p set //p set1 //p set2 //p get ### //volume Display the volume of the current WorldEdit region. //volume ### //set Set the current WorldEdit region to . //set dirt //set default:glass //set mesecons:mesecon ### //replace Replace all instances of with in the current WorldEdit region. //replace cobble stone //replace default:steelblock glass //replace dirt flowers:flower_waterlily //replace flowers:flower_rose flowers:flower_tulip ### //replaceinverse Replace all nodes other than with in the current WorldEdit region. //replaceinverse air stone //replaceinverse water_source default:dirt //replaceinverse mesecons:mesecon air //replaceinverse default:steelblock default:glass ### //hollowsphere Add hollow sphere at WorldEdit position 1 with radius , composed of . //hollowsphere 5 dirt //hollowsphere 12 default:glass //hollowsphere 17 mesecons:mesecon ### //sphere Add sphere at WorldEdit position 1 with radius , composed of . //sphere 5 dirt //sphere 12 default:glass //sphere 17 mesecons:mesecon ### //hollowdome Add hollow dome at WorldEdit position 1 with radius , composed of . //hollowdome 5 dirt //hollowdome 12 default:glass //hollowdome 17 mesecons:mesecon ### //dome Add dome at WorldEdit position 1 with radius , composed of . //dome 5 dirt //dome 12 default:glass //dome 17 mesecons:mesecon ### //hollowcylinder x/y/z/? Add hollow cylinder at WorldEdit position 1 along the x/y/z/? axis with length and radius , composed of . //hollowcylinder x +5 8 dirt //hollowcylinder y 28 10 default:glass //hollowcylinder z -12 3 mesecons:mesecon //hollowcylinder ? 2 4 stone ### //cylinder x/y/z/? Add cylinder at WorldEdit position 1 along the x/y/z/? axis with length and radius , composed of . //cylinder x +5 8 dirt //cylinder y 28 10 default:glass //cylinder z -12 3 mesecons:mesecon //cylinder ? 2 4 stone ### //pyramid Add pyramid at WorldEdit position 1 with height , composed of . //pyramid 8 dirt //pyramid 5 default:glass //pyramid 2 stone ### //spiral Add spiral at WorldEdit position 1 with width , height , space between walls , composed of . //spiral 20 5 3 dirt //spiral 5 2 1 default:glass //spiral 7 1 5 stone ### //copy x/y/z/? Copy the current WorldEdit region along the x/y/z/? axis by nodes. //copy x 15 //copy y -7 //copy z +4 //copy ? 8 ### //move x/y/z/? Move the current WorldEdit positions and region along the x/y/z/? axis by nodes. //move x 15 //move y -7 //move z +4 //move ? -1 ### //stack x/y/z/? Stack the current WorldEdit region along the x/y/z/? axis times. //stack x 3 //stack y -1 //stack z +5 //stack ? 12 ### //transpose x/y/z/? x/y/z/? Transpose the current WorldEdit positions and region along the x/y/z/? and x/y/z/? axes. //transpose x y //transpose x z //transpose y z //transpose ? y ### //flip x/y/z/? Flip the current WorldEdit region along the x/y/z/? axis. //flip x //flip y //flip z //flip ? ### //rotate x/y/z/? Rotate the current WorldEdit positions and region along the x/y/z/? axis by angle (90 degree increment). //rotate x 90 //rotate y 180 //rotate z 270 //rotate ? -90 ### //orient Rotate oriented nodes in the current WorldEdit region around the Y axis by angle (90 degree increment) //orient 90 //orient 180 //orient 270 //orient -90 ### //fixlight Fixes the lighting in the current WorldEdit region. //fixlight ### //hide Hide all nodes in the current WorldEdit region non-destructively. //hide ### //suppress Suppress all in the current WorldEdit region non-destructively. //suppress dirt //suppress default:glass //suppress mesecons:mesecon ### //highlight Highlight in the current WorldEdit region by hiding everything else non-destructively. //highlight dirt //highlight default:glass //highlight mesecons:mesecon ### //restore Restores nodes hidden with WorldEdit in the current WorldEdit region. //restore ### //save Save the current WorldEdit region to "(world folder)/schems/.we". //save some random filename //save huge_base ### //allocate Set the region defined by nodes from "(world folder)/schems/.we" as the current WorldEdit region. //allocate some random filename //allocate huge_base ### //load Load nodes from "(world folder)/schems/.we" with position 1 of the current WorldEdit region as the origin. //load some random filename //load huge_base ### //lua Executes as a Lua chunk in the global namespace. //lua worldedit.pos1["singleplayer"] = {x=0, y=0, z=0} //lua worldedit.rotate(worldedit.pos1["singleplayer"], worldedit.pos2["singleplayer"], "y", 90) ### //luatransform Executes as a Lua chunk in the global namespace with the variable pos available, for each node in the current WorldEdit region. //luatransform minetest.env:add_node(pos, {name="default:stone"}) //luatransform if minetest.env:get_node(pos).name == "air" then minetest.env:add_node(pos, {name="default:water_source"}) MineTest-WorldEdit-0.6/LICENSE.txt000066400000000000000000001033301213726501500166270ustar00rootroot00000000000000 GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software. A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public. The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version. An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU Affero General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Remote Network Interaction; Use with the GNU General Public License. Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements. You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see . MineTest-WorldEdit-0.6/README.md000066400000000000000000000073331213726501500162710ustar00rootroot00000000000000WorldEdit v0.6 for MineTest 0.4 =============================== In-game world editing for [MineTest](http://minetest.net/)! Tons of chat commands to help with building, fixing, and more. For more information, see the [forum topic](http://minetest.net/forum/viewtopic.php?id=572) at the MineTest forums. Usage ----- WorldEdit works primarily through chat commands. Depending on your key bindings, you can invoke chat entry with the "t" key, and open the chat console with the "F10" key. WorldEdit has a huge potential for abuse by untrusted players. Therefore, users will not be able to use WorldEdit unless they have the "worldedit" privelege. This is available by default in single player, but in multiplayer the permission must be explicitly given by someone with the right credentials, using the follwoing chat command: `/grant worldedit`. This privelege can later be removed using the following chat command: `/revoke worldedit`. For in-game information about these commands, type `/help ` in the chat. For example, to learn more about the `//copy` command, simply type `/help /copy` to display information relevant to copying a region. Axes ---- The coordinate system is the same as that used by MineTest; Y is upwards, X is perpendicular, and Z is parallel. When an axis is specified in a WorldEdit command, it is specified as one of the following values: x, y, z, or ?. The value ? represents the axis the player is currently facing. If the player is facing more than one axis, the axis the player face direction is closest to will be used. Regions ------- Most WorldEdit commands operate on regions. Regions are a set of two positions that define a 3D cube. They are local to each player and chat commands affect only the region for the player giving the commands. Each positions together define two opposing corners of the cube. With two opposing corners it is possible to determine both the location and dimensions of the region. Regions are not saved between server restarts. They start off as empty regions, and cannot be used with most WorldEdit commands until they are set to valid values. Markers ------- Entities are used to mark the location of the WorldEdit regions. They appear as boxes containing the number 1 or 2, and represent position 1 and 2 of the WorldEdit region, respectively. To remove the entities, simply punch them. This does not reset the positions themselves. Chat Commands ------------- WorldEdit is accessed in-game through an interface. By default, the mod distribution includes a chat interface for this purpose. It is documented in the [Chat Commands Reference](Chat Commands.md). If visual manipulation of nodes is desired, the [WorldEdit GUI](http://minetest.net/forum/viewtopic.php?id=3112) mod provides a simple interface with buttons and text entry fields for this purpose. WorldEdit API ------------- WorldEdit exposes all significant functionality in a simple interface. Adding WorldEdit to the file "depends.txt" in your mod gives you access to all of the `worldedit` functions. The API is useful for tasks such as high-performance node manipulation, alternative interfaces, and map creation. This API is documented in the [WorldEdit API Reference](WorldEdit API.md). License ------- Copyright 2012 sfan5, Anthony Zhang (Temperest), and Brett O'Donnell (cornernote). This mod is licensed under the [GNU Affero General Public License](http://www.gnu.org/licenses/agpl-3.0.html). Basically, this means everyone is free to use, modify, and distribute the files, as long as these modifications are also licensed the same way. Most importantly, the Affero variant of the GPL requires you to publish your modifications in source form, even if the mod is run only on the server, and not distributed. MineTest-WorldEdit-0.6/WorldEdit API.md000066400000000000000000000163751213726501500176310ustar00rootroot00000000000000WorldEdit API ============= The WorldEdit API is composed of multiple modules, each of which is independent and can be used without the other. Each module is contained within a single file. If needed, individual modules such as visualization.lua can be removed without affecting the rest of the program. The only file that cannot be removed is init.lua, which is necessary for the mod to run. For more information, see the [README](README.md). Manipulations ------------- Contained in manipulations.lua, this module allows several node operations to be applied over a region. ### count = worldedit.set(pos1, pos2, nodename) Sets a region defined by positions `pos1` and `pos2` to `nodename`. To clear to region, use "air" as the value of `nodename`. Returns the number of nodes set. ### count = worldedit.replace(pos1, pos2, searchnode, replacenode) Replaces all instances of `searchnode` with `replacenode` in a region defined by positions `pos1` and `pos2`. Returns the number of nodes replaced. ### count = worldedit.replaceinverse(pos1, pos2, searchnode, replacenode) Replaces all nodes other than `searchnode` with `replacenode` in a region defined by positions `pos1` and `pos2`. Returns the number of nodes replaced. ### count = worldedit.copy(pos1, pos2, axis, amount) Copies the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") by `amount` nodes. Returns the number of nodes copied. ### count = worldedit.move(pos1, pos2, axis, amount) Moves the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") by `amount` nodes. Returns the number of nodes moved. ### count = worldedit.stack(pos1, pos2, axis, count) Duplicates the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") `count` times. Returns the number of nodes stacked. ### count, newpos1, newpos2 = worldedit.transpose(pos1, pos2, axis1, axis2) Transposes a region defined by the positions `pos1` and `pos2` between the `axis1` and `axis2` axes ("x" or "y" or "z"). Returns the number of nodes transposed, the new position 1, and the new position 2. ### count = worldedit.flip(pos1, pos2, axis) Flips a region defined by the positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z"). Returns the number of nodes flipped. ### count, newpos2, newpos2 = worldedit.rotate(pos1, pos2, angle) Rotates a region defined by the positions `pos1` and `pos2` by `angle` degrees clockwise around the y axis (supporting 90 degree increments only). Returns the number of nodes rotated, the new position 1, and the new position 2. ### count = worldedit.orient(pos1, pos2, angle) Rotates all oriented nodes in a region defined by the positions `pos1` and `pos2` by `angle` degrees clockwise (90 degree increment) around the Y axis. Returns the number of nodes oriented. ### count = worldedit.fixlight(pos1, pos2) Fixes the lighting in a region defined by positions `pos1` and `pos2`. Returns the number of nodes updated. Primitives ---------- Contained in primitives.lua, this module allows the creation of several geometric primitives. ### count = worldedit.hollow_sphere(pos, radius, nodename) Adds a hollow sphere at `pos` with radius `radius`, composed of `nodename`. Returns the number of nodes added. ### count = worldedit.sphere(pos, radius, nodename) Adds a sphere at `pos` with radius `radius`, composed of `nodename`. Returns the number of nodes added. ### count = worldedit.hollow_dome(pos, radius, nodename) Adds a hollow dome at `pos` with radius `radius`, composed of `nodename`. Returns the number of nodes added. ### count = worldedit.dome(pos, radius, nodename) Adds a dome at `pos` with radius `radius`, composed of `nodename`. Returns the number of nodes added. ### count = worldedit.hollow_cylinder(pos, axis, length, radius, nodename) Adds a hollow cylinder at `pos` along the `axis` axis ("x" or "y" or "z") with length `length` and radius `radius`, composed of `nodename`. Returns the number of nodes added. ### count = worldedit.cylinder(pos, axis, length, radius, nodename) Adds a cylinder at `pos` along the `axis` axis ("x" or "y" or "z") with length `length` and radius `radius`, composed of `nodename`. Returns the number of nodes added. ### count = worldedit.pyramid(pos, height, nodename) Adds a pyramid at `pos` with height `height`. Returns the number of nodes added. ### count = worldedit.spiral(pos, width, height, spacer, nodename) Adds a spiral at `pos` with width `width`, height `height`, space between walls `spacer`, composed of `nodename`. Returns the number of nodes added. Visualization ------------- Contained in visualization.lua, this module allows nodes to be visualized in different ways. ### volume = worldedit.volume(pos1, pos2) Determines the volume of the region defined by positions `pos1` and `pos2`. Returns the volume. ### count = worldedit.hide(pos1, pos2) Hides all nodes in a region defined by positions `pos1` and `pos2` by non-destructively replacing them with invisible nodes. Returns the number of nodes hidden. ### count = worldedit.suppress(pos1, pos2, nodename) Suppresses all instances of `nodename` in a region defined by positions `pos1` and `pos2` by non-destructively replacing them with invisible nodes. Returns the number of nodes suppressed. ### count = worldedit.highlight(pos1, pos2, nodename) Highlights all instances of `nodename` in a region defined by positions `pos1` and `pos2` by non-destructively hiding all other nodes. Returns the number of nodes found. ### count = worldedit.restore(pos1, pos2) Restores all nodes hidden with WorldEdit functions in a region defined by positions `pos1` and `pos2`. Returns the number of nodes restored. Serialization ------------- Contained in serialization.lua, this module allows regions of nodes to be serialized and deserialized to formats suitable for use outside MineTest. ### version = worldedit.valueversion(value) Determines the version of serialized data `value`. Returns the version as a positive integer or 0 for unknown versions. ### data, count = worldedit.serialize(pos1, pos2) Converts the region defined by positions `pos1` and `pos2` into a single string. Returns the serialized data and the number of nodes serialized. ### pos1, pos2, count = worldedit.allocate(originpos, value) Determines the volume the nodes represented by string `value` would occupy if deserialized at `originpos`. Returns the two corner positions and the number of nodes. ### count = worldedit.deserialize(originpos, value) Loads the nodes represented by string `value` at position `originpos`. Returns the number of nodes deserialized. Code ---- Contained in code.lua, this module allows arbitrary Lua code to be used with WorldEdit. ### error = worldedit.lua(code) Executes `code` as a Lua chunk in the global namespace. Returns an error if the code fails or nil otherwise. ### error = worldedit.luatransform(pos1, pos2, code) Executes `code` as a Lua chunk in the global namespace with the variable pos available, for each node in a region defined by positions `pos1` and `pos2`. Returns an error if the code fails or nil otherwise.MineTest-WorldEdit-0.6/modpack.txt000066400000000000000000000000001213726501500171510ustar00rootroot00000000000000MineTest-WorldEdit-0.6/worldedit/000077500000000000000000000000001213726501500170015ustar00rootroot00000000000000MineTest-WorldEdit-0.6/worldedit/code.lua000066400000000000000000000024411213726501500204170ustar00rootroot00000000000000worldedit = worldedit or {} --executes `code` as a Lua chunk in the global namespace, returning an error if the code fails or nil otherwise worldedit.lua = function(code) local operation, message = loadstring(code) if operation == nil then --code parsing failed return message end local status, message = pcall(operation) if status == nil then --operation failed return message end return nil end --executes `code` as a Lua chunk in the global namespace with the variable pos available, for each node in a region defined by positions `pos1` and `pos2`, returning an error if the code fails or nil otherwise worldedit.luatransform = function(pos1, pos2, code) local pos1, pos2 = worldedit.sort_pos(pos1, pos2) local factory, message = loadstring("return function(pos) " .. code .. " end") if factory == nil then --code parsing failed return message end local operation = factory() local pos = {x=pos1.x, y=0, z=0} while pos.x <= pos2.x do pos.y = pos1.y while pos.y <= pos2.y do pos.z = pos1.z while pos.z <= pos2.z do local status, message = pcall(operation, pos) if status == nil then --operation failed return message end pos.z = pos.z + 1 end pos.y = pos.y + 1 end pos.x = pos.x + 1 end return nil endMineTest-WorldEdit-0.6/worldedit/compatibility.lua000066400000000000000000000011721213726501500223560ustar00rootroot00000000000000worldedit = worldedit or {} worldedit.allocate_old = worldedit.allocate worldedit.deserialize_old = worldedit.deserialize worldedit.metasave = function(pos1, pos2, filename) local file, err = io.open(filename, "wb") if err then return 0 end local data, count = worldedit.serialize(pos1, pos2) file:write(data) file:close() return count end worldedit.metaload = function(originpos, filename) filename = minetest.get_worldpath() .. "/schems/" .. file .. ".wem" local file, err = io.open(filename, "wb") if err then return 0 end local data = file:read("*a") return worldedit.deserialize(originpos, data) endMineTest-WorldEdit-0.6/worldedit/init.lua000066400000000000000000000006371213726501500204550ustar00rootroot00000000000000local path = minetest.get_modpath("worldedit") local loadmodule = function(path) return pcall(function() dofile(path) end) end loadmodule(path .. "/manipulations.lua") loadmodule(path .. "/primitives.lua") loadmodule(path .. "/visualization.lua") loadmodule(path .. "/serialization.lua") loadmodule(path .. "/code.lua") loadmodule(path .. "/compatibility.lua") loadmodule(path .. "/queue.lua") MineTest-WorldEdit-0.6/worldedit/manipulations.lua000066400000000000000000000324261213726501500223760ustar00rootroot00000000000000worldedit = worldedit or {} --modifies positions `pos1` and `pos2` so that each component of `pos1` is less than or equal to its corresponding conent of `pos2`, returning two new positions worldedit.sort_pos = function(pos1, pos2) pos1 = {x=pos1.x, y=pos1.y, z=pos1.z} pos2 = {x=pos2.x, y=pos2.y, z=pos2.z} if pos1.x > pos2.x then pos2.x, pos1.x = pos1.x, pos2.x end if pos1.y > pos2.y then pos2.y, pos1.y = pos1.y, pos2.y end if pos1.z > pos2.z then pos2.z, pos1.z = pos1.z, pos2.z end return pos1, pos2 end --determines the volume of the region defined by positions `pos1` and `pos2`, returning the volume worldedit.volume = function(pos1, pos2) local pos1, pos2 = worldedit.sort_pos(pos1, pos2) return (pos2.x - pos1.x + 1) * (pos2.y - pos1.y + 1) * (pos2.z - pos1.z + 1) end --sets a region defined by positions `pos1` and `pos2` to `nodename`, returning the number of nodes filled worldedit.set = function(pos1, pos2, nodename, env) local pos1, pos2 = worldedit.sort_pos(pos1, pos2) if env == nil then env = minetest.env end local node = {name=nodename} local pos = {x=pos1.x, y=0, z=0} while pos.x <= pos2.x do pos.y = pos1.y while pos.y <= pos2.y do pos.z = pos1.z while pos.z <= pos2.z do env:add_node(pos, node) pos.z = pos.z + 1 end pos.y = pos.y + 1 end pos.x = pos.x + 1 end return worldedit.volume(pos1, pos2) end --replaces all instances of `searchnode` with `replacenode` in a region defined by positions `pos1` and `pos2`, returning the number of nodes replaced worldedit.replace = function(pos1, pos2, searchnode, replacenode, env) local pos1, pos2 = worldedit.sort_pos(pos1, pos2) if env == nil then env = minetest.env end if minetest.registered_nodes[searchnode] == nil then searchnode = "default:" .. searchnode end local pos = {x=pos1.x, y=0, z=0} local node = {name=replacenode} local count = 0 while pos.x <= pos2.x do pos.y = pos1.y while pos.y <= pos2.y do pos.z = pos1.z while pos.z <= pos2.z do if env:get_node(pos).name == searchnode then env:add_node(pos, node) count = count + 1 end pos.z = pos.z + 1 end pos.y = pos.y + 1 end pos.x = pos.x + 1 end return count end --replaces all nodes other than `searchnode` with `replacenode` in a region defined by positions `pos1` and `pos2`, returning the number of nodes replaced worldedit.replaceinverse = function(pos1, pos2, searchnode, replacenode, env) local pos1, pos2 = worldedit.sort_pos(pos1, pos2) if env == nil then env = minetest.env end if minetest.registered_nodes[searchnode] == nil then searchnode = "default:" .. searchnode end local pos = {x=pos1.x, y=0, z=0} local node = {name=replacenode} local count = 0 while pos.x <= pos2.x do pos.y = pos1.y while pos.y <= pos2.y do pos.z = pos1.z while pos.z <= pos2.z do local name = env:get_node(pos).name if name ~= "ignore" and name ~= searchnode then env:add_node(pos, node) count = count + 1 end pos.z = pos.z + 1 end pos.y = pos.y + 1 end pos.x = pos.x + 1 end return count end --copies the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") by `amount` nodes, returning the number of nodes copied worldedit.copy = function(pos1, pos2, axis, amount, env) local pos1, pos2 = worldedit.sort_pos(pos1, pos2) if env == nil then env = minetest.env end if amount < 0 then local pos = {x=pos1.x, y=0, z=0} while pos.x <= pos2.x do pos.y = pos1.y while pos.y <= pos2.y do pos.z = pos1.z while pos.z <= pos2.z do local node = env:get_node(pos) --obtain current node local meta = env:get_meta(pos):to_table() --get meta of current node local value = pos[axis] --store current position pos[axis] = value + amount --move along axis env:add_node(pos, node) --copy node to new position env:get_meta(pos):from_table(meta) --set metadata of new node pos[axis] = value --restore old position pos.z = pos.z + 1 end pos.y = pos.y + 1 end pos.x = pos.x + 1 end else local pos = {x=pos2.x, y=0, z=0} while pos.x >= pos1.x do pos.y = pos2.y while pos.y >= pos1.y do pos.z = pos2.z while pos.z >= pos1.z do local node = minetest.env:get_node(pos) --obtain current node local meta = env:get_meta(pos):to_table() --get meta of current node local value = pos[axis] --store current position pos[axis] = value + amount --move along axis minetest.env:add_node(pos, node) --copy node to new position env:get_meta(pos):from_table(meta) --set metadata of new node pos[axis] = value --restore old position pos.z = pos.z - 1 end pos.y = pos.y - 1 end pos.x = pos.x - 1 end end return worldedit.volume(pos1, pos2) end --moves the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") by `amount` nodes, returning the number of nodes moved worldedit.move = function(pos1, pos2, axis, amount, env) local pos1, pos2 = worldedit.sort_pos(pos1, pos2) if env == nil then env = minetest.env end if amount < 0 then local pos = {x=pos1.x, y=0, z=0} while pos.x <= pos2.x do pos.y = pos1.y while pos.y <= pos2.y do pos.z = pos1.z while pos.z <= pos2.z do local node = env:get_node(pos) --obtain current node local meta = env:get_meta(pos):to_table() --get metadata of current node env:remove_node(pos) local value = pos[axis] --store current position pos[axis] = value + amount --move along axis env:add_node(pos, node) --move node to new position env:get_meta(pos):from_table(meta) --set metadata of new node pos[axis] = value --restore old position pos.z = pos.z + 1 end pos.y = pos.y + 1 end pos.x = pos.x + 1 end else local pos = {x=pos2.x, y=0, z=0} while pos.x >= pos1.x do pos.y = pos2.y while pos.y >= pos1.y do pos.z = pos2.z while pos.z >= pos1.z do local node = env:get_node(pos) --obtain current node local meta = env:get_meta(pos):to_table() --get metadata of current node env:remove_node(pos) local value = pos[axis] --store current position pos[axis] = value + amount --move along axis env:add_node(pos, node) --move node to new position env:get_meta(pos):from_table(meta) --set metadata of new node pos[axis] = value --restore old position pos.z = pos.z - 1 end pos.y = pos.y - 1 end pos.x = pos.x - 1 end end return worldedit.volume(pos1, pos2) end --duplicates the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") `count` times, returning the number of nodes stacked worldedit.stack = function(pos1, pos2, axis, count, env) local pos1, pos2 = worldedit.sort_pos(pos1, pos2) local length = pos2[axis] - pos1[axis] + 1 if count < 0 then count = -count length = -length end local amount = 0 local copy = worldedit.copy for i = 1, count do amount = amount + length copy(pos1, pos2, axis, amount, env) end return worldedit.volume(pos1, pos2) end --transposes a region defined by the positions `pos1` and `pos2` between the `axis1` and `axis2` axes, returning the number of nodes transposed, the new position 1, and the new position 2 worldedit.transpose = function(pos1, pos2, axis1, axis2, env) local pos1, pos2 = worldedit.sort_pos(pos1, pos2) local compare local extent1, extent2 = pos2[axis1] - pos1[axis1], pos2[axis2] - pos1[axis2] if extent1 > extent2 then compare = function(extent1, extent2) return extent1 > extent2 end else compare = function(extent1, extent2) return extent1 < extent2 end end --calculate the new position 2 after transposition local newpos2 = {x=pos2.x, y=pos2.y, z=pos2.z} newpos2[axis1] = pos1[axis1] + extent2 newpos2[axis2] = pos1[axis2] + extent1 local pos = {x=pos1.x, y=0, z=0} if env == nil then env = minetest.env end while pos.x <= pos2.x do pos.y = pos1.y while pos.y <= pos2.y do pos.z = pos1.z while pos.z <= pos2.z do local extent1, extent2 = pos[axis1] - pos1[axis1], pos[axis2] - pos1[axis2] if compare(extent1, extent2) then --transpose only if below the diagonal local node1 = env:get_node(pos) local meta1 = env:get_meta(pos):to_table() local value1, value2 = pos[axis1], pos[axis2] --save position values pos[axis1], pos[axis2] = pos1[axis1] + extent2, pos1[axis2] + extent1 --swap axis extents local node2 = env:get_node(pos) local meta2 = env:get_meta(pos):to_table() env:add_node(pos, node1) env:get_meta(pos):from_table(meta1) pos[axis1], pos[axis2] = value1, value2 --restore position values env:add_node(pos, node2) env:get_meta(pos):from_table(meta2) end pos.z = pos.z + 1 end pos.y = pos.y + 1 end pos.x = pos.x + 1 end return worldedit.volume(pos1, pos2), pos1, newpos2 end --flips a region defined by the positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z"), returning the number of nodes flipped worldedit.flip = function(pos1, pos2, axis, env) local pos1, pos2 = worldedit.sort_pos(pos1, pos2) local pos = {x=pos1.x, y=0, z=0} local start = pos1[axis] + pos2[axis] pos2[axis] = pos1[axis] + math.floor((pos2[axis] - pos1[axis]) / 2) if env == nil then env = minetest.env end while pos.x <= pos2.x do pos.y = pos1.y while pos.y <= pos2.y do pos.z = pos1.z while pos.z <= pos2.z do local node1 = env:get_node(pos) local meta1 = env:get_meta(pos):to_table() local value = pos[axis] pos[axis] = start - value local node2 = env:get_node(pos) local meta2 = env:get_meta(pos):to_table() env:add_node(pos, node1) env:get_meta(pos):from_table(meta1) pos[axis] = value env:add_node(pos, node2) env:get_meta(pos):from_table(meta2) pos.z = pos.z + 1 end pos.y = pos.y + 1 end pos.x = pos.x + 1 end return worldedit.volume(pos1, pos2) end --rotates a region defined by the positions `pos1` and `pos2` by `angle` degrees clockwise around axis `axis` (90 degree increment), returning the number of nodes rotated worldedit.rotate = function(pos1, pos2, axis, angle, env) local pos1, pos2 = worldedit.sort_pos(pos1, pos2) local axis1, axis2 if axis == "x" then axis1, axis2 = "z", "y" elseif axis == "y" then axis1, axis2 = "x", "z" else --axis == "z" axis1, axis2 = "y", "x" end angle = angle % 360 local count if angle == 90 then worldedit.flip(pos1, pos2, axis1, env) count, pos1, pos2 = worldedit.transpose(pos1, pos2, axis1, axis2, env) elseif angle == 180 then worldedit.flip(pos1, pos2, axis1, env) count = worldedit.flip(pos1, pos2, axis2, env) elseif angle == 270 then worldedit.flip(pos1, pos2, axis2, env) count, pos1, pos2 = worldedit.transpose(pos1, pos2, axis1, axis2, env) end return count, pos1, pos2 end --rotates all oriented nodes in a region defined by the positions `pos1` and `pos2` by `angle` degrees clockwise (90 degree increment) around the Y axis, returning the number of nodes oriented worldedit.orient = function(pos1, pos2, angle, env) local pos1, pos2 = worldedit.sort_pos(pos1, pos2) local nodes = minetest.registered_nodes if env == nil then env = minetest.env end local wallmounted = { [90]={[0]=0, [1]=1, [2]=5, [3]=4, [4]=2, [5]=3}, [180]={[0]=0, [1]=1, [2]=3, [3]=2, [4]=5, [5]=4}, [270]={[0]=0, [1]=1, [2]=4, [3]=5, [4]=3, [5]=2} } local facedir = { [90]={[0]=1, [1]=2, [2]=3, [3]=0}, [180]={[0]=2, [1]=3, [2]=0, [3]=1}, [270]={[0]=3, [1]=0, [2]=1, [3]=2} } angle = angle % 360 if angle == 0 then return 0 end local wallmounted_substitution = wallmounted[angle] local facedir_substitution = facedir[angle] local count = 0 local pos = {x=pos1.x, y=0, z=0} while pos.x <= pos2.x do pos.y = pos1.y while pos.y <= pos2.y do pos.z = pos1.z while pos.z <= pos2.z do local node = env:get_node(pos) local def = nodes[node.name] if def then if def.paramtype2 == "wallmounted" then node.param2 = wallmounted_substitution[node.param2] local meta = env:get_meta(pos):to_table() env:add_node(pos, node) env:get_meta(pos):from_table(meta) count = count + 1 elseif def.paramtype2 == "facedir" then node.param2 = facedir_substitution[node.param2] local meta = env:get_meta(pos):to_table() env:add_node(pos, node) env:get_meta(pos):from_table(meta) count = count + 1 end end pos.z = pos.z + 1 end pos.y = pos.y + 1 end pos.x = pos.x + 1 end return count end --fixes the lighting in a region defined by positions `pos1` and `pos2`, returning the number of nodes updated worldedit.fixlight = function(pos1, pos2, env) local pos1, pos2 = worldedit.sort_pos(pos1, pos2) if env == nil then env = minetest.env end local count = 0 local pos = {x=pos1.x, y=0, z=0} while pos.x <= pos2.x do pos.y = pos1.y while pos.y <= pos2.y do pos.z = pos1.z while pos.z <= pos2.z do if env:get_node(pos).name == "air" then env:dig_node(pos) count = count + 1 end pos.z = pos.z + 1 end pos.y = pos.y + 1 end pos.x = pos.x + 1 end return count end MineTest-WorldEdit-0.6/worldedit/primitives.lua000066400000000000000000000230531213726501500217020ustar00rootroot00000000000000worldedit = worldedit or {} --adds a hollow sphere at `pos` with radius `radius`, composed of `nodename`, returning the number of nodes added worldedit.hollow_sphere = function(pos, radius, nodename, env) local node = {name=nodename} local pos1 = {x=0, y=0, z=0} local min_radius = radius * (radius - 1) local max_radius = radius * (radius + 1) local count = 0 if env == nil then env = minetest.env end for x = -radius, radius do pos1.x = pos.x + x for y = -radius, radius do pos1.y = pos.y + y for z = -radius, radius do if x*x+y*y+z*z >= min_radius and x*x+y*y+z*z <= max_radius then pos1.z = pos.z + z env:add_node(pos1, node) count = count + 1 end end end end return count end --adds a sphere at `pos` with radius `radius`, composed of `nodename`, returning the number of nodes added worldedit.sphere = function(pos, radius, nodename, env) local node = {name=nodename} local pos1 = {x=0, y=0, z=0} local max_radius = radius * (radius + 1) local count = 0 if env == nil then env = minetest.env end for x = -radius, radius do pos1.x = pos.x + x for y = -radius, radius do pos1.y = pos.y + y for z = -radius, radius do if x*x+y*y+z*z <= max_radius then pos1.z = pos.z + z env:add_node(pos1, node) count = count + 1 end end end end return count end --adds a hollow dome at `pos` with radius `radius`, composed of `nodename`, returning the number of nodes added worldedit.hollow_dome = function(pos, radius, nodename, env) --wip: use bresenham sphere for maximum speed local node = {name=nodename} local pos1 = {x=0, y=0, z=0} local min_radius = radius * (radius - 1) local max_radius = radius * (radius + 1) local count = 0 if env == nil then env = minetest.env end for x = -radius, radius do pos1.x = pos.x + x for y = 0, radius do pos1.y = pos.y + y for z = -radius, radius do if x*x+y*y+z*z >= min_radius and x*x+y*y+z*z <= max_radius then pos1.z = pos.z + z env:add_node(pos1, node) count = count + 1 end end end end return count end --adds a dome at `pos` with radius `radius`, composed of `nodename`, returning the number of nodes added worldedit.dome = function(pos, radius, nodename, env) --wip: use bresenham sphere for maximum speed local node = {name=nodename} local pos1 = {x=0, y=0, z=0} local max_radius = radius * (radius + 1) local count = 0 if env == nil then env = minetest.env end for x = -radius, radius do pos1.x = pos.x + x for y = 0, radius do pos1.y = pos.y + y for z = -radius, radius do if x*x+y*y+z*z <= max_radius then pos1.z = pos.z + z env:add_node(pos1, node) count = count + 1 end end end end return count end --adds a hollow cylinder at `pos` along the `axis` axis ("x" or "y" or "z") with length `length` and radius `radius`, composed of `nodename`, returning the number of nodes added worldedit.hollow_cylinder = function(pos, axis, length, radius, nodename, env) local other1, other2 if axis == "x" then other1, other2 = "y", "z" elseif axis == "y" then other1, other2 = "x", "z" else --axis == "z" other1, other2 = "x", "y" end if env == nil then env = minetest.env end local currentpos = {x=pos.x, y=pos.y, z=pos.z} local node = {name=nodename} local count = 0 local step = 1 if length < 0 then length = -length step = -1 end for i = 1, length do local offset1, offset2 = 0, radius local delta = -radius while offset1 <= offset2 do --add node at each octant local first1, first2 = pos[other1] + offset1, pos[other1] - offset1 local second1, second2 = pos[other2] + offset2, pos[other2] - offset2 currentpos[other1], currentpos[other2] = first1, second1 env:add_node(currentpos, node) --octant 1 currentpos[other1] = first2 env:add_node(currentpos, node) --octant 4 currentpos[other2] = second2 env:add_node(currentpos, node) --octant 5 currentpos[other1] = first1 env:add_node(currentpos, node) --octant 8 local first1, first2 = pos[other1] + offset2, pos[other1] - offset2 local second1, second2 = pos[other2] + offset1, pos[other2] - offset1 currentpos[other1], currentpos[other2] = first1, second1 env:add_node(currentpos, node) --octant 2 currentpos[other1] = first2 env:add_node(currentpos, node) --octant 3 currentpos[other2] = second2 env:add_node(currentpos, node) --octant 6 currentpos[other1] = first1 env:add_node(currentpos, node) --octant 7 count = count + 8 --wip: broken --move to next location delta = delta + (offset1 * 2) + 1 if delta >= 0 then offset2 = offset2 - 1 delta = delta - (offset2 * 2) end offset1 = offset1 + 1 end currentpos[axis] = currentpos[axis] + step end return count end --adds a cylinder at `pos` along the `axis` axis ("x" or "y" or "z") with length `length` and radius `radius`, composed of `nodename`, returning the number of nodes added worldedit.cylinder = function(pos, axis, length, radius, nodename, env) local other1, other2 if axis == "x" then other1, other2 = "y", "z" elseif axis == "y" then other1, other2 = "x", "z" else --axis == "z" other1, other2 = "x", "y" end if env == nil then env = minetest.env end local currentpos = {x=pos.x, y=pos.y, z=pos.z} local node = {name=nodename} local count = 0 local step = 1 if length < 0 then length = -length step = -1 end for i = 1, length do local offset1, offset2 = 0, radius local delta = -radius while offset1 <= offset2 do --connect each pair of octants currentpos[other1] = pos[other1] - offset1 local second1, second2 = pos[other2] + offset2, pos[other2] - offset2 for i = 0, offset1 * 2 do currentpos[other2] = second1 env:add_node(currentpos, node) --octant 1 to 4 currentpos[other2] = second2 env:add_node(currentpos, node) --octant 5 to 8 currentpos[other1] = currentpos[other1] + 1 end currentpos[other1] = pos[other1] - offset2 local second1, second2 = pos[other2] + offset1, pos[other2] - offset1 for i = 0, offset2 * 2 do currentpos[other2] = second1 env:add_node(currentpos, node) --octant 2 to 3 currentpos[other2] = second2 env:add_node(currentpos, node) --octant 6 to 7 currentpos[other1] = currentpos[other1] + 1 end count = count + (offset1 * 4) + (offset2 * 4) + 4 --wip: broken --move to next location delta = delta + (offset1 * 2) + 1 offset1 = offset1 + 1 if delta >= 0 then offset2 = offset2 - 1 delta = delta - (offset2 * 2) end end currentpos[axis] = currentpos[axis] + step end return count end --adds a pyramid at `pos` with height `height`, composed of `nodename`, returning the number of nodes added worldedit.pyramid = function(pos, height, nodename, env) local pos1x, pos1y, pos1z = pos.x - height, pos.y, pos.z - height local pos2x, pos2y, pos2z = pos.x + height, pos.y + height, pos.z + height local pos = {x=0, y=pos1y, z=0} local count = 0 local node = {name=nodename} if env == nil then env = minetest.env end while pos.y <= pos2y do --each vertical level of the pyramid pos.x = pos1x while pos.x <= pos2x do pos.z = pos1z while pos.z <= pos2z do env:add_node(pos, node) pos.z = pos.z + 1 end pos.x = pos.x + 1 end count = count + ((pos2y - pos.y) * 2 + 1) ^ 2 pos.y = pos.y + 1 pos1x, pos2x = pos1x + 1, pos2x - 1 pos1z, pos2z = pos1z + 1, pos2z - 1 end return count end --adds a spiral at `pos` with width `width`, height `height`, space between walls `spacer`, composed of `nodename`, returning the number of nodes added worldedit.spiral = function(pos, width, height, spacer, nodename, env) --wip: clean this up -- spiral matrix - http://rosettacode.org/wiki/Spiral_matrix#Lua av, sn = math.abs, function(s) return s~=0 and s/av(s) or 0 end local function sindex(z, x) -- returns the value at (x, z) in a spiral that starts at 1 and goes outwards if z == -x and z >= x then return (2*z+1)^2 end local l = math.max(av(z), av(x)) return (2*l-1)^2+4*l+2*l*sn(x+z)+sn(z^2-x^2)*(l-(av(z)==l and sn(z)*x or sn(x)*z)) -- OH GOD WHAT end local function spiralt(side) local ret, id, start, stop = {}, 0, math.floor((-side+1)/2), math.floor((side-1)/2) for i = 1, side do for j = 1, side do local id = side^2 - sindex(stop - i + 1,start + j - 1) ret[id] = {x=i,z=j} end end return ret end if env == nil then env = minetest.env end -- connect the joined parts local spiral = spiralt(width) height = tonumber(height) if height < 1 then height = 1 end spacer = tonumber(spacer)-1 if spacer < 1 then spacer = 1 end local count = 0 local node = {name=nodename} local np,lp for y=0,height do lp = nil for _,v in ipairs(spiral) do np = {x=pos.x+v.x*spacer, y=pos.y+y, z=pos.z+v.z*spacer} if lp~=nil then if lp.x~=np.x then if lp.x pos2.x then pos2.x, pos1.x = pos1.x, pos2.x end if pos1.y > pos2.y then pos2.y, pos1.y = pos1.y, pos2.y end if pos1.z > pos2.z then pos2.z, pos1.z = pos1.z, pos2.z end return pos1, pos2 end --determines the version of serialized data `value`, returning the version as a positive integer or 0 for unknown versions worldedit.valueversion = function(value) if value:find("([+-]?%d+)%s+([+-]?%d+)%s+([+-]?%d+)") and not value:find("%{") then --previous list format return 3 elseif value:find("^[^\"']+%{%d+%}") then if value:find("%[\"meta\"%]") then --previous meta flat table format return 2 end return 1 --original flat table format elseif value:find("%{") then --current nested table format return 4 end return 0 --unknown format end --converts the region defined by positions `pos1` and `pos2` into a single string, returning the serialized data and the number of nodes serialized worldedit.serialize = function(pos1, pos2) --wip: check for ItemStacks and whether they can be serialized local pos1, pos2 = worldedit.sort_pos(pos1, pos2) local pos = {x=pos1.x, y=0, z=0} local count = 0 local result = {} local env = minetest.env while pos.x <= pos2.x do pos.y = pos1.y while pos.y <= pos2.y do pos.z = pos1.z while pos.z <= pos2.z do local node = env:get_node(pos) if node.name ~= "air" and node.name ~= "ignore" then count = count + 1 local meta = env:get_meta(pos):to_table() --convert metadata itemstacks to itemstrings for name, inventory in pairs(meta.inventory) do for index, stack in ipairs(inventory) do inventory[index] = stack:to_string() end end result[count] = { x = pos.x - pos1.x, y = pos.y - pos1.y, z = pos.z - pos1.z, name = node.name, param1 = node.param1, param2 = node.param2, meta = meta, } end pos.z = pos.z + 1 end pos.y = pos.y + 1 end pos.x = pos.x + 1 end result = minetest.serialize(result) --convert entries to a string return result, count end --determines the volume the nodes represented by string `value` would occupy if deserialized at `originpos`, returning the two corner positions and the number of nodes --contains code based on [table.save/table.load](http://lua-users.org/wiki/SaveTableToFile) by ChillCode, available under the MIT license (GPL compatible) worldedit.allocate = function(originpos, value) local huge = math.huge local pos1x, pos1y, pos1z = huge, huge, huge local pos2x, pos2y, pos2z = -huge, -huge, -huge local originx, originy, originz = originpos.x, originpos.y, originpos.z local count = 0 local version = worldedit.valueversion(value) if version == 1 or version == 2 then --flat table format --obtain the node table local get_tables = loadstring(value) if get_tables then --error loading value return originpos, originpos, count end local tables = get_tables() --transform the node table into an array of nodes for i = 1, #tables do for j, v in pairs(tables[i]) do if type(v) == "table" then tables[i][j] = tables[v[1]] end end end local nodes = tables[1] --check the node array count = #nodes if version == 1 then --original flat table format for index = 1, count do local entry = nodes[index] local pos = entry[1] local x, y, z = originx - pos.x, originy - pos.y, originz - pos.z if x < pos1x then pos1x = x end if y < pos1y then pos1y = y end if z < pos1z then pos1z = z end if x > pos2x then pos2x = x end if y > pos2y then pos2y = y end if z > pos2z then pos2z = z end end else --previous meta flat table format for index = 1, count do local entry = nodes[index] local x, y, z = originx - entry.x, originy - entry.y, originz - entry.z if x < pos1x then pos1x = x end if y < pos1y then pos1y = y end if z < pos1z then pos1z = z end if x > pos2x then pos2x = x end if y > pos2y then pos2y = y end if z > pos2z then pos2z = z end end end elseif version == 3 then --previous list format for x, y, z, name, param1, param2 in value:gmatch("([+-]?%d+)%s+([+-]?%d+)%s+([+-]?%d+)%s+([^%s]+)%s+(%d+)%s+(%d+)[^\r\n]*[\r\n]*") do --match node entries x, y, z = originx + tonumber(x), originy + tonumber(y), originz + tonumber(z) if x < pos1x then pos1x = x end if y < pos1y then pos1y = y end if z < pos1z then pos1z = z end if x > pos2x then pos2x = x end if y > pos2y then pos2y = y end if z > pos2z then pos2z = z end count = count + 1 end elseif version == 4 then --current nested table format local nodes = minetest.deserialize(value) count = #nodes for index = 1, count do local entry = nodes[index] x, y, z = originx + entry.x, originy + entry.y, originz + entry.z if x < pos1x then pos1x = x end if y < pos1y then pos1y = y end if z < pos1z then pos1z = z end if x > pos2x then pos2x = x end if y > pos2y then pos2y = y end if z > pos2z then pos2z = z end end end local pos1 = {x=pos1x, y=pos1y, z=pos1z} local pos2 = {x=pos2x, y=pos2y, z=pos2z} return pos1, pos2, count end --loads the nodes represented by string `value` at position `originpos`, returning the number of nodes deserialized --contains code based on [table.save/table.load](http://lua-users.org/wiki/SaveTableToFile) by ChillCode, available under the MIT license (GPL compatible) worldedit.deserialize = function(originpos, value, env) local originx, originy, originz = originpos.x, originpos.y, originpos.z local count = 0 if env == nil then env = minetest.env end local version = worldedit.valueversion(value) if version == 1 or version == 2 then --original flat table format --obtain the node table local get_tables = loadstring(value) if not get_tables then --error loading value return count end local tables = get_tables() --transform the node table into an array of nodes for i = 1, #tables do for j, v in pairs(tables[i]) do if type(v) == "table" then tables[i][j] = tables[v[1]] end end end local nodes = tables[1] --load the node array count = #nodes if version == 1 then --original flat table format for index = 1, count do local entry = nodes[index] local pos = entry[1] pos.x, pos.y, pos.z = originx - pos.x, originy - pos.y, originz - pos.z env:add_node(pos, entry[2]) end else --previous meta flat table format for index = 1, #nodes do local entry = nodes[index] entry.x, entry.y, entry.z = originx + entry.x, originy + entry.y, originz + entry.z env:add_node(entry, entry) --entry acts both as position and as node env:get_meta(entry):from_table(entry.meta) end end elseif version == 3 then --previous list format local pos = {x=0, y=0, z=0} local node = {name="", param1=0, param2=0} for x, y, z, name, param1, param2 in value:gmatch("([+-]?%d+)%s+([+-]?%d+)%s+([+-]?%d+)%s+([^%s]+)%s+(%d+)%s+(%d+)[^\r\n]*[\r\n]*") do --match node entries pos.x = originx + tonumber(x) pos.y = originy + tonumber(y) pos.z = originz + tonumber(z) node.name = name node.param1 = param1 node.param2 = param2 env:add_node(pos, node) count = count + 1 end elseif version == 4 then --current nested table format --wip: this is a filthy hack that works surprisingly well value = value:gsub("return%s*{", "", 1):gsub("}%s*$", "", 1) local escaped = value:gsub("\\\\", "@@"):gsub("\\\"", "@@"):gsub("(\"[^\"]+\")", function(s) return string.rep("@", #s) end) local startpos, startpos1, endpos = 1, 1 local nodes = {} while true do startpos, endpos = escaped:find("},%s*{", startpos) if not startpos then break end local current = value:sub(startpos1, startpos) table.insert(nodes, minetest.deserialize("return " .. current)) startpos, startpos1 = endpos, endpos end --local nodes = minetest.deserialize(value) --wip: this is broken for larger tables in the current version of LuaJIT count = #nodes for index = 1, count do local entry = nodes[index] entry.x, entry.y, entry.z = originx + entry.x, originy + entry.y, originz + entry.z env:add_node(entry, entry) --entry acts both as position and as node env:get_meta(entry):from_table(entry.meta) end end return count end MineTest-WorldEdit-0.6/worldedit/visualization.lua000066400000000000000000000140331213726501500224060ustar00rootroot00000000000000worldedit = worldedit or {} --modifies positions `pos1` and `pos2` so that each component of `pos1` is less than or equal to its corresponding conent of `pos2`, returning two new positions worldedit.sort_pos = function(pos1, pos2) pos1 = {x=pos1.x, y=pos1.y, z=pos1.z} pos2 = {x=pos2.x, y=pos2.y, z=pos2.z} if pos1.x > pos2.x then pos2.x, pos1.x = pos1.x, pos2.x end if pos1.y > pos2.y then pos2.y, pos1.y = pos1.y, pos2.y end if pos1.z > pos2.z then pos2.z, pos1.z = pos1.z, pos2.z end return pos1, pos2 end --determines the volume of the region defined by positions `pos1` and `pos2`, returning the volume worldedit.volume = function(pos1, pos2) local pos1, pos2 = worldedit.sort_pos(pos1, pos2) return (pos2.x - pos1.x + 1) * (pos2.y - pos1.y + 1) * (pos2.z - pos1.z + 1) end minetest.register_node("worldedit:placeholder", { drawtype = "airlike", paramtype = "light", sunlight_propagates = true, diggable = false, groups = {not_in_creative_inventory=1}, }) --hides all nodes in a region defined by positions `pos1` and `pos2` by non-destructively replacing them with invisible nodes, returning the number of nodes hidden worldedit.hide = function(pos1, pos2, tenv) local pos1, pos2 = worldedit.sort_pos(pos1, pos2) if env == nil then env = minetest.env end local pos = {x=pos1.x, y=0, z=0} local placeholder = {name="worldedit:placeholder", param1=0, param2=0} while pos.x <= pos2.x do pos.y = pos1.y while pos.y <= pos2.y do pos.z = pos1.z while pos.z <= pos2.z do local node = env:get_node(pos) placeholder.param1, placeholder.param2 = node.param1, node.param2 --copy node's param1 and param2 local data = env:get_meta(pos):to_table() --obtain metadata of original node env:add_node(pos, placeholder) --add placeholder node local meta = env:get_meta(pos) --obtain placeholder meta meta:from_table(data) --set placeholder metadata to the original node's metadata meta:set_string("worldedit_placeholder", node.name) --add the node's name pos.z = pos.z + 1 end pos.y = pos.y + 1 end pos.x = pos.x + 1 end return worldedit.volume(pos1, pos2) end --suppresses all instances of `nodename` in a region defined by positions `pos1` and `pos2` by non-destructively replacing them with invisible nodes, returning the number of nodes suppressed worldedit.suppress = function(pos1, pos2, nodename, tenv) local pos1, pos2 = worldedit.sort_pos(pos1, pos2) if env == nil then env = minetest.env end if minetest.registered_nodes[nodename] == nil then nodename = "default:" .. nodename end local pos = {x=pos1.x, y=0, z=0} local placeholder = {name="worldedit:placeholder", param1=0, param2=0} local count = 0 while pos.x <= pos2.x do pos.y = pos1.y while pos.y <= pos2.y do pos.z = pos1.z while pos.z <= pos2.z do local node = env:get_node(pos) if node.name == nodename then placeholder.param1, placeholder.param2 = node.param1, node.param2 --copy node's param1 and param2 local data = env:get_meta(pos):to_table() --obtain metadata of original node env:add_node(pos, placeholder) --add placeholder node local meta = env:get_meta(pos) --obtain placeholder meta meta:from_table(data) --set placeholder metadata to the original node's metadata meta:set_string("worldedit_placeholder", nodename) --add the node's name count = count + 1 end pos.z = pos.z + 1 end pos.y = pos.y + 1 end pos.x = pos.x + 1 end return count end --highlights all instances of `nodename` in a region defined by positions `pos1` and `pos2` by non-destructively hiding all other nodes, returning the number of nodes found worldedit.highlight = function(pos1, pos2, nodename, tenv) local pos1, pos2 = worldedit.sort_pos(pos1, pos2) if env == nil then env = minetest.env end if minetest.registered_nodes[nodename] == nil then nodename = "default:" .. nodename end local pos = {x=pos1.x, y=0, z=0} local placeholder = {name="worldedit:placeholder", param1=0, param2=0} local count = 0 while pos.x <= pos2.x do pos.y = pos1.y while pos.y <= pos2.y do pos.z = pos1.z while pos.z <= pos2.z do local node = env:get_node(pos) if node.name == nodename then --node found count = count + 1 else --hide other nodes placeholder.param1, placeholder.param2 = node.param1, node.param2 --copy node's param1 and param2 local data = env:get_meta(pos):to_table() --obtain metadata of original node env:add_node(pos, placeholder) --add placeholder node local meta = env:get_meta(pos) --obtain placeholder meta meta:from_table(data) --set placeholder metadata to the original node's metadata meta:set_string("worldedit_placeholder", node.name) --add the node's name end pos.z = pos.z + 1 end pos.y = pos.y + 1 end pos.x = pos.x + 1 end return count end --restores all nodes hidden with WorldEdit functions in a region defined by positions `pos1` and `pos2`, returning the number of nodes restored worldedit.restore = function(pos1, pos2, tenv) local pos1, pos2 = worldedit.sort_pos(pos1, pos2) if env == nil then env = minetest.env end local pos = {x=pos1.x, y=0, z=0} local node = {name="", param1=0, param2=0} local count = 0 while pos.x <= pos2.x do pos.y = pos1.y while pos.y <= pos2.y do pos.z = pos1.z while pos.z <= pos2.z do local currentnode = env:get_node(pos) if currentnode.name == "worldedit:placeholder" then node.param1, node.param2 = currentnode.param1, currentnode.param2 --copy node's param1 and param2 local data = env:get_meta(pos):to_table() --obtain node metadata node.name = data.fields.worldedit_placeholder --set node name data.fields.worldedit_placeholder = nil --delete old nodename env:add_node(pos, node) --add original node env:get_meta(pos):from_table(data) --set original node metadata count = count + 1 end pos.z = pos.z + 1 end pos.y = pos.y + 1 end pos.x = pos.x + 1 end return count end MineTest-WorldEdit-0.6/worldedit_commands/000077500000000000000000000000001213726501500206625ustar00rootroot00000000000000MineTest-WorldEdit-0.6/worldedit_commands/depends.txt000066400000000000000000000000111213726501500230350ustar00rootroot00000000000000worldeditMineTest-WorldEdit-0.6/worldedit_commands/init.lua000066400000000000000000001020221213726501500223250ustar00rootroot00000000000000minetest.register_privilege("worldedit", "Can use WorldEdit commands") worldedit.set_pos = {} worldedit.pos1 = {} worldedit.pos2 = {} dofile(minetest.get_modpath("worldedit_commands") .. "/mark.lua") --determines whether `nodename` is a valid node name, returning a boolean worldedit.node_is_valid = function(nodename) return minetest.registered_nodes[nodename] ~= nil or minetest.registered_nodes["default:" .. nodename] ~= nil end --determines the axis in which a player is facing, returning an axis ("x", "y", or "z") and the sign (1 or -1) worldedit.player_axis = function(name) local dir = minetest.env:get_player_by_name(name):get_look_dir() local x, y, z = math.abs(dir.x), math.abs(dir.y), math.abs(dir.z) if x > y then if x > z then return "x", dir.x > 0 and 1 or -1 end elseif y > z then return "y", dir.y > 0 and 1 or -1 end return "z", dir.z > 0 and 1 or -1 end minetest.register_chatcommand("/reset", { params = "", description = "Reset the region so that it is empty", privs = {worldedit=true}, func = function(name, param) worldedit.pos1[name] = nil worldedit.pos2[name] = nil worldedit.mark_pos1(name) worldedit.mark_pos2(name) minetest.chat_send_player(name, "WorldEdit region reset", false) end, }) minetest.register_chatcommand("/mark", { params = "", description = "Show markers at the region positions", privs = {worldedit=true}, func = function(name, param) worldedit.mark_pos1(name) worldedit.mark_pos2(name) minetest.chat_send_player(name, "WorldEdit region marked", false) end, }) minetest.register_chatcommand("/pos1", { params = "", description = "Set WorldEdit region position 1 to the player's location", privs = {worldedit=true}, func = function(name, param) local pos = minetest.env:get_player_by_name(name):getpos() pos.x, pos.y, pos.z = math.floor(pos.x + 0.5), math.floor(pos.y + 0.5), math.floor(pos.z + 0.5) worldedit.pos1[name] = pos worldedit.mark_pos1(name) minetest.chat_send_player(name, "WorldEdit position 1 set to " .. minetest.pos_to_string(pos), false) end, }) minetest.register_chatcommand("/pos2", { params = "", description = "Set WorldEdit region position 2 to the player's location", privs = {worldedit=true}, func = function(name, param) local pos = minetest.env:get_player_by_name(name):getpos() pos.x, pos.y, pos.z = math.floor(pos.x + 0.5), math.floor(pos.y + 0.5), math.floor(pos.z + 0.5) worldedit.pos2[name] = pos worldedit.mark_pos2(name) minetest.chat_send_player(name, "WorldEdit position 2 set to " .. minetest.pos_to_string(pos), false) end, }) minetest.register_chatcommand("/p", { params = "set/set1/set2/get", description = "Set WorldEdit region, WorldEdit position 1, or WorldEdit position 2 by punching nodes, or display the current WorldEdit region", privs = {worldedit=true}, func = function(name, param) if param == "set" then --set both WorldEdit positions worldedit.set_pos[name] = "pos1" minetest.chat_send_player(name, "Select positions by punching two nodes", false) elseif param == "set1" then --set WorldEdit position 1 worldedit.set_pos[name] = "pos1only" minetest.chat_send_player(name, "Select position 1 by punching a node", false) elseif param == "set2" then --set WorldEdit position 2 worldedit.set_pos[name] = "pos2" minetest.chat_send_player(name, "Select position 2 by punching a node", false) elseif param == "get" then --display current WorldEdit positions if worldedit.pos1[name] ~= nil then minetest.chat_send_player(name, "WorldEdit position 1: " .. minetest.pos_to_string(worldedit.pos1[name]), false) else minetest.chat_send_player(name, "WorldEdit position 1 not set", false) end if worldedit.pos2[name] ~= nil then minetest.chat_send_player(name, "WorldEdit position 2: " .. minetest.pos_to_string(worldedit.pos2[name]), false) else minetest.chat_send_player(name, "WorldEdit position 2 not set", false) end else minetest.chat_send_player(name, "Unknown subcommand: " .. param, false) end end, }) minetest.register_on_punchnode(function(pos, node, puncher) local name = puncher:get_player_name() if name ~= "" and worldedit.set_pos[name] ~= nil then --currently setting position if worldedit.set_pos[name] == "pos1" then --setting position 1 worldedit.pos1[name] = pos worldedit.mark_pos1(name) worldedit.set_pos[name] = "pos2" --set position 2 on the next invocation minetest.chat_send_player(name, "WorldEdit position 1 set to " .. minetest.pos_to_string(pos), false) elseif worldedit.set_pos[name] == "pos1only" then --setting position 1 only worldedit.pos1[name] = pos worldedit.mark_pos1(name) worldedit.set_pos[name] = nil --finished setting positions minetest.chat_send_player(name, "WorldEdit position 1 set to " .. minetest.pos_to_string(pos), false) elseif worldedit.set_pos[name] == "pos2" then --setting position 2 worldedit.pos2[name] = pos worldedit.mark_pos2(name) worldedit.set_pos[name] = nil --finished setting positions minetest.chat_send_player(name, "WorldEdit position 2 set to " .. minetest.pos_to_string(pos), false) end end end) minetest.register_chatcommand("/volume", { params = "", description = "Display the volume of the current WorldEdit region", privs = {worldedit=true}, func = function(name, param) local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] if pos1 == nil or pos2 == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end local volume = worldedit.volume(pos1, pos2) minetest.chat_send_player(name, "Current WorldEdit region has a volume of " .. volume .. " nodes (" .. pos2.x - pos1.x .. "*" .. pos2.y - pos1.y .. "*" .. pos2.z - pos1.z .. ")", false) end, }) minetest.register_chatcommand("/set", { params = "", description = "Set the current WorldEdit region to ", privs = {worldedit=true}, func = function(name, param) local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] if pos1 == nil or pos2 == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end if param == "" or not worldedit.node_is_valid(param) then minetest.chat_send_player(name, "Invalid node name: " .. param, false) return end local tenv = minetest.env if worldedit.ENABLE_QUEUE then tenv = worldedit.quene_aliasenv end local count = worldedit.set(pos1, pos2, param, tenv) minetest.chat_send_player(name, count .. " nodes set", false) end, }) minetest.register_chatcommand("/replace", { params = " ", description = "Replace all instances of with in the current WorldEdit region", privs = {worldedit=true}, func = function(name, param) local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] if pos1 == nil or pos2 == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end local found, _, searchnode, replacenode = param:find("^([^%s]+)%s+([^%s]+)$") if found == nil then minetest.chat_send_player(name, "Invalid usage: " .. param, false) return end if not worldedit.node_is_valid(searchnode) then minetest.chat_send_player(name, "Invalid search node name: " .. searchnode, false) return end if not worldedit.node_is_valid(replacenode) then minetest.chat_send_player(name, "Invalid replace node name: " .. replacenode, false) return end local tenv = minetest.env if worldedit.ENABLE_QUEUE then tenv = worldedit.quene_aliasenv end local count = worldedit.replace(pos1, pos2, searchnode, replacenode, tenv) minetest.chat_send_player(name, count .. " nodes replaced", false) end, }) minetest.register_chatcommand("/replaceinverse", { params = " ", description = "Replace all nodes other than with in the current WorldEdit region", privs = {worldedit=true}, func = function(name, param) local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] if pos1 == nil or pos2 == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end local found, _, searchnode, replacenode = param:find("^([^%s]+)%s+([^%s]+)$") if found == nil then minetest.chat_send_player(name, "Invalid usage: " .. param, false) return end if not worldedit.node_is_valid(searchnode) then minetest.chat_send_player(name, "Invalid search node name: " .. searchnode, false) return end if not worldedit.node_is_valid(replacenode) then minetest.chat_send_player(name, "Invalid replace node name: " .. replacenode, false) return end local tenv = minetest.env if worldedit.ENABLE_QUEUE then tenv = worldedit.quene_aliasenv end local count = worldedit.replaceinverse(pos1, pos2, searchnode, replacenode, tenv) minetest.chat_send_player(name, count .. " nodes replaced", false) end, }) minetest.register_chatcommand("/hollowsphere", { params = " ", description = "Add hollow sphere at WorldEdit position 1 with radius , composed of ", privs = {worldedit=true}, func = function(name, param) local pos = worldedit.pos1[name] if pos == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end local found, _, radius, nodename = param:find("^(%d+)%s+([^%s]+)$") if found == nil then minetest.chat_send_player(name, "Invalid usage: " .. param, false) return end if not worldedit.node_is_valid(nodename) then minetest.chat_send_player(name, "Invalid node name: " .. param, false) return end local tenv = minetest.env if worldedit.ENABLE_QUEUE then tenv = worldedit.quene_aliasenv end local count = worldedit.hollow_sphere(pos, tonumber(radius), nodename, tenv) minetest.chat_send_player(name, count .. " nodes added", false) end, }) minetest.register_chatcommand("/sphere", { params = " ", description = "Add sphere at WorldEdit position 1 with radius , composed of ", privs = {worldedit=true}, func = function(name, param) local pos = worldedit.pos1[name] if pos == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end local found, _, radius, nodename = param:find("^(%d+)%s+([^%s]+)$") if found == nil then minetest.chat_send_player(name, "Invalid usage: " .. param, false) return end if not worldedit.node_is_valid(nodename) then minetest.chat_send_player(name, "Invalid node name: " .. param, false) return end local tenv = minetest.env if worldedit.ENABLE_QUEUE then tenv = worldedit.quene_aliasenv end local count = worldedit.sphere(pos, tonumber(radius), nodename, tenv) minetest.chat_send_player(name, count .. " nodes added", false) end, }) minetest.register_chatcommand("/hollowdome", { params = " ", description = "Add hollow dome at WorldEdit position 1 with radius , composed of ", privs = {worldedit=true}, func = function(name, param) local pos = worldedit.pos1[name] if pos == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end local found, _, radius, nodename = param:find("^(%d+)%s+([^%s]+)$") if found == nil then minetest.chat_send_player(name, "Invalid usage: " .. param, false) return end if not worldedit.node_is_valid(nodename) then minetest.chat_send_player(name, "Invalid node name: " .. param, false) return end local tenv = minetest.env if worldedit.ENABLE_QUEUE then tenv = worldedit.quene_aliasenv end local count = worldedit.hollow_dome(pos, tonumber(radius), nodename, tenv) minetest.chat_send_player(name, count .. " nodes added", false) end, }) minetest.register_chatcommand("/dome", { params = " ", description = "Add dome at WorldEdit position 1 with radius , composed of ", privs = {worldedit=true}, func = function(name, param) local pos = worldedit.pos1[name] if pos == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end local found, _, radius, nodename = param:find("^(%d+)%s+([^%s]+)$") if found == nil then minetest.chat_send_player(name, "Invalid usage: " .. param, false) return end if not worldedit.node_is_valid(nodename) then minetest.chat_send_player(name, "Invalid node name: " .. param, false) return end local tenv = minetest.env if worldedit.ENABLE_QUEUE then tenv = worldedit.quene_aliasenv end local count = worldedit.dome(pos, tonumber(radius), nodename, tenv) minetest.chat_send_player(name, count .. " nodes added", false) end, }) minetest.register_chatcommand("/hollowcylinder", { params = "x/y/z/? ", description = "Add hollow cylinder at WorldEdit position 1 along the x/y/z/? axis with length and radius , composed of ", privs = {worldedit=true}, func = function(name, param) local pos = worldedit.pos1[name] if pos == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end local found, _, axis, length, radius, nodename = param:find("^([xyz%?])%s+([+-]?%d+)%s+(%d+)%s+([^%s]+)$") if found == nil then minetest.chat_send_player(name, "Invalid usage: " .. param, false) return end if axis == "?" then axis, sign = worldedit.player_axis(name) length = length * sign end if not worldedit.node_is_valid(nodename) then minetest.chat_send_player(name, "Invalid node name: " .. param, false) return end local tenv = minetest.env if worldedit.ENABLE_QUEUE then tenv = worldedit.quene_aliasenv end local count = worldedit.hollow_cylinder(pos, axis, tonumber(length), tonumber(radius), nodename, tenv) minetest.chat_send_player(name, count .. " nodes added", false) end, }) minetest.register_chatcommand("/cylinder", { params = "x/y/z/? ", description = "Add cylinder at WorldEdit position 1 along the x/y/z/? axis with length and radius , composed of ", privs = {worldedit=true}, func = function(name, param) local pos = worldedit.pos1[name] if pos == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end local found, _, axis, length, radius, nodename = param:find("^([xyz%?])%s+([+-]?%d+)%s+(%d+)%s+([^%s]+)$") if found == nil then minetest.chat_send_player(name, "Invalid usage: " .. param, false) return end if axis == "?" then axis, sign = worldedit.player_axis(name) length = length * sign end if not worldedit.node_is_valid(nodename) then minetest.chat_send_player(name, "Invalid node name: " .. param, false) return end local tenv = minetest.env if worldedit.ENABLE_QUEUE then tenv = worldedit.quene_aliasenv end local count = worldedit.cylinder(pos, axis, tonumber(length), tonumber(radius), nodename, tenv) minetest.chat_send_player(name, count .. " nodes added", false) end, }) minetest.register_chatcommand("/pyramid", { params = " ", description = "Add pyramid at WorldEdit position 1 with height , composed of ", privs = {worldedit=true}, func = function(name, param) local pos = worldedit.pos1[name] if pos == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end local found, _, size, nodename = param:find("(%d+)%s+([^%s]+)$") if found == nil then minetest.chat_send_player(name, "Invalid usage: " .. param, false) return end if not worldedit.node_is_valid(nodename) then minetest.chat_send_player(name, "Invalid node name: " .. param, false) return end local tenv = minetest.env if worldedit.ENABLE_QUEUE then tenv = worldedit.quene_aliasenv end local count = worldedit.pyramid(pos, tonumber(size), nodename, tenv) minetest.chat_send_player(name, count .. " nodes added", false) end, }) minetest.register_chatcommand("/spiral", { params = " ", description = "Add spiral at WorldEdit position 1 with width , height , space between walls , composed of ", privs = {worldedit=true}, func = function(name, param) local pos = worldedit.pos1[name] if pos == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end local found, _, width, height, space, nodename = param:find("(%d+)%s+(%d+)%s+(%d+)%s+([^%s]+)$") if found == nil then minetest.chat_send_player(name, "Invalid usage: " .. param, false) return end if not worldedit.node_is_valid(nodename) then minetest.chat_send_player(name, "Invalid node name: " .. param, false) return end local tenv = minetest.env if worldedit.ENABLE_QUEUE then tenv = worldedit.quene_aliasenv end local count = worldedit.spiral(pos, tonumber(width), tonumber(height), tonumber(space), nodename, tenv) minetest.chat_send_player(name, count .. " nodes changed", false) end, }) minetest.register_chatcommand("/copy", { params = "x/y/z/? ", description = "Copy the current WorldEdit region along the x/y/z/? axis by nodes", privs = {worldedit=true}, func = function(name, param) local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] if pos1 == nil or pos2 == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end local found, _, axis, amount = param:find("^([xyz%?])%s+([+-]?%d+)$") if found == nil then minetest.chat_send_player(name, "Invalid usage: " .. param, false) return end if axis == "?" then axis, sign = worldedit.player_axis(name) amount = amount * sign end local tenv = minetest.env if worldedit.ENABLE_QUEUE then tenv = worldedit.quene_aliasenv end local count = worldedit.copy(pos1, pos2, axis, tonumber(amount), tenv) minetest.chat_send_player(name, count .. " nodes copied", false) end, }) minetest.register_chatcommand("/move", { params = "x/y/z/? ", description = "Move the current WorldEdit region along the x/y/z/? axis by nodes", privs = {worldedit=true}, func = function(name, param) local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] if pos1 == nil or pos2 == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end local found, _, axis, amount = param:find("^([xyz%?])%s+([+-]?%d+)$") if found == nil then minetest.chat_send_player(name, "Invalid usage: " .. param, false) return end if axis == "?" then axis, sign = worldedit.player_axis(name) amount = amount * sign end local count = worldedit.move(pos1, pos2, axis, tonumber(amount)) pos1[axis] = pos1[axis] + amount pos2[axis] = pos2[axis] + amount worldedit.mark_pos1(name) worldedit.mark_pos2(name) local tenv = minetest.env if worldedit.ENABLE_QUEUE then tenv = worldedit.quene_aliasenv end local count = worldedit.copy(pos1, pos2, axis, tonumber(amount), tenv) minetest.chat_send_player(name, count .. " nodes moved", false) end, }) minetest.register_chatcommand("/stack", { params = "x/y/z/? ", description = "Stack the current WorldEdit region along the x/y/z/? axis times", privs = {worldedit=true}, func = function(name, param) local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] if pos1 == nil or pos2 == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end local found, _, axis, count = param:find("^([xyz%?])%s+([+-]?%d+)$") if found == nil then minetest.chat_send_player(name, "Invalid usage: " .. param, false) return end if axis == "?" then axis, sign = worldedit.player_axis(name) count = count * sign end local tenv = minetest.env if worldedit.ENABLE_QUEUE then tenv = worldedit.quene_aliasenv end local count = worldedit.stack(pos1, pos2, axis, tonumber(count), tenv) minetest.chat_send_player(name, count .. " nodes stacked", false) end, }) minetest.register_chatcommand("/transpose", { params = "x/y/z/? x/y/z/?", description = "Transpose the current WorldEdit region along the x/y/z/? and x/y/z/? axes", privs = {worldedit=true}, func = function(name, param) local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] if pos1 == nil or pos2 == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end local found, _, axis1, axis2 = param:find("^([xyz%?])%s+([xyz%?])$") if found == nil then minetest.chat_send_player(name, "Invalid usage: " .. param, false) return end if axis1 == "?" then axis1 = worldedit.player_axis(name) end if axis2 == "?" then axis2 = worldedit.player_axis(name) end if axis1 == axis2 then minetest.chat_send_player(name, "Invalid usage: axes are the same", false) return end local tenv = minetest.env if worldedit.ENABLE_QUEUE then tenv = worldedit.quene_aliasenv end local count, pos1, pos2 = worldedit.transpose(pos1, pos2, axis1, axis2, tenv) --reset markers to transposed positions worldedit.pos1[name] = pos1 worldedit.pos2[name] = pos2 worldedit.mark_pos1(name) worldedit.mark_pos2(name) minetest.chat_send_player(name, count .. " nodes transposed", false) end, }) minetest.register_chatcommand("/flip", { params = "x/y/z/?", description = "Flip the current WorldEdit region along the x/y/z/? axis", privs = {worldedit=true}, func = function(name, param) local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] if pos1 == nil or pos2 == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end if param == "?" then param = worldedit.player_axis(name) end if param ~= "x" and param ~= "y" and param ~= "z" then minetest.chat_send_player(name, "Invalid usage: " .. param, false) return end local tenv = minetest.env if worldedit.ENABLE_QUEUE then tenv = worldedit.quene_aliasenv end local count = worldedit.flip(pos1, pos2, param, tenv) minetest.chat_send_player(name, count .. " nodes flipped", false) end, }) minetest.register_chatcommand("/rotate", { params = " ", description = "Rotate the current WorldEdit region around the axis by angle (90 degree increment)", privs = {worldedit=true}, func = function(name, param) local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] if pos1 == nil or pos2 == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end local found, _, axis, angle = param:find("^([xyz%?])%s+([+-]?%d+)$") if found == nil then minetest.chat_send_player(name, "Invalid usage: " .. param, false) return end if axis == "?" then axis = worldedit.player_axis(name) end if angle % 90 ~= 0 then minetest.chat_send_player(name, "Invalid usage: angle must be multiple of 90", false) return end local tenv = minetest.env if worldedit.ENABLE_QUEUE then tenv = worldedit.quene_aliasenv end local count, pos1, pos2 = worldedit.rotate(pos1, pos2, axis, angle, tenv) --reset markers to rotated positions worldedit.pos1[name] = pos1 worldedit.pos2[name] = pos2 worldedit.mark_pos1(name) worldedit.mark_pos2(name) minetest.chat_send_player(name, count .. " nodes rotated", false) end, }) minetest.register_chatcommand("/orient", { params = "", description = "Rotate oriented nodes in the current WorldEdit region around the Y axis by angle (90 degree increment)", privs = {worldedit=true}, func = function(name, param) local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] if pos1 == nil or pos2 == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end local found, _, angle = param:find("^([+-]?%d+)$") if found == nil then minetest.chat_send_player(name, "Invalid usage: " .. param, false) return end if angle % 90 ~= 0 then minetest.chat_send_player(name, "Invalid usage: angle must be multiple of 90", false) return end local tenv = minetest.env if worldedit.ENABLE_QUEUE then tenv = worldedit.quene_aliasenv end local count = worldedit.orient(pos1, pos2, angle, tenv) minetest.chat_send_player(name, count .. " nodes oriented", false) end, }) minetest.register_chatcommand("/fixlight", { params = "", description = "Fix the lighting in the current WorldEdit region", privs = {worldedit=true}, func = function(name, param) local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] if pos1 == nil or pos2 == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end local tenv = minetest.env if worldedit.ENABLE_QUEUE then tenv = worldedit.quene_aliasenv end local count = worldedit.fixlight(pos1, pos2, tenv) minetest.chat_send_player(name, count .. " nodes updated", false) end, }) minetest.register_chatcommand("/hide", { params = "", description = "Hide all nodes in the current WorldEdit region non-destructively", privs = {worldedit=true}, func = function(name, param) local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] if pos1 == nil or pos2 == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end local tenv = minetest.env if worldedit.ENABLE_QUEUE then tenv = worldedit.quene_aliasenv end local count = worldedit.hide(pos1, pos2, tenv) minetest.chat_send_player(name, count .. " nodes hidden", false) end, }) minetest.register_chatcommand("/suppress", { params = "", description = "Suppress all in the current WorldEdit region non-destructively", privs = {worldedit=true}, func = function(name, param) local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] if pos1 == nil or pos2 == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end if param == "" or not worldedit.node_is_valid(param) then minetest.chat_send_player(name, "Invalid node name: " .. param, false) return end local tenv = minetest.env if worldedit.ENABLE_QUEUE then tenv = worldedit.quene_aliasenv end local count = worldedit.suppress(pos1, pos2, param, tenv) minetest.chat_send_player(name, count .. " nodes suppressed", false) end, }) minetest.register_chatcommand("/highlight", { params = "", description = "Highlight in the current WorldEdit region by hiding everything else non-destructively", privs = {worldedit=true}, func = function(name, param) local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] if pos1 == nil or pos2 == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end if param == "" or not worldedit.node_is_valid(param) then minetest.chat_send_player(name, "Invalid node name: " .. param, false) return end local tenv = minetest.env if worldedit.ENABLE_QUEUE then tenv = worldedit.quene_aliasenv end local count = worldedit.highlight(pos1, pos2, param, tenv) minetest.chat_send_player(name, count .. " nodes highlighted", false) end, }) minetest.register_chatcommand("/restore", { params = "", description = "Restores nodes hidden with WorldEdit in the current WorldEdit region", privs = {worldedit=true}, func = function(name, param) local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] if pos1 == nil or pos2 == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end local tenv = minetest.env if worldedit.ENABLE_QUEUE then tenv = worldedit.quene_aliasenv end local count = worldedit.restore(pos1, pos2, tenv) minetest.chat_send_player(name, count .. " nodes restored", false) end, }) minetest.register_chatcommand("/save", { params = "", description = "Save the current WorldEdit region to \"(world folder)/schems/.we\"", privs = {worldedit=true}, func = function(name, param) local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] if pos1 == nil or pos2 == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end if param == "" then minetest.chat_send_player(name, "Invalid usage: " .. param, false) return end local result, count = worldedit.serialize(pos1, pos2) local path = minetest.get_worldpath() .. "/schems" local filename = path .. "/" .. param .. ".we" os.execute("mkdir \"" .. path .. "\"") --create directory if it does not already exist local file, err = io.open(filename, "wb") if err ~= nil then minetest.chat_send_player(name, "Could not save file to \"" .. filename .. "\"", false) return end file:write(result) file:flush() file:close() minetest.chat_send_player(name, count .. " nodes saved", false) end, }) minetest.register_chatcommand("/allocate", { params = "", description = "Set the region defined by nodes from \"(world folder)/schems/.we\" as the current WorldEdit region", privs = {worldedit=true}, func = function(name, param) local pos1 = worldedit.pos1[name] if pos1 == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end if param == "" then minetest.chat_send_player(name, "Invalid usage: " .. param, false) return end local filename = minetest.get_worldpath() .. "/schems/" .. param .. ".we" local file, err = io.open(filename, "rb") if err ~= nil then minetest.chat_send_player(name, "Could not open file \"" .. filename .. "\"", false) return end local value = file:read("*a") file:close() if worldedit.valueversion(value) == 0 then --unknown version minetest.chat_send_player(name, "Invalid file: file is invalid or created with newer version of WorldEdit", false) return end local nodepos1, nodepos2, count = worldedit.allocate(pos1, value) worldedit.pos1[name] = nodepos1 worldedit.mark_pos1(name) worldedit.pos2[name] = nodepos2 worldedit.mark_pos2(name) minetest.chat_send_player(name, count .. " nodes allocated", false) end, }) minetest.register_chatcommand("/load", { params = "", description = "Load nodes from \"(world folder)/schems/[.we[m]]\" with position 1 of the current WorldEdit region as the origin", privs = {worldedit=true}, func = function(name, param) local pos1 = worldedit.pos1[name] if pos1 == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end if param == "" then minetest.chat_send_player(name, "Invalid usage: " .. param, false) return end --find the file in the world path local testpaths = { minetest.get_worldpath() .. "/schems/" .. param, minetest.get_worldpath() .. "/schems/" .. param .. ".we", minetest.get_worldpath() .. "/schems/" .. param .. ".wem", } local file, err for index, path in ipairs(testpaths) do file, err = io.open(path, "rb") if not err then break end end if err then minetest.chat_send_player(name, "Could not open file \"" .. param .. "\"", false) return end local value = file:read("*a") file:close() if worldedit.valueversion(value) == 0 then --unknown version minetest.chat_send_player(name, "Invalid file: file is invalid or created with newer version of WorldEdit", false) return end local tenv = minetest.env if worldedit.ENABLE_QUEUE then tenv = worldedit.quene_aliasenv end local count = worldedit.deserialize(pos1, value, tenv) minetest.chat_send_player(name, count .. " nodes loaded", false) end, }) minetest.register_chatcommand("/lua", { params = "", description = "Executes as a Lua chunk in the global namespace", privs = {worldedit=true, server=true}, func = function(name, param) local err = worldedit.lua(param) if err then minetest.chat_send_player(name, "Code error: " .. err, false) else minetest.chat_send_player(name, "Code successfully executed", false) end end, }) minetest.register_chatcommand("/luatransform", { params = "", description = "Executes as a Lua chunk in the global namespace with the variable pos available, for each node in the current WorldEdit region", privs = {worldedit=true, server=true}, func = function(name, param) local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] if pos1 == nil or pos2 == nil then minetest.chat_send_player(name, "No WorldEdit region selected", false) return end local err = worldedit.luatransform(pos1, pos2, param) if err then minetest.chat_send_player(name, "Code error: " .. err, false) else minetest.chat_send_player(name, "Code successfully executed", false) end end, }) MineTest-WorldEdit-0.6/worldedit_commands/mark.lua000066400000000000000000000041201213726501500223140ustar00rootroot00000000000000worldedit.marker1 = {} worldedit.marker2 = {} --marks worldedit region position 1 worldedit.mark_pos1 = function(name) local pos = worldedit.pos1[name] if worldedit.marker1[name] ~= nil then --marker already exists worldedit.marker1[name]:remove() --remove marker worldedit.marker1[name] = nil end if pos ~= nil then --add marker worldedit.marker1[name] = minetest.env:add_entity(pos, "worldedit:pos1") worldedit.marker1[name]:get_luaentity().active = true end end --marks worldedit region position 2 worldedit.mark_pos2 = function(name) local pos = worldedit.pos2[name] if worldedit.marker2[name] ~= nil then --marker already exists worldedit.marker2[name]:remove() --remove marker worldedit.marker2[name] = nil end if pos ~= nil then --add marker worldedit.marker2[name] = minetest.env:add_entity(pos, "worldedit:pos2") worldedit.marker2[name]:get_luaentity().active = true end end minetest.register_entity(":worldedit:pos1", { initial_properties = { visual = "cube", visual_size = {x=1.1, y=1.1}, textures = {"worldedit_pos1.png", "worldedit_pos1.png", "worldedit_pos1.png", "worldedit_pos1.png", "worldedit_pos1.png", "worldedit_pos1.png"}, collisionbox = {-0.55, -0.55, -0.55, 0.55, 0.55, 0.55}, }, on_step = function(self, dtime) if self.active == nil then self.object:remove() end end, on_punch = function(self, hitter) self.object:remove() local name = hitter:get_player_name() worldedit.marker1[name] = nil end, }) minetest.register_entity(":worldedit:pos2", { initial_properties = { visual = "cube", visual_size = {x=1.1, y=1.1}, textures = {"worldedit_pos2.png", "worldedit_pos2.png", "worldedit_pos2.png", "worldedit_pos2.png", "worldedit_pos2.png", "worldedit_pos2.png"}, collisionbox = {-0.55, -0.55, -0.55, 0.55, 0.55, 0.55}, }, on_step = function(self, dtime) if self.active == nil then self.object:remove() end end, on_punch = function(self, hitter) self.object:remove() local name = hitter:get_player_name() worldedit.marker2[name] = nil end, })MineTest-WorldEdit-0.6/worldedit_commands/textures/000077500000000000000000000000001213726501500225455ustar00rootroot00000000000000MineTest-WorldEdit-0.6/worldedit_commands/textures/worldedit_pos1.png000066400000000000000000000002161213726501500262110ustar00rootroot00000000000000PNG  IHDRa pHYs(J@IDAT8cd``@!ĀLDkJ\R/0B1a0 `!2#.}\H0`4; k%IENDB`MineTest-WorldEdit-0.6/worldedit_commands/textures/worldedit_pos2.png000066400000000000000000000002351213726501500262130ustar00rootroot00000000000000PNG  IHDRa pHYs(JOIDAT8˵ BL$gyPT* Ø &kA4)b@]طKDO'Z IENDB`