diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000..2be56e8 --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,27 @@ +unused_args = false +allow_defined_top = true + +read_globals = { + "DIR_DELIM", + "minetest", + "dump", + "vector", + "VoxelManip", "VoxelArea", + "PseudoRandom", "PcgRandom", + "ItemStack", + "Settings", + "unpack", + -- Silence errors about custom table methods. + table = { fields = { "copy", "indexof" } }, + -- Silence warnings about accessing undefined fields of global 'math' + math = { fields = { "sign" } } +} + +-- Overwrites minetest.handle_node_drops +files["mods/creative/init.lua"].globals = { "minetest" } + +-- Overwrites minetest.calculate_knockback +files["mods/player_api/api.lua"].globals = { "minetest" } + +-- Don't report on legacy definitions of globals. +files["mods/default/legacy.lua"].global = false diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..a367215 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: generic +addons: + apt: + packages: + - luarocks +before_install: + - luarocks install --local luacheck +script: +- $HOME/.luarocks/bin/luacheck ./mods +notifications: + email: false diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..48f0b8d --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,519 @@ +License of media (textures and sounds) +-------------------------------------- +Copyright (C) 2010-2012 celeron55, Perttu Ahola +See README.txt in each mod directory for information about other authors. + +Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) +http://creativecommons.org/licenses/by-sa/3.0/ + +License of menu/header.png +Copyright (C) 2015 paramat CC BY-SA 3.0 + + +License of source code +---------------------- +Copyright (C) 2010-2012 celeron55, Perttu Ahola +See README.txt in each mod directory for information about other authors. + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/game.conf b/game.conf new file mode 100644 index 0000000..7c8ac2c --- /dev/null +++ b/game.conf @@ -0,0 +1,3 @@ +name = Minetest Game +author = Minetest +description = A basic exploration, mining, crafting and building sandbox game with no NPCs, monsters or animals. Minetest Game is usually used with mods added and many mods are available for this game. Reliably maintained by Minetest Engine core developers. diff --git a/game_api.txt b/game_api.txt new file mode 100644 index 0000000..bddf7e2 --- /dev/null +++ b/game_api.txt @@ -0,0 +1,1084 @@ +Minetest Game API +================= +GitHub Repo: https://github.com/minetest/minetest_game + + +Introduction +------------ + +The Minetest Game game offers multiple new possibilities in addition to the Minetest engine's built-in API, +allowing you to add new plants to farming mod, buckets for new liquids, new stairs and custom panes. +For information on the Minetest API, visit https://github.com/minetest/minetest/blob/master/doc/lua_api.txt +Please note: + + * [XYZ] refers to a section the Minetest API + * [#ABC] refers to a section in this document + * [pos] refers to a position table `{x = -5, y = 0, z = 200}` + + +Bucket API +---------- + +The bucket API allows registering new types of buckets for non-default liquids. + + bucket.register_liquid( + "default:lava_source", -- name of the source node + "default:lava_flowing", -- name of the flowing node + "bucket:bucket_lava", -- name of the new bucket item (or nil if liquid is not takeable) + "bucket_lava.png", -- texture of the new bucket item (ignored if itemname == nil) + "Lava Bucket", -- text description of the bucket item + {lava_bucket = 1}, -- groups of the bucket item, OPTIONAL + false -- force-renew, OPTIONAL. Force the liquid source to renew if it has + -- a source neighbour, even if defined as 'liquid_renewable = false'. + -- Needed to avoid creating holes in sloping rivers. + ) + +The filled bucket item is returned to the player that uses an empty bucket pointing to the given liquid source. +When punching with an empty bucket pointing to an entity or a non-liquid node, the on_punch of the entity or node will be triggered. + + +Beds API +-------- + + beds.register_bed( + "beds:bed", -- Bed name + def -- See [#Bed definition] + ) + + * `beds.can_dig(bed_pos)` Returns a boolean whether the bed at `bed_pos` may be dug + * `beds.read_spawns() ` Returns a table containing players respawn positions + * `beds.kick_players()` Forces all players to leave bed + * `beds.skip_night()` Sets world time to morning and saves respawn position of all players currently sleeping + +### Bed definition + + { + description = "Simple Bed", + inventory_image = "beds_bed.png", + wield_image = "beds_bed.png", + tiles = { + bottom = {'Tile definition'}, -- the tiles of the bottom part of the bed. + top = {Tile definition} -- the tiles of the bottom part of the bed. + }, + nodebox = { + bottom = 'regular nodebox', -- bottom part of bed (see [Node boxes]) + top = 'regular nodebox', -- top part of bed (see [Node boxes]) + }, + selectionbox = 'regular nodebox', -- for both nodeboxes (see [Node boxes]) + recipe = { -- Craft recipe + {"group:wool", "group:wool", "group:wool"}, + {"group:wood", "group:wood", "group:wood"} + } + } + + +Bones API +--------- + +An ordered list of listnames (default: "main", "craft") of the player inventory, +that will be placed into bones or dropped on player death can be looked up or changed +in `bones.player_inventory_lists`. + +e.g. `table.insert(bones.player_inventory_lists, "backpack")` + + +Creative API +------------ + +Use `creative.register_tab(name, title, items)` to add a tab with filtered items. +For example, + + creative.register_tab("tools", "Tools", minetest.registered_tools) + +is used to show all tools. Name is used in the sfinv page name, title is the +human readable title. + +Creative provides `creative.is_enabled_for(name)`, which is identical in +functionality to the engine's `minetest.creative_is_enabled(name)`. +Its use is deprecated and it should also not be overriden. + +The contents of `creative.formspec_add` is appended to every creative inventory +page. Mods can use it to add additional formspec elements onto the default +creative inventory formspec to be drawn after each update. + +Group overrides can be used for any registered item, node or tool. Use one of +the groups stated below to pick which category it will appear in. + + node = 1 -- Appears in the Nodes category + tool = 1 -- Appears in the Tools category + craftitem = 1 -- Appears in the Items category + + +Chests API +---------- + +The chests API allows the creation of chests, which have their own inventories for holding items. + +`default.chest.get_chest_formspec(pos)` + + * Returns a formspec for a specific chest. + * `pos` Location of the chest node, e.g `{x = 1, y = 1, z = 1}` + +`default.chest.chest_lid_obstructed(pos)` + + * Returns a boolean depending on whether or not a chest has its top obstructed by a solid node. + * `pos` Location of the chest node, e.g `{x = 1, y = 1, z = 1}` + +`default.chest.chest_lid_close(pn)` + + * Closes the chest that a player is currently looking in. + * `pn` The name of the player whose chest is going to be closed + +`default.chest.open_chests` + + * A table indexed by player name to keep track of who opened what chest. + * Key: The name of the player. + * Value: A table containing information about the chest the player is looking at. + e.g `{ pos = {1, 1, 1}, sound = null, swap = "default:chest" }` + +`default.chest.register_chest(name, def)` + + * Registers new chest + * `name` Name for chest e.g. "default:chest" + * `def` See [#Chest Definition] + +### Chest Definition + + description = "Chest", + tiles = { + "default_chest_top.png", + "default_chest_top.png", + "default_chest_side.png", + "default_chest_side.png", + "default_chest_front.png", + "default_chest_inside.png" + }, -- Textures which are applied to the chest model. + sounds = default.node_sound_wood_defaults(), + sound_open = "default_chest_open", + sound_close = "default_chest_close", + groups = {choppy = 2, oddly_breakable_by_hand = 2}, + protected = false, -- If true, only placer can modify chest. + + +Doors API +--------- + +The doors mod allows modders to register custom doors and trapdoors. + +`doors.registered_doors[name] = Door definition` + * Table of registered doors, indexed by door name + +`doors.registered_trapdoors[name] = Trapdoor definition` + * Table of registered trap doors, indexed by trap door name + +`doors.register_door(name, def)` + + * Registers new door + * `name` Name for door + * `def` See [#Door definition] + +`doors.register_trapdoor(name, def)` + + * Registers new trapdoor + * `name` Name for trapdoor + * `def` See [#Trapdoor definition] + +`doors.register_fencegate(name, def)` + + * Registers new fence gate + * `name` Name for fence gate + * `def` See [#Fence gate definition] + +`doors.get(pos)` + + * `pos` A position as a table, e.g `{x = 1, y = 1, z = 1}` + * Returns an ObjectRef to a door, or nil if the position does not contain a door + + ### Methods + + :open(player) -- Open the door object, returns if door was opened + :close(player) -- Close the door object, returns if door was closed + :toggle(player) -- Toggle the door state, returns if state was toggled + :state() -- returns the door state, true = open, false = closed + + the "player" parameter can be omitted in all methods. If passed then + the usual permission checks will be performed to make sure the player + has the permissions needed to open this door. If omitted then no + permission checks are performed. + +`doors.door_toggle(pos, node, clicker)` + + * Toggle door open or shut + * `pos` Position of the door + * `node` Node definition + * `clicker` Player definition for the player that clicked on the door + +### Door definition + + description = "Door description", + inventory_image = "mod_door_inv.png", + groups = {choppy = 2}, + tiles = {"mod_door.png"}, -- UV map. + -- The front and back of the door must be identical in appearence as they swap on + -- open/close. + recipe = craftrecipe, + sounds = default.node_sound_wood_defaults(), -- optional + sound_open = sound play for open door, -- optional + sound_close = sound play for close door, -- optional + protected = false, -- If true, only placer can open the door (locked for others) + on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) + -- optional function containing the on_rightclick callback, defaults to a doors.door_toggle-wrapper + +### Trapdoor definition + + description = "Trapdoor description", + inventory_image = "mod_trapdoor_inv.png", + groups = {choppy = 2}, + tile_front = "doors_trapdoor.png", -- the texture for the front and back of the trapdoor + tile_side = "doors_trapdoor_side.png", + -- The texture for the four sides of the trapdoor. + -- The texture should have the trapdoor side drawn twice, in the lowest and highest + -- 1/8ths of the texture, both upright. The area between is not used. + -- The lower 1/8th will be used for the closed trapdoor, the higher 1/8th will be used + -- for the open trapdoor. + sounds = default.node_sound_wood_defaults(), -- optional + sound_open = sound play for open door, -- optional + sound_close = sound play for close door, -- optional + protected = false, -- If true, only placer can open the door (locked for others) + on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) + -- function containing the on_rightclick callback + on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) + -- function containing the on_rightclick callback + +### Fence gate definition + + description = "Wooden Fence Gate", + texture = "default_wood.png", -- `backface_culling` will automatically be + -- set to `true` if not specified. + material = "default:wood", + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, + sounds = default.node_sound_wood_defaults(), -- optional + on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) + -- function containing the on_rightclick callback + + +Dungeon Loot API +---------------- + +The mod that places chests with loot in dungeons provides an API to register additional loot. + +`dungeon_loot.register(def)` + + * Registers one or more loot items + * `def` Can be a single [#Loot definition] or a list of them + +`dungeon_loot.registered_loot` + + * Table of all registered loot, not to be modified manually + +### Loot definition + + name = "item:name", + chance = 0.5, + -- ^ chance value from 0.0 to 1.0 that the item will appear in the chest when chosen + -- Due to an extra step in the selection process, 0.5 does not(!) mean that + -- on average every second chest will have this item + count = {1, 4}, + -- ^ table with minimum and maximum amounts of this item + -- optional, defaults to always single item + y = {-32768, -512}, + -- ^ table with minimum and maximum heights this item can be found at + -- optional, defaults to no height restrictions + types = {"desert"}, + -- ^ table with types of dungeons this item can be found in + -- supported types: "normal" (the cobble/mossycobble one), "sandstone" + -- "desert" and "ice" + -- optional, defaults to no type restrictions + + +Fence API +--------- + +Allows creation of new fences with "fencelike" drawtype. + +`default.register_fence(name, item definition)` + + Registers a new fence. Custom fields texture and material are required, as + are name and description. The rest is optional. You can pass most normal + nodedef fields here except drawtype. The fence group will always be added + for this node. + +### fence definition + + name = "default:fence_wood", + description = "Wooden Fence", + texture = "default_wood.png", + material = "default:wood", + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, + sounds = default.node_sound_wood_defaults(), + + +Walls API +--------- + +The walls API allows easy addition of stone auto-connecting wall nodes. + +walls.register(name, desc, texture, mat, sounds) +^ name = "walls:stone_wall". Node name. +^ desc = "A Stone wall" +^ texture = "default_stone.png" +^ mat = "default:stone". Used to auto-generate crafting recipe. +^ sounds = sounds: see [#Default sounds] + + +Farming API +----------- + +The farming API allows you to easily register plants and hoes. + +`farming.register_hoe(name, hoe definition)` + * Register a new hoe, see [#hoe definition] + +`farming.register_plant(name, Plant definition)` + * Register a new growing plant, see [#Plant definition] + +`farming.registered_plants[name] = definition` + * Table of registered plants, indexed by plant name + +### Hoe Definition + + + { + description = "", -- Description for tooltip + inventory_image = "unknown_item.png", -- Image to be used as wield- and inventory image + max_uses = 30, -- Uses until destroyed + material = "", -- Material for recipes + recipe = { -- Craft recipe, if material isn't used + {"air", "air", "air"}, + {"", "group:stick"}, + {"", "group:stick"}, + } + } + +### Plant definition + + { + description = "", -- Description of seed item + harvest_description = "", -- Description of harvest item + -- (optional, derived automatically if not provided) + inventory_image = "unknown_item.png", -- Image to be used as seed's wield- and inventory image + steps = 8, -- How many steps the plant has to grow, until it can be harvested + -- ^ Always provide a plant texture for each step, format: modname_plantname_i.png (i = stepnumber) + minlight = 13, -- Minimum light to grow + maxlight = default.LIGHT_MAX -- Maximum light to grow + } + + +Fire API +-------- + +Add group flammable when registering a node to make fire seek for it. +Add it to an item to make it burn up when dropped in lava or fire. +New node def property: + +`on_burn(pos)` + + * Called when fire attempts to remove a burning node. + * `pos` Position of the burning node. + + `on_ignite(pos, igniter)` + + * Called when Flint and steel (or a mod defined ignitor) is used on a node. + Defining it may prevent the default action (spawning flames) from triggering. + * `pos` Position of the ignited node. + * `igniter` Player that used the tool, when available. + + +Give Initial Stuff API +---------------------- + +`give_initial_stuff.give(player)` + +^ Give initial stuff to "player" + +`give_initial_stuff.add(stack)` + +^ Add item to the initial stuff +^ Stack can be an ItemStack or a item name eg: "default:dirt 99" +^ Can be called after the game has loaded + +`give_initial_stuff.clear()` + +^ Removes all items from the initial stuff +^ Can be called after the game has loaded + +`give_initial_stuff.get_list()` + +^ returns list of item stacks + +`give_initial_stuff.set_list(list)` + +^ List of initial items with numeric indices. + +`give_initial_stuff.add_from_csv(str)` + +^ str is a comma separated list of initial stuff +^ Adds items to the list of items to be given + + +Player API +---------- + +The player API can register player models and update the player's appearance. + +* `player_api.register_model(name, def)` + * Register a new model to be used by players + * `name`: model filename such as "character.x", "foo.b3d", etc. + * `def`: see [#Model definition] + * Saved to player_api.registered_models + +* `player_api.registered_models[name]` + * Get a model's definition + * `name`: model filename + * See [#Model definition] + +* `player_api.set_model(player, model_name)` + * Change a player's model + * `player`: PlayerRef + * `model_name`: model registered with player_api.register_model() + +* `player_api.set_animation(player, anim_name, speed)` + * Applies an animation to a player + * `player`: PlayerRef + * `anim_name`: name of the animation + * `speed`: frames per second. If nil, the default from the model def is used + +* `player_api.set_textures(player, textures)` + * Sets player textures + * `player`: PlayerRef + * `textures`: array of textures. If nil, the default from the model def is used + +* `player_api.get_animation(player)` + * Returns a table containing fields `model`, `textures` and `animation` + * Any of the fields of the returned table may be nil + * `player`: PlayerRef + +* `player_api.player_attached` + * A table that maps a player name to a boolean + * If the value for a given player is set to true, the default player animations + (walking, digging, ...) will no longer be updated, and knockback from damage is + prevented for that player + * Example of usage: A mod sets a player's value to true when attached to a vehicle + +### Model Definition + + { + animation_speed = 30, -- Default animation speed, in FPS + textures = {"character.png", }, -- Default array of textures + visual_size = {x = 1, y = 1}, -- Used to scale the model + animations = { + -- = {x = , y = }, + foo = {x = 0, y = 19}, + bar = {x = 20, y = 39}, + -- ... + }, + collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3}, -- In nodes from feet position + stepheight = 0.6, -- In nodes + eye_height = 1.47, -- In nodes above feet position + } + + +TNT API +------- + +`tnt.register_tnt(definition)` + +^ Register a new type of tnt. + + * `name` The name of the node. If no prefix is given `tnt` is used. + * `description` A description for your TNT. + * `radius` The radius within which the TNT can destroy nodes. The default is 3. + * `damage_radius` The radius within which the TNT can damage players and mobs. By default it is twice the `radius`. + * `sound` The sound played when explosion occurs. By default it is `tnt_explode`. + * `disable_drops` Disable drops. By default it is set to false. + * `ignore_protection` Don't check `minetest.is_protected` before removing a node. + * `ignore_on_blast` Don't call `on_blast` even if a node has one. + * `tiles` Textures for node + * `side` Side tiles. By default the name of the tnt with a suffix of `_side.png`. + * `top` Top tile. By default the name of the tnt with a suffix of `_top.png`. + * `bottom` Bottom tile. By default the name of the tnt with a suffix of `_bottom.png`. + * `burning` Top tile when lit. By default the name of the tnt with a suffix of `_top_burning_animated.png". + +`tnt.boom(position[, definition])` + +^ Create an explosion. + +* `position` The center of explosion. +* `definition` The TNT definion as passed to `tnt.register` with the following addition: + * `explode_center` false by default which removes TNT node on blast, when true will explode center node. + +`tnt.burn(position, [nodename])` + +^ Ignite node at position, triggering its `on_ignite` callback (see fire mod). +If no such callback exists, fallback to turn tnt group nodes to their +"_burning" variant. + nodename isn't required unless already known. + +To make dropping items from node inventories easier, you can use the +following helper function from 'default': + +default.get_inventory_drops(pos, inventory, drops) + +^ Return drops from node inventory "inventory" in drops. + +* `pos` - the node position +* `inventory` - the name of the inventory (string) +* `drops` - an initialized list + +The function returns no values. The drops are returned in the `drops` +parameter, and drops is not reinitialized so you can call it several +times in a row to add more inventory items to it. + + +`on_blast` callbacks: + +Both nodedefs and entitydefs can provide an `on_blast()` callback + +`nodedef.on_blast(pos, intensity)` +^ Allow drop and node removal overriding +* `pos` - node position +* `intensity` - TNT explosion measure. larger or equal to 1.0 +^ Should return a list of drops (e.g. {"default:stone"}) +^ Should perform node removal itself. If callback exists in the nodedef +^ then the TNT code will not destroy this node. + +`entitydef.on_blast(luaobj, damage)` +^ Allow TNT effects on entities to be overridden +* `luaobj` - LuaEntityRef of the entity +* `damage` - suggested HP damage value +^ Should return a list of (bool do_damage, bool do_knockback, table drops) +* `do_damage` - if true then TNT mod wil damage the entity +* `do_knockback` - if true then TNT mod will knock the entity away +* `drops` - a list of drops, e.g. {"wool:red"} + + +Screwdriver API +--------------- + +The screwdriver API allows you to control a node's behaviour when a screwdriver is used on it. +To use it, add the `on_screwdriver` function to the node definition. + +`on_rotate(pos, node, user, mode, new_param2)` + + * `pos` Position of the node that the screwdriver is being used on + * `node` that node + * `user` The player who used the screwdriver + * `mode` screwdriver.ROTATE_FACE or screwdriver.ROTATE_AXIS + * `new_param2` the new value of param2 that would have been set if on_rotate wasn't there + * return value: false to disallow rotation, nil to keep default behaviour, true to allow + it but to indicate that changed have already been made (so the screwdriver will wear out) + * use `on_rotate = false` to always disallow rotation + * use `on_rotate = screwdriver.rotate_simple` to allow only face rotation + + +Sethome API +----------- + +The sethome API adds three global functions to allow mods to read a players home position, +set a players home position and teleport a player to home position. + +`sethome.get(name)` + + * `name` Player who's home position you wish to get + * return value: false if no player home coords exist, position table if true + +`sethome.set(name, pos)` + + * `name` Player who's home position you wish to set + * `pos` Position table containing coords of home position + * return value: false if unable to set and save new home position, otherwise true + +`sethome.go(name)` + + * `name` Player you wish to teleport to their home position + * return value: false if player cannot be sent home, otherwise true + + +Sfinv API +--------- + +It is recommended that you read this link for a good introduction to the +sfinv API by its author: https://rubenwardy.com/minetest_modding_book/en/chapters/sfinv.html + +### sfinv Methods + +**Pages** + +* sfinv.set_page(player, pagename) - changes the page +* sfinv.get_page(player) - get the current page name. Will never return nil +* sfinv.get_homepage_name(player) - get the page name of the first page to show to a player +* sfinv.register_page(name, def) - register a page, see section below +* sfinv.override_page(name, def) - overrides fields of an page registered with register_page. + * Note: Page must already be defined, (opt)depend on the mod defining it. +* sfinv.set_player_inventory_formspec(player) - (re)builds page formspec + and calls set_inventory_formspec(). +* sfinv.get_formspec(player, context) - builds current page's formspec + +**Contexts** + +* sfinv.get_or_create_context(player) - gets the player's context +* sfinv.set_context(player, context) + +**Theming** + +* sfinv.make_formspec(player, context, content, show_inv, size) - adds a theme to a formspec + * show_inv, defaults to false. Whether to show the player's main inventory + * size, defaults to `size[8,8.6]` if not specified +* sfinv.get_nav_fs(player, context, nav, current_idx) - creates tabheader or "" + +### sfinv Members + +* pages - table of pages[pagename] = def +* pages_unordered - array table of pages in order of addition (used to build navigation tabs). +* contexts - contexts[playername] = player_context +* enabled - set to false to disable. Good for inventory rehaul mods like unified inventory + +### Context + +A table with these keys: + +* page - current page name +* nav - a list of page names +* nav_titles - a list of page titles +* nav_idx - current nav index (in nav and nav_titles) +* any thing you want to store + * sfinv will clear the stored data on log out / log in + +### sfinv.register_page + +sfinv.register_page(name, def) + +def is a table containing: + +* `title` - human readable page name (required) +* `get(self, player, context)` - returns a formspec string. See formspec variables. (required) +* `is_in_nav(self, player, context)` - return true to show in the navigation (the tab header, by default) +* `on_player_receive_fields(self, player, context, fields)` - on formspec submit. +* `on_enter(self, player, context)` - called when the player changes pages, usually using the tabs. +* `on_leave(self, player, context)` - when leaving this page to go to another, called before other's on_enter + +### get formspec + +Use sfinv.make_formspec to apply a layout: + + return sfinv.make_formspec(player, context, [[ + list[current_player;craft;1.75,0.5;3,3;] + list[current_player;craftpreview;5.75,1.5;1,1;] + image[4.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270] + listring[current_player;main] + listring[current_player;craft] + image[0,4.25;1,1;gui_hb_bg.png] + image[1,4.25;1,1;gui_hb_bg.png] + image[2,4.25;1,1;gui_hb_bg.png] + image[3,4.25;1,1;gui_hb_bg.png] + image[4,4.25;1,1;gui_hb_bg.png] + image[5,4.25;1,1;gui_hb_bg.png] + image[6,4.25;1,1;gui_hb_bg.png] + image[7,4.25;1,1;gui_hb_bg.png] + ]], true) + +See above (methods section) for more options. + +### Customising themes + +Simply override this function to change the navigation: + + function sfinv.get_nav_fs(player, context, nav, current_idx) + return "navformspec" + end + +And override this function to change the layout: + + function sfinv.make_formspec(player, context, content, show_inv, size) + local tmp = { + size or "size[8,8.6]", + theme_main, + sfinv.get_nav_fs(player, context, context.nav_titles, context.nav_idx), + content + } + if show_inv then + tmp[4] = theme_inv + end + return table.concat(tmp, "") + end + + +Stairs API +---------- + +The stairs API lets you register stairs and slabs and ensures that they are registered the same way as those +delivered with Minetest Game, to keep them compatible with other mods. + +`stairs.register_stair(subname, recipeitem, groups, images, description, sounds, worldaligntex)` + + * Registers a stair + * `subname`: Basically the material name (e.g. cobble) used for the stair name. Nodename pattern: "stairs:stair_subname" + * `recipeitem`: Item used in the craft recipe, e.g. "default:cobble", may be `nil` + * `groups`: See [Known damage and digging time defining groups] + * `images`: See [Tile definition] + * `description`: Used for the description field in the stair's definition + * `sounds`: See [#Default sounds] + * `worldaligntex`: A bool to set all textures world-aligned. Default false. See [Tile definition] + +`stairs.register_slab(subname, recipeitem, groups, images, description, sounds, worldaligntex)` + + * Registers a slab + * `subname`: Basically the material name (e.g. cobble) used for the slab name. Nodename pattern: "stairs:slab_subname" + * `recipeitem`: Item used in the craft recipe, e.g. "default:cobble" + * `groups`: See [Known damage and digging time defining groups] + * `images`: See [Tile definition] + * `description`: Used for the description field in the slab's definition + * `sounds`: See [#Default sounds] + * `worldaligntex`: A bool to set all textures world-aligned. Default false. See [Tile definition] + +`stairs.register_stair_inner(subname, recipeitem, groups, images, description, sounds, worldaligntex, full_description)` + + * Registers an inner corner stair + * `subname`: Basically the material name (e.g. cobble) used for the stair name. Nodename pattern: "stairs:stair_inner_subname" + * `recipeitem`: Item used in the craft recipe, e.g. "default:cobble", may be `nil` + * `groups`: See [Known damage and digging time defining groups] + * `images`: See [Tile definition] + * `description`: Used for the description field in the stair's definition with "Inner" prepended + * `sounds`: See [#Default sounds] + * `worldaligntex`: A bool to set all textures world-aligned. Default false. See [Tile definition] + * `full_description`: Overrides the description, bypassing string concatenation. This is useful for translation. (optional) + +`stairs.register_stair_outer(subname, recipeitem, groups, images, description, sounds, worldaligntex, full_description)` + + * Registers an outer corner stair + * `subname`: Basically the material name (e.g. cobble) used for the stair name. Nodename pattern: "stairs:stair_outer_subname" + * `recipeitem`: Item used in the craft recipe, e.g. "default:cobble", may be `nil` + * `groups`: See [Known damage and digging time defining groups] + * `images`: See [Tile definition] + * `description`: Used for the description field in the stair's definition with "Outer" prepended + * `sounds`: See [#Default sounds] + * `worldaligntex`: A bool to set all textures world-aligned. Default false. See [Tile definition] + * `full_description`: Overrides the description, bypassing string concatenation. This is useful for translation. (optional) + +``` +stairs.register_stair_and_slab(subname, recipeitem, groups, images, desc_stair, desc_slab, + sounds, worldaligntex, desc_stair_inner, desc_stair_outer) +``` + + * A wrapper for stairs.register_stair, stairs.register_slab, stairs.register_stair_inner, stairs.register_stair_outer + * Uses almost the same arguments as stairs.register_stair + * `desc_stair`: Description for stair nodes. For corner stairs 'Inner' or 'Outer' will be prefixed unless + `desc_stair_inner` or `desc_stair_outer` are specified, which are used instead. + * `desc_slab`: Description for slab node + * `desc_stair_inner`: Description for inner stair node + * `desc_stair_outer`: Description for outer stair node + + +Xpanes API +---------- + +Creates panes that automatically connect to each other + +`xpanes.register_pane(subname, def)` + + * `subname`: used for nodename. Result: "xpanes:subname" and "xpanes:subname_{2..15}" + * `def`: See [#Pane definition] + +### Pane definition + + { + textures = { + "texture for front and back", + (unused), + "texture for the 4 edges" + }, -- More tiles aren't supported + groups = {group = rating}, -- Uses the known node groups, see [Known damage and digging time defining groups] + sounds = SoundSpec, -- See [#Default sounds] + recipe = {{"","","","","","","","",""}}, -- Recipe field only + use_texture_alpha = true, -- Optional boolean (default: `false`) for colored glass panes + } + + +Raillike definitions +-------------------- + +The following nodes use the group `connect_to_raillike` and will only connect to +raillike nodes within this group and the same group value. +Use `minetest.raillike_group()` to get the group value. + +| Node type | Raillike group name +|-----------------------|--------------------- +| default:rail | "rail" +| tnt:gunpowder | "gunpowder" +| tnt:gunpowder_burning | "gunpowder" + +Example: +If you want to add a new rail type and want it to connect with default:rail, +add `connect_to_raillike=minetest.raillike_group("rail")` into the `groups` table +of your node. + + +Default sounds +-------------- + +Sounds inside the default table can be used within the sounds field of node definitions. + + * `default.node_sound_defaults()` + * `default.node_sound_stone_defaults()` + * `default.node_sound_dirt_defaults()` + * `default.node_sound_sand_defaults()` + * `default.node_sound_wood_defaults()` + * `default.node_sound_leaves_defaults()` + * `default.node_sound_glass_defaults()` + * `default.node_sound_metal_defaults()` + + +Default constants +----------------- + +`default.LIGHT_MAX` The maximum light level (see [Node definition] light_source) + + +GUI and formspecs +----------------- + +`default.get_hotbar_bg(x, y)` + + * Get the hotbar background as string, containing the formspec elements + * x: Horizontal position in the formspec + * y: Vertical position in the formspec + +`default.gui_bg` + + * Deprecated, remove from mods. + +`default.gui_bg_img` + + * Deprecated, remove from mods. + +`default.gui_slots` + + * Deprecated, remove from mods. + +`default.gui_survival_form` + + * Entire formspec for the survival inventory + +`default.get_furnace_active_formspec(fuel_percent, item_percent)` + + * Get the active furnace formspec using the defined GUI elements + * fuel_percent: Percent of how much the fuel is used + * item_percent: Percent of how much the item is cooked + +`default.get_furnace_inactive_formspec()` + + * Get the inactive furnace formspec using the defined GUI elements + + +Leafdecay +--------- + +To enable leaf decay for leaves when a tree is cut down by a player, +register the tree with the default.register_leafdecay(leafdecaydef) +function. + +If `param2` of any registered node is ~= 0, the node will always be +preserved. Thus, if the player places a node of that kind, you will +want to set `param2 = 1` or so. + +The function `default.after_place_leaves` can be set as +`after_place_node of a node` to set param2 to 1 if the player places +the node (should not be used for nodes that use param2 otherwise +(e.g. facedir)). + +If the node is in the `leafdecay_drop` group then it will always be +dropped as an item. + +`default.register_leafdecay(leafdecaydef)` + +`leafdecaydef` is a table, with following members: + { + trunks = {"default:tree"}, -- nodes considered trunks + leaves = {"default:leaves", "default:apple"}, + -- nodes considered for removal + radius = 3, -- radius to consider for searching + } + +Note: all the listed nodes in `trunks` have their `on_after_destruct` +callback overridden. All the nodes listed in `leaves` have their +`on_timer` callback overridden. + + +Dyes +---- + +Minetest Game dyes are registered with: + + groups = {dye = 1, color_ = 1}, + +To make recipes that will work with dyes from many mods, define them using the +dye group and the color groups. + +Dye color groups: + + * `color_white` + * `color_grey` + * `color_dark_grey` + * `color_black` + * `color_red` + * `color_pink` + * `color_orange` + * `color_brown` + * `color_yellow` + * `color_green` + * `color_dark_green` + * `color_blue` + * `color_cyan` + * `color_violet` + * `color_magenta` + +Example of one shapeless recipe using the dye group and a color group: + + minetest.register_craft({ + type = "shapeless", + output = ":item_yellow", + recipe = {":item_no_color", "group:dye,color_yellow"}, + }) + + +Trees +----- + + * `default.grow_tree(pos, is_apple_tree)` + * Grows a mgv6 tree or apple tree at pos + + * `default.grow_jungle_tree(pos)` + * Grows a mgv6 jungletree at pos + + * `default.grow_pine_tree(pos)` + * Grows a mgv6 pinetree at pos + + * `default.grow_new_apple_tree(pos)` + * Grows a new design apple tree at pos + + * `default.grow_new_jungle_tree(pos)` + * Grows a new design jungle tree at pos + + * `default.grow_new_pine_tree(pos)` + * Grows a new design pine tree at pos + + * `default.grow_new_snowy_pine_tree(pos)` + * Grows a new design snowy pine tree at pos + + * `default.grow_new_acacia_tree(pos)` + * Grows a new design acacia tree at pos + + * `default.grow_new_aspen_tree(pos)` + * Grows a new design aspen tree at pos + + * `default.grow_bush(pos)` + * Grows a bush at pos + + * `default.grow_acacia_bush(pos)` + * Grows an acaia bush at pos + + * `default.grow_pine_bush(pos)` + * Grows a pine bush at pos + + * `default.grow_blueberry_bush(pos)` + * Grows a blueberry bush at pos + + +Carts +----- + + carts.register_rail( + "mycarts:myrail", -- Rail name + nodedef, -- standard nodedef + railparams -- rail parameter struct (optional) + ) + + railparams = { + on_step(obj, dtime), -- Event handler called when + -- cart is on rail + acceleration, -- integer acceleration factor (negative + -- values to brake) + } + + The event handler is called after all default calculations + are made, so the custom on_step handler can override things + like speed, acceleration, player attachment. The handler will + likely be called many times per second, so the function needs + to make sure that the event is handled properly. + + +Key API +------- + +The key API allows mods to add key functionality to nodes that have +ownership or specific permissions. Using the API will make it so +that a node owner can use skeleton keys on their nodes to create keys +for that node in that location, and give that key to other players, +allowing them some sort of access that they otherwise would not have +due to node protection. + +To make your new nodes work with the key API, you need to register +two callback functions in each nodedef: + + +`on_key_use(pos, player)` + * Is called when a player right-clicks (uses) a normal key on your + * node. + * `pos` - position of the node + * `player` - PlayerRef + * return value: none, ignored + +The `on_key_use` callback should validate that the player is wielding +a key item with the right key meta secret. If needed the code should +deny access to the node functionality. + +If formspecs are used, the formspec callbacks should duplicate these +checks in the metadata callback functions. + + +`on_skeleton_key_use(pos, player, newsecret)` + + * Is called when a player right-clicks (uses) a skeleton key on your + * node. + * `pos` - position of the node + * `player` - PlayerRef + * `newsecret` - a secret value(string) + * return values: + * `secret` - `nil` or the secret value that unlocks the door + * `name` - a string description of the node ("a locked chest") + * `owner` - name of the node owner + +The `on_skeleton_key_use` function should validate that the player has +the right permissions to make a new key for the item. The newsecret +value is useful if the node has no secret value. The function should +store this secret value somewhere so that in the future it may compare +key secrets and match them to allow access. If a node already has a +secret value, the function should return that secret value instead +of the newsecret value. The secret value stored for the node should +not be overwritten, as this would invalidate existing keys. + +Aside from the secret value, the function should retun a descriptive +name for the node and the owner name. The return values are all +encoded in the key that will be given to the player in replacement +for the wielded skeleton key. + +if `nil` is returned, it is assumed that the wielder did not have +permissions to create a key for this node, and no key is created. + +`default.register_craft_metadata_copy(ingredient, result)` +---------------------------------------------------------- + +This function registers a shapeless recipe that takes `ingredient` +and `result` as input and outputs `result`. + +The metadata of the input `result` is copied to the output `result`. diff --git a/menu/header.png b/menu/header.png new file mode 100644 index 0000000..b24122f Binary files /dev/null and b/menu/header.png differ diff --git a/menu/icon.png b/menu/icon.png new file mode 100644 index 0000000..bf90c82 Binary files /dev/null and b/menu/icon.png differ diff --git a/minetest.conf b/minetest.conf new file mode 100644 index 0000000..e69de29 diff --git a/minetest.conf.example b/minetest.conf.example new file mode 100644 index 0000000..86eba66 --- /dev/null +++ b/minetest.conf.example @@ -0,0 +1,77 @@ +# This file contains settings of Minetest Game that can be changed in +# minetest.conf. +# By default, all the settings are commented and not functional. +# Uncomment settings by removing the preceding #. + +# Whether creative mode (fast digging of all blocks, unlimited resources) should +# be enabled. +#creative_mode = false + +# Sets the behaviour of the inventory items when a player dies. +# bones: Store items in a bone node but drop items if inside protected area. +# drop: Drop items on the ground. +# keep: Player keeps items. +#bones_mode = bones + +# The time in seconds after which the bones of a dead player can be looted by +# everyone. +# 0 to disable. +#share_bones_time = 1200 + +# How much earlier the bones of a dead player can be looted by +# everyone if the player dies in a protected area they don't own. +# 0 to disable. By default it is "share_bones_time" divide by four. +#share_bones_time_early = 300 + +# Inform player of condition and location of new bones. +#bones_position_message = false + +# Whether fire should be enabled. If disabled, 'basic_flame' nodes will +# disappear. +# 'permanent_flame' nodes will remain with either setting. +#enable_fire = true + +# Enable flame sound. +#flame_sound = true + +# Whether lavacooling should be enabled. +#enable_lavacooling = true + +# Whether the stuff in initial_stuff should be given to new players. +#give_initial_stuff = false +#initial_stuff = default:pick_steel,default:axe_steel,default:shovel_steel, +default:torch 99,default:cobble 99 + +# Whether the TNT mod should be enabled. +#enable_tnt = + +# The radius of a TNT explosion. +#tnt_radius = 3 + +# Enable the stairs mod ABM that replaces the old 'upside down' +# stair and slab nodes in old maps with the new param2 versions. +#enable_stairs_replace_abm = false + +# Whether to allow respawning in beds. +# Default value is true. +#enable_bed_respawn = true + +# Whether players can skip night by sleeping. +# Default value is true. +#enable_bed_night_skip = true + +# If enabled, fences and walls cannot be jumped over. +#enable_fence_tall = false + +# Whether the engine's spawn search, which does not check for a suitable +# starting biome, is used. +# Default value is false. +#engine_spawn = false + +# Whether river water source nodes create flowing sounds. +# Helps rivers create more sound, especially on level sections. +#river_source_sounds = false + +# Enable cloud variation by the 'weather' mod. +# Non-functional in V6 or Singlenode mapgens. +#enable_weather = true diff --git a/mods/basenodes/init.lua b/mods/basenodes/init.lua new file mode 100644 index 0000000..2c808c3 --- /dev/null +++ b/mods/basenodes/init.lua @@ -0,0 +1,351 @@ +local WATER_ALPHA = "^[opacity:" .. 160 +local WATER_VISC = 1 +local LAVA_VISC = 7 + +-- +-- Node definitions +-- + +-- Register nodes + +minetest.register_node("basenodes:stone", { + description = "Stone", + tiles = {"default_stone.png"}, + groups = {cracky=3}, +}) + +minetest.register_node("basenodes:desert_stone", { + description = "Desert Stone", + tiles = {"default_desert_stone.png"}, + groups = {cracky=3}, +}) + +minetest.register_node("basenodes:dirt_with_grass", { + description = "Dirt with Grass", + tiles ={"default_grass.png", + -- a little dot on the bottom to distinguish it from dirt + "default_dirt.png^basenodes_dirt_with_grass_bottom.png", + {name = "default_dirt.png^default_grass_side.png", + tileable_vertical = false}}, + groups = {crumbly=3, soil=1}, +}) + +minetest.register_node("basenodes:dirt_with_snow", { + description = "Dirt with Snow", + tiles ={"basenodes_dirt_with_snow.png", + -- a little dot on the bottom to distinguish it from dirt + "default_dirt.png^basenodes_dirt_with_snow_bottom.png", + {name = "default_dirt.png^default_snow_side.png", + tileable_vertical = false}}, + groups = {crumbly=3, soil=1}, +}) + +minetest.register_node("basenodes:dirt", { + description = "Dirt", + tiles ={"default_dirt.png"}, + groups = {crumbly=3, soil=1}, +}) + +minetest.register_node("basenodes:sand", { + description = "Sand", + tiles ={"default_sand.png"}, + groups = {crumbly=3}, +}) + +minetest.register_node("basenodes:desert_sand", { + description = "Desert Sand", + tiles ={"default_desert_sand.png"}, + groups = {crumbly=3}, +}) + +minetest.register_node("basenodes:gravel", { + description = "Gravel", + tiles ={"default_gravel.png"}, + groups = {crumbly=2}, +}) + +minetest.register_node("basenodes:junglegrass", { + description = "Jungle Grass", + drawtype = "plantlike", + tiles ={"default_junglegrass.png"}, + inventory_image = "default_junglegrass.png", + wield_image = "default_junglegrass.png", + paramtype = "light", + walkable = false, + groups = {snappy=3}, +}) + +minetest.register_node("basenodes:tree", { + description = "Normal Tree Trunk", + tiles = {"default_tree_top.png", "default_tree_top.png", "default_tree.png"}, + is_ground_content = false, + groups = {choppy=2,oddly_breakable_by_hand=1}, +}) + +minetest.register_node("basenodes:leaves", { + description = "Normal Leaves", + drawtype = "allfaces_optional", + tiles = {"default_leaves.png"}, + paramtype = "light", + is_ground_content = false, + groups = {snappy=3}, +}) + +minetest.register_node("basenodes:jungletree", { + description = "Jungle Tree Trunk", + tiles = {"default_jungletree_top.png", "default_jungletree_top.png", "default_jungletree.png"}, + is_ground_content = false, + groups = {choppy=2,oddly_breakable_by_hand=1}, +}) + +minetest.register_node("basenodes:jungleleaves", { + description = "Jungle Leaves", + drawtype = "allfaces_optional", + tiles = {"default_jungleleaves.png"}, + paramtype = "light", + is_ground_content = false, + groups = {snappy=3}, +}) + +minetest.register_node("basenodes:pine_tree", { + description = "Pine Tree Trunk", + tiles = {"default_pine_tree_top.png", "default_pine_tree_top.png", "default_pine_tree.png"}, + is_ground_content = false, + groups = {choppy=2,oddly_breakable_by_hand=1}, +}) + +minetest.register_node("basenodes:pine_needles", { + description = "Pine Needles", + drawtype = "allfaces_optional", + tiles = {"default_pine_needles.png"}, + paramtype = "light", + is_ground_content = false, + groups = {snappy=3}, +}) + +minetest.register_node("basenodes:water_source", { + description = "Water Source".."\n".. + "Drowning damage: 1", + drawtype = "liquid", + waving = 3, + tiles = {"default_water.png"..WATER_ALPHA}, + special_tiles = { + {name = "default_water.png"..WATER_ALPHA, backface_culling = false}, + {name = "default_water.png"..WATER_ALPHA, backface_culling = true}, + }, + use_texture_alpha = "blend", + paramtype = "light", + walkable = false, + pointable = false, + diggable = false, + buildable_to = true, + is_ground_content = false, + drowning = 1, + liquidtype = "source", + liquid_alternative_flowing = "basenodes:water_flowing", + liquid_alternative_source = "basenodes:water_source", + liquid_viscosity = WATER_VISC, + post_effect_color = {a = 64, r = 100, g = 100, b = 200}, + groups = {water = 3, liquid = 3}, +}) + +minetest.register_node("basenodes:water_flowing", { + description = "Flowing Water".."\n".. + "Drowning damage: 1", + drawtype = "flowingliquid", + waving = 3, + tiles = {"default_water_flowing.png"}, + special_tiles = { + {name = "default_water_flowing.png"..WATER_ALPHA, + backface_culling = false}, + {name = "default_water_flowing.png"..WATER_ALPHA, + backface_culling = false}, + }, + use_texture_alpha = "blend", + paramtype = "light", + paramtype2 = "flowingliquid", + walkable = false, + pointable = false, + diggable = false, + buildable_to = true, + is_ground_content = false, + drowning = 1, + liquidtype = "flowing", + liquid_alternative_flowing = "basenodes:water_flowing", + liquid_alternative_source = "basenodes:water_source", + liquid_viscosity = WATER_VISC, + post_effect_color = {a = 64, r = 100, g = 100, b = 200}, + groups = {water = 3, liquid = 3}, +}) + +minetest.register_node("basenodes:river_water_source", { + description = "River Water Source".."\n".. + "Drowning damage: 1", + drawtype = "liquid", + waving = 3, + tiles = { "default_river_water.png"..WATER_ALPHA }, + special_tiles = { + {name = "default_river_water.png"..WATER_ALPHA, backface_culling = false}, + {name = "default_river_water.png"..WATER_ALPHA, backface_culling = true}, + }, + use_texture_alpha = "blend", + paramtype = "light", + walkable = false, + pointable = false, + diggable = false, + buildable_to = true, + is_ground_content = false, + drowning = 1, + liquidtype = "source", + liquid_alternative_flowing = "basenodes:river_water_flowing", + liquid_alternative_source = "basenodes:river_water_source", + liquid_viscosity = 1, + liquid_renewable = false, + liquid_range = 2, + post_effect_color = {a = 103, r = 30, g = 76, b = 90}, + groups = {water = 3, liquid = 3, }, +}) + +minetest.register_node("basenodes:river_water_flowing", { + description = "Flowing River Water".."\n".. + "Drowning damage: 1", + drawtype = "flowingliquid", + waving = 3, + tiles = {"default_river_water_flowing.png"..WATER_ALPHA}, + special_tiles = { + {name = "default_river_water_flowing.png"..WATER_ALPHA, + backface_culling = false}, + {name = "default_river_water_flowing.png"..WATER_ALPHA, + backface_culling = false}, + }, + use_texture_alpha = "blend", + paramtype = "light", + paramtype2 = "flowingliquid", + walkable = false, + pointable = false, + diggable = false, + buildable_to = true, + is_ground_content = false, + drowning = 1, + liquidtype = "flowing", + liquid_alternative_flowing = "basenodes:river_water_flowing", + liquid_alternative_source = "basenodes:river_water_source", + liquid_viscosity = 1, + liquid_renewable = false, + liquid_range = 2, + post_effect_color = {a = 103, r = 30, g = 76, b = 90}, + groups = {water = 3, liquid = 3, }, +}) + +minetest.register_node("basenodes:lava_flowing", { + description = "Flowing Lava".."\n".. + "4 damage per second".."\n".. + "Drowning damage: 1", + drawtype = "flowingliquid", + tiles = {"default_lava_flowing.png"}, + special_tiles = { + {name="default_lava_flowing.png", backface_culling = false}, + {name="default_lava_flowing.png", backface_culling = false}, + }, + paramtype = "light", + light_source = minetest.LIGHT_MAX, + walkable = false, + pointable = false, + diggable = false, + buildable_to = true, + is_ground_content = false, + drowning = 1, + damage_per_second = 4, + liquidtype = "flowing", + liquid_alternative_flowing = "basenodes:lava_flowing", + liquid_alternative_source = "basenodes:lava_source", + liquid_viscosity = LAVA_VISC, + post_effect_color = {a=192, r=255, g=64, b=0}, + groups = {lava=3, liquid=1}, +}) + +minetest.register_node("basenodes:lava_source", { + description = "Lava Source".."\n".. + "4 damage per second".."\n".. + "Drowning damage: 1", + drawtype = "liquid", + tiles = { "default_lava.png" }, + special_tiles = { + {name = "default_lava.png", backface_culling = false}, + {name = "default_lava.png", backface_culling = true}, + }, + paramtype = "light", + light_source = minetest.LIGHT_MAX, + walkable = false, + pointable = false, + diggable = false, + buildable_to = true, + is_ground_content = false, + drowning = 1, + damage_per_second = 4, + liquidtype = "source", + liquid_alternative_flowing = "basenodes:lava_flowing", + liquid_alternative_source = "basenodes:lava_source", + liquid_viscosity = LAVA_VISC, + post_effect_color = {a=192, r=255, g=64, b=0}, + groups = {lava=3, liquid=1}, +}) + +minetest.register_node("basenodes:cobble", { + description = "Cobblestone", + tiles ={"default_cobble.png"}, + is_ground_content = false, + groups = {cracky=3}, +}) + +minetest.register_node("basenodes:mossycobble", { + description = "Mossy Cobblestone", + tiles ={"default_mossycobble.png"}, + is_ground_content = false, + groups = {cracky=3}, +}) + +minetest.register_node("basenodes:apple", { + description = "Apple".."\n".. + "Food (+2)", + drawtype = "plantlike", + tiles ={"default_apple.png"}, + inventory_image = "default_apple.png", + paramtype = "light", + is_ground_content = false, + sunlight_propagates = true, + walkable = false, + groups = {dig_immediate=3}, + + -- Make eatable because why not? + on_use = minetest.item_eat(2), +}) + +minetest.register_node("basenodes:ice", { + description = "Ice", + tiles ={"default_ice.png"}, + groups = {cracky=3}, +}) + +-- The snow nodes intentionally have different tints to make them more +-- distinguishable +minetest.register_node("basenodes:snow", { + description = "Snow Sheet", + tiles = {"basenodes_snow_sheet.png"}, + groups = {crumbly=3}, + walkable = false, + paramtype = "light", + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, -0.25, 0.5}, + }, +}) + +minetest.register_node("basenodes:snowblock", { + description = "Snow Block", + tiles ={"default_snow.png"}, + groups = {crumbly=3}, +}) + + diff --git a/mods/basenodes/mod.conf b/mods/basenodes/mod.conf new file mode 100644 index 0000000..25024dc --- /dev/null +++ b/mods/basenodes/mod.conf @@ -0,0 +1,2 @@ +name = basenodes +description = Contains basic nodes for mapgen diff --git a/mods/basenodes/textures/basenodes_dirt_with_grass_bottom.png b/mods/basenodes/textures/basenodes_dirt_with_grass_bottom.png new file mode 100644 index 0000000..5e8fc41 Binary files /dev/null and b/mods/basenodes/textures/basenodes_dirt_with_grass_bottom.png differ diff --git a/mods/basenodes/textures/basenodes_dirt_with_snow.png b/mods/basenodes/textures/basenodes_dirt_with_snow.png new file mode 100644 index 0000000..7ea2d8d Binary files /dev/null and b/mods/basenodes/textures/basenodes_dirt_with_snow.png differ diff --git a/mods/basenodes/textures/basenodes_dirt_with_snow_bottom.png b/mods/basenodes/textures/basenodes_dirt_with_snow_bottom.png new file mode 100644 index 0000000..447c94e Binary files /dev/null and b/mods/basenodes/textures/basenodes_dirt_with_snow_bottom.png differ diff --git a/mods/basenodes/textures/basenodes_snow_sheet.png b/mods/basenodes/textures/basenodes_snow_sheet.png new file mode 100644 index 0000000..4553320 Binary files /dev/null and b/mods/basenodes/textures/basenodes_snow_sheet.png differ diff --git a/mods/basenodes/textures/default_apple.png b/mods/basenodes/textures/default_apple.png new file mode 100644 index 0000000..9c115da Binary files /dev/null and b/mods/basenodes/textures/default_apple.png differ diff --git a/mods/basenodes/textures/default_cobble.png b/mods/basenodes/textures/default_cobble.png new file mode 100644 index 0000000..5b859e9 Binary files /dev/null and b/mods/basenodes/textures/default_cobble.png differ diff --git a/mods/basenodes/textures/default_desert_sand.png b/mods/basenodes/textures/default_desert_sand.png new file mode 100644 index 0000000..19ec87d Binary files /dev/null and b/mods/basenodes/textures/default_desert_sand.png differ diff --git a/mods/basenodes/textures/default_desert_stone.png b/mods/basenodes/textures/default_desert_stone.png new file mode 100644 index 0000000..5126fb6 Binary files /dev/null and b/mods/basenodes/textures/default_desert_stone.png differ diff --git a/mods/basenodes/textures/default_dirt.png b/mods/basenodes/textures/default_dirt.png new file mode 100644 index 0000000..aa75bff Binary files /dev/null and b/mods/basenodes/textures/default_dirt.png differ diff --git a/mods/basenodes/textures/default_grass.png b/mods/basenodes/textures/default_grass.png new file mode 100644 index 0000000..3d63971 Binary files /dev/null and b/mods/basenodes/textures/default_grass.png differ diff --git a/mods/basenodes/textures/default_gravel.png b/mods/basenodes/textures/default_gravel.png new file mode 100644 index 0000000..7e5ff61 Binary files /dev/null and b/mods/basenodes/textures/default_gravel.png differ diff --git a/mods/basenodes/textures/default_ice.png b/mods/basenodes/textures/default_ice.png new file mode 100644 index 0000000..c4bddd2 Binary files /dev/null and b/mods/basenodes/textures/default_ice.png differ diff --git a/mods/basenodes/textures/default_junglegrass.png b/mods/basenodes/textures/default_junglegrass.png new file mode 100644 index 0000000..d64e33a Binary files /dev/null and b/mods/basenodes/textures/default_junglegrass.png differ diff --git a/mods/basenodes/textures/default_jungleleaves.png b/mods/basenodes/textures/default_jungleleaves.png new file mode 100644 index 0000000..1fa67e8 Binary files /dev/null and b/mods/basenodes/textures/default_jungleleaves.png differ diff --git a/mods/basenodes/textures/default_jungletree.png b/mods/basenodes/textures/default_jungletree.png new file mode 100644 index 0000000..053850f Binary files /dev/null and b/mods/basenodes/textures/default_jungletree.png differ diff --git a/mods/basenodes/textures/default_jungletree_top.png b/mods/basenodes/textures/default_jungletree_top.png new file mode 100644 index 0000000..e80de8a Binary files /dev/null and b/mods/basenodes/textures/default_jungletree_top.png differ diff --git a/mods/basenodes/textures/default_lava.png b/mods/basenodes/textures/default_lava.png new file mode 100644 index 0000000..a4cf649 Binary files /dev/null and b/mods/basenodes/textures/default_lava.png differ diff --git a/mods/basenodes/textures/default_lava_flowing.png b/mods/basenodes/textures/default_lava_flowing.png new file mode 100644 index 0000000..07066a6 Binary files /dev/null and b/mods/basenodes/textures/default_lava_flowing.png differ diff --git a/mods/basenodes/textures/default_leaves.png b/mods/basenodes/textures/default_leaves.png new file mode 100644 index 0000000..c0475d4 Binary files /dev/null and b/mods/basenodes/textures/default_leaves.png differ diff --git a/mods/basenodes/textures/default_mossycobble.png b/mods/basenodes/textures/default_mossycobble.png new file mode 100644 index 0000000..69585e3 Binary files /dev/null and b/mods/basenodes/textures/default_mossycobble.png differ diff --git a/mods/basenodes/textures/default_pine_needles.png b/mods/basenodes/textures/default_pine_needles.png new file mode 100644 index 0000000..137caa2 Binary files /dev/null and b/mods/basenodes/textures/default_pine_needles.png differ diff --git a/mods/basenodes/textures/default_pine_tree.png b/mods/basenodes/textures/default_pine_tree.png new file mode 100644 index 0000000..5743183 Binary files /dev/null and b/mods/basenodes/textures/default_pine_tree.png differ diff --git a/mods/basenodes/textures/default_pine_tree_top.png b/mods/basenodes/textures/default_pine_tree_top.png new file mode 100644 index 0000000..cc18f34 Binary files /dev/null and b/mods/basenodes/textures/default_pine_tree_top.png differ diff --git a/mods/basenodes/textures/default_river_water.png b/mods/basenodes/textures/default_river_water.png new file mode 100644 index 0000000..e1074d2 Binary files /dev/null and b/mods/basenodes/textures/default_river_water.png differ diff --git a/mods/basenodes/textures/default_river_water_flowing.png b/mods/basenodes/textures/default_river_water_flowing.png new file mode 100644 index 0000000..4a756b2 Binary files /dev/null and b/mods/basenodes/textures/default_river_water_flowing.png differ diff --git a/mods/basenodes/textures/default_sand.png b/mods/basenodes/textures/default_sand.png new file mode 100644 index 0000000..0ed0e4c Binary files /dev/null and b/mods/basenodes/textures/default_sand.png differ diff --git a/mods/basenodes/textures/default_snow.png b/mods/basenodes/textures/default_snow.png new file mode 100644 index 0000000..c42e0ee Binary files /dev/null and b/mods/basenodes/textures/default_snow.png differ diff --git a/mods/basenodes/textures/default_snow_side.png b/mods/basenodes/textures/default_snow_side.png new file mode 100644 index 0000000..f34d109 Binary files /dev/null and b/mods/basenodes/textures/default_snow_side.png differ diff --git a/mods/basenodes/textures/default_stone.png b/mods/basenodes/textures/default_stone.png new file mode 100644 index 0000000..763b439 Binary files /dev/null and b/mods/basenodes/textures/default_stone.png differ diff --git a/mods/basenodes/textures/default_tree.png b/mods/basenodes/textures/default_tree.png new file mode 100644 index 0000000..189ec15 Binary files /dev/null and b/mods/basenodes/textures/default_tree.png differ diff --git a/mods/basenodes/textures/default_tree_top.png b/mods/basenodes/textures/default_tree_top.png new file mode 100644 index 0000000..d1a4fa7 Binary files /dev/null and b/mods/basenodes/textures/default_tree_top.png differ diff --git a/mods/basenodes/textures/default_water.png b/mods/basenodes/textures/default_water.png new file mode 100644 index 0000000..3e385ae Binary files /dev/null and b/mods/basenodes/textures/default_water.png differ diff --git a/mods/basenodes/textures/default_water_flowing.png b/mods/basenodes/textures/default_water_flowing.png new file mode 100644 index 0000000..7cdafd5 Binary files /dev/null and b/mods/basenodes/textures/default_water_flowing.png differ diff --git a/mods/basenodes/textures/dirt_with_grass/default_grass.png b/mods/basenodes/textures/dirt_with_grass/default_grass.png new file mode 100644 index 0000000..29fde6b Binary files /dev/null and b/mods/basenodes/textures/dirt_with_grass/default_grass.png differ diff --git a/mods/basenodes/textures/dirt_with_grass/default_grass_side.png b/mods/basenodes/textures/dirt_with_grass/default_grass_side.png new file mode 100644 index 0000000..04770b6 Binary files /dev/null and b/mods/basenodes/textures/dirt_with_grass/default_grass_side.png differ diff --git a/mods/basenodes/textures/info.txt b/mods/basenodes/textures/info.txt new file mode 100644 index 0000000..2d4ef7e --- /dev/null +++ b/mods/basenodes/textures/info.txt @@ -0,0 +1,7 @@ + +The dirt_with_grass folder is for testing loading textures from subfolders. +If it works correctly, the default_grass_side.png file in the folder is used but +default_grass.png is not overwritten by the file in the folder. + +default_dirt.png should be overwritten by the default_dirt.png in the unittests +mod which depends on basenodes. diff --git a/mods/basetools/init.lua b/mods/basetools/init.lua new file mode 100644 index 0000000..bd74800 --- /dev/null +++ b/mods/basetools/init.lua @@ -0,0 +1,350 @@ +-- +-- Tool definitions +-- + +--[[ TOOLS SUMMARY: + +Tool types: + +* Hand: basic tool/weapon (special capabilities in creative mode) +* Pickaxe: dig cracky +* Axe: dig choppy +* Shovel: dig crumbly +* Shears: dig snappy +* Sword: deal damage +* Dagger: deal damage, but faster + +Tool materials: + +* Dirt: dig nodes of rating 3, one use only +* Wood: dig nodes of rating 3 +* Stone: dig nodes of rating 3 or 2 +* Steel: dig nodes of rating 3, 2 or 1 +* Mese: dig "everything" instantly +]] + +-- The hand +if minetest.settings:get_bool("creative_mode") then + local digtime = 42 + local caps = {times = {digtime, digtime, digtime}, uses = 0, maxlevel = 256} + + minetest.register_item(":", { + type = "none", + wield_image = "wieldhand.png", + wield_scale = {x = 1, y = 1, z = 2.5}, + range = 10, + tool_capabilities = { + full_punch_interval = 0.5, + max_drop_level = 3, + groupcaps = { + crumbly = caps, + cracky = caps, + snappy = caps, + choppy = caps, + oddly_breakable_by_hand = caps, + -- dig_immediate group doesn't use value 1. Value 3 is instant dig + dig_immediate = + {times = {[2] = digtime, [3] = 0}, uses = 0, maxlevel = 256}, + }, + damage_groups = {fleshy = 10}, + } + }) +else + minetest.register_item(":", { + type = "none", + wield_image = "wieldhand.png", + wield_scale = {x = 1, y = 1, z = 2.5}, + tool_capabilities = { + full_punch_interval = 0.9, + max_drop_level = 0, + groupcaps = { + crumbly = {times = {[2] = 3.00, [3] = 0.70}, uses = 0, maxlevel = 1}, + snappy = {times = {[3] = 0.40}, uses = 0, maxlevel = 1}, + oddly_breakable_by_hand = + {times = {[1] = 3.50, [2] = 2.00, [3] = 0.70}, uses = 0} + }, + damage_groups = {fleshy = 1}, + } + }) +end + +-- Mese Pickaxe: special tool that digs "everything" instantly +minetest.register_tool("basetools:pick_mese", { + description = "Mese Pickaxe".."\n".. + "Digs diggable nodes instantly", + inventory_image = "basetools_mesepick.png", + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=3, + groupcaps={ + cracky={times={[1]=0.0, [2]=0.0, [3]=0.0}, maxlevel=255}, + crumbly={times={[1]=0.0, [2]=0.0, [3]=0.0}, maxlevel=255}, + snappy={times={[1]=0.0, [2]=0.0, [3]=0.0}, maxlevel=255}, + choppy={times={[1]=0.0, [2]=0.0, [3]=0.0}, maxlevel=255}, + dig_immediate={times={[1]=0.0, [2]=0.0, [3]=0.0}, maxlevel=255}, + }, + damage_groups = {fleshy=100}, + }, +}) + + +-- +-- Pickaxes: Dig cracky +-- + +-- This should break after only 1 use +minetest.register_tool("basetools:pick_dirt", { + description = "Dirt Pickaxe".."\n".. + "Digs cracky=3".."\n".. + "1 use only", + inventory_image = "basetools_dirtpick.png", + tool_capabilities = { + max_drop_level=0, + groupcaps={ + cracky={times={[3]=2.00}, uses=1, maxlevel=0} + }, + }, +}) + +minetest.register_tool("basetools:pick_wood", { + description = "Wooden Pickaxe".."\n".. + "Digs cracky=3", + inventory_image = "basetools_woodpick.png", + tool_capabilities = { + max_drop_level=0, + groupcaps={ + cracky={times={[3]=2.00}, uses=30, maxlevel=0} + }, + }, +}) +minetest.register_tool("basetools:pick_stone", { + description = "Stone Pickaxe".."\n".. + "Digs cracky=2..3", + inventory_image = "basetools_stonepick.png", + tool_capabilities = { + max_drop_level=0, + groupcaps={ + cracky={times={[2]=1.20, [3]=0.80}, uses=60, maxlevel=0} + }, + }, +}) +minetest.register_tool("basetools:pick_steel", { + description = "Steel Pickaxe".."\n".. + "Digs cracky=1..3", + inventory_image = "basetools_steelpick.png", + tool_capabilities = { + max_drop_level=1, + groupcaps={ + cracky={times={[1]=4.00, [2]=1.60, [3]=1.00}, uses=90, maxlevel=0} + }, + }, +}) +minetest.register_tool("basetools:pick_steel_l1", { + description = "Steel Pickaxe Level 1".."\n".. + "Digs cracky=1..3".."\n".. + "maxlevel=1", + inventory_image = "basetools_steelpick_l1.png", + tool_capabilities = { + max_drop_level=1, + groupcaps={ + cracky={times={[1]=4.00, [2]=1.60, [3]=1.00}, uses=90, maxlevel=1} + }, + }, +}) +minetest.register_tool("basetools:pick_steel_l2", { + description = "Steel Pickaxe Level 2".."\n".. + "Digs cracky=1..3".."\n".. + "maxlevel=2", + inventory_image = "basetools_steelpick_l2.png", + tool_capabilities = { + max_drop_level=1, + groupcaps={ + cracky={times={[1]=4.00, [2]=1.60, [3]=1.00}, uses=90, maxlevel=2} + }, + }, +}) + +-- +-- Shovels (dig crumbly) +-- + +minetest.register_tool("basetools:shovel_wood", { + description = "Wooden Shovel".."\n".. + "Digs crumbly=3", + inventory_image = "basetools_woodshovel.png", + tool_capabilities = { + max_drop_level=0, + groupcaps={ + crumbly={times={[3]=0.50}, uses=30, maxlevel=0} + }, + }, +}) +minetest.register_tool("basetools:shovel_stone", { + description = "Stone Shovel".."\n".. + "Digs crumbly=2..3", + inventory_image = "basetools_stoneshovel.png", + tool_capabilities = { + max_drop_level=0, + groupcaps={ + crumbly={times={[2]=0.50, [3]=0.30}, uses=60, maxlevel=0} + }, + }, +}) +minetest.register_tool("basetools:shovel_steel", { + description = "Steel Shovel".."\n".. + "Digs crumbly=1..3", + inventory_image = "basetools_steelshovel.png", + tool_capabilities = { + max_drop_level=1, + groupcaps={ + crumbly={times={[1]=1.00, [2]=0.70, [3]=0.60}, uses=90, maxlevel=0} + }, + }, +}) + +-- +-- Axes (dig choppy) +-- + +minetest.register_tool("basetools:axe_wood", { + description = "Wooden Axe".."\n".. + "Digs choppy=3", + inventory_image = "basetools_woodaxe.png", + tool_capabilities = { + max_drop_level=0, + groupcaps={ + choppy={times={[3]=0.80}, uses=30, maxlevel=0}, + }, + }, +}) +minetest.register_tool("basetools:axe_stone", { + description = "Stone Axe".."\n".. + "Digs choppy=2..3", + inventory_image = "basetools_stoneaxe.png", + tool_capabilities = { + max_drop_level=0, + groupcaps={ + choppy={times={[2]=1.00, [3]=0.60}, uses=60, maxlevel=0}, + }, + }, +}) +minetest.register_tool("basetools:axe_steel", { + description = "Steel Axe".."\n".. + "Digs choppy=1..3", + inventory_image = "basetools_steelaxe.png", + tool_capabilities = { + max_drop_level=1, + groupcaps={ + choppy={times={[1]=2.00, [2]=0.80, [3]=0.40}, uses=90, maxlevel=0}, + }, + }, +}) + +-- +-- Shears (dig snappy) +-- + +minetest.register_tool("basetools:shears_wood", { + description = "Wooden Shears".."\n".. + "Digs snappy=3", + inventory_image = "basetools_woodshears.png", + tool_capabilities = { + max_drop_level=0, + groupcaps={ + snappy={times={[3]=1.00}, uses=30, maxlevel=0}, + }, + }, +}) +minetest.register_tool("basetools:shears_stone", { + description = "Stone Shears".."\n".. + "Digs snappy=2..3", + inventory_image = "basetools_stoneshears.png", + tool_capabilities = { + max_drop_level=0, + groupcaps={ + snappy={times={[2]=1.00, [3]=0.50}, uses=60, maxlevel=0}, + }, + }, +}) +minetest.register_tool("basetools:shears_steel", { + description = "Steel Shears".."\n".. + "Digs snappy=1..3", + inventory_image = "basetools_steelshears.png", + tool_capabilities = { + max_drop_level=1, + groupcaps={ + snappy={times={[1]=1.00, [2]=0.50, [3]=0.25}, uses=90, maxlevel=0}, + }, + }, +}) + +-- +-- Swords (deal damage) +-- + +minetest.register_tool("basetools:sword_wood", { + description = "Wooden Sword".."\n".. + "Damage: fleshy=2", + inventory_image = "basetools_woodsword.png", + tool_capabilities = { + full_punch_interval = 1.0, + damage_groups = {fleshy=2}, + } +}) +minetest.register_tool("basetools:sword_stone", { + description = "Stone Sword".."\n".. + "Damage: fleshy=4", + inventory_image = "basetools_stonesword.png", + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=0, + damage_groups = {fleshy=4}, + } +}) +minetest.register_tool("basetools:sword_steel", { + description = "Steel Sword".."\n".. + "Damage: fleshy=6", + inventory_image = "basetools_steelsword.png", + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=1, + damage_groups = {fleshy=6}, + } +}) + +-- Fire/Ice sword: Deal damage to non-fleshy damage groups +minetest.register_tool("basetools:sword_fire", { + description = "Fire Sword".."\n".. + "Damage: icy=6", + inventory_image = "basetools_firesword.png", + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=0, + damage_groups = {icy=6}, + } +}) +minetest.register_tool("basetools:sword_ice", { + description = "Ice Sword".."\n".. + "Damage: fiery=6", + inventory_image = "basetools_icesword.png", + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=0, + damage_groups = {fiery=6}, + } +}) + +-- +-- Dagger: Low damage, fast punch interval +-- +minetest.register_tool("basetools:dagger_steel", { + description = "Steel Dagger".."\n".. + "Damage: fleshy=2".."\n".. + "Full Punch Interval: 0.5s", + inventory_image = "basetools_steeldagger.png", + tool_capabilities = { + full_punch_interval = 0.5, + max_drop_level=0, + damage_groups = {fleshy=2}, + } +}) diff --git a/mods/basetools/mod.conf b/mods/basetools/mod.conf new file mode 100644 index 0000000..f0d9f65 --- /dev/null +++ b/mods/basetools/mod.conf @@ -0,0 +1,2 @@ +name = basetools +description = Contains basic digging tools diff --git a/mods/basetools/textures/basetools_dirtpick.png b/mods/basetools/textures/basetools_dirtpick.png new file mode 100644 index 0000000..20a021d Binary files /dev/null and b/mods/basetools/textures/basetools_dirtpick.png differ diff --git a/mods/basetools/textures/basetools_firesword.png b/mods/basetools/textures/basetools_firesword.png new file mode 100644 index 0000000..ee2809a Binary files /dev/null and b/mods/basetools/textures/basetools_firesword.png differ diff --git a/mods/basetools/textures/basetools_icesword.png b/mods/basetools/textures/basetools_icesword.png new file mode 100644 index 0000000..35ba821 Binary files /dev/null and b/mods/basetools/textures/basetools_icesword.png differ diff --git a/mods/basetools/textures/basetools_mesepick.png b/mods/basetools/textures/basetools_mesepick.png new file mode 100644 index 0000000..2b5e12c Binary files /dev/null and b/mods/basetools/textures/basetools_mesepick.png differ diff --git a/mods/basetools/textures/basetools_steelaxe.png b/mods/basetools/textures/basetools_steelaxe.png new file mode 100644 index 0000000..aac594d Binary files /dev/null and b/mods/basetools/textures/basetools_steelaxe.png differ diff --git a/mods/basetools/textures/basetools_steeldagger.png b/mods/basetools/textures/basetools_steeldagger.png new file mode 100644 index 0000000..4c91730 Binary files /dev/null and b/mods/basetools/textures/basetools_steeldagger.png differ diff --git a/mods/basetools/textures/basetools_steelpick.png b/mods/basetools/textures/basetools_steelpick.png new file mode 100644 index 0000000..bc02aac Binary files /dev/null and b/mods/basetools/textures/basetools_steelpick.png differ diff --git a/mods/basetools/textures/basetools_steelpick_l1.png b/mods/basetools/textures/basetools_steelpick_l1.png new file mode 100644 index 0000000..dc03f3f Binary files /dev/null and b/mods/basetools/textures/basetools_steelpick_l1.png differ diff --git a/mods/basetools/textures/basetools_steelpick_l2.png b/mods/basetools/textures/basetools_steelpick_l2.png new file mode 100644 index 0000000..011df45 Binary files /dev/null and b/mods/basetools/textures/basetools_steelpick_l2.png differ diff --git a/mods/basetools/textures/basetools_steelshears.png b/mods/basetools/textures/basetools_steelshears.png new file mode 100644 index 0000000..04c86c3 Binary files /dev/null and b/mods/basetools/textures/basetools_steelshears.png differ diff --git a/mods/basetools/textures/basetools_steelshovel.png b/mods/basetools/textures/basetools_steelshovel.png new file mode 100644 index 0000000..8cab607 Binary files /dev/null and b/mods/basetools/textures/basetools_steelshovel.png differ diff --git a/mods/basetools/textures/basetools_steelsword.png b/mods/basetools/textures/basetools_steelsword.png new file mode 100644 index 0000000..9909365 Binary files /dev/null and b/mods/basetools/textures/basetools_steelsword.png differ diff --git a/mods/basetools/textures/basetools_stoneaxe.png b/mods/basetools/textures/basetools_stoneaxe.png new file mode 100644 index 0000000..a374c54 Binary files /dev/null and b/mods/basetools/textures/basetools_stoneaxe.png differ diff --git a/mods/basetools/textures/basetools_stonepick.png b/mods/basetools/textures/basetools_stonepick.png new file mode 100644 index 0000000..d9156ee Binary files /dev/null and b/mods/basetools/textures/basetools_stonepick.png differ diff --git a/mods/basetools/textures/basetools_stoneshears.png b/mods/basetools/textures/basetools_stoneshears.png new file mode 100644 index 0000000..0b4bd3b Binary files /dev/null and b/mods/basetools/textures/basetools_stoneshears.png differ diff --git a/mods/basetools/textures/basetools_stoneshovel.png b/mods/basetools/textures/basetools_stoneshovel.png new file mode 100644 index 0000000..3c1bb48 Binary files /dev/null and b/mods/basetools/textures/basetools_stoneshovel.png differ diff --git a/mods/basetools/textures/basetools_stonesword.png b/mods/basetools/textures/basetools_stonesword.png new file mode 100644 index 0000000..6f3e94c Binary files /dev/null and b/mods/basetools/textures/basetools_stonesword.png differ diff --git a/mods/basetools/textures/basetools_woodaxe.png b/mods/basetools/textures/basetools_woodaxe.png new file mode 100644 index 0000000..4015e91 Binary files /dev/null and b/mods/basetools/textures/basetools_woodaxe.png differ diff --git a/mods/basetools/textures/basetools_woodpick.png b/mods/basetools/textures/basetools_woodpick.png new file mode 100644 index 0000000..15c61f4 Binary files /dev/null and b/mods/basetools/textures/basetools_woodpick.png differ diff --git a/mods/basetools/textures/basetools_woodshears.png b/mods/basetools/textures/basetools_woodshears.png new file mode 100644 index 0000000..4ff92fd Binary files /dev/null and b/mods/basetools/textures/basetools_woodshears.png differ diff --git a/mods/basetools/textures/basetools_woodshovel.png b/mods/basetools/textures/basetools_woodshovel.png new file mode 100644 index 0000000..6cc52f8 Binary files /dev/null and b/mods/basetools/textures/basetools_woodshovel.png differ diff --git a/mods/basetools/textures/basetools_woodsword.png b/mods/basetools/textures/basetools_woodsword.png new file mode 100644 index 0000000..364016e Binary files /dev/null and b/mods/basetools/textures/basetools_woodsword.png differ diff --git a/mods/bucket/init.lua b/mods/bucket/init.lua new file mode 100644 index 0000000..ff58b06 --- /dev/null +++ b/mods/bucket/init.lua @@ -0,0 +1,27 @@ +-- Bucket: Punch liquid source or flowing liquid to collect it + +minetest.register_tool("bucket:bucket", { + description = "Bucket".."\n".. + "Picks up liquid nodes", + inventory_image = "bucket.png", + stack_max = 1, + liquids_pointable = true, + groups = { disable_repair = 1 }, + on_use = function(itemstack, user, pointed_thing) + -- Must be pointing to node + if pointed_thing.type ~= "node" then + return + end + -- Check if pointing to a liquid + local n = minetest.get_node(pointed_thing.under) + local def = minetest.registered_nodes[n.name] + if def ~= nil and (def.liquidtype == "source" or def.liquidtype == "flowing") then + minetest.add_node(pointed_thing.under, {name="air"}) + local inv = user:get_inventory() + if inv then + inv:add_item("main", ItemStack(n.name)) + end + end + end, +}) + diff --git a/mods/bucket/mod.conf b/mods/bucket/mod.conf new file mode 100644 index 0000000..d14deb4 --- /dev/null +++ b/mods/bucket/mod.conf @@ -0,0 +1,2 @@ +name = bucket +description = Minimal bucket to pick up liquids diff --git a/mods/bucket/textures/bucket.png b/mods/bucket/textures/bucket.png new file mode 100644 index 0000000..6779528 Binary files /dev/null and b/mods/bucket/textures/bucket.png differ diff --git a/mods/bucket/textures/bucket_lava.png b/mods/bucket/textures/bucket_lava.png new file mode 100644 index 0000000..dfcae65 Binary files /dev/null and b/mods/bucket/textures/bucket_lava.png differ diff --git a/mods/bucket/textures/bucket_water.png b/mods/bucket/textures/bucket_water.png new file mode 100644 index 0000000..e164b0a Binary files /dev/null and b/mods/bucket/textures/bucket_water.png differ diff --git a/mods/chest/init.lua b/mods/chest/init.lua new file mode 100644 index 0000000..5798c13 --- /dev/null +++ b/mods/chest/init.lua @@ -0,0 +1,40 @@ +minetest.register_node("chest:chest", { + description = "Chest" .. "\n" .. + "32 inventory slots", + tiles ={"chest_chest.png^[sheet:2x2:0,0", "chest_chest.png^[sheet:2x2:0,0", + "chest_chest.png^[sheet:2x2:1,0", "chest_chest.png^[sheet:2x2:1,0", + "chest_chest.png^[sheet:2x2:1,0", "chest_chest.png^[sheet:2x2:0,1"}, + paramtype2 = "facedir", + groups = {dig_immediate=2,choppy=3}, + is_ground_content = false, + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", + "size[8,9]".. + "list[current_name;main;0,0;8,4;]".. + "list[current_player;main;0,5;8,4;]" .. + "listring[]") + meta:set_string("infotext", "Chest") + local inv = meta:get_inventory() + inv:set_size("main", 8*4) + end, + can_dig = function(pos,player) + local meta = minetest.get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty("main") + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + minetest.chat_send_player(player:get_player_name(), "Allow put: " .. stack:to_string()) + return stack:get_count() + end, + allow_metadata_inventory_take = function(pos, listname, index, stack, player) + minetest.chat_send_player(player:get_player_name(), "Allow take: " .. stack:to_string()) + return stack:get_count() + end, + on_metadata_inventory_put = function(pos, listname, index, stack, player) + minetest.chat_send_player(player:get_player_name(), "On put: " .. stack:to_string()) + end, + on_metadata_inventory_take = function(pos, listname, index, stack, player) + minetest.chat_send_player(player:get_player_name(), "On take: " .. stack:to_string()) + end, +}) diff --git a/mods/chest/mod.conf b/mods/chest/mod.conf new file mode 100644 index 0000000..0d75001 --- /dev/null +++ b/mods/chest/mod.conf @@ -0,0 +1,2 @@ +name = chest +description = A simple chest to store items diff --git a/mods/chest/textures/chest_chest.png b/mods/chest/textures/chest_chest.png new file mode 100644 index 0000000..824b4d5 Binary files /dev/null and b/mods/chest/textures/chest_chest.png differ diff --git a/mods/chest_of_everything/init.lua b/mods/chest_of_everything/init.lua new file mode 100644 index 0000000..3e9d267 --- /dev/null +++ b/mods/chest_of_everything/init.lua @@ -0,0 +1,136 @@ +local F = minetest.formspec_escape + +-- Create a detached inventory +local inv_everything = minetest.create_detached_inventory("everything", { + allow_move = function(inv, from_list, from_index, to_list, to_index, count, player) + return 0 + end, + allow_put = function(inv, listname, index, stack, player) + return 0 + end, + allow_take = function(inv, listname, index, stack, player) + return -1 + end, +}) +local inv_trash = minetest.create_detached_inventory("trash", { + allow_take = function(inv, listname, index, stack, player) + return 0 + end, + allow_move = function(inv, from_list, from_index, to_list, to_index, count, player) + return 0 + end, + on_put = function(inv, listname, index, stack, player) + inv:set_list("main", {}) + end, +}) +inv_trash:set_size("main", 1) + +local max_page = 1 + +local function get_chest_formspec(page) + local start = 0 + (page-1)*32 + return "size[8,9]".. + "list[detached:everything;main;0,0;8,4;"..start.."]".. + "list[current_player;main;0,5;8,4;]" .. + "label[6,4;Trash:]" .. + "list[detached:trash;main;7,4;1,1]" .. + "button[0,4;1,1;chest_of_everything_prev;"..F("<").."]".. + "button[1,4;1,1;chest_of_everything_next;"..F(">").."]".. + "label[2,4;"..F("Page: "..page).."]".. + "listring[detached:everything;main]".. + "listring[current_player;main]".. + "listring[detached:trash;main]" +end + +minetest.register_node("chest_of_everything:chest", { + description = "Chest of Everything" .. "\n" .. + "Grants access to all items", + tiles ={"chest_of_everything_chest.png^[sheet:2x2:0,0", "chest_of_everything_chest.png^[sheet:2x2:0,0", + "chest_of_everything_chest.png^[sheet:2x2:1,0", "chest_of_everything_chest.png^[sheet:2x2:1,0", + "chest_of_everything_chest.png^[sheet:2x2:1,0", "chest_of_everything_chest.png^[sheet:2x2:0,1"}, + paramtype2 = "facedir", + groups = {dig_immediate=2,choppy=3}, + is_ground_content = false, + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("infotext", "Chest of Everything") + meta:set_int("page", 1) + meta:set_string("formspec", get_chest_formspec(1)) + end, + on_receive_fields = function(pos, formname, fields, sender) + if formname == "" then + local meta = minetest.get_meta(pos) + local page = meta:get_int("page") + if fields.chest_of_everything_prev then + page = page - 1 + elseif fields.chest_of_everything_next then + page = page + 1 + end + if page < 1 then + page = 1 + end + if page > max_page then + page = max_page + end + meta:set_int("page", page) + meta:set_string("formspec", get_chest_formspec(page)) + end + end, +}) + +minetest.register_on_mods_loaded(function() + local items = {} + for itemstring,_ in pairs(minetest.registered_items) do + if itemstring ~= "" and itemstring ~= "unknown" and itemstring ~= "ignore" then + table.insert(items, itemstring) + end + end + --[[ Sort items in this order: + * Chest of Everything + * Test tools + * Other tools + * Craftitems + * Other items + * Dummy items ]] + local function compare(item1, item2) + local def1 = minetest.registered_items[item1] + local def2 = minetest.registered_items[item2] + local tool1 = def1.type == "tool" + local tool2 = def2.type == "tool" + local testtool1 = minetest.get_item_group(item1, "testtool") == 1 + local testtool2 = minetest.get_item_group(item2, "testtool") == 1 + local dummy1 = minetest.get_item_group(item1, "dummy") == 1 + local dummy2 = minetest.get_item_group(item2, "dummy") == 1 + local craftitem1 = def1.type == "craft" + local craftitem2 = def2.type == "craft" + if item1 == "chest_of_everything:chest" then + return true + elseif item2 == "chest_of_everything:chest" then + return false + elseif dummy1 and not dummy2 then + return false + elseif not dummy1 and dummy2 then + return true + elseif testtool1 and not testtool2 then + return true + elseif not testtool1 and testtool2 then + return false + elseif tool1 and not tool2 then + return true + elseif not tool1 and tool2 then + return false + elseif craftitem1 and not craftitem2 then + return true + elseif not craftitem1 and craftitem2 then + return false + else + return item1 < item2 + end + end + table.sort(items, compare) + inv_everything:set_size("main", #items) + max_page = math.ceil(#items / 32) + for i=1, #items do + inv_everything:add_item("main", items[i]) + end +end) diff --git a/mods/chest_of_everything/mod.conf b/mods/chest_of_everything/mod.conf new file mode 100644 index 0000000..4a4425e --- /dev/null +++ b/mods/chest_of_everything/mod.conf @@ -0,0 +1,2 @@ +name = chest_of_everything +description = Adds the chest of everything from which you can take all items diff --git a/mods/chest_of_everything/textures/chest_of_everything_chest.png b/mods/chest_of_everything/textures/chest_of_everything_chest.png new file mode 100644 index 0000000..6b2fd58 Binary files /dev/null and b/mods/chest_of_everything/textures/chest_of_everything_chest.png differ diff --git a/mods/dignodes/init.lua b/mods/dignodes/init.lua new file mode 100644 index 0000000..8331508 --- /dev/null +++ b/mods/dignodes/init.lua @@ -0,0 +1,37 @@ +local groups = { + "cracky", "dig_immediate" +} + +-- Register dig nodes with 1 digging group, a rating between 1-3 and a level between 0-2 +for g=1, #groups do + local gr = groups[g] + for r=1, 3 do + for l=0, 2 do + if not (gr=="dig_immediate" and (l>0 or r==1)) then + local d + if l > 0 then + d = string.format("Dig Test Node: %s=%d, level=%d", gr, r, l) + else + d = string.format("Dig Test Node: %s=%d", gr, r) + end + local tile = "dignodes_"..gr..".png^dignodes_rating"..r..".png" + if l==1 then + tile = tile .. "^[colorize:#FFFF00:127" + elseif l==2 then + tile = tile .. "^[colorize:#FF0000:127" + end + minetest.register_node("dignodes:"..gr.."_"..r.."_"..l, { + description = d, + tiles = { tile }, + groups = { [gr] = r, level = l }, + }) + end + end + end +end + +-- Node without any digging groups +minetest.register_node("dignodes:none", { + description = "Dig Test Node: groupless", + tiles = {"dignodes_none.png"}, +}) diff --git a/mods/dignodes/mod.conf b/mods/dignodes/mod.conf new file mode 100644 index 0000000..52a80d6 --- /dev/null +++ b/mods/dignodes/mod.conf @@ -0,0 +1,2 @@ +name = dignodes +description = Nodes with different digging groups diff --git a/mods/dignodes/textures/dignodes_choppy.png b/mods/dignodes/textures/dignodes_choppy.png new file mode 100644 index 0000000..a73fc24 Binary files /dev/null and b/mods/dignodes/textures/dignodes_choppy.png differ diff --git a/mods/dignodes/textures/dignodes_cracky.png b/mods/dignodes/textures/dignodes_cracky.png new file mode 100644 index 0000000..eb84e30 Binary files /dev/null and b/mods/dignodes/textures/dignodes_cracky.png differ diff --git a/mods/dignodes/textures/dignodes_crumbly.png b/mods/dignodes/textures/dignodes_crumbly.png new file mode 100644 index 0000000..23f2f7c Binary files /dev/null and b/mods/dignodes/textures/dignodes_crumbly.png differ diff --git a/mods/dignodes/textures/dignodes_dig_immediate.png b/mods/dignodes/textures/dignodes_dig_immediate.png new file mode 100644 index 0000000..a532ad9 Binary files /dev/null and b/mods/dignodes/textures/dignodes_dig_immediate.png differ diff --git a/mods/dignodes/textures/dignodes_none.png b/mods/dignodes/textures/dignodes_none.png new file mode 100644 index 0000000..60f1365 Binary files /dev/null and b/mods/dignodes/textures/dignodes_none.png differ diff --git a/mods/dignodes/textures/dignodes_rating1.png b/mods/dignodes/textures/dignodes_rating1.png new file mode 100644 index 0000000..d2fee3a Binary files /dev/null and b/mods/dignodes/textures/dignodes_rating1.png differ diff --git a/mods/dignodes/textures/dignodes_rating2.png b/mods/dignodes/textures/dignodes_rating2.png new file mode 100644 index 0000000..15329b9 Binary files /dev/null and b/mods/dignodes/textures/dignodes_rating2.png differ diff --git a/mods/dignodes/textures/dignodes_rating3.png b/mods/dignodes/textures/dignodes_rating3.png new file mode 100644 index 0000000..37216bf Binary files /dev/null and b/mods/dignodes/textures/dignodes_rating3.png differ diff --git a/mods/experimental/commands.lua b/mods/experimental/commands.lua new file mode 100644 index 0000000..132b08b --- /dev/null +++ b/mods/experimental/commands.lua @@ -0,0 +1,219 @@ +minetest.register_chatcommand("test_inv", { + params = "", + description = "Test: Modify player's inventory formspec", + func = function(name, param) + local player = minetest.get_player_by_name(name) + if not player then + return false, "No player." + end + player:set_inventory_formspec( + "size[13,7.5]".. + "image[6,0.6;1,2;player.png]".. + "list[current_player;main;5,3.5;8,4;]".. + "list[current_player;craft;8,0;3,3;]".. + "list[current_player;craftpreview;12,1;1,1;]".. + "list[detached:test_inventory;main;0,0;4,6;0]".. + "button[0.5,7;2,1;button1;Button 1]".. + "button_exit[2.5,7;2,1;button2;Exit Button]") + return true, "Done." + end, +}) + +minetest.register_chatcommand("test_bulk_set_node", { + params = "", + description = "Test: Bulk-set 9×9×9 stone nodes", + func = function(name, param) + local player = minetest.get_player_by_name(name) + if not player then + return false, "No player." + end + local pos_list = {} + local ppos = player:get_pos() + local i = 1 + for x=2,10 do + for y=2,10 do + for z=2,10 do + pos_list[i] = {x=ppos.x + x,y = ppos.y + y,z = ppos.z + z} + i = i + 1 + end + end + end + minetest.bulk_set_node(pos_list, {name = "mapgen_stone"}) + return true, "Done." + end, +}) + +minetest.register_chatcommand("bench_bulk_set_node", { + params = "", + description = "Benchmark: Bulk-set 99×99×99 stone nodes", + func = function(name, param) + local player = minetest.get_player_by_name(name) + if not player then + return false, "No player." + end + local pos_list = {} + local ppos = player:get_pos() + local i = 1 + for x=2,100 do + for y=2,100 do + for z=2,100 do + pos_list[i] = {x=ppos.x + x,y = ppos.y + y,z = ppos.z + z} + i = i + 1 + end + end + end + + minetest.chat_send_player(name, "Benchmarking minetest.bulk_set_node. Warming up ..."); + + -- warm up with stone to prevent having different callbacks + -- due to different node topology + minetest.bulk_set_node(pos_list, {name = "mapgen_stone"}) + + minetest.chat_send_player(name, "Warming up finished, now benchmarking ..."); + + local start_time = minetest.get_us_time() + for i=1,#pos_list do + minetest.set_node(pos_list[i], {name = "mapgen_stone"}) + end + local middle_time = minetest.get_us_time() + minetest.bulk_set_node(pos_list, {name = "mapgen_stone"}) + local end_time = minetest.get_us_time() + local msg = string.format("Benchmark results: minetest.set_node loop: %.2f ms; minetest.bulk_set_node: %.2f ms", + ((middle_time - start_time)) / 1000, + ((end_time - middle_time)) / 1000 + ) + return true, msg + end, +}) + +local function advance_pos(pos, start_pos, advance_z) + if advance_z then + pos.z = pos.z + 2 + pos.x = start_pos.x + else + pos.x = pos.x + 2 + end + if pos.x > 30900 or pos.x - start_pos.x > 46 then + pos.x = start_pos.x + pos.z = pos.z + 2 + end + if pos.z > 30900 then + -- We ran out of space! Aborting + aborted = true + return false + end + return pos +end + +local function place_nodes(param) + local nodes = param.nodes + local name = param.name + local pos = param.pos + local start_pos = param.start_pos + table.sort(nodes) + minetest.chat_send_player(name, "Placing nodes …") + local nodes_placed = 0 + local aborted = false + for n=1, #nodes do + local itemstring = nodes[n] + local def = minetest.registered_nodes[itemstring] + local p2_max = 0 + if param.param ~= "no_param2" then + -- Also test the param2 values of the nodes + -- ... but we only use permissible param2 values + if def.paramtype2 == "wallmounted" then + p2_max = 5 + elseif def.paramtype2 == "facedir" then + p2_max = 23 + elseif def.paramtype2 == "glasslikeliquidlevel" then + p2_max = 63 + elseif def.paramtype2 == "meshoptions" and def.drawtype == "plantlike" then + p2_max = 63 + elseif def.paramtype2 == "leveled" then + p2_max = 127 + elseif def.paramtype2 == "degrotate" and def.drawtype == "plantlike" then + p2_max = 179 + elseif def.paramtype2 == "colorfacedir" or + def.paramtype2 == "colorwallmounted" or + def.paramtype2 == "color" then + p2_max = 255 + end + end + for p2 = 0, p2_max do + -- Skip undefined param2 values + if not ((def.paramtype2 == "meshoptions" and p2 % 8 > 4) or + (def.paramtype2 == "colorwallmounted" and p2 % 8 > 5) or + (def.paramtype2 == "colorfacedir" and p2 % 32 > 23)) then + + minetest.set_node(pos, { name = itemstring, param2 = p2 }) + nodes_placed = nodes_placed + 1 + pos = advance_pos(pos, start_pos) + if not pos then + aborted = true + break + end + end + end + if aborted then + break + end + end + if aborted then + minetest.chat_send_player(name, "Not all nodes could be placed, please move further away from the world boundary. Nodes placed: "..nodes_placed) + end + minetest.chat_send_player(name, "Nodes placed: "..nodes_placed..".") +end + +local function after_emerge(blockpos, action, calls_remaining, param) + if calls_remaining == 0 then + place_nodes(param) + end +end + +minetest.register_chatcommand("test_place_nodes", { + params = "[ no_param2 ]", + description = "Test: Place all non-experimental nodes and optionally their permissible param2 variants", + func = function(name, param) + local player = minetest.get_player_by_name(name) + if not player then + return false, "No player." + end + local pos = vector.floor(player:get_pos()) + pos.x = math.ceil(pos.x + 3) + pos.z = math.ceil(pos.z + 3) + pos.y = math.ceil(pos.y + 1) + local start_pos = table.copy(pos) + if pos.x > 30800 then + return false, "Too close to world boundary (+X). Please move to X < 30800." + end + if pos.z > 30800 then + return false, "Too close to world boundary (+Z). Please move to Z < 30800." + end + + local aborted = false + local nodes = {} + local emerge_estimate = 0 + for itemstring, def in pairs(minetest.registered_nodes) do + if itemstring ~= "ignore" and string.sub(itemstring, 1, 13) ~= "experimental:" then + table.insert(nodes, itemstring) + if def.paramtype2 == 0 then + emerge_estimate = emerge_estimate + 1 + else + emerge_estimate = emerge_estimate + 255 + end + end + end + -- Emerge area to make sure that all nodes are being placed. + -- Note we will emerge much more than we need to (overestimation), + -- the estimation code could be improved performance-wise … + local length = 16 + math.ceil(emerge_estimate / 24) * 2 + minetest.emerge_area(start_pos, + { x = start_pos.x + 46, y = start_pos.y, z = start_pos.z + length }, + after_emerge, { nodes = nodes, name = name, pos = pos, start_pos = start_pos, param = param }) + return true, "Emerging area …" + end, +}) + +core.register_on_chatcommand(function(name, command, params) + minetest.log("caught command '"..command.."', issued by '"..name.."'. Parameters: '"..params.."'") +end) diff --git a/mods/experimental/detached.lua b/mods/experimental/detached.lua new file mode 100644 index 0000000..673adfd --- /dev/null +++ b/mods/experimental/detached.lua @@ -0,0 +1,29 @@ +-- Create a detached inventory +local inv = minetest.create_detached_inventory("test_inventory", { + allow_move = function(inv, from_list, from_index, to_list, to_index, count, player) + experimental.print_to_everything("allow move asked") + return count -- Allow all + end, + allow_put = function(inv, listname, index, stack, player) + experimental.print_to_everything("allow put asked") + return 1 -- Allow only 1 + end, + allow_take = function(inv, listname, index, stack, player) + experimental.print_to_everything("allow take asked") + return 4 -- Allow 4 at max + end, + on_move = function(inv, from_list, from_index, to_list, to_index, count, player) + experimental.print_to_everything(player:get_player_name().." moved items") + end, + on_put = function(inv, listname, index, stack, player) + experimental.print_to_everything(player:get_player_name().." put items") + end, + on_take = function(inv, listname, index, stack, player) + experimental.print_to_everything(player:get_player_name().." took items") + end, +}) +inv:set_size("main", 4*6) +inv:add_item("main", "experimental:callback_node") +inv:add_item("main", "experimental:particle_spawner") + + diff --git a/mods/experimental/init.lua b/mods/experimental/init.lua new file mode 100644 index 0000000..b292f79 --- /dev/null +++ b/mods/experimental/init.lua @@ -0,0 +1,23 @@ +-- +-- Experimental things +-- + +experimental = {} + +dofile(minetest.get_modpath("experimental").."/detached.lua") +dofile(minetest.get_modpath("experimental").."/items.lua") +dofile(minetest.get_modpath("experimental").."/commands.lua") + +function experimental.print_to_everything(msg) + minetest.log("action", msg) + minetest.chat_send_all(msg) +end + +minetest.log("info", "[experimental] modname="..dump(minetest.get_current_modname())) +minetest.log("info", "[experimental] modpath="..dump(minetest.get_modpath("experimental"))) +minetest.log("info", "[experimental] worldpath="..dump(minetest.get_worldpath())) + + +minetest.register_on_mods_loaded(function() + minetest.log("action", "[experimental] on_mods_loaded()") +end) diff --git a/mods/experimental/items.lua b/mods/experimental/items.lua new file mode 100644 index 0000000..94be71c --- /dev/null +++ b/mods/experimental/items.lua @@ -0,0 +1,105 @@ +minetest.register_node("experimental:callback_node", { + description = "Callback Test Node (construct/destruct/timer)", + tiles = {"experimental_callback_node.png"}, + groups = {dig_immediate=3}, + -- This was known to cause a bug in minetest.item_place_node() when used + -- via minetest.place_node(), causing a placer with no position + paramtype2 = "facedir", + drop = "", + + on_construct = function(pos) + experimental.print_to_everything("experimental:callback_node:on_construct("..minetest.pos_to_string(pos)..")") + local meta = minetest.get_meta(pos) + meta:set_string("mine", "test") + local timer = minetest.get_node_timer(pos) + timer:start(4, 3) + end, + + after_place_node = function(pos, placer) + experimental.print_to_everything("experimental:callback_node:after_place_node("..minetest.pos_to_string(pos)..")") + local meta = minetest.get_meta(pos) + if meta:get_string("mine") == "test" then + experimental.print_to_everything("correct metadata found") + else + experimental.print_to_everything("incorrect metadata found") + end + end, + + on_destruct = function(pos) + experimental.print_to_everything("experimental:callback_node:on_destruct("..minetest.pos_to_string(pos)..")") + end, + + after_destruct = function(pos) + experimental.print_to_everything("experimental:callback_node:after_destruct("..minetest.pos_to_string(pos)..")") + end, + + after_dig_node = function(pos, oldnode, oldmetadata, digger) + experimental.print_to_everything("experimental:callback_node:after_dig_node("..minetest.pos_to_string(pos)..")") + end, + + on_timer = function(pos, elapsed) + experimental.print_to_everything("on_timer(): elapsed="..dump(elapsed)) + return true + end, +}) + +minetest.register_tool("experimental:privatizer", { + description = "Node Meta Privatizer".."\n".. + "Punch: Marks 'infotext' and 'formspec' meta fields of chest as private", + inventory_image = "experimental_tester_tool_1.png", + groups = { testtool = 1, disable_repair = 1 }, + on_use = function(itemstack, user, pointed_thing) + if pointed_thing.type == "node" then + local node = minetest.get_node(pointed_thing.under) + if node.name == "chest:chest" then + local p = pointed_thing.under + minetest.log("action", "Privatizer used at "..minetest.pos_to_string(p)) + minetest.get_meta(p):mark_as_private({"infotext", "formspec"}) + if user and user:is_player() then + minetest.chat_send_player(user:get_player_name(), "Chest metadata (infotext, formspec) set private!") + end + return + end + end + if user and user:is_player() then + minetest.chat_send_player(user:get_player_name(), "Privatizer can only be used on chest!") + end + end, +}) + +minetest.register_tool("experimental:particle_spawner", { + description = "Particle Spawner".."\n".. + "Punch: Spawn random test particle", + inventory_image = "experimental_tester_tool_1.png^[invert:g", + groups = { testtool = 1, disable_repair = 1 }, + on_use = function(itemstack, user, pointed_thing) + local pos = minetest.get_pointed_thing_position(pointed_thing, true) + if pos == nil then + if user then + pos = user:get_pos() + end + end + pos = vector.add(pos, {x=0, y=0.5, z=0}) + local tex, anim + if math.random(0, 1) == 0 then + tex = "experimental_particle_sheet.png" + anim = {type="sheet_2d", frames_w=3, frames_h=2, frame_length=0.5} + else + tex = "experimental_particle_vertical.png" + anim = {type="vertical_frames", aspect_w=16, aspect_h=16, length=3.3} + end + + minetest.add_particle({ + pos = pos, + velocity = {x=0, y=0, z=0}, + acceleration = {x=0, y=0.04, z=0}, + expirationtime = 6, + collisiondetection = true, + texture = tex, + animation = anim, + size = 4, + glow = math.random(0, 5), + }) + end, +}) + diff --git a/mods/experimental/mod.conf b/mods/experimental/mod.conf new file mode 100644 index 0000000..cf0f9cb --- /dev/null +++ b/mods/experimental/mod.conf @@ -0,0 +1,2 @@ +name = experimental +description = Chaotic mod containing unstructured tests for testing out engine features. The features in this mod should be moved to other mods. diff --git a/mods/experimental/textures/experimental_callback_node.png b/mods/experimental/textures/experimental_callback_node.png new file mode 100644 index 0000000..e9d8743 Binary files /dev/null and b/mods/experimental/textures/experimental_callback_node.png differ diff --git a/mods/experimental/textures/experimental_particle_sheet.png b/mods/experimental/textures/experimental_particle_sheet.png new file mode 100644 index 0000000..6d70394 Binary files /dev/null and b/mods/experimental/textures/experimental_particle_sheet.png differ diff --git a/mods/experimental/textures/experimental_particle_vertical.png b/mods/experimental/textures/experimental_particle_vertical.png new file mode 100644 index 0000000..0320b75 Binary files /dev/null and b/mods/experimental/textures/experimental_particle_vertical.png differ diff --git a/mods/experimental/textures/experimental_tester_tool_1.png b/mods/experimental/textures/experimental_tester_tool_1.png new file mode 100644 index 0000000..5df416a Binary files /dev/null and b/mods/experimental/textures/experimental_tester_tool_1.png differ diff --git a/mods/give_initial_stuff/init.lua b/mods/give_initial_stuff/init.lua new file mode 100644 index 0000000..491a531 --- /dev/null +++ b/mods/give_initial_stuff/init.lua @@ -0,0 +1,37 @@ +local give_if_not_gotten_already = function(inv, list, item) + if not inv:contains_item(list, item) then + inv:add_item(list, item) + end +end + +local give_initial_stuff = function(player) + local inv = player:get_inventory() + give_if_not_gotten_already(inv, "main", "basetools:pick_mese") + give_if_not_gotten_already(inv, "main", "basetools:axe_steel") + give_if_not_gotten_already(inv, "main", "basetools:shovel_steel") + give_if_not_gotten_already(inv, "main", "bucket:bucket") + give_if_not_gotten_already(inv, "main", "testnodes:light14") + give_if_not_gotten_already(inv, "main", "chest_of_everything:chest") + minetest.log("action", "[give_initial_stuff] Giving initial stuff to "..player:get_player_name()) +end + +minetest.register_on_newplayer(function(player) + if minetest.settings:get_bool("give_initial_stuff", true) then + give_initial_stuff(player) + end +end) + +minetest.register_chatcommand("stuff", { + params = "", + privs = { give = true }, + description = "Give yourself initial items", + func = function(name, param) + local player = minetest.get_player_by_name(name) + if not player or not player:is_player() then + return false, "No player." + end + give_initial_stuff(player) + return true + end, +}) + diff --git a/mods/give_initial_stuff/mod.conf b/mods/give_initial_stuff/mod.conf new file mode 100644 index 0000000..1ba49f5 --- /dev/null +++ b/mods/give_initial_stuff/mod.conf @@ -0,0 +1,3 @@ +name = give_initial_stuff +description = Gives items to players on join +depends = basetools, bucket, chest_of_everything, testnodes diff --git a/mods/initial_message/init.lua b/mods/initial_message/init.lua new file mode 100644 index 0000000..59e9f5f --- /dev/null +++ b/mods/initial_message/init.lua @@ -0,0 +1,9 @@ +minetest.register_on_joinplayer(function(player) + local cb = function(player) + if not player or not player:is_player() then + return + end + minetest.chat_send_player(player:get_player_name(), "This is the \"Development Test\" [devtest], meant only for testing and development. Use Minetest Game for the real thing.") + end + minetest.after(2.0, cb, player) +end) diff --git a/mods/initial_message/mod.conf b/mods/initial_message/mod.conf new file mode 100644 index 0000000..32aa2ac --- /dev/null +++ b/mods/initial_message/mod.conf @@ -0,0 +1,2 @@ +name = initial_message +description = Show message to joining players explaining what this testing game is about diff --git a/mods/mapgen/init.lua b/mods/mapgen/init.lua new file mode 100644 index 0000000..a5f9128 --- /dev/null +++ b/mods/mapgen/init.lua @@ -0,0 +1,104 @@ +-- +-- Aliases for map generator outputs +-- + +-- ESSENTIAL node aliases +-- Basic nodes +minetest.register_alias("mapgen_stone", "basenodes:stone") +minetest.register_alias("mapgen_water_source", "basenodes:water_source") +minetest.register_alias("mapgen_river_water_source", "basenodes:river_water_source") + +-- Additional essential aliases for v6 +minetest.register_alias("mapgen_lava_source", "basenodes:lava_source") +minetest.register_alias("mapgen_dirt", "basenodes:dirt") +minetest.register_alias("mapgen_dirt_with_grass", "basenodes:dirt_with_grass") +minetest.register_alias("mapgen_sand", "basenodes:sand") +minetest.register_alias("mapgen_tree", "basenodes:tree") +minetest.register_alias("mapgen_leaves", "basenodes:leaves") +minetest.register_alias("mapgen_apple", "basenodes:apple") + +-- Essential alias for dungeons +minetest.register_alias("mapgen_cobble", "basenodes:cobble") + +-- Optional aliases for v6 (they all have fallback values in the engine) +if minetest.settings:get_bool("devtest_v6_mapgen_aliases", false) then + minetest.register_alias("mapgen_gravel", "basenodes:gravel") + minetest.register_alias("mapgen_desert_stone", "basenodes:desert_stone") + minetest.register_alias("mapgen_desert_sand", "basenodes:desert_sand") + minetest.register_alias("mapgen_dirt_with_snow", "basenodes:dirt_with_snow") + minetest.register_alias("mapgen_snowblock", "basenodes:snowblock") + minetest.register_alias("mapgen_snow", "basenodes:snow") + minetest.register_alias("mapgen_ice", "basenodes:ice") + minetest.register_alias("mapgen_junglegrass", "basenodes:junglegrass") + minetest.register_alias("mapgen_jungletree", "basenodes:jungletree") + minetest.register_alias("mapgen_jungleleaves", "basenodes:jungleleaves") + minetest.register_alias("mapgen_pine_tree", "basenodes:pine_tree") + minetest.register_alias("mapgen_pine_needles", "basenodes:pine_needles") +end +-- Optional alias for mossycobble (should fall back to cobble) +if minetest.settings:get_bool("devtest_dungeon_mossycobble", false) then + minetest.register_alias("mapgen_mossycobble", "basenodes:mossycobble") +end +-- Optional aliases for dungeon stairs (should fall back to full nodes) +if minetest.settings:get_bool("devtest_dungeon_stairs", false) then + minetest.register_alias("mapgen_stair_cobble", "stairs:stair_cobble") + if minetest.settings:get_bool("devtest_v6_mapgen_aliases", false) then + minetest.register_alias("mapgen_stair_desert_stone", "stairs:stair_desert_stone") + end +end + +-- +-- Register biomes for biome API +-- + +minetest.clear_registered_biomes() +minetest.clear_registered_decorations() + +if minetest.settings:get_bool("devtest_register_biomes", true) then + minetest.register_biome({ + name = "mapgen:grassland", + node_top = "basenodes:dirt_with_grass", + depth_top = 1, + node_filler = "basenodes:dirt", + depth_filler = 1, + node_riverbed = "basenodes:sand", + depth_riverbed = 2, + node_dungeon = "basenodes:cobble", + node_dungeon_alt = "basenodes:mossycobble", + node_dungeon_stair = "stairs:stair_cobble", + y_max = 31000, + y_min = 4, + heat_point = 50, + humidity_point = 50, + }) + + minetest.register_biome({ + name = "mapgen:grassland_ocean", + node_top = "basenodes:sand", + depth_top = 1, + node_filler = "basenodes:sand", + depth_filler = 3, + node_riverbed = "basenodes:sand", + depth_riverbed = 2, + node_cave_liquid = "basenodes:water_source", + node_dungeon = "basenodes:cobble", + node_dungeon_alt = "basenodes:mossycobble", + node_dungeon_stair = "stairs:stair_cobble", + y_max = 3, + y_min = -255, + heat_point = 50, + humidity_point = 50, + }) + + minetest.register_biome({ + name = "mapgen:grassland_under", + node_cave_liquid = {"basenodes:water_source", "basenodes:lava_source"}, + node_dungeon = "basenodes:cobble", + node_dungeon_alt = "basenodes:mossycobble", + node_dungeon_stair = "stairs:stair_cobble", + y_max = -256, + y_min = -31000, + heat_point = 50, + humidity_point = 50, + }) +end diff --git a/mods/mapgen/mod.conf b/mods/mapgen/mod.conf new file mode 100644 index 0000000..15750cc --- /dev/null +++ b/mods/mapgen/mod.conf @@ -0,0 +1,3 @@ +name = mapgen +description = Minimal map generator +depends = basenodes diff --git a/mods/modchannels/init.lua b/mods/modchannels/init.lua new file mode 100644 index 0000000..ee925f0 --- /dev/null +++ b/mods/modchannels/init.lua @@ -0,0 +1,14 @@ +-- +-- Mod channels experimental handlers +-- +local mod_channel = minetest.mod_channel_join("experimental_preview") + +minetest.register_on_modchannel_message(function(channel, sender, message) + minetest.log("action", "[modchannels] Server received message `" .. message + .. "` on channel `" .. channel .. "` from sender `" .. sender .. "`") + + if mod_channel:is_writeable() then + mod_channel:send_all("experimental answers to preview") + mod_channel:leave() + end +end) diff --git a/mods/modchannels/mod.conf b/mods/modchannels/mod.conf new file mode 100644 index 0000000..7c13aad --- /dev/null +++ b/mods/modchannels/mod.conf @@ -0,0 +1,2 @@ +name = modchannels +description = Add experimental mod channel handlers diff --git a/mods/soundstuff/init.lua b/mods/soundstuff/init.lua new file mode 100644 index 0000000..b263a3f --- /dev/null +++ b/mods/soundstuff/init.lua @@ -0,0 +1,174 @@ +local simple_nodes = { + footstep = { "Footstep Sound Node", "soundstuff_node_footstep.png" }, + dig = { "Dig Sound Node", "soundstuff_node_dig.png" }, + dug = { "Dug Sound Node", "soundstuff_node_dug.png" }, + place = { "Place Sound Node", "soundstuff_node_place.png" }, + place_failed = { "Place Failed Sound Node", "soundstuff_node_place_failed.png" }, +} + +for k,v in pairs(simple_nodes) do + minetest.register_node("soundstuff:"..k, { + description = v[1], + tiles = {"soundstuff_node_sound.png","soundstuff_node_sound.png",v[2]}, + groups = {dig_immediate=2}, + sounds = { + [k] = { name = "soundstuff_mono", gain = 1.0 }, + } + }) +end + +minetest.register_node("soundstuff:place_failed_attached", { + description = "Attached Place Failed Sound Node", + tiles = {"soundstuff_node_sound.png", "soundstuff_node_sound.png", "soundstuff_node_place_failed.png"}, + groups = {dig_immediate=2, attached_node=1}, + drawtype = "nodebox", + paramtype = "light", + node_box = { type = "fixed", fixed = { + { -7/16, -7/16, -7/16, 7/16, 7/16, 7/16 }, + { -0.5, -0.5, -0.5, 0.5, -7/16, 0.5 }, + }}, + sounds = { + place_failed = { name = "soundstuff_mono", gain = 1.0 }, + }, +}) + +minetest.register_node("soundstuff:fall", { + description = "Fall Sound Node", + tiles = {"soundstuff_node_sound.png", "soundstuff_node_sound.png", "soundstuff_node_fall.png"}, + groups = {dig_immediate=2, falling_node=1}, + sounds = { + fall = { name = "soundstuff_mono", gain = 1.0 }, + } +}) + +minetest.register_node("soundstuff:fall_attached", { + description = "Attached Fall Sound Node", + tiles = {"soundstuff_node_sound.png", "soundstuff_node_sound.png", "soundstuff_node_fall.png"}, + groups = {dig_immediate=2, attached_node=1}, + drawtype = "nodebox", + paramtype = "light", + node_box = { type = "fixed", fixed = { + { -7/16, -7/16, -7/16, 7/16, 7/16, 7/16 }, + { -0.5, -0.5, -0.5, 0.5, -7/16, 0.5 }, + }}, + sounds = { + fall = { name = "soundstuff_mono", gain = 1.0 }, + } +}) + +minetest.register_node("soundstuff:footstep_liquid", { + description = "Liquid Footstep Sound Node", + drawtype = "liquid", + tiles = { + "soundstuff_node_sound.png^[colorize:#0000FF:127^[opacity:190", + }, + special_tiles = { + {name = "soundstuff_node_sound.png^[colorize:#0000FF:127^[opacity:190", + backface_culling = false}, + {name = "soundstuff_node_sound.png^[colorize:#0000FF:127^[opacity:190", + backface_culling = true}, + }, + liquids_pointable = true, + liquidtype = "source", + liquid_alternative_flowing = "soundstuff:footstep_liquid", + liquid_alternative_source = "soundstuff:footstep_liquid", + liquid_renewable = false, + liquid_range = 0, + liquid_viscosity = 0, + use_texture_alpha = "blend", + paramtype = "light", + walkable = false, + pointable = false, + diggable = false, + buildable_to = true, + is_ground_content = false, + post_effect_color = {a = 64, r = 0, g = 0, b = 200}, + sounds = { + footstep = { name = "soundstuff_mono", gain = 1.0 }, + } +}) + +minetest.register_node("soundstuff:footstep_climbable", { + description = "Climbable Footstep Sound Node", + drawtype = "allfaces", + tiles = { + "soundstuff_node_climbable.png", + }, + paramtype = "light", + sunlight_propagates = true, + walkable = false, + climbable = true, + is_ground_content = false, + groups = { dig_immediate = 2 }, + sounds = { + footstep = { name = "soundstuff_mono", gain = 1.0 }, + } +}) + + + +minetest.register_craftitem("soundstuff:eat", { + description = "Eat Sound Item".."\n".. + "Makes a sound when 'eaten' (with punch key)", + inventory_image = "soundstuff_eat.png", + on_use = minetest.item_eat(0), + sound = { + eat = { name = "soundstuff_mono", gain = 1.0 }, + } +}) + +minetest.register_tool("soundstuff:breaks", { + description = "Break Sound Tool".."\n".. + "Digs cracky=3 and more".."\n".. + "Makes a sound when it breaks", + inventory_image = "soundstuff_node_dug.png", + sound = { + breaks = { name = "soundstuff_mono", gain = 1.0 }, + }, + tool_capabilities = { + max_drop_level=0, + groupcaps={ + cracky={times={[2]=2.00, [3]=1.20}, uses=1, maxlevel=0}, + choppy={times={[2]=2.00, [3]=1.20}, uses=1, maxlevel=0}, + snappy={times={[2]=2.00, [3]=1.20}, uses=1, maxlevel=0}, + crumbly={times={[2]=2.00, [3]=1.20}, uses=1, maxlevel=0}, + }, + }, +}) + +-- Plays sound repeatedly +minetest.register_node("soundstuff:positional", { + description = "Positional Sound Node", + on_construct = function(pos) + local timer = minetest.get_node_timer(pos) + timer:start(0) + end, + on_timer = function(pos, elapsed) + local node = minetest.get_node(pos) + local dist = node.param2 + if dist == 0 then + dist = nil + end + minetest.sound_play("soundstuff_mono", { pos = pos, max_hear_distance = dist }) + local timer = minetest.get_node_timer(pos) + timer:start(0.7) + end, + on_rightclick = function(pos, node, clicker) + node.param2 = (node.param2 + 1) % 64 + minetest.set_node(pos, node) + if clicker and clicker:is_player() then + local dist = node.param2 + local diststr + if dist == 0 then + diststr = "" + else + diststr = tostring(dist) + end + minetest.chat_send_player(clicker:get_player_name(), "max_hear_distance = " .. diststr) + end + end, + + groups = { dig_immediate = 2 }, + tiles = { "soundstuff_node_sound.png" }, +}) + diff --git a/mods/soundstuff/mod.conf b/mods/soundstuff/mod.conf new file mode 100644 index 0000000..2c631e2 --- /dev/null +++ b/mods/soundstuff/mod.conf @@ -0,0 +1,2 @@ +name = soundstuff +description = Example items and nodes for testing sound effects diff --git a/mods/soundstuff/sounds/soundstuff_mono.ogg b/mods/soundstuff/sounds/soundstuff_mono.ogg new file mode 100644 index 0000000..43428d5 Binary files /dev/null and b/mods/soundstuff/sounds/soundstuff_mono.ogg differ diff --git a/mods/soundstuff/textures/soundstuff_eat.png b/mods/soundstuff/textures/soundstuff_eat.png new file mode 100644 index 0000000..aed2054 Binary files /dev/null and b/mods/soundstuff/textures/soundstuff_eat.png differ diff --git a/mods/soundstuff/textures/soundstuff_node_blank.png b/mods/soundstuff/textures/soundstuff_node_blank.png new file mode 100644 index 0000000..4dffacc Binary files /dev/null and b/mods/soundstuff/textures/soundstuff_node_blank.png differ diff --git a/mods/soundstuff/textures/soundstuff_node_climbable.png b/mods/soundstuff/textures/soundstuff_node_climbable.png new file mode 100644 index 0000000..3888f79 Binary files /dev/null and b/mods/soundstuff/textures/soundstuff_node_climbable.png differ diff --git a/mods/soundstuff/textures/soundstuff_node_dig.png b/mods/soundstuff/textures/soundstuff_node_dig.png new file mode 100644 index 0000000..67ba111 Binary files /dev/null and b/mods/soundstuff/textures/soundstuff_node_dig.png differ diff --git a/mods/soundstuff/textures/soundstuff_node_dug.png b/mods/soundstuff/textures/soundstuff_node_dug.png new file mode 100644 index 0000000..bab5fbe Binary files /dev/null and b/mods/soundstuff/textures/soundstuff_node_dug.png differ diff --git a/mods/soundstuff/textures/soundstuff_node_fall.png b/mods/soundstuff/textures/soundstuff_node_fall.png new file mode 100644 index 0000000..17b14f1 Binary files /dev/null and b/mods/soundstuff/textures/soundstuff_node_fall.png differ diff --git a/mods/soundstuff/textures/soundstuff_node_footstep.png b/mods/soundstuff/textures/soundstuff_node_footstep.png new file mode 100644 index 0000000..6367ae9 Binary files /dev/null and b/mods/soundstuff/textures/soundstuff_node_footstep.png differ diff --git a/mods/soundstuff/textures/soundstuff_node_place.png b/mods/soundstuff/textures/soundstuff_node_place.png new file mode 100644 index 0000000..d159ad5 Binary files /dev/null and b/mods/soundstuff/textures/soundstuff_node_place.png differ diff --git a/mods/soundstuff/textures/soundstuff_node_place_failed.png b/mods/soundstuff/textures/soundstuff_node_place_failed.png new file mode 100644 index 0000000..780ba94 Binary files /dev/null and b/mods/soundstuff/textures/soundstuff_node_place_failed.png differ diff --git a/mods/soundstuff/textures/soundstuff_node_sound.png b/mods/soundstuff/textures/soundstuff_node_sound.png new file mode 100644 index 0000000..0592a02 Binary files /dev/null and b/mods/soundstuff/textures/soundstuff_node_sound.png differ diff --git a/mods/spawnbuilder/README.md b/mods/spawnbuilder/README.md new file mode 100644 index 0000000..e4c06bc --- /dev/null +++ b/mods/spawnbuilder/README.md @@ -0,0 +1,44 @@ +# Spawn Builder +Version 1.1.0 + +## Description +This mod generates a simple stone platform at the world origin +or the static spawn point. +Ideal for the `singlenode` map generator. + +## Usage +Activate this *before* the spawn area got generated (ideally +in a new world), then just join the world. +Recommended to be used in the `singlenode` mapgen, but it works +in other map generators, too. + +### Settings +With the setting `spawnbuilder_width` you can change the width of +the spawn platform. Note that values below 3 are not recommended. + +If the static spawn point (`static_spawnpoint`) is set on the +first start of the mod, the platform is centered at this +position instead. + +## Behaviour +This mod generates a stone platform of size 33×2×33 with +a single cobblestone in the center. Also, 3 layers +above the platform are turned into air because the +center position might be buried in the ground. + +As a safety measure, nodes with the property +`is_ground_content=false` will never be overwritten. + +Also, no platform is generated if the center position is +already in a safe spawn (in air, a few blocks below solid +ground). + +## Dependencies +This mod works with almost all subgames out of the box. + +The only requirement is that the subgame defines the mapgen +aliases `mapgen_stone` and `mapgen_cobble` which is almost +certainly the case. + +## License of everything in this mod +MIT License. diff --git a/mods/spawnbuilder/init.lua b/mods/spawnbuilder/init.lua new file mode 100644 index 0000000..0da1239 --- /dev/null +++ b/mods/spawnbuilder/init.lua @@ -0,0 +1,159 @@ +local storage_ref = minetest.get_mod_storage() +local stored_centerpos = {} +local check = storage_ref:get_string("spawnbuilder_centerpos_x") +if check ~= "" then + stored_centerpos.x = storage_ref:get_int("spawnbuilder_centerpos_x") + stored_centerpos.y = storage_ref:get_int("spawnbuilder_centerpos_y") + stored_centerpos.z = storage_ref:get_int("spawnbuilder_centerpos_z") + minetest.log("action", "[spawnbuilder] Spawn platform position loaded: "..minetest.pos_to_string(stored_centerpos)) +else + stored_centerpos = minetest.setting_get_pos("static_spawnpoint") + -- Default position + if not stored_centerpos then + stored_centerpos = { x=0, y=-1, z=0 } + end + storage_ref:set_int("spawnbuilder_centerpos_x", stored_centerpos.x) + storage_ref:set_int("spawnbuilder_centerpos_y", stored_centerpos.y) + storage_ref:set_int("spawnbuilder_centerpos_z", stored_centerpos.z) + minetest.log("action", "[spawnbuilder] Initial spawn platform position registered and saved: "..minetest.pos_to_string(stored_centerpos)) +end + +-- Width of the stored_centerpos platform +local WIDTH +check = storage_ref:get_string("spawnbuilder_width") +if check ~= "" then + WIDTH = check +else + WIDTH = tonumber(minetest.settings:get("spawnbuilder_width")) + if type(WIDTH) == "number" then + WIDTH = math.floor(WIDTH) + else + WIDTH = 33 + end +end +minetest.log("action", "[spawnbuilder] Using spawn platform width of "..WIDTH..".") + +-- Height of the platform +local HEIGHT = 2 + +-- Number of air layers above the platform +local AIRSPACE = 3 + +-- Testing noise NOISE_PARAMS +local NOISE_PARAMS = + { + offset = 0, + scale = 1, + spread = { x = 100, y = 100, z = 100 }, + seed = 23, + octaves = 3, + persist = 0.70 + }; +local SIZE = { x = 100, y = 100, z = 100 }; + + +local function logResult(context, obj) + local msg = (obj and "good") or "nil"; + minetest.log("error", context.." returned "..msg.." object"); +end + +minetest.after(0, function() + logResult("get_perlin_map", minetest.get_perlin_map(NOISE_PARAMS, SIZE)); + logResult("get_perlin_map", minetest.get_perlin_map(NOISE_PARAMS, SIZE)); + logResult("PerlinNoise", PerlinNoise(23, 3, 0.70, 100)); + logResult("PerlinNoiseMap", PerlinNoiseMap(NOISE_PARAMS, SIZE)); +end) + + + + +-- Generates the platform or platform piece within minp and maxp with the center at centerpos +local function generate_platform(minp, maxp, centerpos) + -- Get stone and cobble nodes, based on the mapgen aliases. This allows for great compability with practically + -- all subgames! + local c_stone = minetest.get_content_id("mapgen_stone") + local c_cobble + if minetest.registered_aliases["mapgen_cobble"] == "air" or minetest.registered_aliases["mapgen_cobble"] == nil then + -- Fallback option: If cobble mapgen alias is inappropriate or missing, use stone instead. + c_cobble = c_stone + else + c_cobble = minetest.get_content_id("mapgen_cobble") + end + + local w_neg, w_pos + w_pos = math.floor(WIDTH / 2) + if math.fmod(WIDTH, 2) == 0 then + w_neg = -w_pos + 1 + else + w_neg = -w_pos + end + + local xmin = math.max(centerpos.x + w_neg, minp.x) + local xmax = math.min(centerpos.x + w_pos, maxp.x) + local zmin = math.max(centerpos.z + w_neg, minp.z) + local zmax = math.min(centerpos.z + w_pos, maxp.z) + local ymin = math.max(centerpos.y - (HEIGHT-1), minp.y) + local ymax = math.min(centerpos.y + AIRSPACE, maxp.y) + + if maxp.x >= xmin and minp.x <= xmax and maxp.y >= ymin and minp.y <= ymax and maxp.z >= zmin and minp.z <= zmax then + local vm, emin, emax = minetest.get_mapgen_object("voxelmanip") + local data = vm:get_data() + local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax}) + + for x = xmin, xmax do + for y = ymin, ymax do + for z = zmin, zmax do + local p_pos = area:index(x, y, z) + local pos = {x=x,y=y,z=z} + if minetest.registered_nodes[minetest.get_node(pos).name].is_ground_content == true then + if y <= centerpos.y then + if x == centerpos.x and y == centerpos.y and z == centerpos.z then + data[p_pos] = c_cobble + minetest.log("action", "[spawnbuilder] Spawn platform center generated at "..minetest.pos_to_string(pos)..".") + else + data[p_pos] = c_stone + end + elseif y >= centerpos.y + 1 and y <= ymax then + data[p_pos] = core.CONTENT_AIR + end + end + end + end + end + + vm:set_data(data) + vm:calc_lighting() + vm:write_to_map() + end +end + +minetest.register_on_generated(function(minp, maxp, seed) + local centerpos = table.copy(stored_centerpos) + + if minp.x <= centerpos.x and maxp.x >= centerpos.x and minp.y <= centerpos.y and maxp.y >= centerpos.y and minp.z <= centerpos.z and maxp.z >= centerpos.z then + if not WIDTH or WIDTH <= 0 then + minetest.log("warning", "[spawnbuilder] Invalid spawnbuilder_width. Spawn platform will NOT be generated.") + return + end + + local ground = false + local air = true + -- Check for solid ground + for y = 3, -6, -1 do + local nn = minetest.get_node({x=centerpos.x, y=centerpos.y+y, centerpos.z}).name + local walkable = minetest.registered_nodes[nn].walkable + if y >= 0 and nn ~= "air" then + air = false + elseif y < 0 and walkable then + ground = true + end + end + -- Player has enough space and ground to spawn safely. No change required + if air and ground then + minetest.log("action", "[spawnbuilder] Safe player spawn detected. Spawn platform will NOT be generated.") + return + end + end + + generate_platform(minp, maxp, centerpos) +end) diff --git a/mods/spawnbuilder/mod.conf b/mods/spawnbuilder/mod.conf new file mode 100644 index 0000000..771d664 --- /dev/null +++ b/mods/spawnbuilder/mod.conf @@ -0,0 +1,2 @@ +name = spawnbuilder +description = Generates a stone platform below the world origin or static spawn point. Ideal for the singlenode mapgen. diff --git a/mods/spawnbuilder/screenshot.png b/mods/spawnbuilder/screenshot.png new file mode 100644 index 0000000..a147ec4 Binary files /dev/null and b/mods/spawnbuilder/screenshot.png differ diff --git a/mods/spawnbuilder/settingtypes.txt b/mods/spawnbuilder/settingtypes.txt new file mode 100644 index 0000000..55899bc --- /dev/null +++ b/mods/spawnbuilder/settingtypes.txt @@ -0,0 +1,4 @@ +#Side length of the surface area of the spawn platform +#If the number is odd, the platform will be centered at spawn. +#Using a width lower than 3 is not recommended. +spawnbuilder_width (Spawn platform width) int 33 1 diff --git a/mods/stairs/init.lua b/mods/stairs/init.lua new file mode 100644 index 0000000..2701cab --- /dev/null +++ b/mods/stairs/init.lua @@ -0,0 +1,65 @@ +stairs = {} + +-- Node will be called stairs:stair_ +function stairs.register_stair(subname, recipeitem, groups, images, description) + minetest.register_node(":stairs:stair_" .. subname, { + description = description, + drawtype = "nodebox", + tiles = images, + paramtype = "light", + paramtype2 = "facedir", + is_ground_content = true, + groups = groups, + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, + {-0.5, 0, 0, 0.5, 0.5, 0.5}, + }, + }, + }) +end + +-- Node will be called stairs:slab_ +function stairs.register_slab(subname, recipeitem, groups, images, description) + minetest.register_node(":stairs:slab_" .. subname, { + description = description, + drawtype = "nodebox", + tiles = images, + paramtype = "light", + is_ground_content = true, + groups = groups, + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, + }, + selection_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, + }, + }) +end + +-- Nodes will be called stairs:{stair,slab}_ +function stairs.register_stair_and_slab(subname, recipeitem, groups, images, desc_stair, desc_slab) + stairs.register_stair(subname, recipeitem, groups, images, desc_stair) + stairs.register_slab(subname, recipeitem, groups, images, desc_slab) +end + +stairs.register_stair_and_slab("stone", "basenodes:stone", + {cracky=3}, + {"default_stone.png"}, + "Stone Stair", + "Stone Slab") + +stairs.register_stair_and_slab("desert_stone", "basenodes:desert_stone", + {cracky=3}, + {"default_desert_stone.png"}, + "Desert Stone Stair", + "Desert Stone Slab") + +stairs.register_stair_and_slab("cobble", "basenodes:cobble", + {cracky=3}, + {"default_cobble.png"}, + "Cobblestone Stair", + "Cobblestone Slab") diff --git a/mods/stairs/mod.conf b/mods/stairs/mod.conf new file mode 100644 index 0000000..724bff8 --- /dev/null +++ b/mods/stairs/mod.conf @@ -0,0 +1,3 @@ +name = stairs +description = Adds stairs and slabs +depends = basenodes diff --git a/mods/testentities/armor.lua b/mods/testentities/armor.lua new file mode 100644 index 0000000..306953d --- /dev/null +++ b/mods/testentities/armor.lua @@ -0,0 +1,41 @@ +-- Armorball: Test entity for testing armor groups +-- Rightclick to change armor group + +local phasearmor = { + [0]={icy=100}, + [1]={fiery=100}, + [2]={fleshy=100}, + [3]={immortal=1}, + [4]={punch_operable=1}, +} + +minetest.register_entity("testentities:armorball", { + initial_properties = { + hp_max = 20, + physical = false, + collisionbox = {-0.4,-0.4,-0.4, 0.4,0.4,0.4}, + visual = "sprite", + visual_size = {x=1, y=1}, + textures = {"testentities_armorball.png"}, + spritediv = {x=1, y=5}, + initial_sprite_basepos = {x=0, y=0}, + }, + + _phase = 2, + + on_activate = function(self, staticdata) + minetest.log("action", "[testentities] armorball.on_activate") + self.object:set_armor_groups(phasearmor[self._phase]) + self.object:set_sprite({x=0, y=self._phase}) + end, + + on_rightclick = function(self, clicker) + -- Change armor group and sprite + self._phase = self._phase + 1 + if self._phase >= 5 then + self._phase = 0 + end + self.object:set_sprite({x=0, y=self._phase}) + self.object:set_armor_groups(phasearmor[self._phase]) + end, +}) diff --git a/mods/testentities/callbacks.lua b/mods/testentities/callbacks.lua new file mode 100644 index 0000000..320690b --- /dev/null +++ b/mods/testentities/callbacks.lua @@ -0,0 +1,78 @@ +-- Entities that test their callbacks + +local message = function(msg) + minetest.log("action", msg) + minetest.chat_send_all(msg) +end + +local get_object_name = function(obj) + local name = "" + if obj then + if obj:is_player() then + name = obj:get_player_name() + else + name = "" + end + end + return name +end + +local spos = function(self) + return minetest.pos_to_string(vector.round(self.object:get_pos())) +end + +-- Callback test entity (all callbacks except on_step) +minetest.register_entity("testentities:callback", { + initial_properties = { + visual = "upright_sprite", + textures = { "testentities_callback.png" }, + }, + + on_activate = function(self, staticdata, dtime_s) + message("Callback entity: on_activate! pos="..spos(self).."; dtime_s="..dtime_s) + end, + on_deactivate = function(self) + message("Callback entity: on_deactivate! pos="..spos(self)) + end, + on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage) + local name = get_object_name(puncher) + message( + "Callback entity: on_punch! ".. + "pos="..spos(self).."; puncher="..name.."; ".. + "time_from_last_punch="..time_from_last_punch.."; ".. + "tool_capabilities="..tostring(dump(tool_capabilities)).."; ".. + "dir="..tostring(dump(dir)).."; damage="..damage) + end, + on_rightclick = function(self, clicker) + local name = get_object_name(clicker) + message("Callback entity: on_rightclick! pos="..spos(self).."; clicker="..name) + end, + on_death = function(self, killer) + local name = get_object_name(killer) + message("Callback entity: on_death! pos="..spos(self).."; killer="..name) + end, + on_attach_child = function(self, child) + local name = get_object_name(child) + message("Callback entity: on_attach_child! pos="..spos(self).."; child="..name) + end, + on_detach_child = function(self, child) + local name = get_object_name(child) + message("Callback entity: on_detach_child! pos="..spos(self).."; child="..name) + end, + on_detach = function(self, parent) + local name = get_object_name(parent) + message("Callback entity: on_detach! pos="..spos(self).."; parent="..name) + end, + get_staticdata = function(self) + message("Callback entity: get_staticdata! pos="..spos(self)) + end, +}) + +-- Only test on_step callback +minetest.register_entity("testentities:callback_step", { + visual = "upright_sprite", + textures = { "testentities_callback_step.png" }, + on_step = function(self, dtime) + message("on_step callback entity: on_step! pos="..spos(self).."; dtime="..dtime) + end, +}) diff --git a/mods/testentities/init.lua b/mods/testentities/init.lua new file mode 100644 index 0000000..df8c72e --- /dev/null +++ b/mods/testentities/init.lua @@ -0,0 +1,3 @@ +dofile(minetest.get_modpath("testentities").."/visuals.lua") +dofile(minetest.get_modpath("testentities").."/armor.lua") +dofile(minetest.get_modpath("testentities").."/callbacks.lua") diff --git a/mods/testentities/mod.conf b/mods/testentities/mod.conf new file mode 100644 index 0000000..7a8cb5a --- /dev/null +++ b/mods/testentities/mod.conf @@ -0,0 +1,2 @@ +name = testentities +description = Example entities for testing diff --git a/mods/testentities/textures/testentities_armorball.png b/mods/testentities/textures/testentities_armorball.png new file mode 100644 index 0000000..88147bd Binary files /dev/null and b/mods/testentities/textures/testentities_armorball.png differ diff --git a/mods/testentities/textures/testentities_callback.png b/mods/testentities/textures/testentities_callback.png new file mode 100644 index 0000000..c4c9066 Binary files /dev/null and b/mods/testentities/textures/testentities_callback.png differ diff --git a/mods/testentities/textures/testentities_callback_step.png b/mods/testentities/textures/testentities_callback_step.png new file mode 100644 index 0000000..b67506a Binary files /dev/null and b/mods/testentities/textures/testentities_callback_step.png differ diff --git a/mods/testentities/textures/testentities_cube1.png b/mods/testentities/textures/testentities_cube1.png new file mode 100644 index 0000000..c667e42 Binary files /dev/null and b/mods/testentities/textures/testentities_cube1.png differ diff --git a/mods/testentities/textures/testentities_cube2.png b/mods/testentities/textures/testentities_cube2.png new file mode 100644 index 0000000..4818234 Binary files /dev/null and b/mods/testentities/textures/testentities_cube2.png differ diff --git a/mods/testentities/textures/testentities_cube3.png b/mods/testentities/textures/testentities_cube3.png new file mode 100644 index 0000000..03b5daa Binary files /dev/null and b/mods/testentities/textures/testentities_cube3.png differ diff --git a/mods/testentities/textures/testentities_cube4.png b/mods/testentities/textures/testentities_cube4.png new file mode 100644 index 0000000..6392048 Binary files /dev/null and b/mods/testentities/textures/testentities_cube4.png differ diff --git a/mods/testentities/textures/testentities_cube5.png b/mods/testentities/textures/testentities_cube5.png new file mode 100644 index 0000000..d8acdf0 Binary files /dev/null and b/mods/testentities/textures/testentities_cube5.png differ diff --git a/mods/testentities/textures/testentities_cube6.png b/mods/testentities/textures/testentities_cube6.png new file mode 100644 index 0000000..5f81a64 Binary files /dev/null and b/mods/testentities/textures/testentities_cube6.png differ diff --git a/mods/testentities/textures/testentities_dungeon_master.png b/mods/testentities/textures/testentities_dungeon_master.png new file mode 100644 index 0000000..1e31077 Binary files /dev/null and b/mods/testentities/textures/testentities_dungeon_master.png differ diff --git a/mods/testentities/textures/testentities_sprite.png b/mods/testentities/textures/testentities_sprite.png new file mode 100644 index 0000000..a4b0196 Binary files /dev/null and b/mods/testentities/textures/testentities_sprite.png differ diff --git a/mods/testentities/textures/testentities_upright_sprite1.png b/mods/testentities/textures/testentities_upright_sprite1.png new file mode 100644 index 0000000..6242511 Binary files /dev/null and b/mods/testentities/textures/testentities_upright_sprite1.png differ diff --git a/mods/testentities/textures/testentities_upright_sprite2.png b/mods/testentities/textures/testentities_upright_sprite2.png new file mode 100644 index 0000000..a79a760 Binary files /dev/null and b/mods/testentities/textures/testentities_upright_sprite2.png differ diff --git a/mods/testentities/visuals.lua b/mods/testentities/visuals.lua new file mode 100644 index 0000000..e382ec4 --- /dev/null +++ b/mods/testentities/visuals.lua @@ -0,0 +1,137 @@ +-- Minimal test entities to test visuals + +minetest.register_entity("testentities:sprite", { + initial_properties = { + visual = "sprite", + textures = { "testentities_sprite.png" }, + }, +}) + +minetest.register_entity("testentities:upright_sprite", { + initial_properties = { + visual = "upright_sprite", + textures = { + "testentities_upright_sprite1.png", + "testentities_upright_sprite2.png", + }, + }, +}) + +minetest.register_entity("testentities:cube", { + initial_properties = { + visual = "cube", + textures = { + "testentities_cube1.png", + "testentities_cube2.png", + "testentities_cube3.png", + "testentities_cube4.png", + "testentities_cube5.png", + "testentities_cube6.png", + }, + }, +}) + +minetest.register_entity("testentities:item", { + initial_properties = { + visual = "item", + wield_item = "testnodes:normal", + }, +}) + +minetest.register_entity("testentities:wielditem", { + initial_properties = { + visual = "wielditem", + wield_item = "testnodes:normal", + }, +}) + +minetest.register_entity("testentities:mesh", { + initial_properties = { + visual = "mesh", + mesh = "testnodes_pyramid.obj", + textures = { + "testnodes_mesh_stripes2.png" + }, + }, +}) + +minetest.register_entity("testentities:mesh_unshaded", { + initial_properties = { + visual = "mesh", + mesh = "testnodes_pyramid.obj", + textures = { + "testnodes_mesh_stripes2.png" + }, + shaded = false, + }, +}) + +-- Advanced visual tests + +-- An entity for testing animated and yaw-modulated sprites +minetest.register_entity("testentities:yawsprite", { + initial_properties = { + selectionbox = {-0.3, -0.5, -0.3, 0.3, 0.3, 0.3}, + visual = "sprite", + visual_size = {x=0.6666, y=1}, + textures = {"testentities_dungeon_master.png^[makealpha:128,0,0^[makealpha:128,128,0"}, + spritediv = {x=6, y=5}, + initial_sprite_basepos = {x=0, y=0}, + }, + on_activate = function(self, staticdata) + self.object:set_sprite({x=0, y=0}, 3, 0.5, true) + end, +}) + +-- An entity for testing animated upright sprites +minetest.register_entity("testentities:upright_animated", { + initial_properties = { + visual = "upright_sprite", + textures = {"testnodes_anim.png"}, + spritediv = {x = 1, y = 4}, + }, + on_activate = function(self) + self.object:set_sprite({x=0, y=0}, 4, 1.0, false) + end, +}) + +minetest.register_entity("testentities:nametag", { + initial_properties = { + visual = "sprite", + textures = { "testentities_sprite.png" }, + }, + + on_activate = function(self, staticdata) + if staticdata ~= "" then + local data = minetest.deserialize(staticdata) + self.color = data.color + self.bgcolor = data.bgcolor + else + self.color = { + r = math.random(0, 255), + g = math.random(0, 255), + b = math.random(0, 255), + } + + if math.random(0, 10) > 5 then + self.bgcolor = { + r = math.random(0, 255), + g = math.random(0, 255), + b = math.random(0, 255), + a = math.random(0, 255), + } + end + end + + assert(self.color) + self.object:set_properties({ + nametag = tostring(math.random(1000, 10000)), + nametag_color = self.color, + nametag_bgcolor = self.bgcolor, + }) + end, + + get_staticdata = function(self) + return minetest.serialize({ color = self.color, bgcolor = self.bgcolor }) + end, +}) diff --git a/mods/testfood/init.lua b/mods/testfood/init.lua new file mode 100644 index 0000000..39b1213 --- /dev/null +++ b/mods/testfood/init.lua @@ -0,0 +1,31 @@ +local S = minetest.get_translator("testfood") + +minetest.register_craftitem("testfood:good1", { + description = S("Good Food (+1)"), + inventory_image = "testfood_good.png", + on_use = minetest.item_eat(1), +}) +minetest.register_craftitem("testfood:good5", { + description = S("Good Food (+5)"), + inventory_image = "testfood_good2.png", + on_use = minetest.item_eat(5), +}) + +minetest.register_craftitem("testfood:bad1", { + description = S("Bad Food (-1)"), + inventory_image = "testfood_bad.png", + on_use = minetest.item_eat(-1), +}) +minetest.register_craftitem("testfood:bad5", { + description = S("Bad Food (-5)"), + inventory_image = "testfood_bad2.png", + on_use = minetest.item_eat(-5), +}) + +minetest.register_craftitem("testfood:replace1", { + description = S("Replacing Food (+1)").."\n".. + S("Replaced with 'Good Food (+1)' when eaten"), + inventory_image = "testfood_replace.png", + on_use = minetest.item_eat(1, "testfood:good1"), +}) + diff --git a/mods/testfood/mod.conf b/mods/testfood/mod.conf new file mode 100644 index 0000000..7bff21b --- /dev/null +++ b/mods/testfood/mod.conf @@ -0,0 +1,2 @@ +name = testfood +description = For testing food items diff --git a/mods/testfood/textures/testfood_bad.png b/mods/testfood/textures/testfood_bad.png new file mode 100644 index 0000000..6e92514 Binary files /dev/null and b/mods/testfood/textures/testfood_bad.png differ diff --git a/mods/testfood/textures/testfood_bad2.png b/mods/testfood/textures/testfood_bad2.png new file mode 100644 index 0000000..22b5678 Binary files /dev/null and b/mods/testfood/textures/testfood_bad2.png differ diff --git a/mods/testfood/textures/testfood_good.png b/mods/testfood/textures/testfood_good.png new file mode 100644 index 0000000..31df7f5 Binary files /dev/null and b/mods/testfood/textures/testfood_good.png differ diff --git a/mods/testfood/textures/testfood_good2.png b/mods/testfood/textures/testfood_good2.png new file mode 100644 index 0000000..e43dda2 Binary files /dev/null and b/mods/testfood/textures/testfood_good2.png differ diff --git a/mods/testfood/textures/testfood_replace.png b/mods/testfood/textures/testfood_replace.png new file mode 100644 index 0000000..1ef6876 Binary files /dev/null and b/mods/testfood/textures/testfood_replace.png differ diff --git a/mods/testformspec/LICENSE.txt b/mods/testformspec/LICENSE.txt new file mode 100644 index 0000000..07696cc --- /dev/null +++ b/mods/testformspec/LICENSE.txt @@ -0,0 +1,14 @@ +License of media files +---------------------- +Content imported from minetest_game. + + +BlockMen (CC BY-SA 3.0) + default_chest_front.png + default_chest_lock.png + default_chest_side.png + default_chest_top.png + +stujones11 (CC BY-SA 3.0) +An0n3m0us (CC BY-SA 3.0) + testformspec_character.b3d diff --git a/mods/testformspec/callbacks.lua b/mods/testformspec/callbacks.lua new file mode 100644 index 0000000..5593805 --- /dev/null +++ b/mods/testformspec/callbacks.lua @@ -0,0 +1,51 @@ +local callback_test = 0 + +local out = function(player, formname, fields, number) + local snum = "" + if number then + snum = " "..number + end + local msg = "Formspec callback"..snum..": player="..player:get_player_name()..", formname=\""..tostring(formname).."\", fields="..dump(fields) + minetest.chat_send_player(player:get_player_name(), msg) + minetest.log("action", msg) +end + +minetest.register_on_player_receive_fields(function(player, formname, fields) + if callback_test == 1 then + out(player, formname, fields) + elseif callback_test == 2 then + out(player, formname, fields, 1) + end +end) +minetest.register_on_player_receive_fields(function(player, formname, fields) + if callback_test == 2 then + out(player, formname, fields, 2) + return true -- Disable the first callback + end +end) +minetest.register_on_player_receive_fields(function(player, formname, fields) + if callback_test == 2 then + out(player, formname, fields, 3) + end +end) + +minetest.register_chatcommand("test_formspec_callbacks", { + params = "[ 0 | 1 | 2 ]", + description = "Test: Change formspec callbacks testing mode", + func = function(name, param) + local mode = tonumber(param) + if not mode then + callback_test = (callback_test + 1 % 3) + else + callback_test = mode + end + if callback_test == 1 then + minetest.chat_send_player(name, "Formspec callback test mode 1 enabled: Logging only") + elseif callback_test == 2 then + minetest.chat_send_player(name, "Formspec callback test mode 2 enabled: Three callbacks, disable pre-registered callbacks") + else + callback_test = 0 + minetest.chat_send_player(name, "Formspec callback test disabled!") + end + end +}) diff --git a/mods/testformspec/dummy_items.lua b/mods/testformspec/dummy_items.lua new file mode 100644 index 0000000..2037ae9 --- /dev/null +++ b/mods/testformspec/dummy_items.lua @@ -0,0 +1,14 @@ +-- This code adds dummy items that are supposed to be used in formspecs +-- for testing item_image formspec elements. + +minetest.register_node("testformspec:node", { + description = "Formspec Test Node", + tiles = { "testformspec_node.png" }, + groups = { dig_immediate = 3, dummy = 1 }, +}) + +minetest.register_craftitem("testformspec:item", { + description = "Formspec Test Item", + inventory_image = "testformspec_item.png", + groups = { dummy = 1 }, +}) diff --git a/mods/testformspec/formspec.lua b/mods/testformspec/formspec.lua new file mode 100644 index 0000000..2a2bdad --- /dev/null +++ b/mods/testformspec/formspec.lua @@ -0,0 +1,419 @@ +local color = minetest.colorize + +local clip_fs = [[ + style_type[label,button,image_button,item_image_button, + tabheader,scrollbar,table,animated_image + ,field,textarea,checkbox,dropdown;noclip=%c] + + label[0,0;A clipping test] + button[0,1;3,0.8;clip_button;A clipping test] + image_button[0,2;3,0.8;testformspec_button_image.png;clip_image_button;A clipping test] + item_image_button[0,3;3,0.8;testformspec:item;clip_item_image_button;A clipping test] + tabheader[0,4.7;3,0.63;clip_tabheader;Clip,Test,Text,Tabs;1;false;false] + field[0,5;3,0.8;clip_field;Title;] + textarea[0,6;3,1;clip_textarea;Title;] + checkbox[0,7.5;clip_checkbox;This is a test;true] + dropdown[0,8;3,0.8;clip_dropdown;Select An Item,One,Two,Three,Four,Five;1] + scrollbar[0,9;3,0.8;horizontal;clip_scrollbar;3] + tablecolumns[text;text] + table[0,10;3,1;clip_table;one,two,three,four;1] + animated_image[-0.5,11;4.5,1;clip_animated_image;testformspec_animation.png;4;100] +]] + +local tabheaders_fs = [[ + tabheader[0,0;10,0.63;tabs_opaque;Opaque,Without,Border;1;false;false] + tabheader[0,1;10,0.63;tabs_opaque_border;Opaque,With,Border;1;false;true] + tabheader[0,2;10,0.63;tabs_transparent;Transparent,Without,Border;1;true;false] + tabheader[0,3;10,0.63;tabs_transparent_border;Transparent,With,Border;1;true;true] + tabheader[0,4;tabs_default;Default,Tabs;1] + tabheader[0,6;10,0.5;tabs_size1;Height=0.5;1;false;false] + tabheader[2,6;10,0.75;tabs_size1;Height=0.75;1;false;false] + tabheader[4,6;10,1;tabs_size2;Height=1;1;false;false] + tabheader[6,6;10,1.25;tabs_size2;Height=1.25;1;false;false] + tabheader[8,6;10,1.5;tabs_size2;Height=1.5;1;false;false] +]] + +local inv_style_fs = [[ + style_type[list;noclip=true] + list[current_player;main;-0.75,0.75;2,2] + + real_coordinates[false] + list[current_player;main;1.5,0;3,2] + real_coordinates[true] + + real_coordinates[false] + style_type[list;size=1.1;spacing=0.1] + list[current_player;main;5,0;3,2] + real_coordinates[true] + + style_type[list;size=.001;spacing=0] + list[current_player;main;7,3.5;8,4] + + box[3,3.5;1,1;#000000] + box[5,3.5;1,1;#000000] + box[4,4.5;1,1;#000000] + box[3,5.5;1,1;#000000] + box[5,5.5;1,1;#000000] + style_type[list;spacing=.25,.125;size=.75,.875] + list[current_player;main;3,3.5;3,3] + + style_type[list;spacing=0;size=1.1] + list[current_player;main;.5,7;8,4] +]] + +local hypertext_basic = [[ +Normal test +This is a normal text. + +style test + + . + + +Tag test +normal +mono +bold +italic +underlined +big +bigger +left +
center
+right +justify. Here comes a blind text: Lorem testum dolor sit amet consecutor celeron fiftifahivus e shadoninia e smalus jokus anrus relsocutoti rubenwardus. Erasputinus hara holisti dominus wusi. Grumarinsti erltusmuate ol fortitusti fla flo, blani burki e sfani fahif. Ultae ratii, e megus gigae don anonimus. Grinus dimondus krockus e nore. Endus finalus nowus comus endus o blindus tekstus. + +Custom tag test + + + + + +color=green +Action: color=green +Action: hovercolor=yellow +size=24 +font=mono +color=green font=mono size=24 + +action test +action + +img test +Normal: + +width=48 height=48: + +float=left: + +float=right: + + +item test +Normal: + +width=48 height=48 + +angle=30,0,0: + +angle=0,30,0: + +angle=0,0,30: + +rotate=yes: + +rotate=100,0,0: + +rotate=0,100,0: + +rotate=0,0,100: + +rotate=50,75,100: + +angle=-30,-45,90 rotate=100,150,-50: +]] + +local hypertext_global = [[ + +This is a test of the global tag. The parameters are: +background=gray margin=20 valign=bottom halign=right color=pink hovercolor=purple size=12 font=mono +action]] + +local hypertext_fs = "hypertext[0,0;11,9;hypertext;"..minetest.formspec_escape(hypertext_basic).."]".. + "hypertext[0,9.5;11,2.5;hypertext;"..minetest.formspec_escape(hypertext_global).."]" + +local style_fs = [[ + style[one_btn1;bgcolor=red;textcolor=yellow;bgcolor_hovered=orange; + bgcolor_pressed=purple] + button[0,0;2.5,0.8;one_btn1;Button] + + style[one_btn2;border=false;textcolor=cyan] ]].. + "button[0,1.05;2.5,0.8;one_btn2;Text " .. color("#FF0", "Yellow") .. [[] + + style[one_btn3;bgimg=testformspec_button_image.png;bgimg_hovered=testformspec_hovered.png; + bgimg_pressed=testformspec_pressed.png] + button[0,2.1;1,1;one_btn3;Border] + + style[one_btn4;bgimg=testformspec_button_image.png;bgimg_hovered=testformspec_hovered.png; + bgimg_pressed=testformspec_pressed.png;border=false] + button[1.25,2.1;1,1;one_btn4;NoBor] + + style[one_btn5;bgimg=testformspec_button_image.png;bgimg_hovered=testformspec_hovered.png; + bgimg_pressed=testformspec_pressed.png;border=false;alpha=false] + button[0,3.35;1,1;one_btn5;Alph] + + style[one_btn6;border=true] + image_button[0,4.6;1,1;testformspec_button_image.png;one_btn6;Border] + + style[one_btn7;border=false] + image_button[1.25,4.6;1,1;testformspec_button_image.png;one_btn7;NoBor] + + style[one_btn8;border=false] + image_button[0,5.85;1,1;testformspec_button_image.png;one_btn8;Border;false;true;testformspec_pressed.png] + + style[one_btn9;border=true] + image_button[1.25,5.85;1,1;testformspec_button_image.png;one_btn9;NoBor;false;false;testformspec_pressed.png] + + style[one_btn10;alpha=false] + image_button[0,7.1;1,1;testformspec_button_image.png;one_btn10;NoAlpha] + + style[one_btn11;alpha=true] + image_button[1.25,7.1;1,1;testformspec_button_image.png;one_btn11;Alpha] + + style[one_btn12;border=true] + item_image_button[0,8.35;1,1;testformspec:item;one_btn12;Border] + + style[one_btn13;border=false] + item_image_button[1.25,8.35;1,1;testformspec:item;one_btn13;NoBor] + + style[one_btn14;border=false;bgimg=testformspec_bg.png;fgimg=testformspec_button_image.png] + style[one_btn14:hovered;bgimg=testformspec_bg_hovered.png;fgimg=testformspec_hovered.png;textcolor=yellow] + style[one_btn14:pressed;bgimg=testformspec_bg_pressed.png;fgimg=testformspec_pressed.png;textcolor=blue] + style[one_btn14:hovered+pressed;textcolor=purple] + image_button[0,9.6;1,1;testformspec_button_image.png;one_btn14;Bg] + + style[one_btn15;border=false;bgcolor=#1cc;bgimg=testformspec_bg.png;bgimg_hovered=testformspec_bg_hovered.png;bgimg_pressed=testformspec_bg_pressed.png] + item_image_button[1.25,9.6;1,1;testformspec:item;one_btn15;Bg] + + style[one_btn16;border=false;bgimg=testformspec_bg_9slice.png;bgimg_hovered=testformspec_bg_9slice_hovered.png;bgimg_pressed=testformspec_bg_9slice_pressed.png;bgimg_middle=4,6] + button[2.5,9.6;2,1;one_btn16;9-Slice Bg] + + + + container[2.75,0] + + style[one_tb1;textcolor=Yellow] + tabheader[0,3;2.5,0.63;one_tb1;Yellow,Text,Tabs;1;false;false] + + style[one_f1;textcolor=yellow] + field[0,4.25;2.5,0.8;one_f1;Field One;Yellow Text] + + style[one_f2;border=false;textcolor=cyan] + field[0,5.75;2.5,0.8;one_f2;Field Two;Borderless Cyan Text] + + style[one_f3;textcolor=yellow] + textarea[0,7.025;2.5,0.8;one_f3;Label;]] .. + minetest.formspec_escape("Yellow Text\nLine two") .. [[ ] + + style[one_f4;border=false;textcolor=cyan] + textarea[0,8.324999999999999;2.5,0.8;one_f4;Label;]] .. + minetest.formspec_escape("Borderless Cyan Text\nLine two") .. [[ ] + + container_end[] +]] + +local scroll_fs = + "button[8.5,1;4,1;outside;Outside of container]".. + "box[1,1;8,6;#00aa]".. + "scroll_container[1,1;8,6;scrbar;vertical]".. + "button[0,1;1,1;lorem;Lorem]".. + "animated_image[0,1;4.5,1;clip_animated_image;testformspec_animation.png;4;100]" .. + "button[0,10;1,1;ipsum;Ipsum]".. + "pwdfield[2,2;1,1;lorem2;Lorem]".. + "list[current_player;main;4,4;1,5;]".. + "box[2,5;3,2;#ffff00]".. + "image[1,10;3,2;testformspec_item.png]".. + "image[3,1;testformspec_item.png]".. + "item_image[2,6;3,2;testformspec:node]".. + "label[2,15;bla Bli\nfoo bar]".. + "item_image_button[2,3;1,1;testformspec:node;itemimagebutton;ItemImageButton]".. + "tooltip[0,11;3,2;Buz;#f00;#000]".. + "box[0,11;3,2;#00ff00]".. + "hypertext[3,13;3,3;;" .. hypertext_basic .. "]" .. + "hypertext[3,17;3,3;;Hypertext with no scrollbar\\; the scroll container should scroll.]" .. + "textarea[3,21;3,1;textarea;;More scroll within scroll]" .. + "container[0,18]".. + "box[1,2;3,2;#0a0a]".. + "scroll_container[1,2;3,2;scrbar2;horizontal;0.06]".. + "button[0,0;6,1;butnest;Nest]".. + "label[10,0.5;nest]".. + "scroll_container_end[]".. + "scrollbar[1,0;3.5,0.3;horizontal;scrbar2;0]".. + "container_end[]".. + "dropdown[0,6;2;hmdrpdwn;apple,bulb;1]".. + "image_button[0,4;2,2;testformspec_button_image.png;imagebutton;bbbbtt;false;true;testformspec_pressed.png]".. + "box[1,22.5;4,1;#a00a]".. + "scroll_container_end[]".. + "scrollbaroptions[max=170]".. -- lowest seen pos is: 0.1*170+6=23 (factor*max+height) + "scrollbar[7.5,0;0.3,4;vertical;scrbar;0]".. + "scrollbar[8,0;0.3,4;vertical;scrbarhmmm;0]".. + "dropdown[0,6;2;hmdrpdwnnn;Outside,of,container;1]" + +--style_type[label;textcolor=green] +--label[0,0;Green] +--style_type[label;textcolor=blue] +--label[0,1;Blue] +--style_type[label;textcolor=;border=true] +--label[1.2,0;Border] +--style_type[label;border=true;bgcolor=red] +--label[1.2,1;Background] +--style_type[label;border=;bgcolor=] +--label[0.75,2;Reset] + + +local pages = { + -- Real Coordinates + [[ + formspec_version[3] + size[12,13] + image_button[0,0;1,1;logo.png;rc_image_button_1x1;1x1] + image_button[1,0;2,2;logo.png;rc_image_button_2x2;2x2] + button[0,2;1,1;rc_button_1x1;1x1] + button[1,2;2,2;rc_button_2x2;2x2] + item_image[0,4;1,1;air] + item_image[1,4;2,2;air] + item_image_button[0,6;1,1;testformspec:node;rc_item_image_button_1x1;1x1] + item_image_button[1,6;2,2;testformspec:node;rc_item_image_button_2x2;2x2] + field[3,.5;3,.5;rc_field;Field;text] + pwdfield[6,.5;3,1;rc_pwdfield;Password Field] + field[3,1;3,1;;Read-Only Field;text] + textarea[3,2;3,.5;rc_textarea_small;Textarea;text] + textarea[6,2;3,2;rc_textarea_big;Textarea;text\nmore text] + textarea[3,3;3,1;;Read-Only Textarea;text\nmore text] + textlist[3,4;3,2;rc_textlist;Textlist,Perfect Coordinates;1;false] + tableoptions[highlight=#ABCDEF75;background=#00000055;border=false] + table[6,4;3,2;rc_table;Table,Cool Stuff,Foo,Bar;2] + dropdown[3,6;3,1;rc_dropdown_small;This,is,a,dropdown;1] + dropdown[6,6;3,2;rc_dropdown_big;I,am,a,bigger,dropdown;5] + image[0,8;3,2;ignore.png] + box[3,7;3,1;#00A3FF] + checkbox[3,8;rc_checkbox_1;Check me!;false] + checkbox[3,9;rc_checkbox_2;Uncheck me now!;true] + scrollbar[0,11.5;11.5,.5;horizontal;rc_scrollbar_horizontal;500] + scrollbar[11.5,0;.5,11.5;vertical;rc_scrollbar_vertical;0] + list[current_player;main;6,8;3,2;1] + button[9,0;2.5,1;rc_empty_button_1;] + button[9,1;2.5,1;rc_empty_button_2;] + button[9,2;2.5,1;rc_empty_button_3;] ]].. + "label[9,0.5;This is a label.\nLine\nLine\nLine\nEnd]".. + [[button[9,3;1,1;rc_empty_button_4;] + vertlabel[9,4;VERT] + label[10,3;HORIZ] + tabheader[8,0;6,0.65;rc_tabheader;Tab 1,Tab 2,Tab 3,Secrets;1;false;false] + ]], + -- Style + + "formspec_version[3]size[12,13]" .. + ("label[0.375,0.375;Styled - %s %s]"):format( + color("#F00", "red text"), + color("#77FF00CC", "green text")) .. + "label[6.375,0.375;Unstyled]" .. + "box[0,0.75;12,0.1;#999]" .. + "box[6,0.85;0.1,11.15;#999]" .. + "container[0.375,1.225]" .. + style_fs .. + "container_end[]container[6.375,1.225]" .. + style_fs:gsub("one_", "two_"):gsub("style%[[^%]]+%]", ""):gsub("style_type%[[^%]]+%]", "") .. + "container_end[]", + + -- Noclip + "formspec_version[3]size[12,13]" .. + "label[0.1,0.5;Clip]" .. + "container[-2.5,1]" .. clip_fs:gsub("%%c", "false") .. "container_end[]" .. + "label[11,0.5;Noclip]" .. + "container[11.5,1]" .. clip_fs:gsub("%%c", "true") .. "container_end[]", + + -- Hypertext + "size[12,13]real_coordinates[true]" .. + "container[0.5,0.5]" .. hypertext_fs .. "container_end[]", + + -- Tabheaders + "size[12,13]real_coordinates[true]" .. + "container[0.5,1.5]" .. tabheaders_fs .. "container_end[]", + + -- Inv + "size[12,13]real_coordinates[true]" .. inv_style_fs, + + -- Animation + [[ + formspec_version[3] + size[12,13] + animated_image[0.5,0.5;1,1;;testformspec_animation.png;4;100] + animated_image[0.5,1.75;1,1;;testformspec_animation.jpg;4;100] + animated_image[1.75,0.5;1,1;;testformspec_animation.png;100;100] + animated_image[3,0.5;1,1;ani_img_1;testformspec_animation.png;4;1000] + button[4.25,0.5;1,1;ani_btn_1;Current +Number] + animated_image[3,1.75;1,1;ani_img_2;testformspec_animation.png;4;1000;2] + button[4.25,1.75;1,1;ani_btn_2;Current +Number] + animated_image[3,3;1,1;;testformspec_animation.png;4;0] + animated_image[3,4.25;1,1;;testformspec_animation.png;4;0;3] + animated_image[5.5,0.5;5,2;;testformspec_animation.png;4;100] + animated_image[5.5,2.75;5,2;;testformspec_animation.jpg;4;100] + + style[m1;bgcolor=black] + model[0.5,6;4,4;m1;testformspec_character.b3d;testformspec_character.png] + model[5,6;4,4;m2;testformspec_chest.obj;default_chest_top.png,default_chest_top.png,default_chest_side.png,default_chest_side.png,default_chest_front.png,default_chest_inside.png;30,1;true;true] + ]], + + -- Scroll containers + "formspec_version[3]size[12,13]" .. + scroll_fs, +} + +local function show_test_formspec(pname, page_id) + page_id = page_id or 2 + + local fs = pages[page_id] .. "tabheader[0,0;8,0.65;maintabs;Real Coord,Styles,Noclip,Hypertext,Tabs,Invs,Anim,ScrollC;" .. page_id .. ";false;false]" + + minetest.show_formspec(pname, "testformspec:formspec", fs) +end + +minetest.register_on_player_receive_fields(function(player, formname, fields) + if formname ~= "testformspec:formspec" then + return false + end + + + if fields.maintabs then + show_test_formspec(player:get_player_name(), tonumber(fields.maintabs)) + return true + end + + if fields.ani_img_1 and fields.ani_btn_1 then + minetest.chat_send_player(player:get_player_name(), "ani_img_1 = " .. tostring(fields.ani_img_1)) + return true + elseif fields.ani_img_2 and fields.ani_btn_2 then + minetest.chat_send_player(player:get_player_name(), "ani_img_2 = " .. tostring(fields.ani_img_2)) + return true + end + + if fields.hypertext then + minetest.chat_send_player(player:get_player_name(), "Hypertext action received: " .. tostring(fields.hypertext)) + return true + end +end) + +minetest.register_chatcommand("test_formspec", { + params = "", + description = "Open the test formspec", + func = function(name) + if not minetest.get_player_by_name(name) then + return false, "You need to be online!" + end + + show_test_formspec(name) + return true + end, +}) diff --git a/mods/testformspec/init.lua b/mods/testformspec/init.lua new file mode 100644 index 0000000..23b565f --- /dev/null +++ b/mods/testformspec/init.lua @@ -0,0 +1,3 @@ +dofile(minetest.get_modpath("testformspec").."/dummy_items.lua") +dofile(minetest.get_modpath("testformspec").."/formspec.lua") +dofile(minetest.get_modpath("testformspec").."/callbacks.lua") diff --git a/mods/testformspec/mod.conf b/mods/testformspec/mod.conf new file mode 100644 index 0000000..00eac30 --- /dev/null +++ b/mods/testformspec/mod.conf @@ -0,0 +1,2 @@ +name = testformspec +description = Contains an example formspec to test all the features of formspecs diff --git a/mods/testformspec/models/testformspec_character.b3d b/mods/testformspec/models/testformspec_character.b3d new file mode 100644 index 0000000..8edbaf6 Binary files /dev/null and b/mods/testformspec/models/testformspec_character.b3d differ diff --git a/mods/testformspec/models/testformspec_chest.obj b/mods/testformspec/models/testformspec_chest.obj new file mode 100644 index 0000000..72ba175 --- /dev/null +++ b/mods/testformspec/models/testformspec_chest.obj @@ -0,0 +1,79 @@ +# Blender v2.78 (sub 0) OBJ File: 'chest-open.blend' +# www.blender.org +o Top_Cube.002_None_Top_Cube.002_None_bottom +v -0.500000 0.408471 0.720970 +v -0.500000 1.115578 0.013863 +v -0.500000 0.894607 -0.207108 +v -0.500000 0.187501 0.499999 +v 0.500000 1.115578 0.013863 +v 0.500000 0.408471 0.720970 +v 0.500000 0.187501 0.499999 +v 0.500000 0.894607 -0.207108 +v -0.500000 0.187500 -0.500000 +v -0.500000 -0.500000 -0.500000 +v -0.500000 -0.500000 0.500000 +v 0.500000 0.187500 -0.500000 +v 0.500000 -0.500000 0.500000 +v 0.500000 -0.500000 -0.500000 +vt 0.0000 1.0000 +vt 0.0000 0.0000 +vt 1.0000 0.0000 +vt 1.0000 1.0000 +vt 1.0000 0.0000 +vt 1.0000 1.0000 +vt 0.0000 1.0000 +vt 0.0000 0.0000 +vt 0.0000 1.0000 +vt 1.0000 1.0000 +vt 1.0000 0.6875 +vt 0.0000 0.6875 +vt 1.0000 1.0000 +vt 0.0000 0.6875 +vt 1.0000 0.6875 +vt 1.0000 0.6875 +vt 1.0000 0.0000 +vt 0.0000 0.0000 +vt 1.0000 0.6875 +vt 1.0000 0.0000 +vt 1.0000 1.0000 +vt 1.0000 0.6875 +vt 1.0000 0.0000 +vt 0.0000 1.0000 +vt 0.0000 0.6875 +vt 0.0000 0.6875 +vt 0.0000 0.0000 +vt 1.0000 0.5000 +vt 1.0000 1.0000 +vt 0.0000 1.0000 +vt 0.0000 0.5000 +vt 0.0000 0.0000 +vt 1.0000 0.0000 +vn 0.0000 0.7071 0.7071 +vn -0.0000 -1.0000 -0.0000 +vn -1.0000 0.0000 0.0000 +vn 1.0000 0.0000 -0.0000 +vn 0.0000 -0.7071 0.7071 +vn 0.0000 0.0000 1.0000 +vn -0.0000 0.7071 -0.7071 +vn -0.0000 0.0000 -1.0000 +vn -0.0000 -0.7071 -0.7071 +vn -0.0000 1.0000 -0.0000 +g Top_Cube.002_None_Top_Cube.002_None_bottom_Top_Cube.002_None_Top_Cube.002_None_bottom_Top +s off +f 6/1/1 5/2/1 2/3/1 1/4/1 +g Top_Cube.002_None_Top_Cube.002_None_bottom_Top_Cube.002_None_Top_Cube.002_None_bottom_Bottom +f 11/5/2 10/6/2 14/7/2 13/8/2 +g Top_Cube.002_None_Top_Cube.002_None_bottom_Top_Cube.002_None_Top_Cube.002_None_bottom_Right-Left +f 1/9/3 2/10/3 3/11/3 4/12/3 +f 5/13/4 6/1/4 7/14/4 8/15/4 +f 4/12/3 9/16/3 10/17/3 11/18/3 +f 12/19/4 7/14/4 13/8/4 14/20/4 +g Top_Cube.002_None_Top_Cube.002_None_bottom_Top_Cube.002_None_Top_Cube.002_None_bottom_Back +f 6/21/5 1/9/5 4/12/5 7/22/5 +f 7/22/6 4/12/6 11/18/6 13/23/6 +g Top_Cube.002_None_Top_Cube.002_None_bottom_Top_Cube.002_None_Top_Cube.002_None_bottom_Front +f 2/10/7 5/24/7 8/25/7 3/11/7 +f 9/16/8 12/26/8 14/27/8 10/17/8 +g Top_Cube.002_None_Top_Cube.002_None_bottom_Top_Cube.002_None_Top_Cube.002_None_bottom_Inside +f 4/28/9 3/29/9 8/30/9 7/31/9 +f 7/31/10 12/32/10 9/33/10 4/28/10 diff --git a/mods/testformspec/textures/default_chest_front.png b/mods/testformspec/textures/default_chest_front.png new file mode 100644 index 0000000..85227d8 Binary files /dev/null and b/mods/testformspec/textures/default_chest_front.png differ diff --git a/mods/testformspec/textures/default_chest_inside.png b/mods/testformspec/textures/default_chest_inside.png new file mode 100644 index 0000000..5f7b6b1 Binary files /dev/null and b/mods/testformspec/textures/default_chest_inside.png differ diff --git a/mods/testformspec/textures/default_chest_side.png b/mods/testformspec/textures/default_chest_side.png new file mode 100644 index 0000000..44a65a4 Binary files /dev/null and b/mods/testformspec/textures/default_chest_side.png differ diff --git a/mods/testformspec/textures/default_chest_top.png b/mods/testformspec/textures/default_chest_top.png new file mode 100644 index 0000000..f4a92ee Binary files /dev/null and b/mods/testformspec/textures/default_chest_top.png differ diff --git a/mods/testformspec/textures/testformspec_animation.jpg b/mods/testformspec/textures/testformspec_animation.jpg new file mode 100644 index 0000000..b98ca26 Binary files /dev/null and b/mods/testformspec/textures/testformspec_animation.jpg differ diff --git a/mods/testformspec/textures/testformspec_animation.png b/mods/testformspec/textures/testformspec_animation.png new file mode 100644 index 0000000..b972e5d Binary files /dev/null and b/mods/testformspec/textures/testformspec_animation.png differ diff --git a/mods/testformspec/textures/testformspec_bg.png b/mods/testformspec/textures/testformspec_bg.png new file mode 100644 index 0000000..cd1e509 Binary files /dev/null and b/mods/testformspec/textures/testformspec_bg.png differ diff --git a/mods/testformspec/textures/testformspec_bg_9slice.png b/mods/testformspec/textures/testformspec_bg_9slice.png new file mode 100644 index 0000000..34433ac Binary files /dev/null and b/mods/testformspec/textures/testformspec_bg_9slice.png differ diff --git a/mods/testformspec/textures/testformspec_bg_9slice_hovered.png b/mods/testformspec/textures/testformspec_bg_9slice_hovered.png new file mode 100644 index 0000000..01c2dc7 Binary files /dev/null and b/mods/testformspec/textures/testformspec_bg_9slice_hovered.png differ diff --git a/mods/testformspec/textures/testformspec_bg_9slice_pressed.png b/mods/testformspec/textures/testformspec_bg_9slice_pressed.png new file mode 100644 index 0000000..0cbac75 Binary files /dev/null and b/mods/testformspec/textures/testformspec_bg_9slice_pressed.png differ diff --git a/mods/testformspec/textures/testformspec_bg_hovered.png b/mods/testformspec/textures/testformspec_bg_hovered.png new file mode 100644 index 0000000..3ebbb98 Binary files /dev/null and b/mods/testformspec/textures/testformspec_bg_hovered.png differ diff --git a/mods/testformspec/textures/testformspec_bg_pressed.png b/mods/testformspec/textures/testformspec_bg_pressed.png new file mode 100644 index 0000000..2fb5fc2 Binary files /dev/null and b/mods/testformspec/textures/testformspec_bg_pressed.png differ diff --git a/mods/testformspec/textures/testformspec_button_image.png b/mods/testformspec/textures/testformspec_button_image.png new file mode 100644 index 0000000..75c438a Binary files /dev/null and b/mods/testformspec/textures/testformspec_button_image.png differ diff --git a/mods/testformspec/textures/testformspec_character.png b/mods/testformspec/textures/testformspec_character.png new file mode 100644 index 0000000..0502178 Binary files /dev/null and b/mods/testformspec/textures/testformspec_character.png differ diff --git a/mods/testformspec/textures/testformspec_hovered.png b/mods/testformspec/textures/testformspec_hovered.png new file mode 100644 index 0000000..3ccad30 Binary files /dev/null and b/mods/testformspec/textures/testformspec_hovered.png differ diff --git a/mods/testformspec/textures/testformspec_item.png b/mods/testformspec/textures/testformspec_item.png new file mode 100644 index 0000000..4fd823b Binary files /dev/null and b/mods/testformspec/textures/testformspec_item.png differ diff --git a/mods/testformspec/textures/testformspec_node.png b/mods/testformspec/textures/testformspec_node.png new file mode 100644 index 0000000..c107f28 Binary files /dev/null and b/mods/testformspec/textures/testformspec_node.png differ diff --git a/mods/testformspec/textures/testformspec_pressed.png b/mods/testformspec/textures/testformspec_pressed.png new file mode 100644 index 0000000..45c504f Binary files /dev/null and b/mods/testformspec/textures/testformspec_pressed.png differ diff --git a/mods/testnodes/README.md b/mods/testnodes/README.md new file mode 100644 index 0000000..13ed972 --- /dev/null +++ b/mods/testnodes/README.md @@ -0,0 +1,11 @@ +# Test Nodes + +This mod contains a bunch of basic nodes to test development stuff. +Most nodes are kept as minimal as possible in order to show off one particular feature of the engine, to make testing stuff easier. + +This mod includes tests for: + +* drawtypes +* paramtype2's +* node properties such as damage, drowning, falling, etc. +* other random stuff diff --git a/mods/testnodes/drawtypes.lua b/mods/testnodes/drawtypes.lua new file mode 100644 index 0000000..ff97014 --- /dev/null +++ b/mods/testnodes/drawtypes.lua @@ -0,0 +1,557 @@ +--[[ Drawtype Test: This file tests out and provides examples for +all drawtypes in Minetest. It is attempted to keep the node +definitions as simple and minimal as possible to keep +side-effects to a minimum. + +How to read the node definitions: +There are two parts which are separated by 2 newlines: +The first part contains the things that are more or less essential +for defining the drawtype (except description, which is +at the top for readability). +The second part (after the 2 newlines) contains stuff that are +unrelated to the drawtype, stuff that is mostly there to make +testing this node easier and more convenient. +]] + +local S = minetest.get_translator("testnodes") + +-- If set to true, will show an inventory image for nodes that have no inventory image as of Minetest 5.1.0. +-- This is due to . +-- This is only added to make the items more visible to avoid confusion, but you will no longer see +-- the default inventory images for these items. When you want to test the default inventory image of drawtypes, +-- this should be turned off. +-- TODO: Remove support for fallback inventory image as soon #9209 is fixed. +local SHOW_FALLBACK_IMAGE = minetest.settings:get_bool("testnodes_show_fallback_image", false) + +local fallback_image = function(img) + if SHOW_FALLBACK_IMAGE then + return img + else + return nil + end +end + +-- A regular cube +minetest.register_node("testnodes:normal", { + description = S("Normal Drawtype Test Node"), + drawtype = "normal", + tiles = { "testnodes_normal.png" }, + + groups = { dig_immediate = 3 }, +}) + +-- Standard glasslike node +minetest.register_node("testnodes:glasslike", { + description = S("Glasslike Drawtype Test Node"), + drawtype = "glasslike", + paramtype = "light", + tiles = { "testnodes_glasslike.png" }, + + groups = { dig_immediate = 3 }, +}) + +-- Glasslike framed with the two textures (normal and "detail") +minetest.register_node("testnodes:glasslike_framed", { + description = S("Glasslike Framed Drawtype Test Node"), + drawtype = "glasslike_framed", + paramtype = "light", + tiles = { + "testnodes_glasslike_framed.png", + "testnodes_glasslike_detail.png", + }, + + + sunlight_propagates = true, + groups = { dig_immediate = 3 }, +}) + +-- Like the one above, but without the "detail" texture (texture 2). +-- This node was added to see how the engine behaves when the "detail" texture +-- is missing. +minetest.register_node("testnodes:glasslike_framed_no_detail", { + description = S("Glasslike Framed without Detail Drawtype Test Node"), + drawtype = "glasslike_framed", + paramtype = "light", + tiles = { "testnodes_glasslike_framed2.png" }, + + + sunlight_propagates = true, + groups = { dig_immediate = 3 }, +}) + + +minetest.register_node("testnodes:glasslike_framed_optional", { + description = S("Glasslike Framed Optional Drawtype Test Node"), + drawtype = "glasslike_framed_optional", + paramtype = "light", + tiles = { + "testnodes_glasslike_framed_optional.png", + "testnodes_glasslike_detail.png", + }, + + + sunlight_propagates = true, + groups = { dig_immediate = 3 }, +}) + + + +minetest.register_node("testnodes:allfaces", { + description = S("Allfaces Drawtype Test Node"), + drawtype = "allfaces", + paramtype = "light", + tiles = { "testnodes_allfaces.png" }, + + groups = { dig_immediate = 3 }, +}) + +minetest.register_node("testnodes:allfaces_optional", { + description = S("Allfaces Optional Drawtype Test Node"), + drawtype = "allfaces_optional", + paramtype = "light", + tiles = { "testnodes_allfaces_optional.png" }, + + groups = { dig_immediate = 3 }, +}) + +minetest.register_node("testnodes:allfaces_optional_waving", { + description = S("Waving Allfaces Optional Drawtype Test Node"), + drawtype = "allfaces_optional", + paramtype = "light", + tiles = { "testnodes_allfaces_optional.png^[brighten" }, + waving = 2, + + groups = { dig_immediate = 3 }, +}) + +minetest.register_node("testnodes:firelike", { + description = S("Firelike Drawtype Test Node"), + drawtype = "firelike", + paramtype = "light", + tiles = { "testnodes_firelike.png" }, + + + walkable = false, + groups = { dig_immediate = 3 }, +}) + +minetest.register_node("testnodes:fencelike", { + description = S("Fencelike Drawtype Test Node"), + drawtype = "fencelike", + paramtype = "light", + tiles = { "testnodes_fencelike.png" }, + + groups = { dig_immediate = 3 }, +}) + +minetest.register_node("testnodes:torchlike", { + description = S("Torchlike Drawtype Test Node"), + drawtype = "torchlike", + paramtype = "light", + tiles = { + "testnodes_torchlike_floor.png", + "testnodes_torchlike_ceiling.png", + "testnodes_torchlike_wall.png", + }, + + + walkable = false, + sunlight_propagates = true, + groups = { dig_immediate = 3 }, + inventory_image = fallback_image("testnodes_torchlike_floor.png"), +}) + +minetest.register_node("testnodes:torchlike_wallmounted", { + description = S("Wallmounted Torchlike Drawtype Test Node"), + drawtype = "torchlike", + paramtype = "light", + paramtype2 = "wallmounted", + tiles = { + "testnodes_torchlike_floor.png", + "testnodes_torchlike_ceiling.png", + "testnodes_torchlike_wall.png", + }, + + + walkable = false, + sunlight_propagates = true, + groups = { dig_immediate = 3 }, + inventory_image = fallback_image("testnodes_torchlike_floor.png"), +}) + + + +minetest.register_node("testnodes:signlike", { + description = S("Wallmounted Signlike Drawtype Test Node"), + drawtype = "signlike", + paramtype = "light", + paramtype2 = "wallmounted", + tiles = { "testnodes_signlike.png" }, + + + walkable = false, + groups = { dig_immediate = 3 }, + sunlight_propagates = true, + inventory_image = fallback_image("testnodes_signlike.png"), +}) + +minetest.register_node("testnodes:plantlike", { + description = S("Plantlike Drawtype Test Node"), + drawtype = "plantlike", + paramtype = "light", + tiles = { "testnodes_plantlike.png" }, + + + walkable = false, + sunlight_propagates = true, + groups = { dig_immediate = 3 }, +}) + +minetest.register_node("testnodes:plantlike_waving", { + description = S("Waving Plantlike Drawtype Test Node"), + drawtype = "plantlike", + paramtype = "light", + tiles = { "testnodes_plantlike_waving.png" }, + waving = 1, + + + walkable = false, + sunlight_propagates = true, + groups = { dig_immediate = 3 }, +}) + + + +-- param2 will rotate +minetest.register_node("testnodes:plantlike_degrotate", { + description = S("Degrotate Plantlike Drawtype Test Node"), + drawtype = "plantlike", + paramtype = "light", + paramtype2 = "degrotate", + tiles = { "testnodes_plantlike_degrotate.png" }, + + + walkable = false, + sunlight_propagates = true, + groups = { dig_immediate = 3 }, +}) + +-- param2 will change height +minetest.register_node("testnodes:plantlike_leveled", { + description = S("Leveled Plantlike Drawtype Test Node"), + drawtype = "plantlike", + paramtype = "light", + paramtype2 = "leveled", + tiles = { + { name = "testnodes_plantlike_leveled.png", tileable_vertical = true }, + }, + + + -- We set a default param2 here only for convenience, to make the "plant" visible after placement + place_param2 = 8, + walkable = false, + sunlight_propagates = true, + groups = { dig_immediate = 3 }, +}) + +-- param2 changes shape +minetest.register_node("testnodes:plantlike_meshoptions", { + description = S("Meshoptions Plantlike Drawtype Test Node"), + drawtype = "plantlike", + paramtype = "light", + paramtype2 = "meshoptions", + tiles = { "testnodes_plantlike_meshoptions.png" }, + + + walkable = false, + groups = { dig_immediate = 3 }, +}) + +minetest.register_node("testnodes:plantlike_rooted", { + description = S("Rooted Plantlike Drawtype Test Node"), + drawtype = "plantlike_rooted", + paramtype = "light", + tiles = { "testnodes_plantlike_rooted_base.png" }, + special_tiles = { "testnodes_plantlike_rooted.png" }, + + groups = { dig_immediate = 3 }, +}) + +minetest.register_node("testnodes:plantlike_rooted_waving", { + description = S("Waving Rooted Plantlike Drawtype Test Node"), + drawtype = "plantlike_rooted", + paramtype = "light", + tiles = { + "testnodes_plantlike_rooted_base.png", + "testnodes_plantlike_rooted_base.png", + "testnodes_plantlike_rooted_base_side_waving.png", + }, + special_tiles = { "testnodes_plantlike_rooted_waving.png" }, + waving = 1, + + groups = { dig_immediate = 3 }, +}) + +-- param2 changes height +minetest.register_node("testnodes:plantlike_rooted_leveled", { + description = S("Leveled Rooted Plantlike Drawtype Test Node"), + drawtype = "plantlike_rooted", + paramtype = "light", + paramtype2 = "leveled", + tiles = { + "testnodes_plantlike_rooted_base.png", + "testnodes_plantlike_rooted_base.png", + "testnodes_plantlike_rooted_base_side_leveled.png", + }, + special_tiles = { + { name = "testnodes_plantlike_rooted_leveled.png", tileable_vertical = true }, + }, + + + -- We set a default param2 here only for convenience, to make the "plant" visible after placement + place_param2 = 8, + groups = { dig_immediate = 3 }, +}) + +-- param2 changes shape +minetest.register_node("testnodes:plantlike_rooted_meshoptions", { + description = S("Meshoptions Rooted Plantlike Drawtype Test Node"), + drawtype = "plantlike_rooted", + paramtype = "light", + paramtype2 = "meshoptions", + tiles = { + "testnodes_plantlike_rooted_base.png", + "testnodes_plantlike_rooted_base.png", + "testnodes_plantlike_rooted_base_side_meshoptions.png", + }, + special_tiles = { + "testnodes_plantlike_rooted_meshoptions.png", + }, + + groups = { dig_immediate = 3 }, +}) + +-- param2 changes rotation +minetest.register_node("testnodes:plantlike_rooted_degrotate", { + description = S("Degrotate Rooted Plantlike Drawtype Test Node"), + drawtype = "plantlike_rooted", + paramtype = "light", + paramtype2 = "degrotate", + tiles = { + "testnodes_plantlike_rooted_base.png", + "testnodes_plantlike_rooted_base.png", + "testnodes_plantlike_rooted_base_side_degrotate.png", + }, + special_tiles = { + "testnodes_plantlike_rooted_degrotate.png", + }, + + groups = { dig_immediate = 3 }, +}) + +-- Demonstrative liquid nodes, source and flowing form. +-- DRAWTYPE ONLY, NO LIQUID PHYSICS! +-- Liquid ranges 0 to 8 +for r = 0, 8 do + minetest.register_node("testnodes:liquid_"..r, { + description = S("Source Liquid Drawtype Test Node, Range @1", r), + drawtype = "liquid", + paramtype = "light", + tiles = { + "testnodes_liquidsource_r"..r..".png^[colorize:#FFFFFF:100", + }, + special_tiles = { + {name="testnodes_liquidsource_r"..r..".png^[colorize:#FFFFFF:100", backface_culling=false}, + {name="testnodes_liquidsource_r"..r..".png^[colorize:#FFFFFF:100", backface_culling=true}, + }, + use_texture_alpha = "blend", + + + walkable = false, + liquid_range = r, + liquid_viscosity = 0, + liquid_alternative_flowing = "testnodes:liquid_flowing_"..r, + liquid_alternative_source = "testnodes:liquid_"..r, + groups = { dig_immediate = 3 }, + }) + minetest.register_node("testnodes:liquid_flowing_"..r, { + description = S("Flowing Liquid Drawtype Test Node, Range @1", r), + drawtype = "flowingliquid", + paramtype = "light", + paramtype2 = "flowingliquid", + tiles = { + "testnodes_liquidflowing_r"..r..".png^[colorize:#FFFFFF:100", + }, + special_tiles = { + {name="testnodes_liquidflowing_r"..r..".png^[colorize:#FFFFFF:100", backface_culling=false}, + {name="testnodes_liquidflowing_r"..r..".png^[colorize:#FFFFFF:100", backface_culling=false}, + }, + use_texture_alpha = "blend", + + + walkable = false, + liquid_range = r, + liquid_viscosity = 0, + liquid_alternative_flowing = "testnodes:liquid_flowing_"..r, + liquid_alternative_source = "testnodes:liquid_"..r, + groups = { dig_immediate = 3 }, + }) + +end + +-- Waving liquid test (drawtype only) +minetest.register_node("testnodes:liquid_waving", { + description = S("Waving Source Liquid Drawtype Test Node"), + drawtype = "liquid", + paramtype = "light", + tiles = { + "testnodes_liquidsource.png^[colorize:#0000FF:127", + }, + special_tiles = { + {name="testnodes_liquidsource.png^[colorize:#0000FF:127", backface_culling=false}, + {name="testnodes_liquidsource.png^[colorize:#0000FF:127", backface_culling=true}, + }, + use_texture_alpha = "blend", + waving = 3, + + + walkable = false, + liquid_range = 1, + liquid_viscosity = 0, + liquid_alternative_flowing = "testnodes:liquid_flowing_waving", + liquid_alternative_source = "testnodes:liquid_waving", + groups = { dig_immediate = 3 }, +}) +minetest.register_node("testnodes:liquid_flowing_waving", { + description = S("Waving Flowing Liquid Drawtype Test Node"), + drawtype = "flowingliquid", + paramtype = "light", + paramtype2 = "flowingliquid", + tiles = { + "testnodes_liquidflowing.png^[colorize:#0000FF:127", + }, + special_tiles = { + {name="testnodes_liquidflowing.png^[colorize:#0000FF:127", backface_culling=false}, + {name="testnodes_liquidflowing.png^[colorize:#0000FF:127", backface_culling=false}, + }, + use_texture_alpha = "blend", + waving = 3, + + + walkable = false, + liquid_range = 1, + liquid_viscosity = 0, + liquid_alternative_flowing = "testnodes:liquid_flowing_waving", + liquid_alternative_source = "testnodes:liquid_waving", + groups = { dig_immediate = 3 }, +}) + +-- Invisible node +minetest.register_node("testnodes:airlike", { + description = S("Airlike Drawtype Test Node"), + drawtype = "airlike", + paramtype = "light", + + + walkable = false, + groups = { dig_immediate = 3 }, + sunlight_propagates = true, + inventory_image = fallback_image("testnodes_airlike.png"), +}) + +-- param2 changes liquid height +minetest.register_node("testnodes:glassliquid", { + description = S("Glasslike Liquid Level Drawtype Test Node"), + drawtype = "glasslike_framed", + paramtype = "light", + paramtype2 = "glasslikeliquidlevel", + tiles = { + "testnodes_glasslikeliquid.png", + }, + special_tiles = { + "testnodes_liquid.png", + }, + + groups = { dig_immediate = 3 }, +}) + +-- Adding many raillike examples, primarily to demonstrate the behavior of +-- "raillike groups". Nodes of the same type (rail, groupless, line, street) +-- should connect to nodes of the same "rail type" (=same shape, different +-- color) only. +local rails = { + { "rail", {"testnodes_rail_straight.png", "testnodes_rail_curved.png", "testnodes_rail_t_junction.png", "testnodes_rail_crossing.png"} }, + { "line", {"testnodes_line_straight.png", "testnodes_line_curved.png", "testnodes_line_t_junction.png", "testnodes_line_crossing.png"}, }, + { "street", {"testnodes_street_straight.png", "testnodes_street_curved.png", "testnodes_street_t_junction.png", "testnodes_street_crossing.png"}, }, + -- the "groupless" nodes are nodes in which the "connect_to_raillike" group is not set + { "groupless", {"testnodes_rail2_straight.png", "testnodes_rail2_curved.png", "testnodes_rail2_t_junction.png", "testnodes_rail2_crossing.png"} }, +} +local colors = { "", "cyan", "red" } + +for r=1, #rails do + local id = rails[r][1] + local tiles = rails[r][2] + local raillike_group + if id ~= "groupless" then + raillike_group = minetest.raillike_group(id) + end + for c=1, #colors do + local color + if colors[c] ~= "" then + color = colors[c] + end + minetest.register_node("testnodes:raillike_"..id..c, { + description = S("Raillike Drawtype Test Node: @1 @2", id, c), + drawtype = "raillike", + paramtype = "light", + tiles = tiles, + groups = { connect_to_raillike = raillike_group, dig_immediate = 3 }, + + + color = color, + selection_box = { + type = "fixed", + fixed = {{-0.5, -0.5, -0.5, 0.5, -0.4, 0.5}}, + }, + sunlight_propagates = true, + walkable = false, + }) + end +end + + + +-- Add visual_scale variants of previous nodes for half and double size +local scale = function(subname, desc_double, desc_half) + local original = "testnodes:"..subname + local def = table.copy(minetest.registered_items[original]) + def.visual_scale = 2.0 + def.description = desc_double + minetest.register_node("testnodes:"..subname.."_double", def) + def = table.copy(minetest.registered_items[original]) + def.visual_scale = 0.5 + def.description = desc_half + minetest.register_node("testnodes:"..subname.."_half", def) +end + +scale("allfaces", + S("Double-sized Allfaces Drawtype Test Node"), + S("Half-sized Allfaces Drawtype Test Node")) +scale("allfaces_optional", + S("Double-sized Allfaces Optional Drawtype Test Node"), + S("Half-sized Allfaces Optional Drawtype Test Node")) +scale("allfaces_optional_waving", + S("Double-sized Waving Allfaces Optional Drawtype Test Node"), + S("Half-sized Waving Allfaces Optional Drawtype Test Node")) +scale("plantlike", + S("Double-sized Plantlike Drawtype Test Node"), + S("Half-sized Plantlike Drawtype Test Node")) +scale("torchlike_wallmounted", + S("Double-sized Wallmounted Torchlike Drawtype Test Node"), + S("Half-sized Wallmounted Torchlike Drawtype Test Node")) +scale("signlike", + S("Double-sized Wallmounted Signlike Drawtype Test Node"), + S("Half-sized Wallmounted Signlike Drawtype Test Node")) +scale("firelike", + S("Double-sized Firelike Drawtype Test Node"), + S("Half-sized Firelike Drawtype Test Node")) diff --git a/mods/testnodes/init.lua b/mods/testnodes/init.lua new file mode 100644 index 0000000..92e2c56 --- /dev/null +++ b/mods/testnodes/init.lua @@ -0,0 +1,10 @@ +local path = minetest.get_modpath(minetest.get_current_modname()) + +dofile(path.."/drawtypes.lua") +dofile(path.."/meshes.lua") +dofile(path.."/nodeboxes.lua") +dofile(path.."/param2.lua") +dofile(path.."/properties.lua") +dofile(path.."/liquids.lua") +dofile(path.."/light.lua") +dofile(path.."/textures.lua") diff --git a/mods/testnodes/light.lua b/mods/testnodes/light.lua new file mode 100644 index 0000000..8ab4416 --- /dev/null +++ b/mods/testnodes/light.lua @@ -0,0 +1,50 @@ +-- Test Nodes: Light test + +local S = minetest.get_translator("testnodes") + +-- All possible light levels +for i=1, minetest.LIGHT_MAX do + minetest.register_node("testnodes:light"..i, { + description = S("Light Source (@1)", i), + paramtype = "light", + light_source = i, + + + tiles ={"testnodes_light_"..i..".png"}, + drawtype = "glasslike", + walkable = false, + sunlight_propagates = true, + is_ground_content = false, + groups = {dig_immediate=3}, + }) +end + +-- Lets light through, but not sunlight, leading to a +-- reduction in light level when light passes through +minetest.register_node("testnodes:sunlight_filter", { + description = S("Sunlight Filter") .."\n".. + S("Lets light through, but weakens sunlight"), + paramtype = "light", + + + drawtype = "glasslike", + tiles = { + "testnodes_sunlight_filter.png", + }, + groups = { dig_immediate = 3 }, +}) + +-- Lets light and sunlight through without obstruction +minetest.register_node("testnodes:sunlight_propagator", { + description = S("Sunlight Propagator") .."\n".. + S("Lets all light through"), + paramtype = "light", + sunlight_propagates = true, + + + drawtype = "glasslike", + tiles = { + "testnodes_sunlight_filter.png^[brighten", + }, + groups = { dig_immediate = 3 }, +}) diff --git a/mods/testnodes/liquids.lua b/mods/testnodes/liquids.lua new file mode 100644 index 0000000..3d2ea17 --- /dev/null +++ b/mods/testnodes/liquids.lua @@ -0,0 +1,83 @@ +-- Add liquids for ranges and viscosity levels 0-8 + +for d=0, 8 do + minetest.register_node("testnodes:rliquid_"..d, { + description = "Test Liquid Source, Range "..d, + drawtype = "liquid", + tiles = {"testnodes_liquidsource_r"..d..".png"}, + special_tiles = { + {name = "testnodes_liquidsource_r"..d..".png", backface_culling = false}, + {name = "testnodes_liquidsource_r"..d..".png", backface_culling = true}, + }, + use_texture_alpha = "blend", + paramtype = "light", + walkable = false, + buildable_to = true, + is_ground_content = false, + liquidtype = "source", + liquid_alternative_flowing = "testnodes:rliquid_flowing_"..d, + liquid_alternative_source = "testnodes:rliquid_"..d, + liquid_range = d, + }) + + minetest.register_node("testnodes:rliquid_flowing_"..d, { + description = "Flowing Test Liquid, Range "..d, + drawtype = "flowingliquid", + tiles = {"testnodes_liquidflowing_r"..d..".png"}, + special_tiles = { + {name = "testnodes_liquidflowing_r"..d..".png", backface_culling = false}, + {name = "testnodes_liquidflowing_r"..d..".png", backface_culling = false}, + }, + use_texture_alpha = "blend", + paramtype = "light", + paramtype2 = "flowingliquid", + walkable = false, + buildable_to = true, + is_ground_content = false, + liquidtype = "flowing", + liquid_alternative_flowing = "testnodes:rliquid_flowing_"..d, + liquid_alternative_source = "testnodes:rliquid_"..d, + liquid_range = d, + }) + + local mod = "^[colorize:#000000:127" + minetest.register_node("testnodes:vliquid_"..d, { + description = "Test Liquid Source, Viscosity "..d, + drawtype = "liquid", + tiles = {"testnodes_liquidsource_r"..d..".png"..mod}, + special_tiles = { + {name = "testnodes_liquidsource_r"..d..".png"..mod, backface_culling = false}, + {name = "testnodes_liquidsource_r"..d..".png"..mod, backface_culling = true}, + }, + use_texture_alpha = "blend", + paramtype = "light", + walkable = false, + buildable_to = true, + is_ground_content = false, + liquidtype = "source", + liquid_alternative_flowing = "testnodes:vliquid_flowing_"..d, + liquid_alternative_source = "testnodes:vliquid_"..d, + liquid_viscosity = d, + }) + + minetest.register_node("testnodes:vliquid_flowing_"..d, { + description = "Flowing Test Liquid, Viscosity "..d, + drawtype = "flowingliquid", + tiles = {"testnodes_liquidflowing_r"..d..".png"..mod}, + special_tiles = { + {name = "testnodes_liquidflowing_r"..d..".png"..mod, backface_culling = false}, + {name = "testnodes_liquidflowing_r"..d..".png"..mod, backface_culling = false}, + }, + use_texture_alpha = "blend", + paramtype = "light", + paramtype2 = "flowingliquid", + walkable = false, + buildable_to = true, + is_ground_content = false, + liquidtype = "flowing", + liquid_alternative_flowing = "testnodes:vliquid_flowing_"..d, + liquid_alternative_source = "testnodes:vliquid_"..d, + liquid_viscosity = d, + }) + +end diff --git a/mods/testnodes/meshes.lua b/mods/testnodes/meshes.lua new file mode 100644 index 0000000..900abc1 --- /dev/null +++ b/mods/testnodes/meshes.lua @@ -0,0 +1,145 @@ +-- Meshes + +local S = minetest.get_translator("testnodes") + +local ocorner_cbox = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, -0.25, 0.5}, + {-0.5, -0.25, -0.25, 0.25, 0, 0.5}, + {-0.5, 0, 0, 0, 0.25, 0.5}, + {-0.5, 0.25, 0.25, -0.25, 0.5, 0.5} + } +} + +local tall_pyr_cbox = { + type = "fixed", + fixed = { + { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }, + { -0.375, -0.25, -0.375, 0.375, 0, 0.375}, + { -0.25, 0, -0.25, 0.25, 0.25, 0.25}, + { -0.125, 0.25, -0.125, 0.125, 0.5, 0.125} + } +} + +-- Normal mesh +minetest.register_node("testnodes:mesh", { + description = S("Mesh Test Node"), + drawtype = "mesh", + mesh = "testnodes_pyramid.obj", + tiles = {"testnodes_mesh_stripes2.png"}, + paramtype = "light", + collision_box = tall_pyr_cbox, + + groups = {dig_immediate=3}, +}) + +-- Facedir mesh: outer corner slope +minetest.register_node("testnodes:mesh_facedir", { + description = S("Facedir Mesh Test Node"), + drawtype = "mesh", + mesh = "testnodes_ocorner.obj", + tiles = {"testnodes_mesh_stripes.png"}, + paramtype = "light", + paramtype2 = "facedir", + collision_box = ocorner_cbox, + + groups = {dig_immediate=3}, +}) + +minetest.register_node("testnodes:mesh_colorfacedir", { + description = S("Color Facedir Mesh Test Node"), + drawtype = "mesh", + mesh = "testnodes_ocorner.obj", + tiles = {"testnodes_mesh_stripes3.png"}, + paramtype = "light", + paramtype2 = "colorfacedir", + palette = "testnodes_palette_facedir.png", + collision_box = ocorner_cbox, + + groups = {dig_immediate=3}, +}) + +-- Wallmounted mesh: pyramid +minetest.register_node("testnodes:mesh_wallmounted", { + description = S("Wallmounted Mesh Test Node"), + drawtype = "mesh", + mesh = "testnodes_pyramid.obj", + tiles = {"testnodes_mesh_stripes2.png"}, + paramtype = "light", + paramtype2 = "wallmounted", + collision_box = tall_pyr_cbox, + + groups = {dig_immediate=3}, +}) + +minetest.register_node("testnodes:mesh_colorwallmounted", { + description = S("Color Wallmounted Mesh Test Node"), + drawtype = "mesh", + mesh = "testnodes_pyramid.obj", + tiles = {"testnodes_mesh_stripes3.png"}, + paramtype = "light", + paramtype2 = "colorwallmounted", + palette = "testnodes_palette_wallmounted.png", + collision_box = tall_pyr_cbox, + + groups = {dig_immediate=3}, +}) + + +minetest.register_node("testnodes:mesh_double", { + description = S("Double-sized Mesh Test Node"), + drawtype = "mesh", + mesh = "testnodes_pyramid.obj", + tiles = {"testnodes_mesh_stripes2.png"}, + paramtype = "light", + collision_box = tall_pyr_cbox, + visual_scale = 2, + + groups = {dig_immediate=3}, +}) +minetest.register_node("testnodes:mesh_half", { + description = S("Half-sized Mesh Test Node"), + drawtype = "mesh", + mesh = "testnodes_pyramid.obj", + tiles = {"testnodes_mesh_stripes2.png"}, + paramtype = "light", + collision_box = tall_pyr_cbox, + visual_scale = 0.5, + + groups = {dig_immediate=3}, +}) + +minetest.register_node("testnodes:mesh_waving1", { + description = S("Plantlike-waving Mesh Test Node"), + drawtype = "mesh", + mesh = "testnodes_pyramid.obj", + tiles = {"testnodes_mesh_stripes4.png^[multiply:#B0FFB0"}, + paramtype = "light", + collision_box = tall_pyr_cbox, + waving = 1, + + groups = {dig_immediate=3}, +}) +minetest.register_node("testnodes:mesh_waving2", { + description = S("Leaflike-waving Mesh Test Node"), + drawtype = "mesh", + mesh = "testnodes_pyramid.obj", + tiles = {"testnodes_mesh_stripes4.png^[multiply:#FFFFB0"}, + paramtype = "light", + collision_box = tall_pyr_cbox, + waving = 2, + + groups = {dig_immediate=3}, +}) +minetest.register_node("testnodes:mesh_waving3", { + description = S("Liquidlike-waving Mesh Test Node"), + drawtype = "mesh", + mesh = "testnodes_pyramid.obj", + tiles = {"testnodes_mesh_stripes4.png^[multiply:#B0B0FF"}, + paramtype = "light", + collision_box = tall_pyr_cbox, + waving = 3, + + groups = {dig_immediate=3}, +}) diff --git a/mods/testnodes/mod.conf b/mods/testnodes/mod.conf new file mode 100644 index 0000000..d894c34 --- /dev/null +++ b/mods/testnodes/mod.conf @@ -0,0 +1,3 @@ +name = testnodes +description = Contains a bunch of basic example nodes for demonstrative purposes, development and testing +depends = stairs diff --git a/mods/testnodes/models/testnodes_ocorner.obj b/mods/testnodes/models/testnodes_ocorner.obj new file mode 100644 index 0000000..231d705 --- /dev/null +++ b/mods/testnodes/models/testnodes_ocorner.obj @@ -0,0 +1,23 @@ +# Blender v2.73 (sub 0) OBJ File: 'slope_test_ocorner_onetexture.blend' +# www.blender.org +o Cube_Cube.002 +v 0.500000 0.500000 0.500000 +v -0.500000 -0.500000 0.500000 +v 0.500000 -0.500000 0.500000 +v -0.500000 -0.500000 -0.500000 +v 0.500000 -0.500000 -0.500000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vn 0.000000 -1.000000 -0.000000 +vn 1.000000 0.000000 0.000000 +vn 0.000000 -0.000000 1.000000 +vn -0.707100 0.707100 0.000000 +vn 0.000000 0.707100 -0.707100 +s off +f 3/1/1 2/2/1 4/3/1 5/4/1 +f 1/2/2 3/3/2 5/4/2 +f 1/1/3 2/3/3 3/4/3 +f 1/1/4 4/3/4 2/4/4 +f 1/2/5 5/3/5 4/4/5 diff --git a/mods/testnodes/models/testnodes_pyramid.obj b/mods/testnodes/models/testnodes_pyramid.obj new file mode 100644 index 0000000..b305af2 --- /dev/null +++ b/mods/testnodes/models/testnodes_pyramid.obj @@ -0,0 +1,24 @@ +# Blender v2.73 (sub 0) OBJ File: 'slope_test_pyramid_onetexture.blend' +# www.blender.org +o Cube +v 0.500000 -0.500000 -0.500000 +v 0.500000 -0.500000 0.500000 +v -0.500000 -0.500000 0.500000 +v -0.500000 -0.500000 -0.500000 +v -0.000000 0.500000 -0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 0.500000 1.000000 +vn 0.000000 -1.000000 0.000000 +vn -0.894400 0.447200 -0.000000 +vn 0.000000 0.447200 -0.894400 +vn 0.894400 0.447200 0.000000 +vn -0.000000 0.447200 0.894400 +s off +f 1/1/1 2/2/1 3/3/1 4/4/1 +f 3/4/2 5/5/2 4/3/2 +f 5/5/3 1/3/3 4/4/3 +f 1/4/4 5/5/4 2/3/4 +f 2/4/5 5/5/5 3/3/5 diff --git a/mods/testnodes/nodeboxes.lua b/mods/testnodes/nodeboxes.lua new file mode 100644 index 0000000..7e966fd --- /dev/null +++ b/mods/testnodes/nodeboxes.lua @@ -0,0 +1,81 @@ +local S = minetest.get_translator("testnodes") + +-- Nodebox examples and tests. + +-- An simple example nodebox with one centered box +minetest.register_node("testnodes:nodebox_fixed", { + description = S("Fixed Nodebox Test Node"), + tiles = {"testnodes_nodebox.png"}, + drawtype = "nodebox", + paramtype = "light", + node_box = { + type = "fixed", + fixed = {-0.25, -0.25, -0.25, 0.25, 0.25, 0.25}, + }, + + groups = {dig_immediate=3}, +}) + +-- 50% higher than a regular node +minetest.register_node("testnodes:nodebox_overhigh", { + description = S("+50% high Nodebox Test Node"), + tiles = {"testnodes_nodebox.png"}, + drawtype = "nodebox", + paramtype = "light", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, 1, 0.5}, + }, + + groups = {dig_immediate=3}, +}) + +-- 95% higher than a regular node +minetest.register_node("testnodes:nodebox_overhigh2", { + description = S("+95% high Nodebox Test Node"), + tiles = {"testnodes_nodebox.png"}, + drawtype = "nodebox", + paramtype = "light", + node_box = { + type = "fixed", + -- Y max: more is possible, but glitchy + fixed = {-0.5, -0.5, -0.5, 0.5, 1.45, 0.5}, + }, + + groups = {dig_immediate=3}, +}) + +-- Height of nodebox changes with its param2 value +minetest.register_node("testnodes:nodebox_leveled", { + description = S("Leveled Nodebox Test Node"), + tiles = {"testnodes_nodebox.png"}, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "leveled", + node_box = { + type = "leveled", + fixed = {-0.5, 0.0, -0.5, 0.5, -0.499, 0.5}, + }, + + groups = {dig_immediate=3}, +}) + +-- Wall-like nodebox that connects to neighbors +minetest.register_node("testnodes:nodebox_connected", { + description = S("Connected Nodebox Test Node"), + tiles = {"testnodes_nodebox.png"}, + groups = {connected_nodebox=1, dig_immediate=3}, + drawtype = "nodebox", + paramtype = "light", + connects_to = {"group:connected_nodebox"}, + connect_sides = {"front", "back", "left", "right"}, + node_box = { + type = "connected", + fixed = {-0.125, -0.500, -0.125, 0.125, 0.500, 0.125}, + connect_front = {-0.125, -0.500, -0.500, 0.125, 0.400, -0.125}, + connect_back = {-0.125, -0.500, 0.125, 0.125, 0.400, 0.500}, + connect_left = {-0.500, -0.500, -0.125, -0.125, 0.400, 0.125}, + connect_right = {0.125, -0.500, -0.125, 0.500, 0.400, 0.125}, + }, +}) + diff --git a/mods/testnodes/param2.lua b/mods/testnodes/param2.lua new file mode 100644 index 0000000..5d64376 --- /dev/null +++ b/mods/testnodes/param2.lua @@ -0,0 +1,168 @@ +-- This file is for misc. param2 tests that aren't covered in drawtypes.lua already. + +local S = minetest.get_translator("testnodes") + +minetest.register_node("testnodes:facedir", { + description = S("Facedir Test Node"), + paramtype2 = "facedir", + tiles = { + "testnodes_1.png", + "testnodes_2.png", + "testnodes_3.png", + "testnodes_4.png", + "testnodes_5.png", + "testnodes_6.png", + }, + + groups = { dig_immediate = 3 }, +}) + +minetest.register_node("testnodes:facedir_nodebox", { + description = S("Facedir Nodebox Test Node"), + tiles = { + "testnodes_1.png", + "testnodes_2.png", + "testnodes_3.png", + "testnodes_4.png", + "testnodes_5.png", + "testnodes_6.png", + }, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.2, 0.2, 0.2}, + }, + + groups = {dig_immediate=3}, +}) + +minetest.register_node("testnodes:wallmounted", { + description = S("Wallmounted Test Node"), + paramtype2 = "wallmounted", + tiles = { + "testnodes_1w.png", + "testnodes_2w.png", + "testnodes_3w.png", + "testnodes_4w.png", + "testnodes_5w.png", + "testnodes_6w.png", + }, + + groups = { dig_immediate = 3 }, +}) + +minetest.register_node("testnodes:wallmounted_nodebox", { + description = S("Wallmounted Nodebox Test Node"), + paramtype2 = "wallmounted", + paramtype = "light", + tiles = { + "testnodes_1w.png", + "testnodes_2w.png", + "testnodes_3w.png", + "testnodes_4w.png", + "testnodes_5w.png", + "testnodes_6w.png", + }, + drawtype = "nodebox", + node_box = { + type = "wallmounted", + wall_top = { -0.5, 0, -0.5, 0.5, 0.5, 0.5 }, + wall_bottom = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }, + wall_side = { -0.5, -0.5, -0.5, 0, 0.5, 0.5 }, + }, + + groups = { dig_immediate = 3 }, +}) + +minetest.register_node("testnodes:color", { + description = S("Color Test Node"), + paramtype2 = "color", + palette = "testnodes_palette_full.png", + tiles = { + "testnodes_node.png", + }, + + groups = { dig_immediate = 3 }, +}) + +minetest.register_node("testnodes:colorfacedir", { + description = S("Color Facedir Test Node"), + paramtype2 = "colorfacedir", + palette = "testnodes_palette_facedir.png", + tiles = { + "testnodes_1g.png", + "testnodes_2g.png", + "testnodes_3g.png", + "testnodes_4g.png", + "testnodes_5g.png", + "testnodes_6g.png", + }, + + groups = { dig_immediate = 3 }, +}) + +minetest.register_node("testnodes:colorfacedir_nodebox", { + description = S("Color Facedir Nodebox Test Node"), + tiles = { + "testnodes_1g.png", + "testnodes_2g.png", + "testnodes_3g.png", + "testnodes_4g.png", + "testnodes_5g.png", + "testnodes_6g.png", + }, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "colorfacedir", + palette = "testnodes_palette_facedir.png", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.2, 0.2, 0.2}, + }, + + groups = {dig_immediate=3}, +}) + +minetest.register_node("testnodes:colorwallmounted", { + description = S("Color Wallmounted Test Node"), + paramtype2 = "colorwallmounted", + paramtype = "light", + palette = "testnodes_palette_wallmounted.png", + tiles = { + "testnodes_1wg.png", + "testnodes_2wg.png", + "testnodes_3wg.png", + "testnodes_4wg.png", + "testnodes_5wg.png", + "testnodes_6wg.png", + }, + + groups = { dig_immediate = 3 }, +}) + +minetest.register_node("testnodes:colorwallmounted_nodebox", { + description = S("Color Wallmounted Nodebox Test Node"), + paramtype2 = "colorwallmounted", + paramtype = "light", + palette = "testnodes_palette_wallmounted.png", + tiles = { + "testnodes_1wg.png", + "testnodes_2wg.png", + "testnodes_3wg.png", + "testnodes_4wg.png", + "testnodes_5wg.png", + "testnodes_6wg.png", + }, + drawtype = "nodebox", + node_box = { + type = "wallmounted", + wall_top = { -0.5, 0, -0.5, 0.5, 0.5, 0.5 }, + wall_bottom = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }, + wall_side = { -0.5, -0.5, -0.5, 0, 0.5, 0.5 }, + }, + + groups = { dig_immediate = 3 }, +}) + diff --git a/mods/testnodes/properties.lua b/mods/testnodes/properties.lua new file mode 100644 index 0000000..a52cd1d --- /dev/null +++ b/mods/testnodes/properties.lua @@ -0,0 +1,275 @@ +-- Test Nodes: Node property tests + +local S = minetest.get_translator("testnodes") + +-- Is supposed to fall when it doesn't rest on solid ground +minetest.register_node("testnodes:falling", { + description = S("Falling Node"), + tiles = { + "testnodes_node.png", + "testnodes_node.png", + "testnodes_node_falling.png", + }, + groups = { falling_node = 1, dig_immediate = 3 }, +}) + +-- Same as falling node, but will stop falling on top of liquids +minetest.register_node("testnodes:falling_float", { + description = S("Falling+Floating Node"), + groups = { falling_node = 1, float = 1, dig_immediate = 3 }, + + + tiles = { + "testnodes_node.png", + "testnodes_node.png", + "testnodes_node_falling.png", + }, + color = "cyan", +}) + +-- This node attaches to the floor and drops as item +-- when the floor is gone. +minetest.register_node("testnodes:attached", { + description = S("Floor-Attached Node"), + tiles = { + "testnodes_attached_top.png", + "testnodes_attached_bottom.png", + "testnodes_attached_side.png", + }, + groups = { attached_node = 1, dig_immediate = 3 }, +}) + +-- This node attaches to the side of a node and drops as item +-- when the node it attaches to is gone. +minetest.register_node("testnodes:attached_wallmounted", { + description = S("Wallmounted Attached Node"), + paramtype2 = "wallmounted", + tiles = { + "testnodes_attachedw_top.png", + "testnodes_attachedw_bottom.png", + "testnodes_attachedw_side.png", + }, + groups = { attached_node = 1, dig_immediate = 3 }, +}) + +-- Jump disabled +minetest.register_node("testnodes:nojump", { + description = S("Non-jumping Node"), + groups = {disable_jump=1, dig_immediate=3}, + tiles = {"testnodes_nojump_top.png", "testnodes_nojump_side.png"}, +}) + +-- Jump disabled plant +minetest.register_node("testnodes:nojump_walkable", { + description = S("Non-jumping Plant Node"), + drawtype = "plantlike", + groups = {disable_jump=1, dig_immediate=3}, + walkable = false, + tiles = {"testnodes_nojump_top.png"}, +}) + +-- Climbable up and down with jump and sneak keys +minetest.register_node("testnodes:climbable", { + description = S("Climbable Node"), + climbable = true, + walkable = false, + + + paramtype = "light", + sunlight_propagates = true, + is_ground_content = false, + tiles ={"testnodes_climbable_side.png"}, + drawtype = "glasslike", + groups = {dig_immediate=3}, +}) + +-- Climbable only downwards with sneak key +minetest.register_node("testnodes:climbable_nojump", { + description = S("Downwards-climbable Node"), + climbable = true, + walkable = false, + + groups = {disable_jump=1, dig_immediate=3}, + drawtype = "glasslike", + tiles ={"testnodes_climbable_nojump_side.png"}, + paramtype = "light", + sunlight_propagates = true, +}) + +-- A liquid in which you can't rise +minetest.register_node("testnodes:liquid_nojump", { + description = S("Non-jumping Liquid Source Node"), + liquidtype = "source", + liquid_range = 1, + liquid_viscosity = 0, + liquid_alternative_flowing = "testnodes:liquidflowing_nojump", + liquid_alternative_source = "testnodes:liquid_nojump", + liquid_renewable = false, + groups = {disable_jump=1, dig_immediate=3}, + walkable = false, + + drawtype = "liquid", + tiles = {"testnodes_liquidsource.png^[colorize:#FF0000:127"}, + special_tiles = { + {name = "testnodes_liquidsource.png^[colorize:#FF0000:127", backface_culling = false}, + {name = "testnodes_liquidsource.png^[colorize:#FF0000:127", backface_culling = true}, + }, + use_texture_alpha = "blend", + paramtype = "light", + pointable = false, + liquids_pointable = true, + buildable_to = true, + is_ground_content = false, + post_effect_color = {a = 70, r = 255, g = 0, b = 200}, +}) + +-- A liquid in which you can't rise (flowing variant) +minetest.register_node("testnodes:liquidflowing_nojump", { + description = S("Non-jumping Flowing Liquid Node"), + liquidtype = "flowing", + liquid_range = 1, + liquid_viscosity = 0, + liquid_alternative_flowing = "testnodes:liquidflowing_nojump", + liquid_alternative_source = "testnodes:liquid_nojump", + liquid_renewable = false, + groups = {disable_jump=1, dig_immediate=3}, + walkable = false, + + + drawtype = "flowingliquid", + tiles = {"testnodes_liquidflowing.png^[colorize:#FF0000:127"}, + special_tiles = { + {name = "testnodes_liquidflowing.png^[colorize:#FF0000:127", backface_culling = false}, + {name = "testnodes_liquidflowing.png^[colorize:#FF0000:127", backface_culling = false}, + }, + use_texture_alpha = "blend", + paramtype = "light", + paramtype2 = "flowingliquid", + pointable = false, + liquids_pointable = true, + buildable_to = true, + is_ground_content = false, + post_effect_color = {a = 70, r = 255, g = 0, b = 200}, +}) + +-- Nodes that modify fall damage (various damage modifiers) +for i=-100, 100, 25 do + if i ~= 0 then + local subname, descnum + if i < 0 then + subname = "m"..math.abs(i) + descnum = tostring(i) + else + subname = tostring(i) + descnum = S("+@1", i) + end + local tex, color, desc + if i > 0 then + local val = math.floor((i/100)*255) + tex = "testnodes_fall_damage_plus.png" + color = { b=0, g=255-val, r=255, a=255 } + desc = S("Fall Damage Node (+@1%)", i) + else + tex = "testnodes_fall_damage_minus.png" + if i == -100 then + color = { r=0, b=0, g=255, a=255 } + else + local val = math.floor((math.abs(i)/100)*255) + color = { r=0, b=255, g=255-val, a=255 } + end + desc = S("Fall Damage Node (-@1%)", math.abs(i)) + end + minetest.register_node("testnodes:damage"..subname, { + description = desc, + groups = {fall_damage_add_percent=i, dig_immediate=3}, + + + tiles = { tex }, + is_ground_content = false, + color = color, + }) + end +end + +-- Bouncy nodes (various bounce levels) +for i=20, 180, 20 do + local val = math.floor(((i-20)/200)*255) + minetest.register_node("testnodes:bouncy"..i, { + description = S("Bouncy Node (@1%)", i), + groups = {bouncy=i, dig_immediate=3}, + + + tiles ={"testnodes_bouncy.png"}, + is_ground_content = false, + color = { r=255, g=255-val, b=val, a=255 }, + }) +end + +-- Slippery nodes (various slippery levels) +for i=1, 5 do + minetest.register_node("testnodes:slippery"..i, { + description = S("Slippery Node (@1)", i), + tiles ={"testnodes_slippery.png"}, + is_ground_content = false, + groups = {slippery=i, dig_immediate=3}, + color = { r=0, g=255, b=math.floor((i/5)*255), a=255 }, + }) +end + +-- By placing something on the node, the node itself will be replaced +minetest.register_node("testnodes:buildable_to", { + description = S("Replacable Node"), + buildable_to = true, + tiles = {"testnodes_buildable_to.png"}, + is_ground_content = false, + groups = {dig_immediate=3}, +}) + +-- Nodes that deal damage to players that are inside them. +-- Negative damage nodes should heal. +for d=-3,3 do + if d ~= 0 then + local sub, tile + if d > 0 then + sub = tostring(d) + tile = "testnodes_damage.png" + else + sub = "m" .. tostring(math.abs(d)) + tile = "testnodes_damage_neg.png" + end + if math.abs(d) == 2 then + tile = tile .. "^[colorize:#000000:70" + elseif math.abs(d) == 3 then + tile = tile .. "^[colorize:#000000:140" + end + minetest.register_node("testnodes:damage_"..sub, { + description = S("Damage Node (@1 damage per second)", d), + damage_per_second = d, + + + walkable = false, + is_ground_content = false, + drawtype = "allfaces", + paramtype = "light", + sunlight_propagates = true, + tiles = { tile }, + groups = {dig_immediate=3}, + }) + end +end + +-- Causes drowning damage +minetest.register_node("testnodes:drowning_1", { + description = S("Drowning Node (@1 damage)", 1), + drowning = 1, + + + walkable = false, + is_ground_content = false, + drawtype = "allfaces", + paramtype = "light", + sunlight_propagates = true, + tiles = { "testnodes_drowning.png" }, + groups = {dig_immediate=3}, +}) + diff --git a/mods/testnodes/settingtypes.txt b/mods/testnodes/settingtypes.txt new file mode 100644 index 0000000..7f753bf --- /dev/null +++ b/mods/testnodes/settingtypes.txt @@ -0,0 +1,4 @@ +# If set to true, will show an inventory image for nodes that have no inventory image as of Minetest 5.1.0. +# This is due to . +# This is only added to make the items more visible to avoid confusion, but you will no longer see the default inventory images for these items. When you want to test the default inventory image of drawtypes, this should be turned off. +testnodes_show_fallback_image (Use fallback inventory images) bool false diff --git a/mods/testnodes/textures.lua b/mods/testnodes/textures.lua new file mode 100644 index 0000000..f6e6a0c --- /dev/null +++ b/mods/testnodes/textures.lua @@ -0,0 +1,67 @@ +-- Node texture tests + +local S = minetest.get_translator("testnodes") + +minetest.register_node("testnodes:6sides", { + description = S("Six Textures Test Node"), + tiles = { + "testnodes_normal1.png", + "testnodes_normal2.png", + "testnodes_normal3.png", + "testnodes_normal4.png", + "testnodes_normal5.png", + "testnodes_normal6.png", + }, + + groups = { dig_immediate = 2 }, +}) + +minetest.register_node("testnodes:anim", { + description = S("Animated Test Node"), + tiles = { + { name = "testnodes_anim.png", + animation = { + type = "vertical_frames", + aspect_w = 16, + aspect_h = 16, + length = 4.0, + }, }, + }, + + groups = { dig_immediate = 2 }, +}) + +-- Node texture transparency test + +local alphas = { 64, 128, 191 } + +for a=1,#alphas do + local alpha = alphas[a] + + -- Transparency taken from texture + minetest.register_node("testnodes:alpha_texture_"..alpha, { + description = S("Texture Alpha Test Node (@1)", alpha), + drawtype = "glasslike", + paramtype = "light", + tiles = { + "testnodes_alpha"..alpha..".png", + }, + use_texture_alpha = "blend", + + groups = { dig_immediate = 3 }, + }) + + -- Transparency set via texture modifier + minetest.register_node("testnodes:alpha_"..alpha, { + description = S("Alpha Test Node (@1)", alpha), + drawtype = "glasslike", + paramtype = "light", + tiles = { + "testnodes_alpha.png^[opacity:" .. alpha, + }, + use_texture_alpha = "blend", + + groups = { dig_immediate = 3 }, + }) +end + diff --git a/mods/testnodes/textures/testnodes_1.png b/mods/testnodes/textures/testnodes_1.png new file mode 100644 index 0000000..6730997 Binary files /dev/null and b/mods/testnodes/textures/testnodes_1.png differ diff --git a/mods/testnodes/textures/testnodes_1g.png b/mods/testnodes/textures/testnodes_1g.png new file mode 100644 index 0000000..529298e Binary files /dev/null and b/mods/testnodes/textures/testnodes_1g.png differ diff --git a/mods/testnodes/textures/testnodes_1w.png b/mods/testnodes/textures/testnodes_1w.png new file mode 100644 index 0000000..d24e571 Binary files /dev/null and b/mods/testnodes/textures/testnodes_1w.png differ diff --git a/mods/testnodes/textures/testnodes_1wg.png b/mods/testnodes/textures/testnodes_1wg.png new file mode 100644 index 0000000..b2eba0e Binary files /dev/null and b/mods/testnodes/textures/testnodes_1wg.png differ diff --git a/mods/testnodes/textures/testnodes_2.png b/mods/testnodes/textures/testnodes_2.png new file mode 100644 index 0000000..6c87c86 Binary files /dev/null and b/mods/testnodes/textures/testnodes_2.png differ diff --git a/mods/testnodes/textures/testnodes_2g.png b/mods/testnodes/textures/testnodes_2g.png new file mode 100644 index 0000000..cb9060f Binary files /dev/null and b/mods/testnodes/textures/testnodes_2g.png differ diff --git a/mods/testnodes/textures/testnodes_2w.png b/mods/testnodes/textures/testnodes_2w.png new file mode 100644 index 0000000..b56874e Binary files /dev/null and b/mods/testnodes/textures/testnodes_2w.png differ diff --git a/mods/testnodes/textures/testnodes_2wg.png b/mods/testnodes/textures/testnodes_2wg.png new file mode 100644 index 0000000..108dc87 Binary files /dev/null and b/mods/testnodes/textures/testnodes_2wg.png differ diff --git a/mods/testnodes/textures/testnodes_3.png b/mods/testnodes/textures/testnodes_3.png new file mode 100644 index 0000000..05b4562 Binary files /dev/null and b/mods/testnodes/textures/testnodes_3.png differ diff --git a/mods/testnodes/textures/testnodes_3g.png b/mods/testnodes/textures/testnodes_3g.png new file mode 100644 index 0000000..5c84f58 Binary files /dev/null and b/mods/testnodes/textures/testnodes_3g.png differ diff --git a/mods/testnodes/textures/testnodes_3w.png b/mods/testnodes/textures/testnodes_3w.png new file mode 100644 index 0000000..8b435cf Binary files /dev/null and b/mods/testnodes/textures/testnodes_3w.png differ diff --git a/mods/testnodes/textures/testnodes_3wg.png b/mods/testnodes/textures/testnodes_3wg.png new file mode 100644 index 0000000..9ee9006 Binary files /dev/null and b/mods/testnodes/textures/testnodes_3wg.png differ diff --git a/mods/testnodes/textures/testnodes_4.png b/mods/testnodes/textures/testnodes_4.png new file mode 100644 index 0000000..15e6ffe Binary files /dev/null and b/mods/testnodes/textures/testnodes_4.png differ diff --git a/mods/testnodes/textures/testnodes_4g.png b/mods/testnodes/textures/testnodes_4g.png new file mode 100644 index 0000000..8f144fa Binary files /dev/null and b/mods/testnodes/textures/testnodes_4g.png differ diff --git a/mods/testnodes/textures/testnodes_4w.png b/mods/testnodes/textures/testnodes_4w.png new file mode 100644 index 0000000..214e0df Binary files /dev/null and b/mods/testnodes/textures/testnodes_4w.png differ diff --git a/mods/testnodes/textures/testnodes_4wg.png b/mods/testnodes/textures/testnodes_4wg.png new file mode 100644 index 0000000..888b3d4 Binary files /dev/null and b/mods/testnodes/textures/testnodes_4wg.png differ diff --git a/mods/testnodes/textures/testnodes_5.png b/mods/testnodes/textures/testnodes_5.png new file mode 100644 index 0000000..1ef1c72 Binary files /dev/null and b/mods/testnodes/textures/testnodes_5.png differ diff --git a/mods/testnodes/textures/testnodes_5g.png b/mods/testnodes/textures/testnodes_5g.png new file mode 100644 index 0000000..30da479 Binary files /dev/null and b/mods/testnodes/textures/testnodes_5g.png differ diff --git a/mods/testnodes/textures/testnodes_5w.png b/mods/testnodes/textures/testnodes_5w.png new file mode 100644 index 0000000..b4cb424 Binary files /dev/null and b/mods/testnodes/textures/testnodes_5w.png differ diff --git a/mods/testnodes/textures/testnodes_5wg.png b/mods/testnodes/textures/testnodes_5wg.png new file mode 100644 index 0000000..fac9db2 Binary files /dev/null and b/mods/testnodes/textures/testnodes_5wg.png differ diff --git a/mods/testnodes/textures/testnodes_6.png b/mods/testnodes/textures/testnodes_6.png new file mode 100644 index 0000000..805813e Binary files /dev/null and b/mods/testnodes/textures/testnodes_6.png differ diff --git a/mods/testnodes/textures/testnodes_6g.png b/mods/testnodes/textures/testnodes_6g.png new file mode 100644 index 0000000..a88f4c9 Binary files /dev/null and b/mods/testnodes/textures/testnodes_6g.png differ diff --git a/mods/testnodes/textures/testnodes_6w.png b/mods/testnodes/textures/testnodes_6w.png new file mode 100644 index 0000000..e6bbf97 Binary files /dev/null and b/mods/testnodes/textures/testnodes_6w.png differ diff --git a/mods/testnodes/textures/testnodes_6wg.png b/mods/testnodes/textures/testnodes_6wg.png new file mode 100644 index 0000000..29ca933 Binary files /dev/null and b/mods/testnodes/textures/testnodes_6wg.png differ diff --git a/mods/testnodes/textures/testnodes_airlike.png b/mods/testnodes/textures/testnodes_airlike.png new file mode 100644 index 0000000..5a5664a Binary files /dev/null and b/mods/testnodes/textures/testnodes_airlike.png differ diff --git a/mods/testnodes/textures/testnodes_allfaces.png b/mods/testnodes/textures/testnodes_allfaces.png new file mode 100644 index 0000000..c0a7dc5 Binary files /dev/null and b/mods/testnodes/textures/testnodes_allfaces.png differ diff --git a/mods/testnodes/textures/testnodes_allfaces_optional.png b/mods/testnodes/textures/testnodes_allfaces_optional.png new file mode 100644 index 0000000..1f6a173 Binary files /dev/null and b/mods/testnodes/textures/testnodes_allfaces_optional.png differ diff --git a/mods/testnodes/textures/testnodes_alpha.png b/mods/testnodes/textures/testnodes_alpha.png new file mode 100644 index 0000000..157fa73 Binary files /dev/null and b/mods/testnodes/textures/testnodes_alpha.png differ diff --git a/mods/testnodes/textures/testnodes_alpha128.png b/mods/testnodes/textures/testnodes_alpha128.png new file mode 100644 index 0000000..16babf6 Binary files /dev/null and b/mods/testnodes/textures/testnodes_alpha128.png differ diff --git a/mods/testnodes/textures/testnodes_alpha191.png b/mods/testnodes/textures/testnodes_alpha191.png new file mode 100644 index 0000000..f165d28 Binary files /dev/null and b/mods/testnodes/textures/testnodes_alpha191.png differ diff --git a/mods/testnodes/textures/testnodes_alpha64.png b/mods/testnodes/textures/testnodes_alpha64.png new file mode 100644 index 0000000..c343c32 Binary files /dev/null and b/mods/testnodes/textures/testnodes_alpha64.png differ diff --git a/mods/testnodes/textures/testnodes_anim.png b/mods/testnodes/textures/testnodes_anim.png new file mode 100644 index 0000000..d321fe8 Binary files /dev/null and b/mods/testnodes/textures/testnodes_anim.png differ diff --git a/mods/testnodes/textures/testnodes_attached_bottom.png b/mods/testnodes/textures/testnodes_attached_bottom.png new file mode 100644 index 0000000..e01ae57 Binary files /dev/null and b/mods/testnodes/textures/testnodes_attached_bottom.png differ diff --git a/mods/testnodes/textures/testnodes_attached_side.png b/mods/testnodes/textures/testnodes_attached_side.png new file mode 100644 index 0000000..9459cbb Binary files /dev/null and b/mods/testnodes/textures/testnodes_attached_side.png differ diff --git a/mods/testnodes/textures/testnodes_attached_top.png b/mods/testnodes/textures/testnodes_attached_top.png new file mode 100644 index 0000000..0148b41 Binary files /dev/null and b/mods/testnodes/textures/testnodes_attached_top.png differ diff --git a/mods/testnodes/textures/testnodes_attachedw_bottom.png b/mods/testnodes/textures/testnodes_attachedw_bottom.png new file mode 100644 index 0000000..488ad23 Binary files /dev/null and b/mods/testnodes/textures/testnodes_attachedw_bottom.png differ diff --git a/mods/testnodes/textures/testnodes_attachedw_side.png b/mods/testnodes/textures/testnodes_attachedw_side.png new file mode 100644 index 0000000..a02facb Binary files /dev/null and b/mods/testnodes/textures/testnodes_attachedw_side.png differ diff --git a/mods/testnodes/textures/testnodes_attachedw_top.png b/mods/testnodes/textures/testnodes_attachedw_top.png new file mode 100644 index 0000000..1f4fc7b Binary files /dev/null and b/mods/testnodes/textures/testnodes_attachedw_top.png differ diff --git a/mods/testnodes/textures/testnodes_bouncy.png b/mods/testnodes/textures/testnodes_bouncy.png new file mode 100644 index 0000000..eabbbdf Binary files /dev/null and b/mods/testnodes/textures/testnodes_bouncy.png differ diff --git a/mods/testnodes/textures/testnodes_buildable_to.png b/mods/testnodes/textures/testnodes_buildable_to.png new file mode 100644 index 0000000..23b5e54 Binary files /dev/null and b/mods/testnodes/textures/testnodes_buildable_to.png differ diff --git a/mods/testnodes/textures/testnodes_climbable_nojump_side.png b/mods/testnodes/textures/testnodes_climbable_nojump_side.png new file mode 100644 index 0000000..d5ca130 Binary files /dev/null and b/mods/testnodes/textures/testnodes_climbable_nojump_side.png differ diff --git a/mods/testnodes/textures/testnodes_climbable_side.png b/mods/testnodes/textures/testnodes_climbable_side.png new file mode 100644 index 0000000..c56ea90 Binary files /dev/null and b/mods/testnodes/textures/testnodes_climbable_side.png differ diff --git a/mods/testnodes/textures/testnodes_damage.png b/mods/testnodes/textures/testnodes_damage.png new file mode 100644 index 0000000..9de2ab5 Binary files /dev/null and b/mods/testnodes/textures/testnodes_damage.png differ diff --git a/mods/testnodes/textures/testnodes_damage_neg.png b/mods/testnodes/textures/testnodes_damage_neg.png new file mode 100644 index 0000000..85811bc Binary files /dev/null and b/mods/testnodes/textures/testnodes_damage_neg.png differ diff --git a/mods/testnodes/textures/testnodes_drowning.png b/mods/testnodes/textures/testnodes_drowning.png new file mode 100644 index 0000000..57ffc8f Binary files /dev/null and b/mods/testnodes/textures/testnodes_drowning.png differ diff --git a/mods/testnodes/textures/testnodes_fall_damage_minus.png b/mods/testnodes/textures/testnodes_fall_damage_minus.png new file mode 100644 index 0000000..88d3bdf Binary files /dev/null and b/mods/testnodes/textures/testnodes_fall_damage_minus.png differ diff --git a/mods/testnodes/textures/testnodes_fall_damage_plus.png b/mods/testnodes/textures/testnodes_fall_damage_plus.png new file mode 100644 index 0000000..61fdec2 Binary files /dev/null and b/mods/testnodes/textures/testnodes_fall_damage_plus.png differ diff --git a/mods/testnodes/textures/testnodes_fencelike.png b/mods/testnodes/textures/testnodes_fencelike.png new file mode 100644 index 0000000..84dea1b Binary files /dev/null and b/mods/testnodes/textures/testnodes_fencelike.png differ diff --git a/mods/testnodes/textures/testnodes_firelike.png b/mods/testnodes/textures/testnodes_firelike.png new file mode 100644 index 0000000..ee59b0d Binary files /dev/null and b/mods/testnodes/textures/testnodes_firelike.png differ diff --git a/mods/testnodes/textures/testnodes_glasslike.png b/mods/testnodes/textures/testnodes_glasslike.png new file mode 100644 index 0000000..cf3e354 Binary files /dev/null and b/mods/testnodes/textures/testnodes_glasslike.png differ diff --git a/mods/testnodes/textures/testnodes_glasslike_detail.png b/mods/testnodes/textures/testnodes_glasslike_detail.png new file mode 100644 index 0000000..30c9586 Binary files /dev/null and b/mods/testnodes/textures/testnodes_glasslike_detail.png differ diff --git a/mods/testnodes/textures/testnodes_glasslike_framed.png b/mods/testnodes/textures/testnodes_glasslike_framed.png new file mode 100644 index 0000000..8a513f2 Binary files /dev/null and b/mods/testnodes/textures/testnodes_glasslike_framed.png differ diff --git a/mods/testnodes/textures/testnodes_glasslike_framed2.png b/mods/testnodes/textures/testnodes_glasslike_framed2.png new file mode 100644 index 0000000..4ea839c Binary files /dev/null and b/mods/testnodes/textures/testnodes_glasslike_framed2.png differ diff --git a/mods/testnodes/textures/testnodes_glasslike_framed_optional.png b/mods/testnodes/textures/testnodes_glasslike_framed_optional.png new file mode 100644 index 0000000..37de77d Binary files /dev/null and b/mods/testnodes/textures/testnodes_glasslike_framed_optional.png differ diff --git a/mods/testnodes/textures/testnodes_glasslikeliquid.png b/mods/testnodes/textures/testnodes_glasslikeliquid.png new file mode 100644 index 0000000..e1e96ff Binary files /dev/null and b/mods/testnodes/textures/testnodes_glasslikeliquid.png differ diff --git a/mods/testnodes/textures/testnodes_light.png b/mods/testnodes/textures/testnodes_light.png new file mode 100644 index 0000000..4ba0081 Binary files /dev/null and b/mods/testnodes/textures/testnodes_light.png differ diff --git a/mods/testnodes/textures/testnodes_light_1.png b/mods/testnodes/textures/testnodes_light_1.png new file mode 100644 index 0000000..57adf5a Binary files /dev/null and b/mods/testnodes/textures/testnodes_light_1.png differ diff --git a/mods/testnodes/textures/testnodes_light_10.png b/mods/testnodes/textures/testnodes_light_10.png new file mode 100644 index 0000000..4838347 Binary files /dev/null and b/mods/testnodes/textures/testnodes_light_10.png differ diff --git a/mods/testnodes/textures/testnodes_light_11.png b/mods/testnodes/textures/testnodes_light_11.png new file mode 100644 index 0000000..4c423d9 Binary files /dev/null and b/mods/testnodes/textures/testnodes_light_11.png differ diff --git a/mods/testnodes/textures/testnodes_light_12.png b/mods/testnodes/textures/testnodes_light_12.png new file mode 100644 index 0000000..bc7946d Binary files /dev/null and b/mods/testnodes/textures/testnodes_light_12.png differ diff --git a/mods/testnodes/textures/testnodes_light_13.png b/mods/testnodes/textures/testnodes_light_13.png new file mode 100644 index 0000000..0b63c84 Binary files /dev/null and b/mods/testnodes/textures/testnodes_light_13.png differ diff --git a/mods/testnodes/textures/testnodes_light_14.png b/mods/testnodes/textures/testnodes_light_14.png new file mode 100644 index 0000000..a817bd3 Binary files /dev/null and b/mods/testnodes/textures/testnodes_light_14.png differ diff --git a/mods/testnodes/textures/testnodes_light_2.png b/mods/testnodes/textures/testnodes_light_2.png new file mode 100644 index 0000000..852eaef Binary files /dev/null and b/mods/testnodes/textures/testnodes_light_2.png differ diff --git a/mods/testnodes/textures/testnodes_light_3.png b/mods/testnodes/textures/testnodes_light_3.png new file mode 100644 index 0000000..79fc834 Binary files /dev/null and b/mods/testnodes/textures/testnodes_light_3.png differ diff --git a/mods/testnodes/textures/testnodes_light_4.png b/mods/testnodes/textures/testnodes_light_4.png new file mode 100644 index 0000000..75f8c61 Binary files /dev/null and b/mods/testnodes/textures/testnodes_light_4.png differ diff --git a/mods/testnodes/textures/testnodes_light_5.png b/mods/testnodes/textures/testnodes_light_5.png new file mode 100644 index 0000000..b6eede0 Binary files /dev/null and b/mods/testnodes/textures/testnodes_light_5.png differ diff --git a/mods/testnodes/textures/testnodes_light_6.png b/mods/testnodes/textures/testnodes_light_6.png new file mode 100644 index 0000000..ef54add Binary files /dev/null and b/mods/testnodes/textures/testnodes_light_6.png differ diff --git a/mods/testnodes/textures/testnodes_light_7.png b/mods/testnodes/textures/testnodes_light_7.png new file mode 100644 index 0000000..4a885b0 Binary files /dev/null and b/mods/testnodes/textures/testnodes_light_7.png differ diff --git a/mods/testnodes/textures/testnodes_light_8.png b/mods/testnodes/textures/testnodes_light_8.png new file mode 100644 index 0000000..b283301 Binary files /dev/null and b/mods/testnodes/textures/testnodes_light_8.png differ diff --git a/mods/testnodes/textures/testnodes_light_9.png b/mods/testnodes/textures/testnodes_light_9.png new file mode 100644 index 0000000..2aa9023 Binary files /dev/null and b/mods/testnodes/textures/testnodes_light_9.png differ diff --git a/mods/testnodes/textures/testnodes_line_crossing.png b/mods/testnodes/textures/testnodes_line_crossing.png new file mode 100644 index 0000000..e566f27 Binary files /dev/null and b/mods/testnodes/textures/testnodes_line_crossing.png differ diff --git a/mods/testnodes/textures/testnodes_line_curved.png b/mods/testnodes/textures/testnodes_line_curved.png new file mode 100644 index 0000000..ab9f8e7 Binary files /dev/null and b/mods/testnodes/textures/testnodes_line_curved.png differ diff --git a/mods/testnodes/textures/testnodes_line_straight.png b/mods/testnodes/textures/testnodes_line_straight.png new file mode 100644 index 0000000..4f33d9c Binary files /dev/null and b/mods/testnodes/textures/testnodes_line_straight.png differ diff --git a/mods/testnodes/textures/testnodes_line_t_junction.png b/mods/testnodes/textures/testnodes_line_t_junction.png new file mode 100644 index 0000000..5668f6e Binary files /dev/null and b/mods/testnodes/textures/testnodes_line_t_junction.png differ diff --git a/mods/testnodes/textures/testnodes_liquid.png b/mods/testnodes/textures/testnodes_liquid.png new file mode 100644 index 0000000..98ab270 Binary files /dev/null and b/mods/testnodes/textures/testnodes_liquid.png differ diff --git a/mods/testnodes/textures/testnodes_liquidflowing.png b/mods/testnodes/textures/testnodes_liquidflowing.png new file mode 100644 index 0000000..1736b89 Binary files /dev/null and b/mods/testnodes/textures/testnodes_liquidflowing.png differ diff --git a/mods/testnodes/textures/testnodes_liquidflowing_r0.png b/mods/testnodes/textures/testnodes_liquidflowing_r0.png new file mode 100644 index 0000000..e8a6103 Binary files /dev/null and b/mods/testnodes/textures/testnodes_liquidflowing_r0.png differ diff --git a/mods/testnodes/textures/testnodes_liquidflowing_r1.png b/mods/testnodes/textures/testnodes_liquidflowing_r1.png new file mode 100644 index 0000000..b4e45b4 Binary files /dev/null and b/mods/testnodes/textures/testnodes_liquidflowing_r1.png differ diff --git a/mods/testnodes/textures/testnodes_liquidflowing_r2.png b/mods/testnodes/textures/testnodes_liquidflowing_r2.png new file mode 100644 index 0000000..e064b8f Binary files /dev/null and b/mods/testnodes/textures/testnodes_liquidflowing_r2.png differ diff --git a/mods/testnodes/textures/testnodes_liquidflowing_r3.png b/mods/testnodes/textures/testnodes_liquidflowing_r3.png new file mode 100644 index 0000000..bef7739 Binary files /dev/null and b/mods/testnodes/textures/testnodes_liquidflowing_r3.png differ diff --git a/mods/testnodes/textures/testnodes_liquidflowing_r4.png b/mods/testnodes/textures/testnodes_liquidflowing_r4.png new file mode 100644 index 0000000..de1001b Binary files /dev/null and b/mods/testnodes/textures/testnodes_liquidflowing_r4.png differ diff --git a/mods/testnodes/textures/testnodes_liquidflowing_r5.png b/mods/testnodes/textures/testnodes_liquidflowing_r5.png new file mode 100644 index 0000000..97b422e Binary files /dev/null and b/mods/testnodes/textures/testnodes_liquidflowing_r5.png differ diff --git a/mods/testnodes/textures/testnodes_liquidflowing_r6.png b/mods/testnodes/textures/testnodes_liquidflowing_r6.png new file mode 100644 index 0000000..4cd8e4e Binary files /dev/null and b/mods/testnodes/textures/testnodes_liquidflowing_r6.png differ diff --git a/mods/testnodes/textures/testnodes_liquidflowing_r7.png b/mods/testnodes/textures/testnodes_liquidflowing_r7.png new file mode 100644 index 0000000..711dd96 Binary files /dev/null and b/mods/testnodes/textures/testnodes_liquidflowing_r7.png differ diff --git a/mods/testnodes/textures/testnodes_liquidflowing_r8.png b/mods/testnodes/textures/testnodes_liquidflowing_r8.png new file mode 100644 index 0000000..9cf22b8 Binary files /dev/null and b/mods/testnodes/textures/testnodes_liquidflowing_r8.png differ diff --git a/mods/testnodes/textures/testnodes_liquidsource.png b/mods/testnodes/textures/testnodes_liquidsource.png new file mode 100644 index 0000000..b3f29b7 Binary files /dev/null and b/mods/testnodes/textures/testnodes_liquidsource.png differ diff --git a/mods/testnodes/textures/testnodes_liquidsource_r0.png b/mods/testnodes/textures/testnodes_liquidsource_r0.png new file mode 100644 index 0000000..da0a996 Binary files /dev/null and b/mods/testnodes/textures/testnodes_liquidsource_r0.png differ diff --git a/mods/testnodes/textures/testnodes_liquidsource_r1.png b/mods/testnodes/textures/testnodes_liquidsource_r1.png new file mode 100644 index 0000000..66bf2be Binary files /dev/null and b/mods/testnodes/textures/testnodes_liquidsource_r1.png differ diff --git a/mods/testnodes/textures/testnodes_liquidsource_r2.png b/mods/testnodes/textures/testnodes_liquidsource_r2.png new file mode 100644 index 0000000..fc5f65c Binary files /dev/null and b/mods/testnodes/textures/testnodes_liquidsource_r2.png differ diff --git a/mods/testnodes/textures/testnodes_liquidsource_r3.png b/mods/testnodes/textures/testnodes_liquidsource_r3.png new file mode 100644 index 0000000..0f46e29 Binary files /dev/null and b/mods/testnodes/textures/testnodes_liquidsource_r3.png differ diff --git a/mods/testnodes/textures/testnodes_liquidsource_r4.png b/mods/testnodes/textures/testnodes_liquidsource_r4.png new file mode 100644 index 0000000..0693a04 Binary files /dev/null and b/mods/testnodes/textures/testnodes_liquidsource_r4.png differ diff --git a/mods/testnodes/textures/testnodes_liquidsource_r5.png b/mods/testnodes/textures/testnodes_liquidsource_r5.png new file mode 100644 index 0000000..cc9d039 Binary files /dev/null and b/mods/testnodes/textures/testnodes_liquidsource_r5.png differ diff --git a/mods/testnodes/textures/testnodes_liquidsource_r6.png b/mods/testnodes/textures/testnodes_liquidsource_r6.png new file mode 100644 index 0000000..e276a07 Binary files /dev/null and b/mods/testnodes/textures/testnodes_liquidsource_r6.png differ diff --git a/mods/testnodes/textures/testnodes_liquidsource_r7.png b/mods/testnodes/textures/testnodes_liquidsource_r7.png new file mode 100644 index 0000000..3534a4b Binary files /dev/null and b/mods/testnodes/textures/testnodes_liquidsource_r7.png differ diff --git a/mods/testnodes/textures/testnodes_liquidsource_r8.png b/mods/testnodes/textures/testnodes_liquidsource_r8.png new file mode 100644 index 0000000..ee1a8b1 Binary files /dev/null and b/mods/testnodes/textures/testnodes_liquidsource_r8.png differ diff --git a/mods/testnodes/textures/testnodes_mesh_stripes.png b/mods/testnodes/textures/testnodes_mesh_stripes.png new file mode 100644 index 0000000..51b8e00 Binary files /dev/null and b/mods/testnodes/textures/testnodes_mesh_stripes.png differ diff --git a/mods/testnodes/textures/testnodes_mesh_stripes2.png b/mods/testnodes/textures/testnodes_mesh_stripes2.png new file mode 100644 index 0000000..9ea65c1 Binary files /dev/null and b/mods/testnodes/textures/testnodes_mesh_stripes2.png differ diff --git a/mods/testnodes/textures/testnodes_mesh_stripes3.png b/mods/testnodes/textures/testnodes_mesh_stripes3.png new file mode 100644 index 0000000..96bc55a Binary files /dev/null and b/mods/testnodes/textures/testnodes_mesh_stripes3.png differ diff --git a/mods/testnodes/textures/testnodes_mesh_stripes4.png b/mods/testnodes/textures/testnodes_mesh_stripes4.png new file mode 100644 index 0000000..fca3372 Binary files /dev/null and b/mods/testnodes/textures/testnodes_mesh_stripes4.png differ diff --git a/mods/testnodes/textures/testnodes_node.png b/mods/testnodes/textures/testnodes_node.png new file mode 100644 index 0000000..145099b Binary files /dev/null and b/mods/testnodes/textures/testnodes_node.png differ diff --git a/mods/testnodes/textures/testnodes_node_falling.png b/mods/testnodes/textures/testnodes_node_falling.png new file mode 100644 index 0000000..4415318 Binary files /dev/null and b/mods/testnodes/textures/testnodes_node_falling.png differ diff --git a/mods/testnodes/textures/testnodes_nodebox.png b/mods/testnodes/textures/testnodes_nodebox.png new file mode 100644 index 0000000..66e8dd6 Binary files /dev/null and b/mods/testnodes/textures/testnodes_nodebox.png differ diff --git a/mods/testnodes/textures/testnodes_nojump_side.png b/mods/testnodes/textures/testnodes_nojump_side.png new file mode 100644 index 0000000..6a64cff Binary files /dev/null and b/mods/testnodes/textures/testnodes_nojump_side.png differ diff --git a/mods/testnodes/textures/testnodes_nojump_top.png b/mods/testnodes/textures/testnodes_nojump_top.png new file mode 100644 index 0000000..fe77083 Binary files /dev/null and b/mods/testnodes/textures/testnodes_nojump_top.png differ diff --git a/mods/testnodes/textures/testnodes_normal.png b/mods/testnodes/textures/testnodes_normal.png new file mode 100644 index 0000000..a1acfd9 Binary files /dev/null and b/mods/testnodes/textures/testnodes_normal.png differ diff --git a/mods/testnodes/textures/testnodes_normal1.png b/mods/testnodes/textures/testnodes_normal1.png new file mode 100644 index 0000000..edaba77 Binary files /dev/null and b/mods/testnodes/textures/testnodes_normal1.png differ diff --git a/mods/testnodes/textures/testnodes_normal2.png b/mods/testnodes/textures/testnodes_normal2.png new file mode 100644 index 0000000..0080a9e Binary files /dev/null and b/mods/testnodes/textures/testnodes_normal2.png differ diff --git a/mods/testnodes/textures/testnodes_normal3.png b/mods/testnodes/textures/testnodes_normal3.png new file mode 100644 index 0000000..0426ab2 Binary files /dev/null and b/mods/testnodes/textures/testnodes_normal3.png differ diff --git a/mods/testnodes/textures/testnodes_normal4.png b/mods/testnodes/textures/testnodes_normal4.png new file mode 100644 index 0000000..0d1922e Binary files /dev/null and b/mods/testnodes/textures/testnodes_normal4.png differ diff --git a/mods/testnodes/textures/testnodes_normal5.png b/mods/testnodes/textures/testnodes_normal5.png new file mode 100644 index 0000000..0b7dcd2 Binary files /dev/null and b/mods/testnodes/textures/testnodes_normal5.png differ diff --git a/mods/testnodes/textures/testnodes_normal6.png b/mods/testnodes/textures/testnodes_normal6.png new file mode 100644 index 0000000..f34a67d Binary files /dev/null and b/mods/testnodes/textures/testnodes_normal6.png differ diff --git a/mods/testnodes/textures/testnodes_palette_facedir.png b/mods/testnodes/textures/testnodes_palette_facedir.png new file mode 100644 index 0000000..8cf47bb Binary files /dev/null and b/mods/testnodes/textures/testnodes_palette_facedir.png differ diff --git a/mods/testnodes/textures/testnodes_palette_full.png b/mods/testnodes/textures/testnodes_palette_full.png new file mode 100644 index 0000000..e0a5f8b Binary files /dev/null and b/mods/testnodes/textures/testnodes_palette_full.png differ diff --git a/mods/testnodes/textures/testnodes_palette_wallmounted.png b/mods/testnodes/textures/testnodes_palette_wallmounted.png new file mode 100644 index 0000000..682f3ac Binary files /dev/null and b/mods/testnodes/textures/testnodes_palette_wallmounted.png differ diff --git a/mods/testnodes/textures/testnodes_plantlike.png b/mods/testnodes/textures/testnodes_plantlike.png new file mode 100644 index 0000000..cc46444 Binary files /dev/null and b/mods/testnodes/textures/testnodes_plantlike.png differ diff --git a/mods/testnodes/textures/testnodes_plantlike_degrotate.png b/mods/testnodes/textures/testnodes_plantlike_degrotate.png new file mode 100644 index 0000000..01c81da Binary files /dev/null and b/mods/testnodes/textures/testnodes_plantlike_degrotate.png differ diff --git a/mods/testnodes/textures/testnodes_plantlike_leveled.png b/mods/testnodes/textures/testnodes_plantlike_leveled.png new file mode 100644 index 0000000..53504db Binary files /dev/null and b/mods/testnodes/textures/testnodes_plantlike_leveled.png differ diff --git a/mods/testnodes/textures/testnodes_plantlike_meshoptions.png b/mods/testnodes/textures/testnodes_plantlike_meshoptions.png new file mode 100644 index 0000000..d504d45 Binary files /dev/null and b/mods/testnodes/textures/testnodes_plantlike_meshoptions.png differ diff --git a/mods/testnodes/textures/testnodes_plantlike_rooted.png b/mods/testnodes/textures/testnodes_plantlike_rooted.png new file mode 100644 index 0000000..79cf212 Binary files /dev/null and b/mods/testnodes/textures/testnodes_plantlike_rooted.png differ diff --git a/mods/testnodes/textures/testnodes_plantlike_rooted_base.png b/mods/testnodes/textures/testnodes_plantlike_rooted_base.png new file mode 100644 index 0000000..b9ee9e5 Binary files /dev/null and b/mods/testnodes/textures/testnodes_plantlike_rooted_base.png differ diff --git a/mods/testnodes/textures/testnodes_plantlike_rooted_base_side_degrotate.png b/mods/testnodes/textures/testnodes_plantlike_rooted_base_side_degrotate.png new file mode 100644 index 0000000..85311cb Binary files /dev/null and b/mods/testnodes/textures/testnodes_plantlike_rooted_base_side_degrotate.png differ diff --git a/mods/testnodes/textures/testnodes_plantlike_rooted_base_side_leveled.png b/mods/testnodes/textures/testnodes_plantlike_rooted_base_side_leveled.png new file mode 100644 index 0000000..bc602ba Binary files /dev/null and b/mods/testnodes/textures/testnodes_plantlike_rooted_base_side_leveled.png differ diff --git a/mods/testnodes/textures/testnodes_plantlike_rooted_base_side_meshoptions.png b/mods/testnodes/textures/testnodes_plantlike_rooted_base_side_meshoptions.png new file mode 100644 index 0000000..d100023 Binary files /dev/null and b/mods/testnodes/textures/testnodes_plantlike_rooted_base_side_meshoptions.png differ diff --git a/mods/testnodes/textures/testnodes_plantlike_rooted_base_side_waving.png b/mods/testnodes/textures/testnodes_plantlike_rooted_base_side_waving.png new file mode 100644 index 0000000..527817b Binary files /dev/null and b/mods/testnodes/textures/testnodes_plantlike_rooted_base_side_waving.png differ diff --git a/mods/testnodes/textures/testnodes_plantlike_rooted_degrotate.png b/mods/testnodes/textures/testnodes_plantlike_rooted_degrotate.png new file mode 100644 index 0000000..45e75bd Binary files /dev/null and b/mods/testnodes/textures/testnodes_plantlike_rooted_degrotate.png differ diff --git a/mods/testnodes/textures/testnodes_plantlike_rooted_leveled.png b/mods/testnodes/textures/testnodes_plantlike_rooted_leveled.png new file mode 100644 index 0000000..8954b2c Binary files /dev/null and b/mods/testnodes/textures/testnodes_plantlike_rooted_leveled.png differ diff --git a/mods/testnodes/textures/testnodes_plantlike_rooted_meshoptions.png b/mods/testnodes/textures/testnodes_plantlike_rooted_meshoptions.png new file mode 100644 index 0000000..a782d48 Binary files /dev/null and b/mods/testnodes/textures/testnodes_plantlike_rooted_meshoptions.png differ diff --git a/mods/testnodes/textures/testnodes_plantlike_rooted_waving.png b/mods/testnodes/textures/testnodes_plantlike_rooted_waving.png new file mode 100644 index 0000000..112a054 Binary files /dev/null and b/mods/testnodes/textures/testnodes_plantlike_rooted_waving.png differ diff --git a/mods/testnodes/textures/testnodes_plantlike_waving.png b/mods/testnodes/textures/testnodes_plantlike_waving.png new file mode 100644 index 0000000..b584a8d Binary files /dev/null and b/mods/testnodes/textures/testnodes_plantlike_waving.png differ diff --git a/mods/testnodes/textures/testnodes_rail2_crossing.png b/mods/testnodes/textures/testnodes_rail2_crossing.png new file mode 100644 index 0000000..530bbba Binary files /dev/null and b/mods/testnodes/textures/testnodes_rail2_crossing.png differ diff --git a/mods/testnodes/textures/testnodes_rail2_curved.png b/mods/testnodes/textures/testnodes_rail2_curved.png new file mode 100644 index 0000000..4ed1ca0 Binary files /dev/null and b/mods/testnodes/textures/testnodes_rail2_curved.png differ diff --git a/mods/testnodes/textures/testnodes_rail2_straight.png b/mods/testnodes/textures/testnodes_rail2_straight.png new file mode 100644 index 0000000..8749330 Binary files /dev/null and b/mods/testnodes/textures/testnodes_rail2_straight.png differ diff --git a/mods/testnodes/textures/testnodes_rail2_t_junction.png b/mods/testnodes/textures/testnodes_rail2_t_junction.png new file mode 100644 index 0000000..0517f65 Binary files /dev/null and b/mods/testnodes/textures/testnodes_rail2_t_junction.png differ diff --git a/mods/testnodes/textures/testnodes_rail_crossing.png b/mods/testnodes/textures/testnodes_rail_crossing.png new file mode 100644 index 0000000..3916ce1 Binary files /dev/null and b/mods/testnodes/textures/testnodes_rail_crossing.png differ diff --git a/mods/testnodes/textures/testnodes_rail_curved.png b/mods/testnodes/textures/testnodes_rail_curved.png new file mode 100644 index 0000000..e444198 Binary files /dev/null and b/mods/testnodes/textures/testnodes_rail_curved.png differ diff --git a/mods/testnodes/textures/testnodes_rail_straight.png b/mods/testnodes/textures/testnodes_rail_straight.png new file mode 100644 index 0000000..872d04f Binary files /dev/null and b/mods/testnodes/textures/testnodes_rail_straight.png differ diff --git a/mods/testnodes/textures/testnodes_rail_t_junction.png b/mods/testnodes/textures/testnodes_rail_t_junction.png new file mode 100644 index 0000000..7e4af51 Binary files /dev/null and b/mods/testnodes/textures/testnodes_rail_t_junction.png differ diff --git a/mods/testnodes/textures/testnodes_signlike.png b/mods/testnodes/textures/testnodes_signlike.png new file mode 100644 index 0000000..33ffcba Binary files /dev/null and b/mods/testnodes/textures/testnodes_signlike.png differ diff --git a/mods/testnodes/textures/testnodes_slippery.png b/mods/testnodes/textures/testnodes_slippery.png new file mode 100644 index 0000000..b990468 Binary files /dev/null and b/mods/testnodes/textures/testnodes_slippery.png differ diff --git a/mods/testnodes/textures/testnodes_street_crossing.png b/mods/testnodes/textures/testnodes_street_crossing.png new file mode 100644 index 0000000..d6e35ad Binary files /dev/null and b/mods/testnodes/textures/testnodes_street_crossing.png differ diff --git a/mods/testnodes/textures/testnodes_street_curved.png b/mods/testnodes/textures/testnodes_street_curved.png new file mode 100644 index 0000000..251b7fb Binary files /dev/null and b/mods/testnodes/textures/testnodes_street_curved.png differ diff --git a/mods/testnodes/textures/testnodes_street_straight.png b/mods/testnodes/textures/testnodes_street_straight.png new file mode 100644 index 0000000..639e24b Binary files /dev/null and b/mods/testnodes/textures/testnodes_street_straight.png differ diff --git a/mods/testnodes/textures/testnodes_street_t_junction.png b/mods/testnodes/textures/testnodes_street_t_junction.png new file mode 100644 index 0000000..713621e Binary files /dev/null and b/mods/testnodes/textures/testnodes_street_t_junction.png differ diff --git a/mods/testnodes/textures/testnodes_sunlight_filter.png b/mods/testnodes/textures/testnodes_sunlight_filter.png new file mode 100644 index 0000000..b38ea40 Binary files /dev/null and b/mods/testnodes/textures/testnodes_sunlight_filter.png differ diff --git a/mods/testnodes/textures/testnodes_torchlike_ceiling.png b/mods/testnodes/textures/testnodes_torchlike_ceiling.png new file mode 100644 index 0000000..5d9862c Binary files /dev/null and b/mods/testnodes/textures/testnodes_torchlike_ceiling.png differ diff --git a/mods/testnodes/textures/testnodes_torchlike_floor.png b/mods/testnodes/textures/testnodes_torchlike_floor.png new file mode 100644 index 0000000..adf1e00 Binary files /dev/null and b/mods/testnodes/textures/testnodes_torchlike_floor.png differ diff --git a/mods/testnodes/textures/testnodes_torchlike_wall.png b/mods/testnodes/textures/testnodes_torchlike_wall.png new file mode 100644 index 0000000..cb442b2 Binary files /dev/null and b/mods/testnodes/textures/testnodes_torchlike_wall.png differ diff --git a/mods/testpathfinder/README.md b/mods/testpathfinder/README.md new file mode 100644 index 0000000..2b9d46e --- /dev/null +++ b/mods/testpathfinder/README.md @@ -0,0 +1,15 @@ +# Pathfinder Tester + +Usage: + +Use the Pathfinder Tester tool (`testpathfinder:testpathfinder`). +Here's how it works: + +* Place on node: Set destination position +* Punch: Find path +* Sneak+punch: Select pathfinding algorithm + +Information will be shown in chat. If a path was found, all waypoints +will be shown for a few seconds. + +See `init.lua` for config variables. diff --git a/mods/testpathfinder/init.lua b/mods/testpathfinder/init.lua new file mode 100644 index 0000000..67748af --- /dev/null +++ b/mods/testpathfinder/init.lua @@ -0,0 +1,136 @@ +local S = minetest.get_translator("testpathfinder") + +-- Config parameters + +-- Maximum direct distance between start and end +local MAX_DIRECT_DISTANCE = 64 +-- Maximum search distance +local MAX_SEARCH_DISTANCE = 32 +-- Maximum permitted jump height +local MAX_JUMP = 1 +-- Maximum permitted drop height +local MAX_DROP = 5 +-- If true, mod won't refuse to run pathfinder even at long distances +local IGNORE_MAX_DISTANCE_SAFEGUARD = false + +-- End of config parameters + +local timer = 0 +local algorithms = { + "A*_noprefetch", + "A*", + "Dijkstra", +} + +local function find_path_for_player(player, itemstack) + local meta = itemstack:get_meta() + if not meta then + return + end + local x = meta:get_int("pos_x") + local y = meta:get_int("pos_y") + local z = meta:get_int("pos_z") + local algo = meta:get_int("algorithm") + if x and y and z then + local pos2 = {x=x, y=y, z=z} + algo = algorithms[algo+1] + local pos1 = vector.round(player:get_pos()) + -- Don't bother calling pathfinder for high distance to avoid freezing + if (not IGNORE_MAX_DISTANCE_SAFEGUARD) and (vector.distance(pos1, pos2) > MAX_DIRECT_DISTANCE) then + minetest.chat_send_player(player:get_player_name(), S("Destination too far away! Set a destination (via placing) within a distance of @1 and try again!", MAX_DIRECT_DISTANCE)) + return + end + local str = S("Path from @1 to @2:", + minetest.pos_to_string(pos1), + minetest.pos_to_string(pos2)) + + minetest.chat_send_player(player:get_player_name(), str) + local time_start = minetest.get_us_time() + local path = minetest.find_path(pos1, pos2, MAX_SEARCH_DISTANCE, MAX_JUMP, MAX_DROP, algo) + local time_end = minetest.get_us_time() + local time_diff = time_end - time_start + str = "" + if not path then + minetest.chat_send_player(player:get_player_name(), S("No path!")) + minetest.chat_send_player(player:get_player_name(), S("Time: @1 ms", time_diff/1000)) + return + end + for s=1, #path do + str = str .. minetest.pos_to_string(path[s]) .. "\n" + local t + if s == #path then + t = "testpathfinder_waypoint_end.png" + elseif s == 1 then + t = "testpathfinder_waypoint_start.png" + else + local c = math.floor(((#path-s)/#path)*255) + t = string.format("testpathfinder_waypoint.png^[multiply:#%02x%02x00", 0xFF-c, c) + end + minetest.add_particle({ + pos = path[s], + expirationtime = 5 + 0.2 * s, + playername = player:get_player_name(), + glow = minetest.LIGHT_MAX, + texture = t, + size = 3, + }) + end + minetest.chat_send_player(player:get_player_name(), str) + minetest.chat_send_player(player:get_player_name(), S("Path length: @1", #path)) + minetest.chat_send_player(player:get_player_name(), S("Time: @1 ms", time_diff/1000)) + end +end + +local function set_destination(itemstack, user, pointed_thing) + if not (user and user:is_player()) then + return + end + local name = user:get_player_name() + local obj + local meta = itemstack:get_meta() + if pointed_thing.type == "node" then + local pos = pointed_thing.above + meta:set_int("pos_x", pos.x) + meta:set_int("pos_y", pos.y) + meta:set_int("pos_z", pos.z) + minetest.chat_send_player(user:get_player_name(), S("Destination set to @1", minetest.pos_to_string(pos))) + return itemstack + end +end + +local function find_path_or_set_algorithm(itemstack, user, pointed_thing) + if not (user and user:is_player()) then + return + end + local ctrl = user:get_player_control() + -- No sneak: Find path + if not ctrl.sneak then + find_path_for_player(user, itemstack) + else + -- Sneak: Set algorithm + local meta = itemstack:get_meta() + local algo = meta:get_int("algorithm") + algo = (algo + 1) % #algorithms + meta:set_int("algorithm", algo) + minetest.chat_send_player(user:get_player_name(), S("Algorithm: @1", algorithms[algo+1])) + return itemstack + end +end + +-- Punch: Find path +-- Sneak+punch: Select pathfinding algorithm +-- Place: Select destination node +minetest.register_tool("testpathfinder:testpathfinder", { + description = S("Pathfinder Tester") .."\n".. + S("Finds path between 2 points") .."\n".. + S("Place on node: Select destination") .."\n".. + S("Punch: Find path from here") .."\n".. + S("Sneak+Punch: Change algorithm"), + inventory_image = "testpathfinder_testpathfinder.png", + groups = { testtool = 1, disable_repair = 1 }, + on_use = find_path_or_set_algorithm, + on_secondary_use = set_destination, + on_place = set_destination, +}) + + diff --git a/mods/testpathfinder/mod.conf b/mods/testpathfinder/mod.conf new file mode 100644 index 0000000..e6034ae --- /dev/null +++ b/mods/testpathfinder/mod.conf @@ -0,0 +1,2 @@ +name = testpathfinder +description = Tool to test Minetest's pathfinder function diff --git a/mods/testpathfinder/textures/testpathfinder_testpathfinder.png b/mods/testpathfinder/textures/testpathfinder_testpathfinder.png new file mode 100644 index 0000000..37eef05 Binary files /dev/null and b/mods/testpathfinder/textures/testpathfinder_testpathfinder.png differ diff --git a/mods/testpathfinder/textures/testpathfinder_waypoint.png b/mods/testpathfinder/textures/testpathfinder_waypoint.png new file mode 100644 index 0000000..661dcf9 Binary files /dev/null and b/mods/testpathfinder/textures/testpathfinder_waypoint.png differ diff --git a/mods/testpathfinder/textures/testpathfinder_waypoint_end.png b/mods/testpathfinder/textures/testpathfinder_waypoint_end.png new file mode 100644 index 0000000..41a1cc5 Binary files /dev/null and b/mods/testpathfinder/textures/testpathfinder_waypoint_end.png differ diff --git a/mods/testpathfinder/textures/testpathfinder_waypoint_start.png b/mods/testpathfinder/textures/testpathfinder_waypoint_start.png new file mode 100644 index 0000000..a22e31c Binary files /dev/null and b/mods/testpathfinder/textures/testpathfinder_waypoint_start.png differ diff --git a/mods/testtools/README.md b/mods/testtools/README.md new file mode 100644 index 0000000..9cfe29e --- /dev/null +++ b/mods/testtools/README.md @@ -0,0 +1,99 @@ +# Test Tools readme + +Test Tools is a mod for developers that adds a bunch of tools to directly manipulate nodes and entities. This is great for quickly testing out stuff. + +Here's the list of tools: + +## Remover +Removes nodes and non-player entities that you punch. + +## Node Setter +Replace a node with another one. + +First, punch a node you want to remember. +Then rightclick any other node to replace it with the node you remembered. + +If you rightclick while pointing nothing, you can manually enter the node and param2. + +## Param2 Tool +Change the value param2 of nodes. + +* Punch: Add 1 to param2 +* Sneak+Punch: Add 8 to param2 +* Place: Subtract 1 from param2 +* Sneak+Place: Subtract 8 from param2 + +Note: Use the debug screen (F5) to see the param2 of the pointed node. + +## Falling Node Tool +Turns nodes into falling nodes. + +Usage: + +* Punch node: Make it fall +* Place: Try to teleport up to 2 units upwards, then make it fall + +## Entity Rotator +Changes the entity rotation (with `set_rotation`). + +Usage: + +* Punch entity: Rotate yaw +* Punch entity while holding down “Sneak” key: Rotate pitch +* Punch entity while holding down “Special” key (aka “Aux”): Rotate roll + +Each usage rotates the entity by 22.5°. + +## Entity Spawner +Spawns entities. + +Usage: + +* Punch to select entity or spawn one directly +* Place to place selected entity + +## Object Property Editor +Edits properties of objects. + +Usage: + +* Punch object to open a formspec that allows you to view and edit properties +* Punch air to edit properties of your own player object + +To edit a property, select it in the list, enter a new value (in Lua syntax) +and hit “Submit”. + +## Object Attacher +Allows you to attach an object to another one. + +Basic usage: +* First select the parent object, then the child object that should be attached +* Selecting an object is done by punching it +* Sneak+punch to detach selected object +* If you punch air, you select yourself + +Configuration: +* Place: Increase attachment Y position +* Sneak+place: decrease attachment Y position +* Aux+place: Increase attachment X rotation +* Aux+Sneak+Rightclick: Decrease attachment X rotation + +Hint: To detach all objects nearby you (including on yourself), use the +`/detach` server command. + +## Object Mover +Move an object by a given distance. + +Usage: +* Punch object into the direction you want to move it +* Sneak+punch: Move object towards you +* Place: Increase move distance +* Sneak+place: Decrease move distance + +## Entity Visual Scaler +Change visual size of entities + +Usage: + +* Punch entity to increase visual size +* Sneak+punch entity to decrease visual size diff --git a/mods/testtools/init.lua b/mods/testtools/init.lua new file mode 100644 index 0000000..d578b26 --- /dev/null +++ b/mods/testtools/init.lua @@ -0,0 +1,732 @@ +local S = minetest.get_translator("testtools") +local F = minetest.formspec_escape + +dofile(minetest.get_modpath("testtools") .. "/light.lua") + +-- TODO: Add a Node Metadata tool + +minetest.register_tool("testtools:param2tool", { + description = S("Param2 Tool") .."\n".. + S("Modify param2 value of nodes") .."\n".. + S("Punch: +1") .."\n".. + S("Sneak+Punch: +8") .."\n".. + S("Place: -1") .."\n".. + S("Sneak+Place: -8"), + inventory_image = "testtools_param2tool.png", + groups = { testtool = 1, disable_repair = 1 }, + on_use = function(itemstack, user, pointed_thing) + local pos = minetest.get_pointed_thing_position(pointed_thing) + if pointed_thing.type ~= "node" or (not pos) then + return + end + local add = 1 + if user then + local ctrl = user:get_player_control() + if ctrl.sneak then + add = 8 + end + end + local node = minetest.get_node(pos) + node.param2 = node.param2 + add + minetest.swap_node(pos, node) + end, + on_place = function(itemstack, user, pointed_thing) + local pos = minetest.get_pointed_thing_position(pointed_thing) + if pointed_thing.type ~= "node" or (not pos) then + return + end + local add = -1 + if user then + local ctrl = user:get_player_control() + if ctrl.sneak then + add = -8 + end + end + local node = minetest.get_node(pos) + node.param2 = node.param2 + add + minetest.swap_node(pos, node) + end, +}) + +minetest.register_tool("testtools:node_setter", { + description = S("Node Setter") .."\n".. + S("Replace pointed node with something else") .."\n".. + S("Punch: Select pointed node") .."\n".. + S("Place on node: Replace node with selected node") .."\n".. + S("Place in air: Manually select a node"), + inventory_image = "testtools_node_setter.png", + groups = { testtool = 1, disable_repair = 1 }, + on_use = function(itemstack, user, pointed_thing) + local pos = minetest.get_pointed_thing_position(pointed_thing) + if pointed_thing.type == "nothing" then + local meta = itemstack:get_meta() + meta:set_string("node", "air") + meta:set_int("node_param2", 0) + if user and user:is_player() then + minetest.chat_send_player(user:get_player_name(), S("Now placing: @1 (param2=@2)", "air", 0)) + end + return itemstack + elseif pointed_thing.type ~= "node" or (not pos) then + return + end + local node = minetest.get_node(pos) + local meta = itemstack:get_meta() + meta:set_string("node", node.name) + meta:set_int("node_param2", node.param2) + if user and user:is_player() then + minetest.chat_send_player(user:get_player_name(), S("Now placing: @1 (param2=@2)", node.name, node.param2)) + end + return itemstack + end, + on_secondary_use = function(itemstack, user, pointed_thing) + local meta = itemstack:get_meta() + local nodename = meta:get_string("node") or "" + local param2 = meta:get_int("node_param2") or 0 + + minetest.show_formspec(user:get_player_name(), "testtools:node_setter", + "size[4,4]".. + "field[0.5,1;3,1;nodename;"..F(S("Node name (itemstring):"))..";"..F(nodename).."]".. + "field[0.5,2;3,1;param2;"..F(S("param2:"))..";"..F(tostring(param2)).."]".. + "button_exit[0.5,3;3,1;submit;"..F(S("Submit")).."]" + ) + end, + on_place = function(itemstack, user, pointed_thing) + local pos = minetest.get_pointed_thing_position(pointed_thing) + local meta = itemstack:get_meta() + local nodename = meta:get_string("node") + if nodename == "" and user and user:is_player() then + minetest.chat_send_player(user:get_player_name(), S("Punch a node first!")) + return + end + local param2 = meta:get_int("node_param2") + if not param2 then + param2 = 0 + end + local node = { name = nodename, param2 = param2 } + if not minetest.registered_nodes[nodename] then + minetest.chat_send_player(user:get_player_name(), S("Cannot set unknown node: @1", nodename)) + return + end + minetest.set_node(pos, node) + end, +}) + +minetest.register_on_player_receive_fields(function(player, formname, fields) + if formname == "testtools:node_setter" then + local playername = player:get_player_name() + local witem = player:get_wielded_item() + if witem:get_name() == "testtools:node_setter" then + if fields.nodename and fields.param2 then + local param2 = tonumber(fields.param2) + if not param2 then + return + end + local meta = witem:get_meta() + meta:set_string("node", fields.nodename) + meta:set_int("node_param2", param2) + player:set_wielded_item(witem) + end + end + end +end) + +minetest.register_tool("testtools:remover", { + description = S("Remover") .."\n".. + S("Punch: Remove pointed node or object"), + inventory_image = "testtools_remover.png", + groups = { testtool = 1, disable_repair = 1 }, + on_use = function(itemstack, user, pointed_thing) + local pos = minetest.get_pointed_thing_position(pointed_thing) + if pointed_thing.type == "node" and pos ~= nil then + minetest.remove_node(pos) + elseif pointed_thing.type == "object" then + local obj = pointed_thing.ref + if not obj:is_player() then + obj:remove() + else + minetest.chat_send_player(user:get_player_name(), S("Can't remove players!")) + end + end + end, +}) + +minetest.register_tool("testtools:falling_node_tool", { + description = S("Falling Node Tool") .."\n".. + S("Punch: Make pointed node fall") .."\n".. + S("Place: Move pointed node 2 units upwards, then make it fall"), + inventory_image = "testtools_falling_node_tool.png", + groups = { testtool = 1, disable_repair = 1 }, + on_place = function(itemstack, user, pointed_thing) + -- Teleport node 1-2 units upwards (if possible) and make it fall + local pos = minetest.get_pointed_thing_position(pointed_thing) + if pointed_thing.type ~= "node" or (not pos) then + return + end + local ok = false + local highest + for i=1,2 do + local above = {x=pos.x,y=pos.y+i,z=pos.z} + local n2 = minetest.get_node(above) + local def2 = minetest.registered_nodes[n2.name] + if def2 and (not def2.walkable) then + highest = above + else + break + end + end + if highest then + local node = minetest.get_node(pos) + local metatable = minetest.get_meta(pos):to_table() + minetest.remove_node(pos) + minetest.set_node(highest, node) + local meta_highest = minetest.get_meta(highest) + meta_highest:from_table(metatable) + ok = minetest.spawn_falling_node(highest) + else + ok = minetest.spawn_falling_node(pos) + end + if not ok and user and user:is_player() then + minetest.chat_send_player(user:get_player_name(), S("Falling node could not be spawned!")) + end + end, + on_use = function(itemstack, user, pointed_thing) + local pos = minetest.get_pointed_thing_position(pointed_thing) + if pointed_thing.type ~= "node" or (not pos) then + return + end + local ok = minetest.spawn_falling_node(pos) + if not ok and user and user:is_player() then + minetest.chat_send_player(user:get_player_name(), S("Falling node could not be spawned!")) + end + end, +}) + +minetest.register_tool("testtools:rotator", { + description = S("Entity Rotator") .. "\n" .. + S("Rotate pointed entity") .."\n".. + S("Punch: Yaw") .."\n".. + S("Sneak+Punch: Pitch") .."\n".. + S("Aux1+Punch: Roll"), + inventory_image = "testtools_entity_rotator.png", + groups = { testtool = 1, disable_repair = 1 }, + on_use = function(itemstack, user, pointed_thing) + if pointed_thing.type ~= "object" then + return + end + local obj = pointed_thing.ref + if obj:is_player() then + -- No player rotation + return + else + local axis = "y" + if user and user:is_player() then + local ctrl = user:get_player_control() + if ctrl.sneak then + axis = "x" + elseif ctrl.aux1 then + axis = "z" + end + end + local rot = obj:get_rotation() + rot[axis] = rot[axis] + math.pi/8 + if rot[axis] > math.pi*2 then + rot[axis] = rot[axis] - math.pi*2 + end + obj:set_rotation(rot) + end + end, +}) + +local mover_config = function(itemstack, user, pointed_thing) + if not (user and user:is_player()) then + return + end + local name = user:get_player_name() + local ctrl = user:get_player_control() + local meta = itemstack:get_meta() + local dist = 1.0 + if meta:contains("distance") then + dist = meta:get_int("distance") + end + if ctrl.sneak then + dist = dist - 1 + else + dist = dist + 1 + end + meta:set_int("distance", dist) + minetest.chat_send_player(user:get_player_name(), S("distance=@1/10", dist*2)) + return itemstack +end + +minetest.register_tool("testtools:object_mover", { + description = S("Object Mover") .."\n".. + S("Move pointed object towards or away from you") .."\n".. + S("Punch: Move by distance").."\n".. + S("Sneak+Punch: Move by negative distance").."\n".. + S("Place: Increase distance").."\n".. + S("Sneak+Place: Decrease distance"), + inventory_image = "testtools_object_mover.png", + groups = { testtool = 1, disable_repair = 1 }, + on_place = mover_config, + on_secondary_use = mover_config, + on_use = function(itemstack, user, pointed_thing) + if pointed_thing.type ~= "object" then + return + end + local obj = pointed_thing.ref + if not (user and user:is_player()) then + return + end + local yaw = user:get_look_horizontal() + local dir = minetest.yaw_to_dir(yaw) + local pos = obj:get_pos() + local pitch = user:get_look_vertical() + if pitch > 0.25 * math.pi then + dir.y = -1 + dir.x = 0 + dir.z = 0 + elseif pitch < -0.25 * math.pi then + dir.y = 1 + dir.x = 0 + dir.z = 0 + end + local ctrl = user:get_player_control() + if ctrl.sneak then + dir = vector.multiply(dir, -1) + end + local meta = itemstack:get_meta() + if meta:contains("distance") then + local dist = meta:get_int("distance") + dir = vector.multiply(dir, dist*0.2) + end + pos = vector.add(pos, dir) + obj:set_pos(pos) + end, +}) + + + +minetest.register_tool("testtools:entity_scaler", { + description = S("Entity Visual Scaler") .."\n".. + S("Scale visual size of entities") .."\n".. + S("Punch: Increase size") .."\n".. + S("Sneak+Punch: Decrease scale"), + inventory_image = "testtools_entity_scaler.png", + groups = { testtool = 1, disable_repair = 1 }, + on_use = function(itemstack, user, pointed_thing) + if pointed_thing.type ~= "object" then + return + end + local obj = pointed_thing.ref + if obj:is_player() then + -- No player scaling + return + else + local diff = 0.1 + if user and user:is_player() then + local ctrl = user:get_player_control() + if ctrl.sneak then + diff = -0.1 + end + end + local prop = obj:get_properties() + if not prop.visual_size then + prop.visual_size = { x=1, y=1, z=1 } + else + prop.visual_size = { x=prop.visual_size.x+diff, y=prop.visual_size.y+diff, z=prop.visual_size.z+diff } + if prop.visual_size.x <= 0.1 then + prop.visual_size.x = 0.1 + end + if prop.visual_size.y <= 0.1 then + prop.visual_size.y = 0.1 + end + if prop.visual_size.z <= 0.1 then + prop.visual_size.z = 0.1 + end + end + obj:set_properties(prop) + end + end, +}) + +local selections = {} +local entity_list +local function get_entity_list() + if entity_list then + return entity_list + end + local ents = minetest.registered_entities + local list = {} + for k,_ in pairs(ents) do + table.insert(list, k) + end + table.sort(list) + entity_list = list + return entity_list +end +minetest.register_tool("testtools:entity_spawner", { + description = S("Entity Spawner") .."\n".. + S("Spawns entities") .."\n".. + S("Punch: Select entity to spawn") .."\n".. + S("Place: Spawn selected entity"), + inventory_image = "testtools_entity_spawner.png", + groups = { testtool = 1, disable_repair = 1 }, + on_place = function(itemstack, user, pointed_thing) + local name = user:get_player_name() + if pointed_thing.type == "node" then + if selections[name] then + local pos = pointed_thing.above + minetest.add_entity(pos, get_entity_list()[selections[name]]) + else + minetest.chat_send_player(name, S("Select an entity first (with punch key)!")) + end + end + end, + on_use = function(itemstack, user, pointed_thing) + if pointed_thing.type == "object" then + return + end + if user and user:is_player() then + local list = table.concat(get_entity_list(), ",") + local name = user:get_player_name() + local sel = selections[name] or "" + minetest.show_formspec(name, "testtools:entity_list", + "size[9,9]".. + "textlist[0,0;9,8;entity_list;"..list..";"..sel..";false]".. + "button[0,8;4,1;spawn;Spawn entity]" + ) + end + end, +}) + +local function prop_to_string(property) + if type(property) == "string" then + return "\"" .. property .. "\"" + elseif type(property) == "table" then + return tostring(dump(property)):gsub("\n", "") + else + return tostring(property) + end +end + +local property_formspec_data = {} +local property_formspec_index = {} +local selected_objects = {} +local function get_object_properties_form(obj, playername) + if not playername then return "" end + local props = obj:get_properties() + local str = "" + property_formspec_data[playername] = {} + local proplist = {} + for k,_ in pairs(props) do + table.insert(proplist, k) + end + table.sort(proplist) + for p=1, #proplist do + local k = proplist[p] + local v = props[k] + local newline = "" + newline = k .. " = " + newline = newline .. prop_to_string(v) + str = str .. F(newline) + if p < #proplist then + str = str .. "," + end + table.insert(property_formspec_data[playername], k) + end + return str +end + +local editor_formspec_selindex = {} + +local editor_formspec = function(playername, obj, value, sel) + if not value then + value = "" + end + if not sel then + sel = "" + end + local list = get_object_properties_form(obj, playername) + local title + if obj:is_player() then + title = S("Object properties of player “@1”", obj:get_player_name()) + else + local ent = obj:get_luaentity() + title = S("Object properties of @1", ent.name) + end + minetest.show_formspec(playername, "testtools:object_editor", + "size[9,9]".. + "label[0,0;"..F(title).."]".. + "textlist[0,0.5;9,7.5;object_props;"..list..";"..sel..";false]".. + "field[0.2,8.75;8,1;value;"..F(S("Value"))..";"..F(value).."]".. + "field_close_on_enter[value;false]".. + "button[8,8.5;1,1;submit;"..F(S("Submit")).."]" + ) +end + +minetest.register_tool("testtools:object_editor", { + description = S("Object Property Editor") .."\n".. + S("Edit properties of objects") .."\n".. + S("Punch object: Edit object") .."\n".. + S("Punch air: Edit yourself"), + inventory_image = "testtools_object_editor.png", + groups = { testtool = 1, disable_repair = 1 }, + on_use = function(itemstack, user, pointed_thing) + if user and user:is_player() then + local name = user:get_player_name() + + if pointed_thing.type == "object" then + selected_objects[name] = pointed_thing.ref + elseif pointed_thing.type == "nothing" then + -- Use on yourself if pointing nothing + selected_objects[name] = user + else + -- Unsupported pointed thing + return + end + + local sel = editor_formspec_selindex[name] + local val + if selected_objects[name] and selected_objects[name]:get_properties() then + local props = selected_objects[name]:get_properties() + local keys = property_formspec_data[name] + if property_formspec_index[name] and props then + local key = keys[property_formspec_index[name]] + val = prop_to_string(props[key]) + end + end + + editor_formspec(name, selected_objects[name], val, sel) + end + end, +}) + +local ent_parent = {} +local ent_child = {} +local DEFAULT_ATTACH_OFFSET_Y = 11 + +local attacher_config = function(itemstack, user, pointed_thing) + if not (user and user:is_player()) then + return + end + if pointed_thing.type == "object" then + return + end + local name = user:get_player_name() + local ctrl = user:get_player_control() + local meta = itemstack:get_meta() + if ctrl.aux1 then + local rot_x = meta:get_float("rot_x") + if ctrl.sneak then + rot_x = rot_x - math.pi/8 + else + rot_x = rot_x + math.pi/8 + end + if rot_x > 6.2 then + rot_x = 0 + elseif rot_x < 0 then + rot_x = math.pi * (15/8) + end + minetest.chat_send_player(name, S("rotation=@1", minetest.pos_to_string({x=rot_x,y=0,z=0}))) + meta:set_float("rot_x", rot_x) + else + local pos_y + if meta:contains("pos_y") then + pos_y = meta:get_int("pos_y") + else + pos_y = DEFAULT_ATTACH_OFFSET_Y + end + if ctrl.sneak then + pos_y = pos_y - 1 + else + pos_y = pos_y + 1 + end + minetest.chat_send_player(name, S("position=@1", minetest.pos_to_string({x=0,y=pos_y,z=0}))) + meta:set_int("pos_y", pos_y) + end + return itemstack +end + +minetest.register_tool("testtools:object_attacher", { + description = S("Object Attacher") .."\n".. + S("Attach object to another") .."\n".. + S("Punch objects to first select parent object, then the child object to attach") .."\n".. + S("Punch air to select yourself") .."\n".. + S("Place: Incease attachment Y offset") .."\n".. + S("Sneak+Place: Decease attachment Y offset") .."\n".. + S("Aux1+Place: Incease attachment rotation") .."\n".. + S("Aux1+Sneak+Place: Decrease attachment rotation"), + inventory_image = "testtools_object_attacher.png", + groups = { testtool = 1, disable_repair = 1 }, + on_place = attacher_config, + on_secondary_use = attacher_config, + on_use = function(itemstack, user, pointed_thing) + if user and user:is_player() then + local name = user:get_player_name() + local selected_object + if pointed_thing.type == "object" then + selected_object = pointed_thing.ref + elseif pointed_thing.type == "nothing" then + selected_object = user + else + return + end + local ctrl = user:get_player_control() + if ctrl.sneak then + if selected_object:get_attach() then + selected_object:set_detach() + minetest.chat_send_player(name, S("Object detached!")) + else + minetest.chat_send_player(name, S("Object is not attached!")) + end + return + end + local parent = ent_parent[name] + local child = ent_child[name] + local ename = S("") + if not parent then + parent = selected_object + ent_parent[name] = parent + elseif not child then + child = selected_object + ent_child[name] = child + end + local entity = selected_object:get_luaentity() + if entity then + ename = entity.name + elseif selected_object:is_player() then + ename = selected_object:get_player_name() + end + if selected_object == parent then + minetest.chat_send_player(name, S("Parent object selected: @1", ename)) + elseif selected_object == child then + minetest.chat_send_player(name, S("Child object selected: @1", ename)) + end + if parent and child then + if parent == child then + minetest.chat_send_player(name, S("Can't attach an object to itself!")) + ent_parent[name] = nil + ent_child[name] = nil + return + end + local meta = itemstack:get_meta() + local y + if meta:contains("pos_y") then + y = meta:get_int("pos_y") + else + y = DEFAULT_ATTACH_OFFSET_Y + end + local rx = meta:get_float("rot_x") or 0 + local offset = {x=0,y=y,z=0} + local angle = {x=rx,y=0,z=0} + child:set_attach(parent, "", offset, angle) + local check_parent = child:get_attach() + if check_parent then + minetest.chat_send_player(name, S("Object attached! position=@1, rotation=@2", + minetest.pos_to_string(offset), minetest.pos_to_string(angle))) + else + minetest.chat_send_player(name, S("Attachment failed!")) + end + ent_parent[name] = nil + ent_child[name] = nil + end + end + end, +}) + +-- Use loadstring to parse param as a Lua value +local function use_loadstring(param, player) + -- For security reasons, require 'server' priv, just in case + -- someone is actually crazy enough to run this on a public server. + local privs = minetest.get_player_privs(player:get_player_name()) + if not privs.server then + return false, "You need 'server' privilege to change object properties!" + end + if not param then + return false, "Failed: parameter is nil" + end + --[[ DANGER ZONE ]] + -- Interpret string as Lua value + local func, errormsg = loadstring("return (" .. param .. ")") + if not func then + return false, "Failed: " .. errormsg + end + + -- Apply sandbox here using setfenv + setfenv(func, {}) + + -- Run it + local good, errOrResult = pcall(func) + if not good then + -- A Lua error was thrown + return false, "Failed: " .. errOrResult + end + + -- errOrResult will be the value + return true, errOrResult +end + +minetest.register_on_player_receive_fields(function(player, formname, fields) + if not (player and player:is_player()) then + return + end + if formname == "testtools:entity_list" then + local name = player:get_player_name() + if fields.entity_list then + local expl = minetest.explode_textlist_event(fields.entity_list) + if expl.type == "DCL" then + local pos = vector.add(player:get_pos(), {x=0,y=1,z=0}) + selections[name] = expl.index + minetest.add_entity(pos, get_entity_list()[expl.index]) + return + elseif expl.type == "CHG" then + selections[name] = expl.index + return + end + elseif fields.spawn and selections[name] then + local pos = vector.add(player:get_pos(), {x=0,y=1,z=0}) + minetest.add_entity(pos, get_entity_list()[selections[name]]) + return + end + elseif formname == "testtools:object_editor" then + local name = player:get_player_name() + if fields.object_props then + local expl = minetest.explode_textlist_event(fields.object_props) + if expl.type == "DCL" or expl.type == "CHG" then + property_formspec_index[name] = expl.index + + local props = selected_objects[name]:get_properties() + local keys = property_formspec_data[name] + if (not property_formspec_index[name]) or (not props) then + return + end + local key = keys[property_formspec_index[name]] + editor_formspec_selindex[name] = expl.index + editor_formspec(name, selected_objects[name], prop_to_string(props[key]), expl.index) + return + end + end + if fields.key_enter_field == "value" or fields.submit then + local props = selected_objects[name]:get_properties() + local keys = property_formspec_data[name] + if (not property_formspec_index[name]) or (not props) then + return + end + local key = keys[property_formspec_index[name]] + if not key then + return + end + local success, str = use_loadstring(fields.value, player) + if success then + props[key] = str + else + minetest.chat_send_player(name, str) + return + end + selected_objects[name]:set_properties(props) + local sel = editor_formspec_selindex[name] + editor_formspec(name, selected_objects[name], prop_to_string(props[key]), sel) + return + end + end +end) diff --git a/mods/testtools/light.lua b/mods/testtools/light.lua new file mode 100644 index 0000000..a9458ca --- /dev/null +++ b/mods/testtools/light.lua @@ -0,0 +1,22 @@ + +local S = minetest.get_translator("testtools") + +minetest.register_tool("testtools:lighttool", { + description = S("Light tool"), + inventory_image = "testtools_lighttool.png", + groups = { testtool = 1, disable_repair = 1 }, + on_use = function(itemstack, user, pointed_thing) + local pos = pointed_thing.above + if pointed_thing.type ~= "node" or not pos then + return + end + + local node = minetest.get_node(pos) + local time = minetest.get_timeofday() + local sunlight = minetest.get_natural_light(pos) + local artificial = minetest.get_artificial_light(node.param1) + local message = ("param1 0x%02x | time %.5f | sunlight %d | artificial %d") + :format(node.param1, time, sunlight, artificial) + minetest.chat_send_player(user:get_player_name(), message) + end +}) diff --git a/mods/testtools/mod.conf b/mods/testtools/mod.conf new file mode 100644 index 0000000..cde1b26 --- /dev/null +++ b/mods/testtools/mod.conf @@ -0,0 +1,2 @@ +name = testtools +description = Some tools to directly manipulate nodes and entities. Great for development and testing diff --git a/mods/testtools/textures/testtools_entity_rotator.png b/mods/testtools/textures/testtools_entity_rotator.png new file mode 100644 index 0000000..17ebb2d Binary files /dev/null and b/mods/testtools/textures/testtools_entity_rotator.png differ diff --git a/mods/testtools/textures/testtools_entity_scaler.png b/mods/testtools/textures/testtools_entity_scaler.png new file mode 100644 index 0000000..4909c25 Binary files /dev/null and b/mods/testtools/textures/testtools_entity_scaler.png differ diff --git a/mods/testtools/textures/testtools_entity_spawner.png b/mods/testtools/textures/testtools_entity_spawner.png new file mode 100644 index 0000000..6199e01 Binary files /dev/null and b/mods/testtools/textures/testtools_entity_spawner.png differ diff --git a/mods/testtools/textures/testtools_falling_node_tool.png b/mods/testtools/textures/testtools_falling_node_tool.png new file mode 100644 index 0000000..30099a7 Binary files /dev/null and b/mods/testtools/textures/testtools_falling_node_tool.png differ diff --git a/mods/testtools/textures/testtools_lighttool.png b/mods/testtools/textures/testtools_lighttool.png new file mode 100644 index 0000000..6f744b7 Binary files /dev/null and b/mods/testtools/textures/testtools_lighttool.png differ diff --git a/mods/testtools/textures/testtools_node_setter.png b/mods/testtools/textures/testtools_node_setter.png new file mode 100644 index 0000000..8599438 Binary files /dev/null and b/mods/testtools/textures/testtools_node_setter.png differ diff --git a/mods/testtools/textures/testtools_object_attacher.png b/mods/testtools/textures/testtools_object_attacher.png new file mode 100644 index 0000000..4d9bf6f Binary files /dev/null and b/mods/testtools/textures/testtools_object_attacher.png differ diff --git a/mods/testtools/textures/testtools_object_editor.png b/mods/testtools/textures/testtools_object_editor.png new file mode 100644 index 0000000..d1ce9ce Binary files /dev/null and b/mods/testtools/textures/testtools_object_editor.png differ diff --git a/mods/testtools/textures/testtools_object_mover.png b/mods/testtools/textures/testtools_object_mover.png new file mode 100644 index 0000000..8b14e9f Binary files /dev/null and b/mods/testtools/textures/testtools_object_mover.png differ diff --git a/mods/testtools/textures/testtools_param2tool.png b/mods/testtools/textures/testtools_param2tool.png new file mode 100644 index 0000000..dbc6635 Binary files /dev/null and b/mods/testtools/textures/testtools_param2tool.png differ diff --git a/mods/testtools/textures/testtools_remover.png b/mods/testtools/textures/testtools_remover.png new file mode 100644 index 0000000..73f14cd Binary files /dev/null and b/mods/testtools/textures/testtools_remover.png differ diff --git a/mods/tiled/init.lua b/mods/tiled/init.lua new file mode 100644 index 0000000..68ead8e --- /dev/null +++ b/mods/tiled/init.lua @@ -0,0 +1,33 @@ +minetest.register_node("tiled:tiled", { + description = "Tiled Node (world-aligned)", + tiles = {{ + name = "tiled_tiled.png", + align_style = "world", + scale = 8, + }}, + groups = {cracky=3}, +}) + +minetest.register_node("tiled:tiled_n", { + description = "Tiled Node (node-aligned)", + tiles = {{ + name = "tiled_tiled.png", + align_style = "node", + scale = 8, + }}, + groups = {cracky=3}, +}) + +stairs.register_stair_and_slab("tiled_n", "tiled:tiled", + {cracky=3}, + {{name="tiled_tiled.png", align_style="node", scale=8}}, + "Tiled Stair (node-aligned)", + "Tiled Slab (node-aligned)") + +stairs.register_stair_and_slab("tiled", "tiled:tiled", + {cracky=3}, + {{name="tiled_tiled.png", align_style="world", scale=8}}, + "Tiled Stair (world-aligned)", + "Tiled Slab (world-aligned)") + + diff --git a/mods/tiled/mod.conf b/mods/tiled/mod.conf new file mode 100644 index 0000000..78b19f9 --- /dev/null +++ b/mods/tiled/mod.conf @@ -0,0 +1,3 @@ +name = tiled +description = Add nodes with a special texture that spans multiple nodes (aka "world-aligned") +depends = stairs diff --git a/mods/tiled/textures/tiled_tiled.png b/mods/tiled/textures/tiled_tiled.png new file mode 100644 index 0000000..363a264 Binary files /dev/null and b/mods/tiled/textures/tiled_tiled.png differ diff --git a/mods/unittests/crafting.lua b/mods/unittests/crafting.lua new file mode 100644 index 0000000..eff13ce --- /dev/null +++ b/mods/unittests/crafting.lua @@ -0,0 +1,120 @@ +-- Test minetest.clear_craft function +local function test_clear_craft() + minetest.log("info", "[unittests] Testing minetest.clear_craft") + -- Clearing by output + minetest.register_craft({ + output = "foo", + recipe = {{"bar"}} + }) + minetest.register_craft({ + output = "foo 4", + recipe = {{"foo", "bar"}} + }) + assert(#minetest.get_all_craft_recipes("foo") == 2) + minetest.clear_craft({output="foo"}) + assert(minetest.get_all_craft_recipes("foo") == nil) + -- Clearing by input + minetest.register_craft({ + output = "foo 4", + recipe = {{"foo", "bar"}} + }) + assert(#minetest.get_all_craft_recipes("foo") == 1) + minetest.clear_craft({recipe={{"foo", "bar"}}}) + assert(minetest.get_all_craft_recipes("foo") == nil) +end + +-- Test minetest.get_craft_result function +local function test_get_craft_result() + minetest.log("info", "[unittests] Testing minetest.get_craft_result") + + -- normal + local input = { + method = "normal", + width = 2, + items = {"", "unittests:coal_lump", "", "unittests:stick"} + } + minetest.log("info", "[unittests] torch crafting input: "..dump(input)) + local output, decremented_input = minetest.get_craft_result(input) + minetest.log("info", "[unittests] torch crafting output: "..dump(output)) + minetest.log("info", "[unittests] torch crafting decremented input: "..dump(decremented_input)) + assert(output.item) + minetest.log("info", "[unittests] torch crafting output.item:to_table(): "..dump(output.item:to_table())) + assert(output.item:get_name() == "unittests:torch") + assert(output.item:get_count() == 4) + + -- fuel + input = { + method = "fuel", + width = 1, + items = {"unittests:coal_lump"} + } + minetest.log("info", "[unittests] coal fuel input: "..dump(input)) + output, decremented_input = minetest.get_craft_result(input) + minetest.log("info", "[unittests] coal fuel output: "..dump(output)) + minetest.log("info", "[unittests] coal fuel decremented input: "..dump(decremented_input)) + assert(output.time) + assert(output.time > 0) + + -- cooking + input = { + method = "cooking", + width = 1, + items = {"unittests:iron_lump"} + } + minetest.log("info", "[unittests] iron lump cooking input: "..dump(output)) + output, decremented_input = minetest.get_craft_result(input) + minetest.log("info", "[unittests] iron lump cooking output: "..dump(output)) + minetest.log("info", "[unittests] iron lump cooking decremented input: "..dump(decremented_input)) + assert(output.time) + assert(output.time > 0) + assert(output.item) + minetest.log("info", "[unittests] iron lump cooking output.item:to_table(): "..dump(output.item:to_table())) + assert(output.item:get_name() == "unittests:steel_ingot") + assert(output.item:get_count() == 1) + + -- tool repair (repairable) + input = { + method = "normal", + width = 2, + -- Using a wear of 60000 + items = {"unittests:repairable_tool 1 60000", "unittests:repairable_tool 1 60000"} + } + minetest.log("info", "[unittests] repairable tool crafting input: "..dump(input)) + output, decremented_input = minetest.get_craft_result(input) + minetest.log("info", "[unittests] repairable tool crafting output: "..dump(output)) + minetest.log("info", "[unittests] repairable tool crafting decremented input: "..dump(decremented_input)) + assert(output.item) + minetest.log("info", "[unittests] repairable tool crafting output.item:to_table(): "..dump(output.item:to_table())) + assert(output.item:get_name() == "unittests:repairable_tool") + -- Test the wear value. + -- See src/craftdef.cpp in Minetest source code for the formula. The formula to calculate + -- the value 51187 is: + -- 65536 - ((65536-60000)+(65536-60000)) + floor(additonal_wear * 65536 + 0.5) = 51187 + -- where additional_wear = 0.05 + assert(output.item:get_wear() == 51187) + assert(output.item:get_count() == 1) + + -- failing tool repair (unrepairable) + input = { + method = "normal", + width = 2, + items = {"unittests:unrepairable_tool 1 60000", "unittests:unrepairable_tool 1 60000"} + } + minetest.log("info", "[unittests] unrepairable tool crafting input: "..dump(input)) + output, decremented_input = minetest.get_craft_result(input) + minetest.log("info", "[unittests] unrepairable tool crafting output: "..dump(output)) + minetest.log("info", "[unittests] unrepairable tool crafting decremented input: "..dump(decremented_input)) + assert(output.item) + minetest.log("info", "[unittests] unrepairable tool crafting output.item:to_table(): "..dump(output.item:to_table())) + -- unrepairable tool must not yield any output + assert(output.item:get_name() == "") + +end + +function unittests.test_crafting() + test_clear_craft() + test_get_craft_result() + minetest.log("action", "[unittests] Crafting tests passed!") + return true +end + diff --git a/mods/unittests/crafting_prepare.lua b/mods/unittests/crafting_prepare.lua new file mode 100644 index 0000000..a097348 --- /dev/null +++ b/mods/unittests/crafting_prepare.lua @@ -0,0 +1,88 @@ +-- Registering some dummy items and recipes for the crafting tests + +minetest.register_craftitem("unittests:torch", { + description = "Crafting Test Item: Torch", + inventory_image = "unittests_torch.png", + + groups = { dummy = 1 }, +}) +minetest.register_craftitem("unittests:coal_lump", { + description = "Crafting Test Item: Coal Lump", + inventory_image = "unittests_coal_lump.png", + + groups = { dummy = 1 }, +}) +minetest.register_craftitem("unittests:stick", { + description = "Crafting Test Item: Stick", + inventory_image = "unittests_stick.png", + + groups = { dummy = 1 }, +}) +minetest.register_craftitem("unittests:iron_lump", { + description = "Crafting Test Item: Iron Lump", + inventory_image = "unittests_iron_lump.png", + + groups = { dummy = 1 }, +}) +minetest.register_craftitem("unittests:steel_ingot", { + description = "Crafting Test Item: Steel Ingot", + inventory_image = "unittests_steel_ingot.png", + + groups = { dummy = 1 }, +}) + +-- Recipes for tests: Normal crafting, cooking and fuel + +minetest.register_craft({ + output = 'unittests:torch 4', + recipe = { + {'unittests:coal_lump'}, + {'unittests:stick'}, + } +}) + +minetest.register_craft({ + type = "cooking", + output = "unittests:steel_ingot", + recipe = "unittests:iron_lump", +}) + +minetest.register_craft({ + type = "fuel", + recipe = "unittests:coal_lump", + burntime = 40, +}) + +-- Test tool repair +minetest.register_craft({ + type = "toolrepair", + additional_wear = -0.05, +}) + +-- Test the disable_repair=1 group +minetest.register_tool("unittests:unrepairable_tool", { + description = "Crafting Test Item: Unrepairable Tool", + inventory_image = "unittests_unrepairable_tool.png", + tool_capabilities = { + groupcaps = { + cracky = { + times = {3, 2, 1}, + } + } + }, + groups = { disable_repair = 1, dummy = 1 } +}) + +minetest.register_tool("unittests:repairable_tool", { + description = "Crafting Test Item: Repairable Tool", + inventory_image = "unittests_repairable_tool.png", + tool_capabilities = { + groupcaps = { + cracky = { + times = {3, 2, 1}, + } + } + }, + + groups = { dummy = 1 }, +}) diff --git a/mods/unittests/init.lua b/mods/unittests/init.lua new file mode 100644 index 0000000..12c67f7 --- /dev/null +++ b/mods/unittests/init.lua @@ -0,0 +1,18 @@ +unittests = {} + +local modpath = minetest.get_modpath("unittests") +dofile(modpath .. "/random.lua") +dofile(modpath .. "/player.lua") +dofile(modpath .. "/crafting_prepare.lua") +dofile(modpath .. "/crafting.lua") +dofile(modpath .. "/itemdescription.lua") + +if minetest.settings:get_bool("devtest_unittests_autostart", false) then + unittests.test_random() + unittests.test_crafting() + unittests.test_short_desc() + minetest.register_on_joinplayer(function(player) + unittests.test_player(player) + end) +end + diff --git a/mods/unittests/itemdescription.lua b/mods/unittests/itemdescription.lua new file mode 100644 index 0000000..d6ee655 --- /dev/null +++ b/mods/unittests/itemdescription.lua @@ -0,0 +1,51 @@ +local full_description = "Colorful Pickaxe\nThe best pick." +minetest.register_tool("unittests:colorful_pick", { + description = full_description, + inventory_image = "basetools_mesepick.png", + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=3, + groupcaps={ + cracky={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3}, + crumbly={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3}, + snappy={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3} + }, + damage_groups = {fleshy=4}, + }, +}) + +minetest.register_chatcommand("item_description", { + param = "", + description = "Show the short and full description of the wielded item.", + func = function(name) + local player = minetest.get_player_by_name(name) + local item = player:get_wielded_item() + return true, string.format("short_description: %s\ndescription: %s", + item:get_short_description(), item:get_description()) + end +}) + +function unittests.test_short_desc() + local function get_short_description(item) + return ItemStack(item):get_short_description() + end + + local stack = ItemStack("unittests:colorful_pick") + assert(stack:get_short_description() == "Colorful Pickaxe") + assert(get_short_description("unittests:colorful_pick") == "Colorful Pickaxe") + assert(minetest.registered_items["unittests:colorful_pick"].short_description == nil) + assert(stack:get_description() == full_description) + assert(stack:get_description() == minetest.registered_items["unittests:colorful_pick"].description) + + stack:get_meta():set_string("description", "Hello World") + assert(stack:get_short_description() == "Hello World") + assert(stack:get_description() == "Hello World") + assert(get_short_description(stack) == "Hello World") + assert(get_short_description("unittests:colorful_pick") == "Colorful Pickaxe") + + stack:get_meta():set_string("short_description", "Foo Bar") + assert(stack:get_short_description() == "Foo Bar") + assert(stack:get_description() == "Hello World") + + return true +end diff --git a/mods/unittests/mod.conf b/mods/unittests/mod.conf new file mode 100644 index 0000000..fa94e01 --- /dev/null +++ b/mods/unittests/mod.conf @@ -0,0 +1,3 @@ +name = unittests +description = Adds automated unit tests for the engine +depends = basenodes diff --git a/mods/unittests/player.lua b/mods/unittests/player.lua new file mode 100644 index 0000000..4a68131 --- /dev/null +++ b/mods/unittests/player.lua @@ -0,0 +1,76 @@ +-- +-- HP Change Reasons +-- +local expect = nil +local function run_hpchangereason_tests(player) + local old_hp = player:get_hp() + + player:set_hp(20) + expect = { type = "set_hp", from = "mod" } + player:set_hp(3) + assert(expect == nil) + + expect = { a = 234, type = "set_hp", from = "mod" } + player:set_hp(7, { a= 234 }) + assert(expect == nil) + + expect = { df = 3458973454, type = "fall", from = "mod" } + player:set_hp(10, { type = "fall", df = 3458973454 }) + assert(expect == nil) + + player:set_hp(old_hp) +end + +local function run_player_meta_tests(player) + local meta = player:get_meta() + meta:set_string("foo", "bar") + assert(meta:contains("foo")) + assert(meta:get_string("foo") == "bar") + assert(meta:get("foo") == "bar") + + local meta2 = player:get_meta() + assert(meta2:get_string("foo") == "bar") + assert(meta2:get("foo") == "bar") + assert(meta:equals(meta2)) + + meta:set_string("bob", "dillan") + assert(meta:get_string("foo") == "bar") + assert(meta:get_string("bob") == "dillan") + assert(meta:get("bob") == "dillan") + assert(meta2:get_string("foo") == "bar") + assert(meta2:get_string("bob") == "dillan") + assert(meta2:get("bob") == "dillan") + assert(meta:equals(meta2)) + + meta:set_string("foo", "") + assert(not meta:contains("foo")) + assert(meta:get("foo") == nil) + assert(meta:get_string("foo") == "") + assert(meta:equals(meta2)) +end + +function unittests.test_player(player) + minetest.register_on_player_hpchange(function(player, hp, reason) + if not expect then + return + end + + for key, value in pairs(reason) do + assert(expect[key] == value) + end + + for key, value in pairs(expect) do + assert(reason[key] == value) + end + + expect = nil + end) + + run_hpchangereason_tests(player) + run_player_meta_tests(player) + local msg = "Player tests passed for player '"..player:get_player_name().."'!" + minetest.chat_send_all(msg) + minetest.log("action", "[unittests] "..msg) + return true +end + diff --git a/mods/unittests/random.lua b/mods/unittests/random.lua new file mode 100644 index 0000000..f94f0a8 --- /dev/null +++ b/mods/unittests/random.lua @@ -0,0 +1,10 @@ +function unittests.test_random() + -- Try out PseudoRandom + minetest.log("action", "[unittests] Testing PseudoRandom ...") + local pseudo = PseudoRandom(13) + assert(pseudo:next() == 22290) + assert(pseudo:next() == 13854) + minetest.log("action", "[unittests] PseudoRandom test passed!") + return true +end + diff --git a/mods/unittests/textures/default_dirt.png b/mods/unittests/textures/default_dirt.png new file mode 100644 index 0000000..5867030 Binary files /dev/null and b/mods/unittests/textures/default_dirt.png differ diff --git a/mods/unittests/textures/unittests_coal_lump.png b/mods/unittests/textures/unittests_coal_lump.png new file mode 100644 index 0000000..f460d90 Binary files /dev/null and b/mods/unittests/textures/unittests_coal_lump.png differ diff --git a/mods/unittests/textures/unittests_iron_lump.png b/mods/unittests/textures/unittests_iron_lump.png new file mode 100644 index 0000000..22f43e9 Binary files /dev/null and b/mods/unittests/textures/unittests_iron_lump.png differ diff --git a/mods/unittests/textures/unittests_repairable_tool.png b/mods/unittests/textures/unittests_repairable_tool.png new file mode 100644 index 0000000..46fbbaa Binary files /dev/null and b/mods/unittests/textures/unittests_repairable_tool.png differ diff --git a/mods/unittests/textures/unittests_steel_ingot.png b/mods/unittests/textures/unittests_steel_ingot.png new file mode 100644 index 0000000..6977696 Binary files /dev/null and b/mods/unittests/textures/unittests_steel_ingot.png differ diff --git a/mods/unittests/textures/unittests_stick.png b/mods/unittests/textures/unittests_stick.png new file mode 100644 index 0000000..ffdce70 Binary files /dev/null and b/mods/unittests/textures/unittests_stick.png differ diff --git a/mods/unittests/textures/unittests_torch.png b/mods/unittests/textures/unittests_torch.png new file mode 100644 index 0000000..ba5eebe Binary files /dev/null and b/mods/unittests/textures/unittests_torch.png differ diff --git a/mods/unittests/textures/unittests_unrepairable_tool.png b/mods/unittests/textures/unittests_unrepairable_tool.png new file mode 100644 index 0000000..c676213 Binary files /dev/null and b/mods/unittests/textures/unittests_unrepairable_tool.png differ diff --git a/mods/util_commands/init.lua b/mods/util_commands/init.lua new file mode 100644 index 0000000..ca5dca2 --- /dev/null +++ b/mods/util_commands/init.lua @@ -0,0 +1,195 @@ +minetest.register_chatcommand("hotbar", { + params = "", + description = "Set hotbar size", + func = function(name, param) + local player = minetest.get_player_by_name(name) + if not player then + return false, "No player." + end + local size = tonumber(param) + if not size then + return false, "Missing or incorrect size parameter!" + end + local ok = player:hud_set_hotbar_itemcount(size) + if ok then + return true + else + return false, "Invalid item count!" + end + end, +}) + +minetest.register_chatcommand("hp", { + params = "", + description = "Set your health", + func = function(name, param) + local player = minetest.get_player_by_name(name) + if not player then + return false, "No player." + end + local hp = tonumber(param) + if not hp then + return false, "Missing or incorrect hp parameter!" + end + player:set_hp(hp) + return true + end, +}) + +minetest.register_on_joinplayer(function(player) + player:set_properties({zoom_fov = 15}) +end) + +minetest.register_chatcommand("zoomfov", { + params = "[]", + description = "Set or display your zoom_fov", + func = function(name, param) + local player = minetest.get_player_by_name(name) + if not player then + return false, "No player." + end + if param == "" then + local fov = player:get_properties().zoom_fov + return true, "zoom_fov = "..tostring(fov) + end + local fov = tonumber(param) + if not fov then + return false, "Missing or incorrect zoom_fov parameter!" + end + player:set_properties({zoom_fov = fov}) + fov = player:get_properties().zoom_fov + return true, "zoom_fov = "..tostring(fov) + end, +}) + +local s_infplace = minetest.settings:get("devtest_infplace") +if s_infplace == "true" then + infplace = true +elseif s_infplace == "false" then + infplace = false +else + infplace = minetest.is_creative_enabled("") +end + +minetest.register_chatcommand("infplace", { + params = "", + description = "Toggle infinite node placement", + func = function(name, param) + infplace = not infplace + if infplace then + minetest.chat_send_all("Infinite node placement enabled!") + minetest.log("action", "Infinite node placement enabled") + else + minetest.chat_send_all("Infinite node placement disabled!") + minetest.log("action", "Infinite node placement disabled") + end + return true + end, +}) + +minetest.register_chatcommand("detach", { + params = "[]", + description = "Detach all objects nearby", + func = function(name, param) + local radius = tonumber(param) + if type(radius) ~= "number" then + radius = 8 + end + if radius < 1 then + radius = 1 + end + local player = minetest.get_player_by_name(name) + if not player then + return false, "No player." + end + local objs = minetest.get_objects_inside_radius(player:get_pos(), radius) + local num = 0 + for o=1, #objs do + if objs[o]:get_attach() then + objs[o]:set_detach() + num = num + 1 + end + end + return true, string.format("%d object(s) detached.", num) + end, +}) + +-- Use this to test waypoint capabilities +minetest.register_chatcommand("test_waypoints", { + params = "[change_immediate]", + description = "tests waypoint capabilities", + func = function(name, params) + local player = minetest.get_player_by_name(name) + local regular = player:hud_add { + hud_elem_type = "waypoint", + name = "regular waypoint", + text = "m", + number = 0xFF0000, + world_pos = vector.add(player:get_pos(), {x = 0, y = 1.5, z = 0}) + } + local reduced_precision = player:hud_add { + hud_elem_type = "waypoint", + name = "better waypoint", + text = "m (0.5 steps, precision = 2)", + precision = 10, + number = 0xFFFF00, + world_pos = vector.add(player:get_pos(), {x = 0, y = 1, z = 0}) + } + local function change() + if regular then + player:hud_change(regular, "world_pos", vector.add(player:get_pos(), {x = 0, y = 3, z = 0})) + end + if reduced_precision then + player:hud_change(reduced_precision, "precision", 2) + end + end + if params ~= "" then + -- change immediate + change() + else + minetest.after(0.5, change) + end + regular = regular or "error" + reduced_precision = reduced_precision or "error" + local hidden_distance = player:hud_add { + hud_elem_type = "waypoint", + name = "waypoint with hidden distance", + text = "this text is hidden as well (precision = 0)", + precision = 0, + number = 0x0000FF, + world_pos = vector.add(player:get_pos(), {x = 0, y = 0.5, z = 0}) + } or "error" + local image_waypoint = player:hud_add { + hud_elem_type = "image_waypoint", + text = "wieldhand.png", + world_pos = player:get_pos(), + scale = {x = 10, y = 10}, + offset = {x = 0, y = -32} + } or "error" + minetest.chat_send_player(name, "Waypoint IDs: regular: " .. regular .. ", reduced precision: " .. reduced_precision .. + ", hidden distance: " .. hidden_distance .. ", image waypoint: " .. image_waypoint) + end +}) + +-- Unlimited node placement +minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack) + if placer and placer:is_player() then + return infplace + end +end) + +-- Don't pick up if the item is already in the inventory +local old_handle_node_drops = minetest.handle_node_drops +function minetest.handle_node_drops(pos, drops, digger) + if not digger or not digger:is_player() or not infplace then + return old_handle_node_drops(pos, drops, digger) + end + local inv = digger:get_inventory() + if inv then + for _, item in ipairs(drops) do + if not inv:contains_item("main", item, true) then + inv:add_item("main", item) + end + end + end +end diff --git a/mods/util_commands/mod.conf b/mods/util_commands/mod.conf new file mode 100644 index 0000000..fea6dd3 --- /dev/null +++ b/mods/util_commands/mod.conf @@ -0,0 +1,2 @@ +name = util_commands +description = Random server commands to make testing easier and more convenient diff --git a/schematic_tables.txt b/schematic_tables.txt new file mode 100644 index 0000000..eff2d35 --- /dev/null +++ b/schematic_tables.txt @@ -0,0 +1,2228 @@ +Minetest Game schematic tables +============================== + +This document acts as the official record of all schematic tables used in +Minetest Game, and should be updated by any commit that adds a table type +schematic. + +The following tables are for pasting into mods that contain a function to +convert the Lua tables into .mts files. Such mods often have two functions to +process two formats of the 'data' table: + +The standard table format is described in the 'Schematic specifier' section of +the lua_api.txt file in the Minetest Engine. +The 'data' table appears as a sequence of vertical slices through the structure +the schematic describes. +Each XY-plane slice has the X-rows formatted in order of increasing Y, so the +slices of the structure visually appear upside-down in the table. +In this document this format is used where 'mts_save()' appears. + +The transformed table format was created to be easier to work with. +Each XY-plane slice has the X-rows formatted in order of decreasing Y, so the +slices of the structure visually appear upright in the table. +In this document this format is used where 'mts_save_up()' appears. + + +-- This node will not replace existing world nodes + +local _ = {name = "air", prob = 0} + + +-- Mapgen Apple tree + +local M = {name = "default:leaves", prob = 255} +local N = {name = "default:leaves", prob = 223} +local F = {name = "default:apple", prob = 63} +local Y = {name = "default:tree", prob = 255, force_place = true} +local T = {name = "default:tree", prob = 255} + +mts_save("apple_tree", { + size = {x = 7, y = 8, z = 7}, + data = { + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, N, M, N, _, _, + _, _, _, N, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, M, M, F, M, M, _, + _, N, M, M, M, N, _, + _, _, N, M, N, _, _, + _, _, _, _, _, _, _, + + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + N, M, Y, _, _, M, N, + _, M, M, _, Y, M, _, + _, N, M, M, M, N, _, + _, _, _, N, _, _, _, + + _, _, _, Y, _, _, _, + _, _, _, Y, _, _, _, + _, _, _, Y, _, _, _, + _, _, _, Y, _, _, _, + M, F, _, Y, _, F, M, + N, M, _, _, _, M, N, + _, M, M, M, M, M, _, + _, _, N, M, N, _, _, + + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + N, M, _, _, Y, M, N, + _, M, Y, _, M, M, _, + _, N, M, M, M, N, _, + _, _, _, N, _, _, _, + + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, M, M, F, M, M, _, + _, N, M, M, M, N, _, + _, _, N, M, N, _, _, + _, _, _, _, _, _, _, + + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, N, M, N, _, _, + _, _, _, N, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + }, + yslice_prob = { + {ypos = 2, prob = 127}, + }, +}) + + +-- Apple tree from sapling + +mts_save("apple_tree_from_sapling", { + size = {x = 7, y = 8, z = 7}, + data = { + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, N, M, N, _, _, + _, _, _, N, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, M, M, F, M, M, _, + _, N, M, M, M, N, _, + _, _, N, M, N, _, _, + _, _, _, _, _, _, _, + + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + N, M, T, _, _, M, N, + _, M, M, _, T, M, _, + _, N, M, M, M, N, _, + _, _, _, N, _, _, _, + + _, _, _, T, _, _, _, + _, _, _, Y, _, _, _, + _, _, _, T, _, _, _, + _, _, _, T, _, _, _, + M, F, _, T, _, F, M, + N, M, _, _, _, M, N, + _, M, M, M, M, M, _, + _, _, N, M, N, _, _, + + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + N, M, _, _, T, M, N, + _, M, T, _, M, M, _, + _, N, M, M, M, N, _, + _, _, _, N, _, _, _, + + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, M, M, F, M, M, _, + _, N, M, M, M, N, _, + _, _, N, M, N, _, _, + _, _, _, _, _, _, _, + + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, N, M, N, _, _, + _, _, _, N, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + }, + yslice_prob = { + {ypos = 2, prob = 127}, + }, +}) + + +-- Mapgen Jungle tree + +local L = {name = "default:jungleleaves", prob = 255} +local N = {name = "default:jungleleaves", prob = 223} +local M = {name = "default:jungleleaves", prob = 191} +local B = {name = "default:jungletree", prob = 255, force_place = true} +local Y = {name = "default:jungletree", prob = 191, force_place = true} +local U = {name = "default:jungletree", prob = 127, force_place = true} +local I = {name = "default:jungletree", prob = 255} + +mts_save("jungle_tree", { + size = {x = 5, y = 17, z = 5}, + data = { + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + N, L, N, _, _, + _, _, N, L, N, + _, _, _, _, _, + _, _, _, _, _, + M, N, N, N, M, + M, N, N, N, M, + _, _, _, _, _, + + _, _, B, _, _, + _, _, B, _, _, + _, _, U, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + L, B, L, _, _, + _, _, L, B, L, + _, _, _, _, _, + _, _, _, _, _, + N, B, L, B, N, + N, L, L, L, N, + _, N, N, N, _, + + _, B, B, B, _, + _, B, B, B, _, + _, U, B, U, _, + _, _, B, _, _, + _, _, B, _, _, + _, _, B, _, _, + _, _, B, _, _, + _, _, B, _, _, + _, _, B, L, N, + N, L, B, _, _, + N, L, B, _, _, + _, _, B, L, N, + _, _, B, L, N, + _, _, B, _, _, + N, L, L, L, N, + N, L, L, L, N, + _, N, L, N, _, + + _, _, B, _, _, + _, _, B, _, _, + _, _, U, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, L, B, L, + L, B, L, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, L, B, L, + _, _, _, _, _, + N, B, L, B, N, + N, L, L, L, N, + _, N, N, N, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, N, L, N, + N, L, N, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, N, L, N, + _, _, _, _, _, + M, N, N, N, M, + M, N, N, N, M, + _, _, _, _, _, + }, + yslice_prob = { + {ypos=6, prob=191}, + {ypos=7, prob=191}, + {ypos=8, prob=191}, + {ypos=9, prob=191}, + {ypos=10, prob=191}, + }, +}) + + +-- Jungle tree from sapling + +local B = {name = "default:jungletree", prob = 255} +local C = {name = "default:jungletree", prob = 255, force_place = true} +local Y = {name = "default:jungletree", prob = 191} +local U = {name = "default:jungletree", prob = 127} + +mts_save("jungle_tree_from_sapling", { + size = {x = 5, y = 17, z = 5}, + data = { + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + N, L, N, _, _, + _, _, N, L, N, + _, _, _, _, _, + _, _, _, _, _, + M, N, N, N, M, + M, N, N, N, M, + _, _, _, _, _, + + _, _, B, _, _, + _, _, B, _, _, + _, _, U, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + L, B, L, _, _, + _, _, L, B, L, + _, _, _, _, _, + _, _, _, _, _, + N, B, L, B, N, + N, L, L, L, N, + _, N, N, N, _, + + _, B, B, B, _, + _, B, C, B, _, + _, U, B, U, _, + _, _, B, _, _, + _, _, B, _, _, + _, _, B, _, _, + _, _, B, _, _, + _, _, B, _, _, + _, _, B, L, N, + N, L, B, _, _, + N, L, B, _, _, + _, _, B, L, N, + _, _, B, L, N, + _, _, B, _, _, + N, L, L, L, N, + N, L, L, L, N, + _, N, L, N, _, + + _, _, B, _, _, + _, _, B, _, _, + _, _, U, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, L, B, L, + L, B, L, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, L, B, L, + _, _, _, _, _, + N, B, L, B, N, + N, L, L, L, N, + _, N, N, N, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, N, L, N, + N, L, N, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, N, L, N, + _, _, _, _, _, + M, N, N, N, M, + M, N, N, N, M, + _, _, _, _, _, + }, + yslice_prob = { + {ypos=6, prob=191}, + {ypos=7, prob=191}, + {ypos=8, prob=191}, + {ypos=9, prob=191}, + {ypos=10, prob=191}, + }, +}) + + +-- Mapgen Pine tree + +local L = {name = "default:pine_needles", prob = 255} +local M = {name = "default:pine_needles", prob = 223} +local N = {name = "default:pine_needles", prob = 191} +local T = {name = "default:pine_tree", prob = 255, force_place = true} +local B = {name = "default:pine_tree", prob = 255} + +mts_save("pine_tree", { + size = {x = 5, y = 16, z = 5}, + data = { + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + N, M, L, M, N, + _, _, _, _, _, + _, _, _, _, _, + N, M, L, M, N, + _, _, _, _, _, + _, _, _, _, _, + N, M, L, M, N, + _, _, _, _, _, + _, _, _, _, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + M, L, _, L, M, + _, L, L, L, _, + _, _, _, _, _, + M, L, _, L, M, + _, L, L, L, _, + _, _, _, _, _, + M, L, _, L, M, + _, L, L, L, _, + _, _, _, _, _, + + _, _, T, _, _, + _, _, T, _, _, + _, _, T, _, _, + _, _, T, _, _, + _, _, T, _, _, + _, _, T, _, _, + _, _, T, _, _, + L, _, T, _, L, + _, L, T, L, _, + _, _, T, _, _, + L, _, T, _, L, + _, L, T, L, _, + _, _, T, _, _, + L, _, T, _, L, + _, L, L, L, _, + _, _, L, _, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + M, L, _, L, M, + _, L, L, L, _, + _, _, _, _, _, + M, L, _, L, M, + _, L, L, L, _, + _, _, _, _, _, + M, L, _, L, M, + _, L, L, L, _, + _, _, _, _, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + N, M, L, M, N, + _, _, _, _, _, + _, _, _, _, _, + N, M, L, M, N, + _, _, _, _, _, + _, _, _, _, _, + N, M, L, M, N, + _, _, _, _, _, + _, _, _, _, _, + }, + yslice_prob = { + {ypos = 2, prob = 127}, + {ypos = 3, prob = 127}, + {ypos = 4, prob = 127}, + {ypos = 5, prob = 127}, + {ypos = 9, prob = 127}, + {ypos = 12, prob = 127}, + }, +}) + + +-- Pine tree from sapling + +local T = {name = "default:pine_tree", prob = 255} +local U = {name = "default:pine_tree", prob = 255, force_place = true} + +mts_save("pine_tree_from_sapling", { + size = {x = 5, y = 16, z = 5}, + data = { + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + N, M, L, M, N, + _, _, _, _, _, + _, _, _, _, _, + N, M, L, M, N, + _, _, _, _, _, + _, _, _, _, _, + N, M, L, M, N, + _, _, _, _, _, + _, _, _, _, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + M, L, _, L, M, + _, L, L, L, _, + _, _, _, _, _, + M, L, _, L, M, + _, L, L, L, _, + _, _, _, _, _, + M, L, _, L, M, + _, L, L, L, _, + _, _, _, _, _, + + _, _, T, _, _, + _, _, U, _, _, + _, _, T, _, _, + _, _, T, _, _, + _, _, T, _, _, + _, _, T, _, _, + _, _, T, _, _, + L, _, T, _, L, + _, L, T, L, _, + _, _, T, _, _, + L, _, T, _, L, + _, L, T, L, _, + _, _, T, _, _, + L, _, T, _, L, + _, L, L, L, _, + _, _, L, _, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + M, L, _, L, M, + _, L, L, L, _, + _, _, _, _, _, + M, L, _, L, M, + _, L, L, L, _, + _, _, _, _, _, + M, L, _, L, M, + _, L, L, L, _, + _, _, _, _, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + N, M, L, M, N, + _, _, _, _, _, + _, _, _, _, _, + N, M, L, M, N, + _, _, _, _, _, + _, _, _, _, _, + N, M, L, M, N, + _, _, _, _, _, + _, _, _, _, _, + }, + yslice_prob = { + {ypos = 2, prob = 127}, + {ypos = 3, prob = 127}, + {ypos = 4, prob = 127}, + {ypos = 5, prob = 127}, + {ypos = 9, prob = 127}, + {ypos = 12, prob = 127}, + }, +}) + + +-- Snowy pine tree from sapling + +local T = {name = "default:pine_tree", prob = 255} +local U = {name = "default:pine_tree", prob = 255, force_place = true} +local L = {name = "default:pine_needles", prob = 255} +local S = {name = "default:snow", prob = 255} + +mts_save("snowy_pine_tree_from_sapling", { + size = {x = 5, y = 16, z = 5}, + data = { + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + N, M, L, M, N, + _, _, _, _, _, + _, _, _, _, _, + N, M, L, M, N, + _, _, _, _, _, + _, _, _, _, _, + L, L, L, L, L, + S, S, S, S, S, + _, _, _, _, _, + _, _, _, _, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + M, L, _, L, M, + _, L, L, L, _, + _, _, _, _, _, + L, L, _, L, M, + S, L, L, L, _, + _, _, _, _, _, + _, L, _, L, L, + _, L, L, L, S, + _, S, S, S, _, + _, _, _, _, _, + + _, _, T, _, _, + _, _, U, _, _, + _, _, T, _, _, + _, _, T, _, _, + _, _, T, _, _, + _, _, T, _, _, + L, _, T, _, L, + _, L, T, L, _, + _, _, T, _, _, + L, _, T, _, L, + _, L, T, L, _, + _, _, T, _, _, + L, _, T, _, L, + S, L, L, L, S, + _, S, L, S, _, + _, _, S, _, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + M, L, _, L, M, + _, L, L, L, _, + _, _, _, _, _, + M, L, _, L, M, + _, L, L, L, _, + _, _, _, _, _, + L, L, _, L, L, + S, L, L, L, S, + _, S, S, S, _, + _, _, _, _, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + N, M, L, M, N, + _, _, _, _, _, + _, _, _, _, _, + N, M, L, M, L, + _, _, _, _, S, + _, _, _, _, _, + L, L, L, L, _, + S, S, S, S, _, + _, _, _, _, _, + _, _, _, _, _, + }, + yslice_prob = { + {ypos = 2, prob = 127}, + {ypos = 3, prob = 127}, + {ypos = 4, prob = 127}, + {ypos = 8, prob = 127}, + {ypos = 11, prob = 127}, + }, +}) + + +-- Mapgen Acacia tree + +local L = {name = "default:acacia_leaves", prob = 255} +local M = {name = "default:acacia_leaves", prob = 223} +local T = {name = "default:acacia_tree", prob = 255, force_place = true} + +mts_save("acacia_tree", { + size = {x = 9, y = 9, z = 9}, + data = { + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + M, M, M, M, _, _, _, _, _, + _, _, _, _, M, M, M, M, M, + + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + M, L, L, M, _, _, _, _, _, + _, _, _, _, M, L, L, L, M, + + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, T, _, _, _, _, _, _, + M, L, L, M, _, _, T, _, _, + _, _, _, _, M, L, L, L, M, + + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, T, _, _, _, _, _, + _, _, _, _, _, T, _, _, _, + M, M, M, M, _, _, _, _, _, + _, _, _, _, M, L, L, L, M, + + _, _, _, _, T, _, _, _, _, + _, _, _, _, T, _, _, _, _, + _, _, _, _, T, _, _, _, _, + _, _, _, _, T, _, _, _, _, + _, _, _, _, T, _, _, _, _, + _, _, _, _, T, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + M, M, M, M, M, M, M, M, M, + + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, T, _, _, _, + _, _, _, T, _, _, _, _, _, + _, _, _, _, _, M, M, M, M, + M, L, L, L, M, _, _, _, _, + + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, T, _, _, + _, _, T, _, _, M, L, L, M, + M, L, L, L, M, _, _, _, _, + + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, M, L, L, M, + M, L, L, L, M, _, _, _, _, + + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, M, M, M, M, + M, M, M, M, M, _, _, _, _, + }, + yslice_prob = { + {ypos = 2, prob = 127}, + {ypos = 3, prob = 127}, + {ypos = 4, prob = 127}, + }, +}) + + +-- Acacia tree from sapling + +local T = {name = "default:acacia_tree", prob = 255} +local U = {name = "default:acacia_tree", prob = 255, force_place = true} + +mts_save("acacia_tree_from_sapling", { + size = {x = 9, y = 9, z = 9}, + data = { + + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + M, M, M, M, _, _, _, _, _, + _, _, _, _, M, M, M, M, M, + + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + M, L, L, M, _, _, _, _, _, + _, _, _, _, M, L, L, L, M, + + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, T, _, _, _, _, _, _, + M, L, L, M, _, _, T, _, _, + _, _, _, _, M, L, L, L, M, + + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, T, _, _, _, _, _, + _, _, _, _, _, T, _, _, _, + M, M, M, M, _, _, _, _, _, + _, _, _, _, M, L, L, L, M, + + _, _, _, _, T, _, _, _, _, + _, _, _, _, U, _, _, _, _, + _, _, _, _, T, _, _, _, _, + _, _, _, _, T, _, _, _, _, + _, _, _, _, T, _, _, _, _, + _, _, _, _, T, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + M, M, M, M, M, M, M, M, M, + + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, T, _, _, _, + _, _, _, T, _, _, _, _, _, + _, _, _, _, _, M, M, M, M, + M, L, L, L, M, _, _, _, _, + + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, T, _, _, + _, _, T, _, _, M, L, L, M, + M, L, L, L, M, _, _, _, _, + + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, M, L, L, M, + M, L, L, L, M, _, _, _, _, + + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, + _, _, _, _, _, M, M, M, M, + M, M, M, M, M, _, _, _, _, + }, + yslice_prob = { + {ypos = 2, prob = 127}, + {ypos = 3, prob = 127}, + {ypos = 4, prob = 127}, + }, +}) + + +-- Mapgen Aspen tree + +local T = {name = "default:aspen_tree", prob = 255, force_place = true} +local B = {name = "default:aspen_tree", prob = 255} +local L = {name = "default:aspen_leaves", prob = 255} +local M = {name = "default:aspen_leaves", prob = 223} +local N = {name = "default:aspen_leaves", prob = 127} + +mts_save("aspen_tree", { + size = {x = 5, y = 14, z = 5}, + data = { + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + N, M, L, M, N, + _, _, _, _, _, + N, M, L, M, N, + _, _, _, _, _, + N, M, L, M, N, + _, _, _, _, _, + _, _, _, _, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, M, L, M, _, + M, L, L, L, M, + _, M, L, M, _, + M, L, L, L, M, + _, M, L, M, _, + M, L, L, L, M, + _, M, L, M, _, + _, _, _, _, _, + + _, _, T, _, _, + _, _, T, _, _, + _, _, T, _, _, + _, _, T, _, _, + _, _, T, _, _, + _, _, T, _, _, + _, L, T, L, _, + L, L, T, L, L, + _, L, T, L, _, + L, L, T, L, L, + _, L, T, L, _, + L, L, T, L, L, + _, L, L, L, _, + _, _, L, _, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, M, L, M, _, + M, L, L, L, M, + _, M, L, M, _, + M, L, L, L, M, + _, M, L, M, _, + M, L, L, L, M, + _, M, L, M, _, + _, _, _, _, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + N, M, L, M, N, + _, _, _, _, _, + N, M, L, M, N, + _, _, _, _, _, + N, M, L, M, N, + _, _, _, _, _, + _, _, _, _, _, + }, + yslice_prob = { + {ypos = 2, prob = 127}, + {ypos = 3, prob = 127}, + {ypos = 4, prob = 127}, + {ypos = 8, prob = 127}, + {ypos = 10, prob = 127}, + }, +}) + + +-- Aspen tree from sapling + +mts_save("aspen_tree_from_sapling", { + size = {x = 5, y = 14, z = 5}, + data = { + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + N, M, L, M, N, + _, _, _, _, _, + N, M, L, M, N, + _, _, _, _, _, + N, M, L, M, N, + _, _, _, _, _, + _, _, _, _, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, M, L, M, _, + M, L, L, L, M, + _, M, L, M, _, + M, L, L, L, M, + _, M, L, M, _, + M, L, L, L, M, + _, M, L, M, _, + _, _, _, _, _, + + _, _, B, _, _, + _, _, T, _, _, + _, _, B, _, _, + _, _, B, _, _, + _, _, B, _, _, + _, _, B, _, _, + _, L, B, L, _, + L, L, B, L, L, + _, L, B, L, _, + L, L, B, L, L, + _, L, B, L, _, + L, L, B, L, L, + _, L, L, L, _, + _, _, L, _, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, M, L, M, _, + M, L, L, L, M, + _, M, L, M, _, + M, L, L, L, M, + _, M, L, M, _, + M, L, L, L, M, + _, M, L, M, _, + _, _, _, _, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + N, M, L, M, N, + _, _, _, _, _, + N, M, L, M, N, + _, _, _, _, _, + N, M, L, M, N, + _, _, _, _, _, + _, _, _, _, _, + }, + yslice_prob = { + {ypos = 2, prob = 127}, + {ypos = 3, prob = 127}, + {ypos = 4, prob = 127}, + {ypos = 8, prob = 127}, + {ypos = 10, prob = 127}, + }, +}) + + +-- Mapgen emergent jungle tree + +local L = {name = "default:jungleleaves", prob = 255} +local N = {name = "default:jungleleaves", prob = 223} +local M = {name = "default:jungleleaves", prob = 127} +local B = {name = "default:jungletree", prob = 255, force_place = true} +local U = {name = "default:jungletree", prob = 127, force_place = true} + +mts_save("emergent_jungle_tree", { + size = {x = 7, y = 37, z = 7}, + data = { + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + B, _, _, _, _, _, B, + B, _, _, _, _, _, B, + B, _, _, _, _, _, B, + U, _, _, _, _, _, U, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + N, N, N, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, N, N, N, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, N, N, N, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + N, N, N, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, N, N, N, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, M, M, M, M, M, _, + _, N, N, N, N, N, _, + _, N, N, N, N, N, _, + _, N, N, N, N, N, _, + _, _, _, _, _, _, _, + + _, _, _, _, _, _, _, + _, _, B, _, B, _, _, + _, B, B, _, B, B, _, + _, B, B, _, B, B, _, + _, B, B, _, B, B, _, + _, B, B, _, B, B, _, + _, B, B, _, B, B, _, + _, U, B, _, B, U, _, + _, _, U, _, U, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + N, B, N, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, N, B, N, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, N, B, N, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + N, B, N, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, N, B, N, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + M, _, _, _, _, _, M, + N, L, _, _, _, L, N, + N, B, L, L, L, B, N, + N, L, L, L, L, L, N, + _, N, N, N, N, N, _, + + _, _, B, _, B, _, _, + _, B, B, _, B, B, _, + _, B, B, _, B, B, _, + _, B, B, _, B, B, _, + _, B, B, B, B, B, _, + _, B, B, B, B, B, _, + _, B, B, B, B, B, _, + _, B, B, B, B, B, _, + _, U, B, B, B, U, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + N, N, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, _, B, B, N, N, + N, N, N, B, _, _, _, + _, _, _, B, _, _, _, + _, _, N, B, N, _, _, + _, _, _, B, _, _, _, + _, _, _, B, N, N, N, + N, N, B, B, _, _, _, + _, _, _, B, _, _, _, + _, _, _, B, B, N, N, + N, N, N, B, _, _, _, + _, _, _, B, _, _, _, + M, _, B, B, B, _, M, + N, _, B, _, B, _, N, + N, L, L, _, L, L, N, + N, L, L, L, L, L, N, + _, N, L, L, L, N, _, + + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + N, B, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, B, N, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + N, B, B, B, B, _, _, + _, _, B, B, B, _, _, + M, _, B, _, B, _, M, + N, _, _, _, _, _, N, + N, L, _, _, _, L, N, + N, L, L, L, L, L, N, + _, N, L, L, L, N, _, + + _, _, B, _, B, _, _, + _, B, B, _, B, B, _, + _, B, B, _, B, B, _, + _, B, B, _, B, B, _, + _, B, B, B, B, B, _, + _, B, B, B, B, B, _, + _, B, B, B, B, B, _, + _, B, B, B, B, B, _, + _, U, B, B, B, U, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, _, B, _, _, _, + N, N, N, B, _, _, _, + _, _, _, B, B, N, N, + _, _, _, B, _, _, _, + N, N, B, B, _, _, _, + _, _, _, B, N, N, N, + _, _, _, B, _, _, _, + _, _, N, B, N, _, _, + _, _, _, B, _, _, _, + N, N, N, B, _, _, _, + _, _, _, B, _, _, _, + M, _, B, B, B, _, M, + N, _, B, _, B, _, N, + N, L, L, _, L, L, N, + N, L, L, L, L, L, N, + _, N, L, L, L, N, _, + + _, _, _, _, _, _, _, + _, _, B, _, B, _, _, + _, B, B, _, B, B, _, + _, B, B, _, B, B, _, + _, B, B, _, B, B, _, + _, B, B, _, B, B, _, + _, B, B, _, B, B, _, + _, U, B, _, B, U, _, + _, _, U, _, U, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, N, B, N, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, N, B, N, + _, _, _, _, _, _, _, + N, B, N, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, N, B, N, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + M, _, _, _, _, _, M, + N, L, _, _, _, L, N, + N, B, L, L, L, B, N, + N, L, L, L, L, L, N, + _, N, N, N, N, N, _, + + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + B, _, _, _, _, _, B, + B, _, _, _, _, _, B, + B, _, _, _, _, _, B, + U, _, _, _, _, _, U, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, N, N, N, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, N, N, N, + _, _, _, _, _, _, _, + N, N, N, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, N, N, N, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, M, M, M, M, M, _, + _, N, N, N, N, N, _, + _, N, N, N, N, N, _, + _, N, N, N, N, N, _, + _, _, _, _, _, _, _, + }, + yslice_prob = { + {ypos = 13, prob = 127}, + {ypos = 14, prob = 127}, + {ypos = 15, prob = 127}, + {ypos = 16, prob = 127}, + {ypos = 17, prob = 127}, + {ypos = 18, prob = 127}, + {ypos = 19, prob = 127}, + {ypos = 20, prob = 127}, + {ypos = 21, prob = 127}, + {ypos = 22, prob = 127}, + {ypos = 23, prob = 127}, + {ypos = 24, prob = 127}, + }, +}) + + +-- Emergent jungle tree from sapling + +local L = {name = "default:jungleleaves", prob = 255} +local N = {name = "default:jungleleaves", prob = 223} +local M = {name = "default:jungleleaves", prob = 127} +local S = {name = "default:jungletree", prob = 255, force_place = true} +local B = {name = "default:jungletree", prob = 255} +local U = {name = "default:jungletree", prob = 127} + +mts_save("emergent_jungle_tree_from_sapling", { + size = {x = 7, y = 37, z = 7}, + data = { + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + B, _, _, _, _, _, B, + B, _, _, _, _, _, B, + B, _, _, _, _, _, B, + U, _, _, _, _, _, U, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + N, N, N, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, N, N, N, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, N, N, N, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + N, N, N, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, N, N, N, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, M, M, M, M, M, _, + _, N, N, N, N, N, _, + _, N, N, N, N, N, _, + _, N, N, N, N, N, _, + _, _, _, _, _, _, _, + + _, _, _, _, _, _, _, + _, _, B, _, B, _, _, + _, B, B, _, B, B, _, + _, B, B, _, B, B, _, + _, B, B, _, B, B, _, + _, B, B, _, B, B, _, + _, B, B, _, B, B, _, + _, U, B, _, B, U, _, + _, _, U, _, U, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + N, B, N, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, N, B, N, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, N, B, N, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + N, B, N, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, N, B, N, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + M, _, _, _, _, _, M, + N, L, _, _, _, L, N, + N, B, L, L, L, B, N, + N, L, L, L, L, L, N, + _, N, N, N, N, N, _, + + _, _, B, _, B, _, _, + _, B, B, _, B, B, _, + _, B, B, _, B, B, _, + _, B, B, _, B, B, _, + _, B, B, B, B, B, _, + _, B, B, B, B, B, _, + _, B, B, B, B, B, _, + _, B, B, B, B, B, _, + _, U, B, B, B, U, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + N, N, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, _, B, B, N, N, + N, N, N, B, _, _, _, + _, _, _, B, _, _, _, + _, _, N, B, N, _, _, + _, _, _, B, _, _, _, + _, _, _, B, N, N, N, + N, N, B, B, _, _, _, + _, _, _, B, _, _, _, + _, _, _, B, B, N, N, + N, N, N, B, _, _, _, + _, _, _, B, _, _, _, + M, _, B, B, B, _, M, + N, _, B, _, B, _, N, + N, L, L, _, L, L, N, + N, L, L, L, L, L, N, + _, N, L, L, L, N, _, + + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, B, B, B, _, _, + _, _, B, S, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + N, B, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, B, N, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + N, B, B, B, B, _, _, + _, _, B, B, B, _, _, + M, _, B, _, B, _, M, + N, _, _, _, _, _, N, + N, L, _, _, _, L, N, + N, L, L, L, L, L, N, + _, N, L, L, L, N, _, + + _, _, B, _, B, _, _, + _, B, B, _, B, B, _, + _, B, B, _, B, B, _, + _, B, B, _, B, B, _, + _, B, B, B, B, B, _, + _, B, B, B, B, B, _, + _, B, B, B, B, B, _, + _, B, B, B, B, B, _, + _, U, B, B, B, U, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, B, B, B, _, _, + _, _, _, B, _, _, _, + N, N, N, B, _, _, _, + _, _, _, B, B, N, N, + _, _, _, B, _, _, _, + N, N, B, B, _, _, _, + _, _, _, B, N, N, N, + _, _, _, B, _, _, _, + _, _, N, B, N, _, _, + _, _, _, B, _, _, _, + N, N, N, B, _, _, _, + _, _, _, B, _, _, _, + M, _, B, B, B, _, M, + N, _, B, _, B, _, N, + N, L, L, _, L, L, N, + N, L, L, L, L, L, N, + _, N, L, L, L, N, _, + + _, _, _, _, _, _, _, + _, _, B, _, B, _, _, + _, B, B, _, B, B, _, + _, B, B, _, B, B, _, + _, B, B, _, B, B, _, + _, B, B, _, B, B, _, + _, B, B, _, B, B, _, + _, U, B, _, B, U, _, + _, _, U, _, U, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, N, B, N, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, N, B, N, + _, _, _, _, _, _, _, + N, B, N, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, N, B, N, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + M, _, _, _, _, _, M, + N, L, _, _, _, L, N, + N, B, L, L, L, B, N, + N, L, L, L, L, L, N, + _, N, N, N, N, N, _, + + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + B, _, _, _, _, _, B, + B, _, _, _, _, _, B, + B, _, _, _, _, _, B, + U, _, _, _, _, _, U, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, N, N, N, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, N, N, N, + _, _, _, _, _, _, _, + N, N, N, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, N, N, N, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, _, _, _, _, _, _, + _, M, M, M, M, M, _, + _, N, N, N, N, N, _, + _, N, N, N, N, N, _, + _, N, N, N, N, N, _, + _, _, _, _, _, _, _, + }, + yslice_prob = { + {ypos = 13, prob = 127}, + {ypos = 14, prob = 127}, + {ypos = 15, prob = 127}, + {ypos = 16, prob = 127}, + {ypos = 17, prob = 127}, + {ypos = 18, prob = 127}, + {ypos = 19, prob = 127}, + {ypos = 20, prob = 127}, + {ypos = 21, prob = 127}, + {ypos = 22, prob = 127}, + {ypos = 23, prob = 127}, + {ypos = 24, prob = 127}, + }, +}) + + +-- Mapgen small pine tree + +local L = {name = "default:pine_needles", prob = 255} +local M = {name = "default:pine_needles", prob = 223} +local N = {name = "default:pine_needles", prob = 191} +local T = {name = "default:pine_tree", prob = 255, force_place = true} +local B = {name = "default:pine_tree", prob = 255} +local S = {name = "default:snow", prob = 255} + +mts_save("small_pine_tree", { + size = {x = 5, y = 12, z = 5}, + data = { + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, L, L, L, _, + _, _, L, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + L, L, _, L, L, + _, L, L, L, _, + _, L, L, L, _, + _, L, L, L, _, + _, _, L, _, _, + _, _, L, _, _, + _, _, _, _, _, + _, _, _, _, _, + + _, _, T, _, _, + _, _, T, _, _, + _, _, T, _, _, + _, _, T, _, _, + L, _, T, _, L, + L, L, T, L, L, + _, L, T, L, _, + _, L, T, L, _, + _, L, T, L, _, + _, L, L, L, _, + _, _, L, _, _, + _, _, L, _, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + L, L, _, L, L, + _, L, L, L, _, + _, L, L, L, _, + _, L, L, L, _, + _, _, L, _, _, + _, _, L, _, _, + _, _, _, _, _, + _, _, _, _, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, L, L, L, _, + _, _, L, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + }, + yslice_prob = { + {ypos = 2, prob = 127}, + {ypos = 3, prob = 127}, + {ypos = 4, prob = 127}, + }, +}) + + +-- Small pine tree from sapling + +mts_save("small_pine_tree_from_sapling", { + size = {x = 5, y = 12, z = 5}, + data = { + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, L, L, L, _, + _, _, L, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + L, L, _, L, L, + _, L, L, L, _, + _, L, L, L, _, + _, L, L, L, _, + _, _, L, _, _, + _, _, L, _, _, + _, _, _, _, _, + _, _, _, _, _, + + _, _, B, _, _, + _, _, T, _, _, + _, _, B, _, _, + _, _, B, _, _, + L, _, B, _, L, + L, L, B, L, L, + _, L, B, L, _, + _, L, B, L, _, + _, L, B, L, _, + _, L, L, L, _, + _, _, L, _, _, + _, _, L, _, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + L, L, _, L, L, + _, L, L, L, _, + _, L, L, L, _, + _, L, L, L, _, + _, _, L, _, _, + _, _, L, _, _, + _, _, _, _, _, + _, _, _, _, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, L, L, L, _, + _, _, L, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + }, + yslice_prob = { + {ypos = 2, prob = 127}, + {ypos = 3, prob = 127}, + {ypos = 4, prob = 127}, + }, +}) + + +-- Snowy small pine tree from sapling + +mts_save("snowy_small_pine_tree_from_sapling", { + size = {x = 5, y = 13, z = 5}, + data = { + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, L, L, L, _, + _, S, L, S, _, + _, _, S, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + L, L, _, L, L, + S, L, L, L, S, + _, L, L, L, _, + _, L, L, L, _, + _, S, L, S, _, + _, _, L, _, _, + _, _, S, _, _, + _, _, _, _, _, + _, _, _, _, _, + + _, _, B, _, _, + _, _, T, _, _, + _, _, B, _, _, + _, _, B, _, _, + L, _, B, _, L, + L, L, B, L, L, + S, L, B, L, S, + _, L, B, L, _, + _, L, B, L, _, + _, L, L, L, _, + _, S, L, S, _, + _, _, L, _, _, + _, _, S, _, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + L, L, _, L, L, + S, L, L, L, S, + _, L, L, L, _, + _, L, L, L, _, + _, S, L, S, _, + _, _, L, _, _, + _, _, S, _, _, + _, _, _, _, _, + _, _, _, _, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, L, L, L, _, + _, S, L, S, _, + _, _, S, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + }, + yslice_prob = { + {ypos = 2, prob = 127}, + {ypos = 3, prob = 127}, + }, +}) + + +-- Apple tree log + +mts_save("apple_log", { + size = {x = 4, y = 2, z = 1}, + data = { + {name = "default:tree", param2 = 12, prob = 127}, + {name = "default:tree", param2 = 12}, + {name = "default:tree", param2 = 12}, + {name = "default:tree", param2 = 12}, + {name = "air", prob = 0}, + {name = "flowers:mushroom_brown", prob = 63}, + {name = "air", prob = 0}, + {name = "air", prob = 0}, + }, +}) + + +-- Jungletree log + +mts_save("jungle_log", { + size = {x = 5, y = 2, z = 1}, + data = { + {name = "default:jungletree", param2 = 12, prob = 127}, + {name = "default:jungletree", param2 = 12}, + {name = "default:jungletree", param2 = 12}, + {name = "default:jungletree", param2 = 12}, + {name = "default:jungletree", param2 = 12, prob = 127}, + {name = "air", prob = 0}, + {name = "air", prob = 0}, + {name = "flowers:mushroom_brown", prob = 127}, + {name = "air", prob = 0}, + {name = "air", prob = 0}, + }, +}) + + +-- Pine tree log + +mts_save("pine_log", { + size = {x = 5, y = 2, z = 1}, + data = { + {name = "default:pine_tree", param2 = 12, prob = 127}, + {name = "default:pine_tree", param2 = 12}, + {name = "default:pine_tree", param2 = 12}, + {name = "default:pine_tree", param2 = 12}, + {name = "default:pine_tree", param2 = 12, prob = 127}, + {name = "air", prob = 0}, + {name = "air", prob = 0}, + {name = "flowers:mushroom_red", prob = 63}, + {name = "air", prob = 0}, + {name = "air", prob = 0}, + }, +}) + + +-- Acacia tree log + +mts_save("acacia_log", { + size = {x = 5, y = 1, z = 1}, + data = { + {name = "default:acacia_tree", param2 = 12, prob = 127}, + {name = "default:acacia_tree", param2 = 12}, + {name = "default:acacia_tree", param2 = 12}, + {name = "default:acacia_tree", param2 = 12}, + {name = "default:acacia_tree", param2 = 12, prob = 127}, + }, +}) + + +-- Aspen tree log + +mts_save("aspen_log", { + size = {x = 5, y = 2, z = 1}, + data = { + {name = "default:aspen_tree", param2 = 12, prob = 127}, + {name = "default:aspen_tree", param2 = 12}, + {name = "default:aspen_tree", param2 = 12}, + {name = "default:aspen_tree", param2 = 12}, + {name = "default:aspen_tree", param2 = 12, prob = 127}, + {name = "air", prob = 0}, + {name = "flowers:mushroom_red", prob = 63}, + {name = "flowers:mushroom_brown", prob = 63}, + {name = "air", prob = 0}, + {name = "air", prob = 0}, + }, +}) + + +-- Large cactus + +local C = {name = "default:cactus", prob = 255, param2 = 20} +local R = {name = "default:cactus", prob = 255, param2 = 20, force_place = true} +local E = {name = "default:cactus", prob = 127, param2 = 20} + +mts_save("large_cactus", { + size = {x = 5, y = 7, z = 5}, + data = { + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + + _, _, C, _, _, + _, _, R, _, _, + _, _, C, _, _, + C, C, C, C, C, + C, _, C, _, C, + E, _, C, _, E, + _, _, C, _, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + _, _, _, _, _, + }, + yslice_prob = { + {ypos = 2, prob = 127}, + }, +}) + + +-- Papyrus + +mts_save("papyrus_on_dirt", { + size = {x = 1, y = 7, z = 1}, + data = { + {name = "default:dirt", prob = 255, force_place = true}, + {name = "default:dirt", prob = 255, force_place = true}, + {name = "default:papyrus", prob = 255}, + {name = "default:papyrus", prob = 255}, + {name = "default:papyrus", prob = 255}, + {name = "default:papyrus", prob = 255}, + {name = "default:papyrus", prob = 255}, + }, + yslice_prob = { + {ypos = 2, prob = 127}, + {ypos = 3, prob = 127}, + }, +}) + +mts_save("papyrus_on_dry_dirt", { + size = {x = 1, y = 7, z = 1}, + data = { + {name = "default:dry_dirt", prob = 255, force_place = true}, + {name = "default:dry_dirt", prob = 255, force_place = true}, + {name = "default:papyrus", prob = 255}, + {name = "default:papyrus", prob = 255}, + {name = "default:papyrus", prob = 255}, + {name = "default:papyrus", prob = 255}, + {name = "default:papyrus", prob = 255}, + }, + yslice_prob = { + {ypos = 2, prob = 127}, + {ypos = 3, prob = 127}, + }, +}) + + +-- Bush + +local L = {name = "default:bush_leaves", prob = 255} +local M = {name = "default:bush_leaves", prob = 191} +local N = {name = "default:bush_leaves", prob = 127} +local S = {name = "default:bush_stem", prob = 255, force_place = true} + +mts_save("bush", { + size = {x = 3, y = 3, z = 3}, + data = { + _, _, _, + M, L, M, + N, M, N, + + _, _, _, + L, S, L, + M, L, M, + + _, _, _, + M, L, M, + N, M, N, + }, +}) + + +-- Blueberry bush + +local L = {name = "default:blueberry_bush_leaves_with_berries", prob = 255, force_place = true} +local M = {name = "default:blueberry_bush_leaves_with_berries", prob = 223} +local N = {name = "default:blueberry_bush_leaves_with_berries", prob = 95} + +mts_save("blueberry_bush", { + size = {x = 3, y = 1, z = 3}, + data = { + N, M, N, + + M, L, M, + + N, M, N, + }, +}) + + +-- Acacia bush + +local L = {name = "default:acacia_bush_leaves", prob = 255} +local M = {name = "default:acacia_bush_leaves", prob = 191} +local N = {name = "default:acacia_bush_leaves", prob = 127} +local S = {name = "default:acacia_bush_stem", prob = 255, force_place = true} + +mts_save("acacia_bush", { + size = {x = 3, y = 3, z = 3}, + data = { + _, _, _, + N, M, N, + M, L, M, + + _, _, _, + M, S, M, + L, L, L, + + _, _, _, + N, M, N, + M, L, M, + }, +}) + + +-- Pine bush + +local L = {name = "default:pine_bush_needles", prob = 255} +local M = {name = "default:pine_bush_needles", prob = 191} +local N = {name = "default:pine_bush_needles", prob = 127} +local S = {name = "default:pine_bush_stem", prob = 255, force_place = true} + +mts_save("pine_bush", { + size = {x = 3, y = 3, z = 3}, + data = { + _, _, _, + M, L, M, + N, M, N, + + _, _, _, + L, S, L, + M, L, M, + + _, _, _, + M, L, M, + N, M, N, + }, +}) diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..d648ea4 Binary files /dev/null and b/screenshot.png differ diff --git a/settingtypes.txt b/settingtypes.txt new file mode 100644 index 0000000..eff1e90 --- /dev/null +++ b/settingtypes.txt @@ -0,0 +1,77 @@ +# This file contains settings of minetest_game that can be changed in +# minetest.conf + +# In creative mode players are able to dig all kind of blocks nearly +# instantly, and have access to unlimited resources. +# Some of the functionality is only available if this setting is present +# at startup. +creative_mode (Creative mode) bool false + +# Flammable nodes will be ignited by nearby igniters. Spreading fire may +# cause severe destruction. +# Spreading fire nodes will disappear when fire is disabled, but +# 'permanent_flame' nodes are unaffected. +enable_fire (Fire) bool true + +# Enable flame sound. +flame_sound (Flame sound) bool true + +# Enable lavacooling. +enable_lavacooling (Lavacooling) bool true + +# If enabled, steel tools, torches and cobblestone will be given to new +# players. +give_initial_stuff (Give initial items) bool false + +# If enabled, players respawn at the bed they last lay on instead of normal +# spawn. +# This setting is only read at startup. +enable_bed_respawn (Respawn at bed) bool true + +# If enabled, the night can be skipped if more than half of the players are +# in beds. +enable_bed_night_skip (Skip night when sleeping) bool true + +# If enabled, fences and walls cannot be jumped over. +enable_fence_tall (Tall fences and walls) bool false + +# When TNT explodes, it destroys nearby nodes and damages nearby players. +# This setting is disabled by default on servers. +enable_tnt (TNT) bool true + +# The radius in which nodes will be destroyed by a TNT explosion. +tnt_radius (TNT radius) int 3 0 + +# Sets the behaviour of the inventory items when a player dies. +# bones: Store items in a bone node but drop items if inside protected area. +# drop: Drop items on the ground. +# keep: Player keeps items. +bones_mode (Bones mode) enum bones bones,drop,keep + +# The time in seconds after which the bones of a dead player can be looted +# by everyone. +# Setting this to 0 will disable sharing of bones completely. +share_bones_time (Bones share time) int 1200 0 + +# How much earlier the bones of a dead player can be looted by +# everyone if the player dies in a protected area they don't own. +# 0 to disable. By default it is "share_bones_time" divide by four. +share_bones_time_early (Earlier bones share time) int 300 0 + +# Inform player of condition and location of new bones. +bones_position_message (Inform player about bones) bool false + +# Replaces old stairs with new ones. Only required for older worlds. +enable_stairs_replace_abm (Replace old stairs) bool false + +# If enabled, use the engine's spawn search which does not check for a +# suitable starting biome. +engine_spawn (Use engine spawn search) bool false + +# Whether river water source nodes create flowing sounds. +# Helps rivers create more sound, especially on level sections. +river_source_sounds (River source node sounds) bool false + +# Enable cloud variation by the 'weather' mod. +# Non-functional in V6 or Singlenode mapgens. +enable_weather (Enable weather) bool true diff --git a/utils/optimize_textures.sh b/utils/optimize_textures.sh new file mode 100644 index 0000000..2f9a6da --- /dev/null +++ b/utils/optimize_textures.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# Colors with 0 alpha need to be preserved, because opaque leaves ignore alpha. +# For that purpose, the use of indexed colors is disabled (-nc). + +find -name '../*.png' -print0 | xargs -0 optipng -o7 -zm1-9 -nc -strip all -clobber