develop #35

Merged
milan merged 16 commits from develop into master 2021-07-24 12:49:35 +02:00
121 changed files with 2343 additions and 1516 deletions
Showing only changes of commit a8d9bba4b3 - Show all commits

View file

@ -2,14 +2,14 @@
local S = minetest.get_translator(minetest.get_current_modname())
local F = minetest.formspec_escape
local has_technic = minetest.get_modpath("technic") ~= nil
local ui = unified_inventory
if not minetest.global_exists("unified_inventory") then
minetest.log("warning", S("3d_armor_ui: Mod loaded but unused."))
minetest.log("warning", "3d_armor_ui: Mod loaded but unused.")
return
end
if unified_inventory.sfinv_compat_layer then
local ui = unified_inventory
if ui.sfinv_compat_layer then
return
end

View file

@ -4,7 +4,6 @@
### init.lua ###
3d Armor=Armure 3d
3d_armor_ui: Mod loaded but unused.=3d_armor_ui : Mod chargé mais inutilisé.
Armor=Armure
Armor not initialized!=Armure non initialisée !
Fire=Feu

View file

@ -4,7 +4,6 @@
### init.lua ###
3d Armor=
3d_armor_ui: Mod loaded but unused.=
Armor=
Armor not initialized!=
Fire=

View file

@ -640,10 +640,34 @@ function worldedit.clear_objects(pos1, pos2)
worldedit.keep_loaded(pos1, pos2)
local function should_delete(obj)
-- Avoid players and WorldEdit entities
if obj:is_player() then
return false
end
local entity = obj:get_luaentity()
return not entity or not entity.name:find("^worldedit:")
end
-- Offset positions to include full nodes (positions are in the center of nodes)
local pos1x, pos1y, pos1z = pos1.x - 0.5, pos1.y - 0.5, pos1.z - 0.5
local pos2x, pos2y, pos2z = pos2.x + 0.5, pos2.y + 0.5, pos2.z + 0.5
local count = 0
if minetest.get_objects_in_area then
local objects = minetest.get_objects_in_area({x=pos1x, y=pos1y, z=pos1z},
{x=pos2x, y=pos2y, z=pos2z})
for _, obj in pairs(objects) do
if should_delete(obj) then
obj:remove()
count = count + 1
end
end
return count
end
-- Fallback implementation via get_objects_inside_radius
-- Center of region
local center = {
x = pos1x + ((pos2x - pos1x) / 2),
@ -655,12 +679,8 @@ function worldedit.clear_objects(pos1, pos2)
(center.x - pos1x) ^ 2 +
(center.y - pos1y) ^ 2 +
(center.z - pos1z) ^ 2)
local count = 0
for _, obj in pairs(minetest.get_objects_inside_radius(center, radius)) do
local entity = obj:get_luaentity()
-- Avoid players and WorldEdit entities
if not obj:is_player() and (not entity or
not entity.name:find("^worldedit:")) then
if should_delete(obj) then
local pos = obj:get_pos()
if pos.x >= pos1x and pos.x <= pos2x and
pos.y >= pos1y and pos.y <= pos2y and

View file

@ -149,7 +149,6 @@ minetest.register_entity("advtrains:couple", {
end
self.position_set=true
end
atprintbm("couple step", t)
advtrains.atprint_context_tid=nil
end,
})

View file

@ -116,6 +116,8 @@ function ndb.load_callback(file)
local stid_byte = file:read(2)
local stid = bytes_to_int(stid_byte)
local stna = file:read("*l")
-- possibly windows fix: strip trailing \r's from line
stna = string.gsub(stna, "\r$", "")
--atdebug("content id:", stid, "->", stna)
ndb_nodeids[stid] = stna
end

View file

@ -286,6 +286,7 @@ function tp.register_track_placer(nnprefix, imgprefix, dispname, def)
return itemstack, false
end
if minetest.registered_nodes[minetest.get_node(pos).name] and minetest.registered_nodes[minetest.get_node(pos).name].buildable_to then
local s
if def.suitable_substrate then
s = def.suitable_substrate(upos)
else

View file

@ -524,7 +524,7 @@ function advtrains.register_tracks(tracktype, def, preset)
end
ndef.on_rightclick = function(pos, node, player)
if advtrains.check_turnout_signal_protection(pos, player:get_player_name()) then
advtrains.setstate(pos, newstate, node)
advtrains.setstate(pos, nil, node)
advtrains.log("Switch", player:get_player_name(), pos)
end
end
@ -667,7 +667,7 @@ function sl.create_slopeplacer_on_place(def, preset)
local yaw=player.get_look_horizontal and player:get_look_horizontal() or (player:get_look_yaw() - math.pi/2)
--rounding unit vectors is a nice way for selecting 1 of 8 directions since sin(30°) is 0.5.
dirvec={x=math.floor(math.sin(-yaw)+0.5), y=0, z=math.floor(math.cos(-yaw)+0.5)}
local dirvec={x=math.floor(math.sin(-yaw)+0.5), y=0, z=math.floor(math.cos(-yaw)+0.5)}
--translate to direction to look up inside the preset table
local param2, rot45=({
[-1]={

View file

@ -139,11 +139,14 @@ minetest.register_on_joinplayer(function(player)
advtrains.hhud[player:get_player_name()] = nil
--independent of this, cause all wagons of the train which are loaded to reattach their players
--needed because already loaded wagons won't call reattach_all()
local id=advtrains.player_to_train_mapping[pname]
if id then
for _,wagon in pairs(minetest.luaentities) do
if wagon.is_wagon and wagon.initialized and wagon.train_id==id then
wagon:reattach_all()
end
end
end
end)
@ -160,6 +163,8 @@ minetest.register_on_dieplayer(function(player)
wagon:get_off_plr(pname)
end
end
-- just in case no wagon felt responsible for this player: clear train mapping
advtrains.player_to_train_mapping[pname] = nil
end
end)
@ -1077,6 +1082,12 @@ function advtrains.split_train_at_index(train, index)
return
end
-- make sure that the train is fully on track before splitting. May cause problems otherwise
if train.index > train.path_trk_f or train.end_index < train.path_trk_b then
atwarn("Train",train_id,": cannot split train because it is off track!")
return
end
local p_index=advtrains.path_get_index_by_offset(train, train.index, - data.pos_in_train + wagon.wagon_span)
local pos, connid, frac = advtrains.path_getrestore(train, p_index)
local tp = {}

View file

@ -934,6 +934,7 @@ function wagon:show_bordcom(pname)
if not self:train() then return end
local train = self:train()
local data = advtrains.wagons[self.id]
local linhei
local form = "size[11,9]label[0.5,0;AdvTrains Boardcom v0.1]"
form=form.."textarea[0.5,1.5;7,1;text_outside;"..attrans("Text displayed outside on train")..";"..(minetest.formspec_escape(train.text_outside or "")).."]"

View file

@ -201,7 +201,10 @@ advtrains.register_tracks("default", {
--set arrowconn (for ATC)
local ph=minetest.pos_to_string(pos)
local _, conns=advtrains.get_rail_info_at(pos, advtrains.all_tracktypes)
atlatc.active.nodes[ph].arrowconn=conns[1].c
local nodeent = atlatc.active.nodes[ph]
if nodeent then
nodeent.arrowconn=conns[1].c
end
end,
advtrains = {

View file

@ -2,12 +2,8 @@
-- Lua automation features for advtrains
-- Uses global table 'atlatc' (AdvTrains_LuaATC)
-- Boilerplate to support localized strings if intllib mod is installed.
if intllib then
atltrans = intllib.Getter()
else
atltrans = function(s,a,...)a={a,...}return s:gsub("@(%d+)",function(n)return a[tonumber(n)]end)end
end
--TODO: re-add localization (if merging localization, discard this hunk please)
atltrans = function(s,a,...)a={a,...}return s:gsub("@(%d+)",function(n)return a[tonumber(n)]end)end
--Privilege
--Only trusted players should be enabled to build stuff which can break the server.

View file

@ -228,7 +228,7 @@ local function train_load(pos, train_id, unload)
for k, v in ipairs(train.trainparts) do
local i=minetest.get_inventory({type="detached", name="advtrains_wgn_"..v})
if i then
if i and i:get_list("box") then
if not unload then
for _, item in ipairs(inv:get_list("main")) do
if i:get_list("box") and i:room_for_item("box", item) then

View file

@ -107,7 +107,7 @@ function serialize_lib.load_atomic(filename, callback)
end
end
if minetest.settings:get_bool("serialize_lib_strict_loading") then
if minetest.settings:get_bool("serialize_lib_strict_loading", true) then
serialize_lib.save_lock = true
error("Loading data from file '"..filename.."' failed:\n"
..ret.."\nDisable Strict Loading to ignore.")

View file

@ -117,6 +117,8 @@ function read_table(t, file)
file:close()
error("Unexpected EOF or read error!")
end
-- possibly windows fix: strip trailing \r's from line
line = string.gsub(line, "\r$", "")
if line=="E" then
-- done with this table
@ -203,6 +205,8 @@ end
-- config: see above
local function read_from_fd(file)
local first_line = file:read("*line")
-- possibly windows fix: strip trailing \r's from line
first_line = string.gsub(first_line, "\r$", "")
if not string.match(first_line, "LUA_SER v=[12]") then
file:close()
error("Expected header, got '"..first_line.."' instead!")
@ -210,6 +214,8 @@ local function read_from_fd(file)
local t = {}
read_table(t, file)
local last_line = file:read("*line")
-- possibly windows fix: strip trailing \r's from line
last_line = string.gsub(last_line, "\r$", "")
file:close()
if last_line ~= "END_SER" then
error("Missing END_SER, got '"..last_line.."' instead!")

View file

@ -129,13 +129,13 @@ local get_ambience = function(player, tod, name)
pos.y = pos.y + 1.4 -- head level
local nod_head = pplus and name and playerplus[name].nod_head or
minetest.get_node(pos).name
local nod_head = pplus and name and playerplus[name]
and playerplus[name].nod_head or minetest.get_node(pos).name
pos.y = pos.y - 1.2 -- foot level
local nod_feet = pplus and name and playerplus[name].nod_feet or
minetest.get_node(pos).name
local nod_feet = pplus and name and playerplus[name]
and playerplus[name].nod_feet or minetest.get_node(pos).name
pos.y = pos.y - 0.2 -- reset pos

View file

@ -4,5 +4,6 @@ farming?
ethereal?
moreores?
3d_armor?
shields?
xanadu?
mobs?

View file

@ -208,6 +208,7 @@ local anvildef = {
is_ground_content = false,
paramtype2 = "facedir",
drawtype = "nodebox",
use_texture_alpha = "clip",
node_box = {
type = "fixed",
fixed = {

View file

@ -180,4 +180,7 @@ if minetest.get_modpath("xanadu") then
add_tool("xanadu:chestplate_ccrystal", "ethereal:crystal_ingot", 8)
add_tool("xanadu:leggings_ccrystal", "ethereal:crystal_ingot", 7)
add_tool("xanadu:boots_ccrystal", "ethereal:crystal_ingot", 4)
add_tool("3d_armor:boots_nyan", "nyancat:nyancat_rainbow", 4)
add_tool("3d_armor:helmet_watercrystal", "ethereal:crystal_ingot", 5)
add_tool("3d_armor:boots_mese", "default:mese_crystal", 8)
end

2
mods/basic_trains/advtrains_train_industrial/init.lua Normal file → Executable file
View file

@ -45,7 +45,7 @@ advtrains.register_wagon("engine_industrial_big", {
seats = {
{
name=S("Driver Stand (right)"),
attach_offset={x=5, y=7, z=20},
attach_offset={x=5, y=-3, z=20},
view_offset={x=5.2, y=-4, z=11},
driving_ctrl_access=true,
group = "dstand",

View file

@ -81,13 +81,13 @@ advtrains.register_wagon("detailed_steam_engine", {
seats = {
{
name=S("Driver Stand (left)"),
attach_offset={x=-5, y=10, z=-10},
attach_offset={x=-8, y=0, z=-10},
view_offset={x=9, y=-2, z=-6},
group = "dstand",
},
{
name=S("Driver Stand (right)"),
attach_offset={x=5, y=10, z=-10},
attach_offset={x=8, y=0, z=-10},
view_offset={x=0, y=6, z=0},
group = "dstand",
},

View file

@ -0,0 +1,198 @@
Copyright (C) 2016-2020 Moritz Blei (orwell96) and contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
=================================
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright © 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software.
A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public.
The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version.
An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based on the Program.
To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work.
A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices".
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph.
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation.
If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.

View file

@ -0,0 +1,68 @@
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
1. Definitions
"Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed, or adapted including in any form recognizably derived from the original, except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or phonogram, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License.
"Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances, phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(f) below, which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not be considered an Adaptation (as defined below) for the purposes of this License.
"Creative Commons Compatible License" means a license that is listed at https://creativecommons.org/compatiblelicenses that has been approved by Creative Commons as being essentially equivalent to this License, including, at a minimum, because that license: (i) contains terms that have the same purpose, meaning and effect as the License Elements of this License; and, (ii) explicitly permits the relicensing of adaptations of works made available under that license under this License or a Creative Commons jurisdiction license with the same License Elements as this License.
"Distribute" means to make available to the public the original and copies of the Work or Adaptation, as appropriate, through sale or other transfer of ownership.
"License Elements" means the following high-level license attributes as selected by Licensor and indicated in the title of this License: Attribution, ShareAlike.
"Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License.
"Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the broadcast.
"Work" means the literary and/or artistic work offered under the terms of this License including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; a musical composition with or without words; a cinematographic work to which are assimilated works expressed by a process analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan, sketch or three-dimensional work relative to geography, topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise considered a literary or artistic work.
"You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation.
"Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and the communication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images.
"Reproduce" means to make copies of the Work by any means including without limitation by sound or visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a protected performance or phonogram in digital form or other electronic medium.
2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or other applicable laws.
3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below:
to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections;
to create and Reproduce Adaptations provided that any such Adaptation, including any translation in any medium, takes reasonable steps to clearly label, demarcate or otherwise identify that changes were made to the original Work. For example, a translation could be marked "The original work was translated from English to Spanish," or a modification could indicate "The original work has been modified.";
to Distribute and Publicly Perform the Work including as incorporated in Collections; and,
to Distribute and Publicly Perform Adaptations.
For the avoidance of doubt:
Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License;
Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor waives the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; and,
Voluntary License Schemes. The Licensor waives the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License.
The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. Subject to Section 8(f), all rights not expressly granted by Licensor are hereby reserved.
4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:
You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(c), as requested. If You create an Adaptation, upon notice from any Licensor You must, to the extent practicable, remove from the Adaptation any credit as required by Section 4(c), as requested.
You may Distribute or Publicly Perform an Adaptation only under the terms of: (i) this License; (ii) a later version of this License with the same License Elements as this License; (iii) a Creative Commons jurisdiction license (either this or a later license version) that contains the same License Elements as this License (e.g., Attribution-ShareAlike 3.0 US)); (iv) a Creative Commons Compatible License. If you license the Adaptation under one of the licenses mentioned in (iv), you must comply with the terms of that license. If you license the Adaptation under the terms of any of the licenses mentioned in (i), (ii) or (iii) (the "Applicable License"), you must comply with the terms of the Applicable License generally and the following provisions: (I) You must include a copy of, or the URI for, the Applicable License with every copy of each Adaptation You Distribute or Publicly Perform; (II) You may not offer or impose any terms on the Adaptation that restrict the terms of the Applicable License or the ability of the recipient of the Adaptation to exercise the rights granted to that recipient under the terms of the Applicable License; (III) You must keep intact all notices that refer to the Applicable License and to the disclaimer of warranties with every copy of the Work as included in the Adaptation You Distribute or Publicly Perform; (IV) when You Distribute or Publicly Perform the Adaptation, You may not impose any effective technological measures on the Adaptation that restrict the ability of a recipient of the Adaptation from You to exercise the rights granted to that recipient under the terms of the Applicable License. This Section 4(b) applies to the Adaptation as incorporated in a Collection, but this does not require the Collection apart from the Adaptation itself to be made subject to the terms of the Applicable License.
If You Distribute, or Publicly Perform the Work or any Adaptations or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and (iv) , consistent with Ssection 3(b), in the case of an Adaptation, a credit identifying the use of the Work in the Adaptation (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). The credit required by this Section 4(c) may be implemented in any reasonable manner; provided, however, that in the case of a Adaptation or Collection, at a minimum such credit will appear, if a credit for all contributing authors of the Adaptation or Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties.
Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation. Licensor agrees that in those jurisdictions (e.g. Japan), in which any exercise of the right granted in Section 3(b) of this License (the right to make Adaptations) would be deemed to be a distortion, mutilation, modification or other derogatory action prejudicial to the Original Author's honor and reputation, the Licensor will waive or not assert, as appropriate, this Section, to the fullest extent permitted by the applicable national law, to enable You to reasonably exercise Your right under Section 3(b) of this License (right to make Adaptations) but not otherwise.
5. Representations, Warranties and Disclaimer
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
7. Termination
This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Adaptations or Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License.
Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above.
8. Miscellaneous
Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License.
Each time You Distribute or Publicly Perform an Adaptation, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License.
If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent.
This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You.
The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law.
Creative Commons Notice
Creative Commons is not a party to this License, and makes no warranty whatsoever in connection with the Work. Creative Commons will not be liable to You or any party on any legal theory for any damages whatsoever, including without limitation any general, special, incidental or consequential damages arising in connection to this license. Notwithstanding the foregoing two (2) sentences, if Creative Commons has expressly identified itself as the Licensor hereunder, it shall have all rights and obligations of Licensor.
Except for the limited purpose of indicating to the public that the Work is licensed under the CCPL, Creative Commons does not authorize the use by either party of the trademark "Creative Commons" or any related trademark or logo of Creative Commons without the prior written consent of Creative Commons. Any permitted use will be in compliance with Creative Commons' then-current trademark usage guidelines, as may be published on its website or otherwise made available upon request from time to time. For the avoidance of doubt, this trademark restriction does not form part of the License.
Creative Commons may be contacted at https://creativecommons.org/.

View file

@ -1,30 +1,28 @@
This document describes the Plantlife mod API.
Last revision: 2015-02-16
Last revision: 2021-04-20
=========
Functions
=========
There are three main functions defined by the main "biome_lib" mod:
There are two main functions defined by this mod:
spawn_on_surfaces()
register_generate_plant()
grow_plants()
biome_lib.register_active_spawner()
biome_lib.register_on_generate()
There are also several internal, helper functions that can be called if so
desired, but they are not really intended for use by other mods and may change
at any time. They are briefly described below these main functions, but see
init.lua for details.
Most functions in plants lib are declared locally to avoid namespace
collisions with other mods. They are accessible via the "biome_lib" method,
e.g. biome_lib:spawn_on_surfaces() and so forth.
Most functions in biome_lib are either declared locally or kept within its
own namespace to avoid collisions/conflicts with other mods.
=====
spawn_on_surfaces(biome)
spawn_on_surfaces(sdelay, splant, sradius, schance, ssurface, savoid)
biome_lib.register_active_spawner(biome)
biome_lib.register_active_spawner(sdelay, splant, sradius, schance, ssurface, savoid)
This first function is an ABM-based spawner function originally created as
part of Ironzorg's flowers mod. It has since been largely extended and
@ -112,9 +110,9 @@ biome = {
depth_max = num, -- If the object spawns on top of a water source, the
-- water must be at most this deep. Defaults to 1.
min_elevation = num, -- Surface must be at this altitude or higher to
-- spawn at all. Defaults to -31000...
max_elevation = num, -- ...but must be no higher than this altitude.
-- Defaults to +31000.
-- spawn at all. Defaults to -16 meters.
max_elevation = num, -- Surface must be no higher than this altitude.
-- Defaults to +48.
near_nodes = {table}, -- List of nodes that must be somewhere in the
-- vicinity in order for the plant to spawn. Can also
-- be a string with a single node name. If not
@ -220,7 +218,7 @@ checking is disabled. Same holds true for the nneighbors bit above that.
=====
biome_lib:register_generate_plant(biome, nodes_or_function_or_treedef)
biome_lib.register_on_generate(biome, nodes_or_function_or_treedef)
To register an object to be spawned at mapgen time rather than via an ABM,
call this function with two parameters: a table with your object's biome
@ -270,8 +268,8 @@ biome = {
depth = num, -- How deep/thick of a layer the spawned-on node must
-- be. Typically used for water.
min_elevation = num, -- Minimum elevation in meters/nodes. Defaults to
-- -31000 (unlimited).
max_elevation = num, -- Max elevation. Defaults to +31000 (unlimited).
-- -16 meters.
max_elevation = num, -- Max elevation. Defaults to +48m.
near_nodes = {table}, -- what nodes must be in the general vicinity of the
-- object being spawned.
near_nodes_size = num, -- how wide of a search area to look for the nodes
@ -334,18 +332,17 @@ will be called in the form:
somefunction(pos)
=====
biome_lib:grow_plants(options)
biome_lib.update_plant(options)
The third function, grow_plants() is used to turn the spawned nodes above
into something else over time. This function has no return value, and accepts
a biome definition table as the only parameter. These are defined like so:
This third function is used to turn the spawned nodes above into something
else over time. This function has no return value, and accepts a biome
definition table as the only parameter. These are defined like so:
options = {
label = string, -- set this to identify the ABM for Minetest's
-- profiler. If not set, biome_lib will set it to
-- "biome_lib grow_plants(): " appended with the node
-- "biome_lib.update_plant(): " appended with the node
-- in grow_plant (or the first item if it's a table)
grow_plant = "string" or {table}, -- Name(s) of the node(s) to be grown
-- into something else. This value is passed to the
@ -426,7 +423,7 @@ and grow_result is ignored.
=====
find_adjacent_wall(pos, verticals, randomflag)
biome_lib.find_adjacent_wall(pos, verticals, randomflag)
Of the few helper functions, this one expects a position parameter and a table
with the list of nodes that should be considered as walls. The code will
@ -438,7 +435,7 @@ random wall it finds adjacent to the target position. Defaults to false if
not specified.
=====
is_node_loaded(pos)
biome_lib.is_node_loaded(pos)
This acts as a wrapper for the minetest.get_node_or_nil(node_pos)
function and accepts a single position parameter. Returns true if the node in
@ -446,7 +443,7 @@ question is already loaded, or false if not.
=====
dbg(string, level)
biome_lib.dbg(string, level)
This is a simple debug output function which takes one string parameter. It
just checks if DEBUG is true and outputs the phrase "[Plantlife] " followed by
@ -463,8 +460,8 @@ ought always be shown, 1 for errors, 2 for warnings, 3 for info, 4 for verbose
spammy stuff.
=====
biome_lib:generate_tree(pos, treemodel)
biome_lib:grow_tree(pos, treemodel)
biome_lib.generate_ltree(pos, treemodel)
biome_lib.grow_ltree(pos, treemodel)
In the case of the growing code and the mapgen-based tree generator code,
generating a tree is done via the above two calls, which in turn immediately
@ -472,13 +469,13 @@ call the usual spawn_tree() functions. This rerouting exists as a way for
other mods to hook into biome_lib's tree-growing functions in general,
perhaps to execute something extra whenever a tree is spawned.
biome_lib:generate_tree(pos, treemodel) is called any time a tree is spawned
biome_lib.generate_ltree(pos, treemodel) is called any time a tree is spawned
at map generation time. 'pos' is the position of the block on which the tree
is to be placed. 'treemodel' is the standard L-Systems tree definition table
expected by the spawn_tree() function. Refer to the 'trunk' field in that
table to derive the name of the tree being spawned.
biome_lib:grow_tree(pos, treemodel) does the same sort of thing whenever a
biome_lib.grow_ltree(pos, treemodel) does the same sort of thing whenever a
tree is spawned within the abm-based growing code, for example when growing a
sapling into a tree.
@ -487,22 +484,6 @@ sapling into a tree.
There are other, internal helper functions that are not meant for use by other
mods. Don't rely on them, as they are subject to change without notice.
===============
Global Settings
===============
Set this to true if you want the mod to spam your console with debug info :-)
plantlife_debug = false
To slow down the playback of the queue (e.g. for really slow machines where
the 0.2 second max limiter isn't enough), set:
biome_lib_queue_run_ratio = <some value 1 to 100>
Default is 100 (basically percent of maximum runtime)
======================
Fertile Ground Mapping
======================
@ -514,7 +495,6 @@ Perlin noise used.
The first one is for a "fertile ground" layer, which I tend to refer to as the
generic "stuff can potentially grow here" layer. Its values are hard-coded:
biome_lib.plantlife_seed_diff = 329
perlin_octaves = 3
perlin_persistence = 0.6
perlin_scale = 100
@ -611,3 +591,66 @@ See settingtypes.txt for a list. Any item listed there can be changed either
by adding it to your minetest.conf, or by using the "all settings" menu in
Minetest, whatever's appropriate for your particular setup.
==================
Engine Decorations
==================
If a call to biome_lib.register_on_generate() contains items and biome
definition settings that are suitable, biome_lib will pass that call on to the
engine instead, to use its built-in decorations feature, since it'll be much
faster than Lua.
For this to work, first the item to be added must either be a node, or a
table with a list of nodes that biome_lib would normally pick from randomly.
That is to say, you cannot specify an L-tree or a function here, as the engine
does not support that sort of thing (biome_lib will just switch to its normal
handling if you do).
Second, these biome definition items must not be present:
* below_nodes
* avoid_nodes
* avoid_radius
* neighbors
* ncount
* depth
* near_nodes_size
* near_nodes_vertical
* temp_min
* temp_max
* verticals_list
* delete_above
* delete_above_surround
The plantlife_limit definition item is ignored when checking if a particular
call can be routed to the engine.
The call given to the engine will use the remaining biome definition items in
the following manner:
deco_type = "simple",
flags = "all_floors"
decoration = node or table with node list
place_on = surface
y_min = min_elevation
y_max = max_elevation
spawn_by = near_nodes
num_spawn_by = near_nodes_count
param2 = \_ set to the range specified by the biome definition's
param2_max = / random_facedir table, if present, otherwise omitted
noise_params = {
octaves = biome_lib.fertile_perlin_octaves,
persist = biome_lib.fertile_perlin_persistence * (250/biome_lib.fertile_perlin_scale),
scale = ((100-biome.rarity)/100) * (math.min(biome.max_count, 6400)/6400),
seed = biome.seed_diff,
offset = 0,
spread = {x = 100, y = 100, z = 100},
lacunarity = 2,
flags = "absvalue"
}
If the biome definition's check_air setting is false, "force_placement" is
added to the decoration's flags setting.
If the biome def's spawn_replace_node is set to true, the decoration's
place_offset_y is set to -1 (otherwise it is omitted).

View file

@ -25,4 +25,6 @@ It is primarily intended for mapgen v6, but it should work fine when used with m
* biome_lib:find_valid_wall()
* biome_lib:is_node_loaded()
For a complete description of these functions as well as several of the internal variables within the mod, [read the API.txt document](https://raw.githubusercontent.com/minetest-mods/biome_lib/master/API.txt) included in this package.
For a complete description of these functions as well as several of the internal variables within the mod, see `API.txt`.
**Configuration:** This mod has several variables you can set in your `minetest.conf` to change things a bit, from the default nodes it uses, to the debug log level and the block queue behavior. For a list with complete descriptions, see `settingtypes.txt`.

689
mods/biome_lib/api.lua Normal file
View file

@ -0,0 +1,689 @@
biome_lib.block_log = {}
biome_lib.block_recheck_list = {}
biome_lib.run_block_recheck_list = false
biome_lib.actionslist_aircheck = {}
biome_lib.actionslist_no_aircheck = {}
biome_lib.surfaceslist_aircheck = {}
biome_lib.surfaceslist_no_aircheck = {}
biome_lib.registered_decorations = {}
biome_lib.fertile_perlin_octaves = 3
biome_lib.fertile_perlin_persistence = 0.6
biome_lib.fertile_perlin_scale = 100
local temperature_seeddiff = 112
local temperature_octaves = 3
local temperature_persistence = 0.5
local temperature_scale = 150
local humidity_seeddiff = 9130
local humidity_octaves = 3
local humidity_persistence = 0.5
local humidity_scale = 250
local time_speed = tonumber(minetest.settings:get("time_speed"))
biome_lib.time_scale = 1
if time_speed and time_speed > 0 then
biome_lib.time_scale = 72 / time_speed
end
biome_lib.air = {name = "air"}
-- the mapgen rarely creates useful surfaces outside this range, but mods can
-- still specify a wider range if needed.
biome_lib.mapgen_elevation_limit = { ["min"] = -16, ["max"] = 48 }
--PerlinNoise(seed, octaves, persistence, scale)
biome_lib.perlin_temperature = PerlinNoise(temperature_seeddiff, temperature_octaves, temperature_persistence, temperature_scale)
biome_lib.perlin_humidity = PerlinNoise(humidity_seeddiff, humidity_octaves, humidity_persistence, humidity_scale)
-- Local functions
local function tableize(s)
return string.split(string.trim(string.gsub(s, " ", "")))
end
function biome_lib.dbg(msg, level)
local l = tonumber(level) or 0
if biome_lib.debug_log_level >= l then
print(os.date("%Y-%m-%d %H:%M:%S").." [Biome Lib]: "..msg)
minetest.log("verbose", "[Biome Lib]: "..msg)
end
end
local function get_biome_data(pos, perlin_fertile)
local fertility = perlin_fertile:get_2d({x=pos.x, y=pos.z})
if type(minetest.get_biome_data) == "function" then
local data = minetest.get_biome_data(pos)
if data then
return fertility, data.heat / 100, data.humidity / 100
end
end
local temperature = biome_lib.perlin_temperature:get2d({x=pos.x, y=pos.z})
local humidity = biome_lib.perlin_humidity:get2d({x=pos.x+150, y=pos.z+50})
return fertility, temperature, humidity
end
function biome_lib.is_node_loaded(node_pos)
local n = minetest.get_node_or_nil(node_pos)
if (not n) or (n.name == "ignore") then
return false
end
return true
end
function biome_lib.set_defaults(biome)
biome.seed_diff = biome.seed_diff or 0
biome.min_elevation = biome.min_elevation or biome_lib.mapgen_elevation_limit.min
biome.max_elevation = biome.max_elevation or biome_lib.mapgen_elevation_limit.max
biome.temp_min = biome.temp_min or 1
biome.temp_max = biome.temp_max or -1
biome.humidity_min = biome.humidity_min or 1
biome.humidity_max = biome.humidity_max or -1
biome.plantlife_limit = biome.plantlife_limit or 0.1
biome.near_nodes_vertical = biome.near_nodes_vertical or 1
-- specific to on-generate
biome.neighbors = biome.neighbors or biome.surface
biome.near_nodes_size = biome.near_nodes_size or 0
biome.near_nodes_count = biome.near_nodes_count or 1
biome.rarity = biome.rarity or 50
biome.max_count = biome.max_count or 125
if biome.check_air ~= false then biome.check_air = true end
-- specific to abm spawner
biome.seed_diff = biome.seed_diff or 0
biome.light_min = biome.light_min or 0
biome.light_max = biome.light_max or 15
biome.depth_max = biome.depth_max or 1
biome.facedir = biome.facedir or 0
return biome
end
local function search_table(t, s)
for i = 1, #t do
if t[i] == s then return true end
end
return false
end
-- register the list of surfaces to spawn stuff on, filtering out all duplicates.
-- separate the items by air-checking or non-air-checking map eval methods
function biome_lib.register_on_generate(biomedef, nodes_or_function_or_model)
-- if calling code passes an undefined node for a surface or
-- as a node to be spawned, don't register an action for it.
if type(nodes_or_function_or_model) == "string"
and string.find(nodes_or_function_or_model, ":")
and not minetest.registered_nodes[nodes_or_function_or_model] then
biome_lib.dbg("Warning: Ignored registration for undefined spawn node: "..dump(nodes_or_function_or_model), 2)
return
end
if type(nodes_or_function_or_model) == "string"
and not string.find(nodes_or_function_or_model, ":") then
biome_lib.dbg("Warning: Registered function call using deprecated string method: "..dump(nodes_or_function_or_model), 2)
end
biome_lib.mapgen_elevation_limit.min = math.min(biomedef.min_elevation or 0, biome_lib.mapgen_elevation_limit.min)
biome_lib.mapgen_elevation_limit.max = math.max(biomedef.max_elevation or 0, biome_lib.mapgen_elevation_limit.max)
local decor_def = biome_lib.can_use_decorations(biomedef, nodes_or_function_or_model)
if decor_def then
biome_lib.dbg("Using engine decorations instead of biome_lib functions for node(s): "..dump(nodes_or_function_or_model), 3)
biome_lib.registered_decorations[#biome_lib.registered_decorations + 1] = nodes_or_function_or_model
minetest.register_decoration(decor_def)
return
elseif biomedef.check_air == false then
biome_lib.dbg("Register no-air-check mapgen hook: "..dump(nodes_or_function_or_model), 3)
biome_lib.actionslist_no_aircheck[#biome_lib.actionslist_no_aircheck + 1] = { biomedef, nodes_or_function_or_model }
local s = biomedef.surface
if type(s) == "string" then
if s and (string.find(s, "^group:") or minetest.registered_nodes[s]) then
if not search_table(biome_lib.surfaceslist_no_aircheck, s) then
biome_lib.surfaceslist_no_aircheck[#biome_lib.surfaceslist_no_aircheck + 1] = s
end
else
biome_lib.dbg("Warning: Ignored no-air-check registration for undefined surface node: "..dump(s), 2)
end
else
for i = 1, #biomedef.surface do
local s = biomedef.surface[i]
if s and (string.find(s, "^group:") or minetest.registered_nodes[s]) then
if not search_table(biome_lib.surfaceslist_no_aircheck, s) then
biome_lib.surfaceslist_no_aircheck[#biome_lib.surfaceslist_no_aircheck + 1] = s
end
else
biome_lib.dbg("Warning: Ignored no-air-check registration for undefined surface node: "..dump(s), 2)
end
end
end
else
biome_lib.dbg("Register with-air-checking mapgen hook: "..dump(nodes_or_function_or_model), 3)
biome_lib.actionslist_aircheck[#biome_lib.actionslist_aircheck + 1] = { biomedef, nodes_or_function_or_model }
local s = biomedef.surface
if type(s) == "string" then
if s and (string.find(s, "^group:") or minetest.registered_nodes[s]) then
if not search_table(biome_lib.surfaceslist_aircheck, s) then
biome_lib.surfaceslist_aircheck[#biome_lib.surfaceslist_aircheck + 1] = s
end
else
biome_lib.dbg("Warning: Ignored with-air-checking registration for undefined surface node: "..dump(s), 2)
end
else
for i = 1, #biomedef.surface do
local s = biomedef.surface[i]
if s and (string.find(s, "^group:") or minetest.registered_nodes[s]) then
if not search_table(biome_lib.surfaceslist_aircheck, s) then
biome_lib.surfaceslist_aircheck[#biome_lib.surfaceslist_aircheck + 1] = s
end
else
biome_lib.dbg("Warning: Ignored with-air-checking registration for undefined surface node: "..dump(s), 2)
end
end
end
end
end
-- Function to check whether a position matches the given biome definition
-- Returns true when the surface can be populated
local function populate_single_surface(biome, pos, perlin_fertile_area, checkair)
local p_top = { x = pos.x, y = pos.y + 1, z = pos.z }
if math.random(1, 100) <= biome.rarity then
return
end
local fertility, temperature, humidity = get_biome_data(pos, perlin_fertile_area)
local pos_biome_ok = pos.y >= biome.min_elevation and pos.y <= biome.max_elevation
and fertility > biome.plantlife_limit
and temperature <= biome.temp_min and temperature >= biome.temp_max
and humidity <= biome.humidity_min and humidity >= biome.humidity_max
if not pos_biome_ok then
return -- Y position mismatch, outside of biome
end
local biome_surfaces_string = dump(biome.surface)
local surface_ok = false
if not biome.depth then
local dest_node = minetest.get_node(pos)
if string.find(biome_surfaces_string, dest_node.name) then
surface_ok = true
else
if string.find(biome_surfaces_string, "group:") then
for j = 1, #biome.surface do
if string.find(biome.surface[j], "^group:")
and minetest.get_item_group(dest_node.name, biome.surface[j]) then
surface_ok = true
break
end
end
end
end
elseif not string.find(biome_surfaces_string,
minetest.get_node({ x = pos.x, y = pos.y-biome.depth-1, z = pos.z }).name) then
surface_ok = true
end
if not surface_ok then
return -- Surface does not match the given node group/name
end
if checkair and minetest.get_node(p_top).name ~= "air" then
return
end
if biome.below_nodes and
not string.find(dump(biome.below_nodes),
minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
) then
return -- Node below does not match
end
if biome.ncount and
#minetest.find_nodes_in_area(
{x=pos.x-1, y=pos.y, z=pos.z-1},
{x=pos.x+1, y=pos.y, z=pos.z+1},
biome.neighbors
) <= biome.ncount then
return -- Not enough similar biome nodes around
end
if biome.near_nodes and
#minetest.find_nodes_in_area(
{x=pos.x-biome.near_nodes_size, y=pos.y-biome.near_nodes_vertical, z=pos.z-biome.near_nodes_size},
{x=pos.x+biome.near_nodes_size, y=pos.y+biome.near_nodes_vertical, z=pos.z+biome.near_nodes_size},
biome.near_nodes
) < biome.near_nodes_count then
return -- Long distance neighbours do not match
end
-- Position fits into given biome
return true
end
function biome_lib.populate_surfaces(b, nodes_or_function_or_model, snodes, checkair)
local items_added = 0
local biome = biome_lib.set_defaults(b)
-- filter stage 1 - find nodes from the supplied surfaces that are within the current biome.
local in_biome_nodes = {}
local perlin_fertile_area = minetest.get_perlin(biome.seed_diff, biome_lib.fertile_perlin_octaves, biome_lib.fertile_perlin_persistence, biome_lib.fertile_perlin_scale)
for i = 1, #snodes do
local pos = vector.new(snodes[i])
if populate_single_surface(biome, pos, perlin_fertile_area, checkair) then
in_biome_nodes[#in_biome_nodes + 1] = pos
end
end
-- filter stage 2 - find places within that biome area to place the plants.
local num_in_biome_nodes = #in_biome_nodes
if num_in_biome_nodes == 0 then
return 0
end
for i = 1, math.min(math.ceil(biome.max_count/25), num_in_biome_nodes) do
local tries = 0
local spawned = false
while tries < 2 and not spawned do
local pos = in_biome_nodes[math.random(1, num_in_biome_nodes)]
if biome.spawn_replace_node then
pos.y = pos.y-1
end
local p_top = { x = pos.x, y = pos.y + 1, z = pos.z }
if not (biome.avoid_nodes and biome.avoid_radius
and minetest.find_node_near(p_top, biome.avoid_radius
+ math.random(-1.5,2), biome.avoid_nodes)) then
if biome.delete_above then
minetest.swap_node(p_top, biome_lib.air)
minetest.swap_node({x=p_top.x, y=p_top.y+1, z=p_top.z}, biome_lib.air)
end
if biome.delete_above_surround then
minetest.swap_node({x=p_top.x-1, y=p_top.y, z=p_top.z}, biome_lib.air)
minetest.swap_node({x=p_top.x+1, y=p_top.y, z=p_top.z}, biome_lib.air)
minetest.swap_node({x=p_top.x, y=p_top.y, z=p_top.z-1}, biome_lib.air)
minetest.swap_node({x=p_top.x, y=p_top.y, z=p_top.z+1}, biome_lib.air)
minetest.swap_node({x=p_top.x-1, y=p_top.y+1, z=p_top.z}, biome_lib.air)
minetest.swap_node({x=p_top.x+1, y=p_top.y+1, z=p_top.z}, biome_lib.air)
minetest.swap_node({x=p_top.x, y=p_top.y+1, z=p_top.z-1}, biome_lib.air)
minetest.swap_node({x=p_top.x, y=p_top.y+1, z=p_top.z+1}, biome_lib.air)
end
if biome.spawn_replace_node then
minetest.swap_node(pos, biome_lib.air)
end
local objtype = type(nodes_or_function_or_model)
if objtype == "table" then
if nodes_or_function_or_model.axiom then
biome_lib.generate_ltree(p_top, nodes_or_function_or_model)
biome_lib.dbg("An L-tree was spawned at "..minetest.pos_to_string(p_top), 4)
spawned = true
else
local fdir = nil
if biome.random_facedir then
fdir = math.random(biome.random_facedir[1], biome.random_facedir[2])
end
local n=nodes_or_function_or_model[math.random(#nodes_or_function_or_model)]
minetest.swap_node(p_top, { name = n, param2 = fdir })
biome_lib.dbg("Node \""..n.."\" was randomly picked from a list and placed at "..minetest.pos_to_string(p_top), 4)
spawned = true
end
elseif objtype == "string" and
minetest.registered_nodes[nodes_or_function_or_model] then
local fdir = nil
if biome.random_facedir then
fdir = math.random(biome.random_facedir[1], biome.random_facedir[2])
end
minetest.swap_node(p_top, { name = nodes_or_function_or_model, param2 = fdir })
biome_lib.dbg("Node \""..nodes_or_function_or_model.."\" was placed at "..minetest.pos_to_string(p_top), 4)
spawned = true
elseif objtype == "function" then
nodes_or_function_or_model(pos)
biome_lib.dbg("A function was run on surface node at "..minetest.pos_to_string(pos), 4)
spawned = true
elseif objtype == "string" and pcall(loadstring(("return %s(...)"):
format(nodes_or_function_or_model)),pos) then
spawned = true
biome_lib.dbg("An obsolete string-specified function was run on surface node at "..minetest.pos_to_string(p_top), 4)
else
biome_lib.dbg("Warning: Ignored invalid definition for object "..dump(nodes_or_function_or_model).." that was pointed at {"..dump(pos).."}", 2)
end
else
tries = tries + 1
end
end
if spawned then items_added = items_added + 1 end
end
return items_added
end
-- Primary log read-out/mapgen spawner
local function confirm_block_surroundings(p)
local n=minetest.get_node_or_nil(p)
if not n or n.name == "ignore" then return false end
for x = -32,32,64 do -- step of 64 causes it to only check the 8 corner blocks
for y = -32,32,64 do
for z = -32,32,64 do
local n=minetest.get_node_or_nil({x=p.x + x, y=p.y + y, z=p.z + z})
if not n or n.name == "ignore" then return false end
end
end
end
return true
end
function biome_lib.generate_block(shutting_down)
if shutting_down then
if #biome_lib.block_recheck_list > 0 then
for i = 1, #biome_lib.block_recheck_list do
biome_lib.block_log[#biome_lib.block_log + 1] = biome_lib.block_recheck_list[i]
end
biome_lib.block_recheck_list = {}
end
biome_lib.run_block_recheck_list = false
else
if biome_lib.run_block_recheck_list
and not biome_lib.block_recheck_list[1] then
biome_lib.run_block_recheck_list = false
end
end
local blocklog = biome_lib.run_block_recheck_list
and biome_lib.block_recheck_list
or biome_lib.block_log
if not blocklog[1] then return end
local minp = blocklog[1][1]
local maxp = blocklog[1][2]
local airflag = blocklog[1][3]
local pos_hash = minetest.hash_node_position(minp)
if not biome_lib.pos_hash then -- we need to read the maplock and get the surfaces list
local now = minetest.get_us_time()
biome_lib.pos_hash = {}
minetest.load_area(minp)
if not confirm_block_surroundings(minp)
and not shutting_down
and (blocklog[1][4] + biome_lib.block_timeout) > now then -- if any neighbors appear not to be loaded and the block hasn't expired yet, defer it
if biome_lib.run_block_recheck_list then
biome_lib.block_log[#biome_lib.block_log + 1] = table.copy(biome_lib.block_recheck_list[1])
table.remove(biome_lib.block_recheck_list, 1)
else
biome_lib.block_recheck_list[#biome_lib.block_recheck_list + 1] = table.copy(biome_lib.block_log[1])
table.remove(biome_lib.block_log, 1)
end
biome_lib.pos_hash = nil
biome_lib.dbg("Mapblock at "..minetest.pos_to_string(minp)..
" had a neighbor not fully emerged, skipped it for now.", 4)
return
else
biome_lib.pos_hash.surface_node_list = airflag
and minetest.find_nodes_in_area_under_air(minp, maxp, biome_lib.surfaceslist_aircheck)
or minetest.find_nodes_in_area(minp, maxp, biome_lib.surfaceslist_no_aircheck)
if #biome_lib.pos_hash.surface_node_list == 0 then
biome_lib.dbg("Mapblock at "..minetest.pos_to_string(minp).." dequeued: no detected surfaces.", 4)
table.remove(blocklog, 1)
biome_lib.pos_hash = nil
return
else
biome_lib.pos_hash.action_index = 1
biome_lib.dbg("Mapblock at "..minetest.pos_to_string(minp)..
" has "..#biome_lib.pos_hash.surface_node_list..
" surface nodes to work on (airflag="..dump(airflag)..")", 4)
end
end
elseif not (airflag and biome_lib.actionslist_aircheck[biome_lib.pos_hash.action_index])
and not (not airflag and biome_lib.actionslist_no_aircheck[biome_lib.pos_hash.action_index]) then
-- the block is finished, remove it
if #biome_lib.pos_hash.surface_node_list > 0 then
biome_lib.dbg("Deleted mapblock "..minetest.pos_to_string(minp).." from the block log", 4)
end
table.remove(blocklog, 1)
biome_lib.pos_hash = nil
else
-- below, [1] is biome, [2] is the thing to be added
local added = 0
if airflag then
if biome_lib.actionslist_aircheck[biome_lib.pos_hash.action_index] then
added = biome_lib.populate_surfaces(
biome_lib.actionslist_aircheck[biome_lib.pos_hash.action_index][1],
biome_lib.actionslist_aircheck[biome_lib.pos_hash.action_index][2],
biome_lib.pos_hash.surface_node_list, true)
biome_lib.pos_hash.action_index = biome_lib.pos_hash.action_index + 1
end
else
if biome_lib.actionslist_no_aircheck[biome_lib.pos_hash.action_index] then
added = biome_lib.populate_surfaces(
biome_lib.actionslist_no_aircheck[biome_lib.pos_hash.action_index][1],
biome_lib.actionslist_no_aircheck[biome_lib.pos_hash.action_index][2],
biome_lib.pos_hash.surface_node_list, false)
biome_lib.pos_hash.action_index = biome_lib.pos_hash.action_index + 1
end
end
if added > 0 then
biome_lib.dbg("biome_lib.populate_surfaces ran on mapblock at "..
minetest.pos_to_string(minp)..". Entry #"..
(biome_lib.pos_hash.action_index-1).." added "..added.." items.", 4)
end
end
end
-- The spawning ABM
function biome_lib.register_active_spawner(sd,sp,sr,sc,ss,sa)
local b = {}
if type(sd) ~= "table" then
b.spawn_delay = sd -- old api expects ABM interval param here.
b.spawn_plants = {sp}
b.avoid_radius = sr
b.spawn_chance = sc
b.spawn_surfaces = {ss}
b.avoid_nodes = sa
else
b = sd
end
if b.spawn_delay*biome_lib.time_scale >= 1 then
b.interval = b.spawn_delay*biome_lib.time_scale
else
b.interval = 1
end
local biome = biome_lib.set_defaults(b)
biome.spawn_plants_count = #(biome.spawn_plants)
local n
if type(biome.spawn_plants) == "table" then
n = "random: "..biome.spawn_plants[1]..", ..."
else
n = biome.spawn_plants
end
biome.label = biome.label or "biome_lib spawn_on_surfaces(): "..n
minetest.register_abm({
nodenames = biome.spawn_surfaces,
interval = biome.interval,
chance = biome.spawn_chance,
neighbors = biome.neighbors,
label = biome.label,
action = function(pos, node, active_object_count, active_object_count_wider)
local p_top = { x = pos.x, y = pos.y + 1, z = pos.z }
local n_top = minetest.get_node(p_top)
local perlin_fertile_area = minetest.get_perlin(biome.seed_diff, biome_lib.fertile_perlin_octaves, biome_lib.fertile_perlin_persistence, biome_lib.fertile_perlin_scale)
local fertility, temperature, humidity = get_biome_data(pos, perlin_fertile_area)
local pos_biome_ok = pos.y >= biome.min_elevation and pos.y <= biome.max_elevation
and fertility > biome.plantlife_limit
and temperature <= biome.temp_min and temperature >= biome.temp_max
and humidity <= biome.humidity_min and humidity >= biome.humidity_max
and biome_lib.is_node_loaded(p_top)
if not pos_biome_ok then
return -- Outside of biome
end
local n_light = minetest.get_node_light(p_top, nil)
if n_light < biome.light_min or n_light > biome.light_max then
return -- Too dark or too bright
end
if biome.avoid_nodes and biome.avoid_radius and minetest.find_node_near(
p_top, biome.avoid_radius + math.random(-1.5,2), biome.avoid_nodes) then
return -- Nodes to avoid are nearby
end
if biome.neighbors and biome.ncount and
#minetest.find_nodes_in_area(
{x=pos.x-1, y=pos.y, z=pos.z-1},
{x=pos.x+1, y=pos.y, z=pos.z+1},
biome.neighbors
) <= biome.ncount then
return -- Near neighbour nodes are not present
end
local NEAR_DST = biome.near_nodes_size
if biome.near_nodes and biome.near_nodes_count and biome.near_nodes_size and
#minetest.find_nodes_in_area(
{x=pos.x-NEAR_DST, y=pos.y-biome.near_nodes_vertical, z=pos.z-NEAR_DST},
{x=pos.x+NEAR_DST, y=pos.y+biome.near_nodes_vertical, z=pos.z+NEAR_DST},
biome.near_nodes
) < biome.near_nodes_count then
return -- Far neighbour nodes are not present
end
if (biome.air_count and biome.air_size) and
#minetest.find_nodes_in_area(
{x=p_top.x-biome.air_size, y=p_top.y, z=p_top.z-biome.air_size},
{x=p_top.x+biome.air_size, y=p_top.y, z=p_top.z+biome.air_size},
"air"
) < biome.air_count then
return -- Not enough air
end
local walldir = biome_lib.find_adjacent_wall(p_top, biome.verticals_list, biome.choose_random_wall)
if biome.alt_wallnode and walldir then
if n_top.name == "air" then
minetest.swap_node(p_top, { name = biome.alt_wallnode, param2 = walldir })
end
return
end
local currentsurface = minetest.get_node(pos).name
if biome_lib.default_water_nodes[currentsurface] and
#minetest.find_nodes_in_area(
{x=pos.x, y=pos.y-biome.depth_max-1, z=pos.z},
vector.new(pos),
biome_lib.default_wet_surfaces
) == 0 then
return -- On water but no ground nearby
end
local rnd = math.random(1, biome.spawn_plants_count)
local plant_to_spawn = biome.spawn_plants[rnd]
local fdir = biome.facedir
if biome.random_facedir then
fdir = math.random(biome.random_facedir[1],biome.random_facedir[2])
end
if type(biome.spawn_plants) == "string" then
assert(loadstring(biome.spawn_plants.."(...)"))(pos)
elseif not biome.spawn_on_side and not biome.spawn_on_bottom and not biome.spawn_replace_node then
if n_top.name == "air" then
minetest.swap_node(p_top, { name = plant_to_spawn, param2 = fdir })
end
elseif biome.spawn_replace_node then
minetest.swap_node(pos, { name = plant_to_spawn, param2 = fdir })
elseif biome.spawn_on_side then
local onside = biome_lib.find_open_side(pos)
if onside then
minetest.swap_node(onside.newpos, { name = plant_to_spawn, param2 = onside.facedir })
end
elseif biome.spawn_on_bottom then
if minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" then
minetest.swap_node({x=pos.x, y=pos.y-1, z=pos.z}, { name = plant_to_spawn, param2 = fdir} )
end
end
end
})
end
-- Function to decide how to replace a plant - either grow it, replace it with
-- a tree, run a function, or die with an error.
function biome_lib.replace_plant(pos, replacement, grow_function, walldir, seeddiff)
local growtype = type(grow_function)
if growtype == "table" then
minetest.swap_node(pos, biome_lib.air)
biome_lib.grow_ltree(pos, grow_function)
return
elseif growtype == "function" then
local perlin_fertile_area = minetest.get_perlin(seeddiff, biome_lib.fertile_perlin_octaves, biome_lib.fertile_perlin_persistence, biome_lib.fertile_perlin_scale)
local fertility, temperature, _ = get_biome_data(pos, perlin_fertile_area)
grow_function(pos, fertility, temperature, walldir)
return
elseif growtype == "string" then
local perlin_fertile_area = minetest.get_perlin(seeddiff, biome_lib.fertile_perlin_octaves, biome_lib.fertile_perlin_persistence, biome_lib.fertile_perlin_scale)
local fertility, temperature, _ = get_biome_data(pos, perlin_fertile_area)
assert(loadstring(grow_function.."(...)"))(pos, fertility, temperature, walldir)
return
elseif growtype == "nil" then
minetest.swap_node(pos, { name = replacement, param2 = walldir})
return
elseif growtype ~= "nil" and growtype ~= "string" and growtype ~= "table" then
error("Invalid grow function "..dump(grow_function).." used on object at ("..dump(pos)..")")
end
end
-- Check for infinite stacks
if minetest.get_modpath("unified_inventory") or not minetest.settings:get_bool("creative_mode") then
biome_lib.expect_infinite_stacks = false
else
biome_lib.expect_infinite_stacks = true
end
-- read a field from a node's definition
function biome_lib.get_nodedef_field(nodename, fieldname)
if not minetest.registered_nodes[nodename] then
return nil
end
return minetest.registered_nodes[nodename][fieldname]
end

View file

@ -0,0 +1,140 @@
-- Iterate through the mapblock log,
-- populating blocks with new stuff in the process.
minetest.register_globalstep(function(dtime)
if not biome_lib.block_log[1] then return end -- the block log is empty
if math.random(100) > biome_lib.queue_ratio then return end
for s = 1, biome_lib.entries_per_step do
biome_lib.generate_block()
end
end)
-- Periodically wake-up the queue to give old blocks a chance to time-out
-- if the player isn't currently exploring (i.e. they're just playing in one area)
function biome_lib.wake_up_queue()
if #biome_lib.block_recheck_list > 1
and #biome_lib.block_log == 0 then
biome_lib.block_log[#biome_lib.block_log + 1] =
table.copy(biome_lib.block_recheck_list[#biome_lib.block_recheck_list])
biome_lib.block_recheck_list[#biome_lib.block_recheck_list] = nil
biome_lib.run_block_recheck_list = true
biome_lib.dbg("Woke-up the map queue to give old blocks a chance to time-out.", 3)
end
minetest.after(biome_lib.block_queue_wakeup_time, biome_lib.wake_up_queue)
end
biome_lib.wake_up_queue()
-- Play out the entire log all at once on shutdown
-- to prevent unpopulated map areas
local function format_time(t)
if t > 59999999 then
return os.date("!%M minutes and %S seconds", math.ceil(t/1000000))
else
return os.date("!%S seconds", math.ceil(t/1000000))
end
end
function biome_lib.check_remaining_time()
if minetest.get_us_time() > (biome_lib.shutdown_last_timestamp + 10000000) then -- report progress every 10s
biome_lib.shutdown_last_timestamp = minetest.get_us_time()
local entries_remaining = #biome_lib.block_log + #biome_lib.block_recheck_list
local total_purged = biome_lib.starting_count - entries_remaining
local elapsed_time = biome_lib.shutdown_last_timestamp - biome_lib.shutdown_start_time
biome_lib.dbg(string.format("%i entries, approximately %s remaining.",
entries_remaining, format_time(elapsed_time/total_purged * entries_remaining)))
end
end
--Purge the block log at shutdown
minetest.register_on_shutdown(function()
biome_lib.shutdown_start_time = minetest.get_us_time()
biome_lib.shutdown_last_timestamp = minetest.get_us_time()+1
biome_lib.starting_count = #biome_lib.block_log + #biome_lib.block_recheck_list
if biome_lib.starting_count == 0 then
return
end
biome_lib.dbg("Stand by, purging the mapblock log "..
"(there are "..biome_lib.starting_count.." entries) ...", 0)
while #biome_lib.block_log > 0 do
biome_lib.generate_block(true)
biome_lib.check_remaining_time()
end
if #biome_lib.block_recheck_list > 0 then
biome_lib.block_log = table.copy(biome_lib.block_recheck_list)
biome_lib.block_recheck_list = {}
while #biome_lib.block_log > 0 do
biome_lib.generate_block(true)
biome_lib.check_remaining_time()
end
end
biome_lib.dbg("Log purge completed after "..
format_time(minetest.get_us_time() - biome_lib.shutdown_start_time)..".", 0)
end)
-- "Record" the map chunks being generated by the core mapgen,
-- split into individual mapblocks to reduce lag
minetest.register_on_generated(function(minp, maxp, blockseed)
local timestamp = minetest.get_us_time()
for y = 0, 4 do
local miny = minp.y + y*16
if miny >= biome_lib.mapgen_elevation_limit.min
and (miny + 15) <= biome_lib.mapgen_elevation_limit.max then
for x = 0, 4 do
local minx = minp.x + x*16
for z = 0, 4 do
local minz = minp.z + z*16
local bmin = {x=minx, y=miny, z=minz}
local bmax = {x=minx + 15, y=miny + 15, z=minz + 15}
biome_lib.block_log[#biome_lib.block_log + 1] = { bmin, bmax, true, timestamp }
biome_lib.block_log[#biome_lib.block_log + 1] = { bmin, bmax, false, timestamp }
end
end
else
biome_lib.dbg("Did not enqueue mapblocks at elevation "..miny.."m, they're out of range of any generate_plant() calls.", 4)
end
end
biome_lib.run_block_recheck_list = true
end)
if biome_lib.debug_log_level >= 3 then
biome_lib.last_count = 0
function biome_lib.show_pending_block_count()
if biome_lib.last_count ~= #biome_lib.block_log then
biome_lib.dbg(string.format("Pending block counts - ready to process: %-8icurrently deferred: %i",
#biome_lib.block_log, #biome_lib.block_recheck_list), 3)
biome_lib.last_count = #biome_lib.block_log
biome_lib.queue_idle_flag = false
elseif not biome_lib.queue_idle_flag then
if #biome_lib.block_recheck_list > 0 then
biome_lib.dbg("Mapblock queue only contains blocks that can't yet be processed.", 3)
biome_lib.dbg("Idling the queue until new blocks arrive or the next wake-up call occurs.", 3)
else
biome_lib.dbg("Mapblock queue has run dry.", 3)
biome_lib.dbg("Idling the queue until new blocks arrive.", 3)
end
biome_lib.queue_idle_flag = true
end
minetest.after(1, biome_lib.show_pending_block_count)
end
biome_lib.show_pending_block_count()
end

115
mods/biome_lib/compat.lua Normal file
View file

@ -0,0 +1,115 @@
-- compatibility shims for old mods
function biome_lib:register_generate_plant(b, n)
biome_lib.dbg("Warning: biome_lib:register_generate_plant() is deprecated!", 2)
biome_lib.dbg("Use biome_lib.register_on_generate() instead", 2)
biome_lib.dbg("Item: "..dump(n), 2)
biome_lib.register_on_generate(b, n)
end
function biome_lib:spawn_on_surfaces(sd, sp, sr, sc, ss, sa)
biome_lib.dbg("Warning: biome_lib:spawn_on_surfaces() is deprecated!", 2)
biome_lib.dbg("Use biome_lib.register_active_spawner() instead.", 2)
biome_lib.dbg("Item: "..dump(sd.spawn_plants or sp[1] or sp), 2)
biome_lib.register_active_spawner(sd, sp, sr, sc, ss, sa)
end
function biome_lib:replace_object(p, r, f, w, d)
biome_lib.dbg("Warning: biome_lib:replace_object() is deprecated!", 2)
biome_lib.dbg("Use biome_lib.replace_plant() instead.", 2)
biome_lib.dbg("Item: "..dump(r), 2)
biome_lib.replace_plant(p, r, f, w, d)
end
function biome_lib:grow_plants(o)
biome_lib.dbg("Warning: biome_lib:grow_plants() is deprecated!", 2)
biome_lib.dbg("Use biome_lib.update_plant() instead.", 2)
biome_lib.dbg("Item: "..dump(o.grow_nodes), 2)
biome_lib.update_plant(o)
end
function biome_lib.generate_ltree(p, n)
minetest.spawn_tree(p, n)
end
function biome_lib.grow_ltree(p, n)
minetest.spawn_tree(p, n)
end
function biome_lib:generate_tree(p, n)
biome_lib.dbg("Warning: biome_lib:generate_tree() is deprecated!", 2)
biome_lib.dbg("Use biome_lib.generate_ltree() instead.", 2)
biome_lib.dbg("Item: "..dump(n), 2)
biome_lib.generate_ltree(p, n)
end
function biome_lib:grow_tree(p, n)
biome_lib.dbg("Warning: biome_lib:grow_tree() is deprecated!", 2)
biome_lib.dbg("Use biome_lib.grow_ltree() instead.", 2)
biome_lib.dbg("Item: "..dump(n), 2)
biome_lib.grow_ltree(p, n)
end
function biome_lib.can_use_decorations(b, nodes_or_function_or_treedef)
if not b or not nodes_or_function_or_treedef
or b.below_nodes
or b.avoid_nodes
or b.avoid_radius
or b.neighbors
or b.ncount
or b.depth
or b.near_nodes_size
or b.near_nodes_vertical
or b.temp_min
or b.temp_max
or b.verticals_list
or b.delete_above
or b.delete_above_surround
or ( type(nodes_or_function_or_treedef) == "string" and not minetest.registered_nodes[nodes_or_function_or_treedef] )
or ( type(nodes_or_function_or_treedef) == "table" and nodes_or_function_or_treedef.axiom )
or type(nodes_or_function_or_treedef) == "function"
then return false
end
local biome = biome_lib.set_defaults(b)
local decor_def = {
["deco_type"] = "simple",
["flags"] = "all_floors",
["decoration"] = nodes_or_function_or_treedef,
["place_on"] = biome.surface,
["y_min"] = biome.min_elevation,
["y_max"] = biome.max_elevation,
["spawn_by"] = biome.near_nodes,
["num_spawn_by"] = biome.near_nodes and biome.near_nodes_count,
}
local r = (100-biome.rarity)/100
local mc = math.min(biome.max_count, 6400)/6400
decor_def.noise_params = {
octaves = biome_lib.fertile_perlin_octaves,
persist = biome_lib.fertile_perlin_persistence * (100/biome_lib.fertile_perlin_scale),
scale = math.min(r, mc),
seed = biome.seed_diff,
offset = 0,
spread = {x = 100, y = 100, z = 100},
lacunarity = 2,
flags = "absvalue"
}
if not b.check_air then
decor_def.flags = decor_def.flags..",force_placement"
end
if b.spawn_replace_node then
decor_def.place_offset_y = -1
end
if b.random_facedir then
decor_def.param2 = math.min(b.random_facedir[1], b.random_facedir[2])
decor_def.param2_max = math.max(b.random_facedir[1], b.random_facedir[2])
end
return decor_def
end

View file

@ -1,5 +1,3 @@
local time_scale = ...
-- The growing ABM
function biome_lib.check_surface(name, nodes)
@ -15,7 +13,7 @@ function biome_lib.check_surface(name, nodes)
return false
end
function biome_lib:grow_plants(opts)
function biome_lib.update_plant(opts)
local options = opts
@ -32,10 +30,10 @@ function biome_lib:grow_plants(opts)
n = options.grow_plant
end
options.label = options.label or "biome_lib grow_plants(): "..n
options.label = options.label or "biome_lib.update_plant(): "..n
if options.grow_delay*time_scale >= 1 then
options.interval = options.grow_delay*time_scale
if options.grow_delay*biome_lib.time_scale >= 1 then
options.interval = options.grow_delay*biome_lib.time_scale
else
options.interval = 1
end
@ -53,12 +51,12 @@ function biome_lib:grow_plants(opts)
local root_node = minetest.get_node({x=pos.x, y=pos.y-options.height_limit, z=pos.z})
local walldir = nil
if options.need_wall and options.verticals_list then
walldir = biome_lib:find_adjacent_wall(p_top, options.verticals_list, options.choose_random_wall)
walldir = biome_lib.find_adjacent_wall(p_top, options.verticals_list, options.choose_random_wall)
end
if biome_lib.default_grow_through_nodes[n_top.name]
and (not options.need_wall or (options.need_wall and walldir)) then
if options.grow_vertically and walldir then
if biome_lib:search_downward(pos, options.height_limit, options.ground_nodes) then
if biome_lib.search_downward(pos, options.height_limit, options.ground_nodes) then
minetest.swap_node(p_top, { name = options.grow_plant, param2 = walldir})
end
@ -67,24 +65,10 @@ function biome_lib:grow_plants(opts)
minetest.swap_node(pos, biome_lib.air)
else
biome_lib:replace_object(pos, options.grow_result, options.grow_function, options.facedir, options.seed_diff)
biome_lib.replace_plant(pos, options.grow_result, options.grow_function, options.facedir, options.seed_diff)
end
end
end
end
})
end
-- spawn_tree() on generate is routed through here so that other mods can hook
-- into it.
function biome_lib:generate_tree(pos, nodes_or_function_or_model)
minetest.spawn_tree(pos, nodes_or_function_or_model)
end
-- and this one's for the call used in the growing code
function biome_lib:grow_tree(pos, nodes_or_function_or_model)
minetest.spawn_tree(pos, nodes_or_function_or_model)
end

View file

@ -5,6 +5,7 @@
--
biome_lib = {}
biome_lib.modpath = minetest.get_modpath("biome_lib")
-- Boilerplate to support localized strings if intllib mod is installed.
local S
@ -19,26 +20,6 @@ else
end
biome_lib.intllib = S
-- Various settings - most of these probably won't need to be changed
biome_lib.air = {name = "air"}
biome_lib.block_log = {}
biome_lib.block_recheck_list = {}
biome_lib.run_block_recheck_list = false
biome_lib.actionslist_aircheck = {}
biome_lib.actionslist_no_aircheck = {}
biome_lib.surfaceslist_aircheck = {}
biome_lib.surfaceslist_no_aircheck = {}
biome_lib.modpath = minetest.get_modpath("biome_lib")
local function tableize(s)
return string.split(string.trim(string.gsub(s, " ", "")))
end
local c1 = minetest.settings:get("biome_lib_default_grow_through_nodes")
biome_lib.default_grow_through_nodes = {["air"] = true}
if c1 then
@ -72,8 +53,8 @@ biome_lib.default_grow_nodes = c5 and tableize(c5) or {"default:dirt_with_gras
biome_lib.debug_log_level = tonumber(minetest.settings:get("biome_lib_debug_log_level")) or 0
local rr = tonumber(minetest.settings:get("biome_lib_queue_run_ratio")) or -100
biome_lib.queue_run_ratio = 100 - rr
local rr = tonumber(minetest.settings:get("biome_lib_queue_ratio")) or -200
biome_lib.queue_ratio = 100 - rr
biome_lib.entries_per_step = math.max(-rr, 1)
-- the timer that manages the block timeout is in microseconds, but the timer
@ -86,773 +67,35 @@ biome_lib.block_timeout = t * 1000000
-- we don't want the wakeup function to trigger TOO often,
-- in case the user's block timeout setting is really low
biome_lib.block_queue_wakeup_time = math.min(t/2, math.max(20, t/10))
local time_speed = tonumber(minetest.settings:get("time_speed"))
biome_lib.plantlife_seed_diff = 329 -- needs to be global so other mods can see it
local perlin_octaves = 3
local perlin_persistence = 0.6
local perlin_scale = 100
local temperature_seeddiff = 112
local temperature_octaves = 3
local temperature_persistence = 0.5
local temperature_scale = 150
local humidity_seeddiff = 9130
local humidity_octaves = 3
local humidity_persistence = 0.5
local humidity_scale = 250
local time_scale = 1
if time_speed and time_speed > 0 then
time_scale = 72 / time_speed
end
--PerlinNoise(seed, octaves, persistence, scale)
biome_lib.perlin_temperature = PerlinNoise(temperature_seeddiff, temperature_octaves, temperature_persistence, temperature_scale)
biome_lib.perlin_humidity = PerlinNoise(humidity_seeddiff, humidity_octaves, humidity_persistence, humidity_scale)
-- Local functions
function biome_lib.dbg(msg, level)
local l = tonumber(level) or 0
if biome_lib.debug_log_level >= l then
print("[Biome Lib] "..msg)
minetest.log("verbose", "[Biome Lib] "..msg)
end
end
local function get_biome_data(pos, perlin_fertile)
local fertility = perlin_fertile:get_2d({x=pos.x, y=pos.z})
if type(minetest.get_biome_data) == "function" then
local data = minetest.get_biome_data(pos)
if data then
return fertility, data.heat / 100, data.humidity / 100
end
end
local temperature = biome_lib.perlin_temperature:get2d({x=pos.x, y=pos.z})
local humidity = biome_lib.perlin_humidity:get2d({x=pos.x+150, y=pos.z+50})
return fertility, temperature, humidity
end
function biome_lib:is_node_loaded(node_pos)
local n = minetest.get_node_or_nil(node_pos)
if (not n) or (n.name == "ignore") then
return false
end
return true
end
function biome_lib:set_defaults(biome)
biome.seed_diff = biome.seed_diff or 0
biome.min_elevation = biome.min_elevation or -31000
biome.max_elevation = biome.max_elevation or 31000
biome.temp_min = biome.temp_min or 1
biome.temp_max = biome.temp_max or -1
biome.humidity_min = biome.humidity_min or 1
biome.humidity_max = biome.humidity_max or -1
biome.plantlife_limit = biome.plantlife_limit or 0.1
biome.near_nodes_vertical = biome.near_nodes_vertical or 1
-- specific to on-generate
biome.neighbors = biome.neighbors or biome.surface
biome.near_nodes_size = biome.near_nodes_size or 0
biome.near_nodes_count = biome.near_nodes_count or 1
biome.rarity = biome.rarity or 50
biome.max_count = biome.max_count or 125
if biome.check_air ~= false then biome.check_air = true end
-- specific to abm spawner
biome.seed_diff = biome.seed_diff or 0
biome.light_min = biome.light_min or 0
biome.light_max = biome.light_max or 15
biome.depth_max = biome.depth_max or 1
biome.facedir = biome.facedir or 0
end
local function search_table(t, s)
for i = 1, #t do
if t[i] == s then return true end
end
return false
end
-- register the list of surfaces to spawn stuff on, filtering out all duplicates.
-- separate the items by air-checking or non-air-checking map eval methods
function biome_lib:register_generate_plant(biomedef, nodes_or_function_or_model)
-- if calling code passes an undefined node for a surface or
-- as a node to be spawned, don't register an action for it.
if type(nodes_or_function_or_model) == "string"
and string.find(nodes_or_function_or_model, ":")
and not minetest.registered_nodes[nodes_or_function_or_model] then
biome_lib.dbg("Warning: Ignored registration for undefined spawn node: "..dump(nodes_or_function_or_model), 2)
return
end
if type(nodes_or_function_or_model) == "string"
and not string.find(nodes_or_function_or_model, ":") then
biome_lib.dbg("Warning: Registered function call using deprecated string method: "..dump(nodes_or_function_or_model), 2)
end
if biomedef.check_air == false then
biome_lib.dbg("Register no-air-check mapgen hook: "..dump(nodes_or_function_or_model), 3)
biome_lib.actionslist_no_aircheck[#biome_lib.actionslist_no_aircheck + 1] = { biomedef, nodes_or_function_or_model }
local s = biomedef.surface
if type(s) == "string" then
if s and (string.find(s, "^group:") or minetest.registered_nodes[s]) then
if not search_table(biome_lib.surfaceslist_no_aircheck, s) then
biome_lib.surfaceslist_no_aircheck[#biome_lib.surfaceslist_no_aircheck + 1] = s
end
else
biome_lib.dbg("Warning: Ignored no-air-check registration for undefined surface node: "..dump(s), 2)
end
else
for i = 1, #biomedef.surface do
local s = biomedef.surface[i]
if s and (string.find(s, "^group:") or minetest.registered_nodes[s]) then
if not search_table(biome_lib.surfaceslist_no_aircheck, s) then
biome_lib.surfaceslist_no_aircheck[#biome_lib.surfaceslist_no_aircheck + 1] = s
end
else
biome_lib.dbg("Warning: Ignored no-air-check registration for undefined surface node: "..dump(s), 2)
end
end
end
else
biome_lib.dbg("Register with-air-checking mapgen hook: "..dump(nodes_or_function_or_model), 3)
biome_lib.actionslist_aircheck[#biome_lib.actionslist_aircheck + 1] = { biomedef, nodes_or_function_or_model }
local s = biomedef.surface
if type(s) == "string" then
if s and (string.find(s, "^group:") or minetest.registered_nodes[s]) then
if not search_table(biome_lib.surfaceslist_aircheck, s) then
biome_lib.surfaceslist_aircheck[#biome_lib.surfaceslist_aircheck + 1] = s
end
else
biome_lib.dbg("Warning: Ignored with-air-checking registration for undefined surface node: "..dump(s), 2)
end
else
for i = 1, #biomedef.surface do
local s = biomedef.surface[i]
if s and (string.find(s, "^group:") or minetest.registered_nodes[s]) then
if not search_table(biome_lib.surfaceslist_aircheck, s) then
biome_lib.surfaceslist_aircheck[#biome_lib.surfaceslist_aircheck + 1] = s
end
else
biome_lib.dbg("Warning: Ignored with-air-checking registration for undefined surface node: "..dump(s), 2)
end
end
end
end
end
-- Function to check whether a position matches the given biome definition
-- Returns true when the surface can be populated
local function populate_single_surface(biome, pos, perlin_fertile_area, checkair)
local p_top = { x = pos.x, y = pos.y + 1, z = pos.z }
if math.random(1, 100) <= biome.rarity then
return
end
local fertility, temperature, humidity = get_biome_data(pos, perlin_fertile_area)
local pos_biome_ok = pos.y >= biome.min_elevation and pos.y <= biome.max_elevation
and fertility > biome.plantlife_limit
and temperature <= biome.temp_min and temperature >= biome.temp_max
and humidity <= biome.humidity_min and humidity >= biome.humidity_max
if not pos_biome_ok then
return -- Y position mismatch, outside of biome
end
local biome_surfaces_string = dump(biome.surface)
local surface_ok = false
if not biome.depth then
local dest_node = minetest.get_node(pos)
if string.find(biome_surfaces_string, dest_node.name) then
surface_ok = true
else
if string.find(biome_surfaces_string, "group:") then
for j = 1, #biome.surface do
if string.find(biome.surface[j], "^group:")
and minetest.get_item_group(dest_node.name, biome.surface[j]) then
surface_ok = true
break
end
end
end
end
elseif not string.find(biome_surfaces_string,
minetest.get_node({ x = pos.x, y = pos.y-biome.depth-1, z = pos.z }).name) then
surface_ok = true
end
if not surface_ok then
return -- Surface does not match the given node group/name
end
if checkair and minetest.get_node(p_top).name ~= "air" then
return
end
if biome.below_nodes and
not string.find(dump(biome.below_nodes),
minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
) then
return -- Node below does not match
end
if biome.ncount and
#minetest.find_nodes_in_area(
{x=pos.x-1, y=pos.y, z=pos.z-1},
{x=pos.x+1, y=pos.y, z=pos.z+1},
biome.neighbors
) <= biome.ncount then
return -- Not enough similar biome nodes around
end
if biome.near_nodes and
#minetest.find_nodes_in_area(
{x=pos.x-biome.near_nodes_size, y=pos.y-biome.near_nodes_vertical, z=pos.z-biome.near_nodes_size},
{x=pos.x+biome.near_nodes_size, y=pos.y+biome.near_nodes_vertical, z=pos.z+biome.near_nodes_size},
biome.near_nodes
) < biome.near_nodes_count then
return -- Long distance neighbours do not match
end
-- Position fits into given biome
return true
end
function biome_lib.populate_surfaces(biome, nodes_or_function_or_model, snodes, checkair)
local items_added = 0
biome_lib:set_defaults(biome)
-- filter stage 1 - find nodes from the supplied surfaces that are within the current biome.
local in_biome_nodes = {}
local perlin_fertile_area = minetest.get_perlin(biome.seed_diff, perlin_octaves, perlin_persistence, perlin_scale)
for i = 1, #snodes do
local pos = vector.new(snodes[i])
if populate_single_surface(biome, pos, perlin_fertile_area, checkair) then
in_biome_nodes[#in_biome_nodes + 1] = pos
end
end
-- filter stage 2 - find places within that biome area to place the plants.
local num_in_biome_nodes = #in_biome_nodes
if num_in_biome_nodes == 0 then
return 0
end
for i = 1, math.min(math.ceil(biome.max_count/25), num_in_biome_nodes) do
local tries = 0
local spawned = false
while tries < 2 and not spawned do
local pos = in_biome_nodes[math.random(1, num_in_biome_nodes)]
if biome.spawn_replace_node then
pos.y = pos.y-1
end
local p_top = { x = pos.x, y = pos.y + 1, z = pos.z }
if not (biome.avoid_nodes and biome.avoid_radius
and minetest.find_node_near(p_top, biome.avoid_radius
+ math.random(-1.5,2), biome.avoid_nodes)) then
if biome.delete_above then
minetest.swap_node(p_top, biome_lib.air)
minetest.swap_node({x=p_top.x, y=p_top.y+1, z=p_top.z}, biome_lib.air)
end
if biome.delete_above_surround then
minetest.swap_node({x=p_top.x-1, y=p_top.y, z=p_top.z}, biome_lib.air)
minetest.swap_node({x=p_top.x+1, y=p_top.y, z=p_top.z}, biome_lib.air)
minetest.swap_node({x=p_top.x, y=p_top.y, z=p_top.z-1}, biome_lib.air)
minetest.swap_node({x=p_top.x, y=p_top.y, z=p_top.z+1}, biome_lib.air)
minetest.swap_node({x=p_top.x-1, y=p_top.y+1, z=p_top.z}, biome_lib.air)
minetest.swap_node({x=p_top.x+1, y=p_top.y+1, z=p_top.z}, biome_lib.air)
minetest.swap_node({x=p_top.x, y=p_top.y+1, z=p_top.z-1}, biome_lib.air)
minetest.swap_node({x=p_top.x, y=p_top.y+1, z=p_top.z+1}, biome_lib.air)
end
if biome.spawn_replace_node then
minetest.swap_node(pos, biome_lib.air)
end
local objtype = type(nodes_or_function_or_model)
if objtype == "table" then
if nodes_or_function_or_model.axiom then
biome_lib:generate_tree(p_top, nodes_or_function_or_model)
biome_lib.dbg("An L-tree was spawned at "..minetest.pos_to_string(p_top), 4)
spawned = true
else
local fdir = nil
if biome.random_facedir then
fdir = math.random(biome.random_facedir[1], biome.random_facedir[2])
end
local n=nodes_or_function_or_model[math.random(#nodes_or_function_or_model)]
minetest.swap_node(p_top, { name = n, param2 = fdir })
biome_lib.dbg("Node \""..n.."\" was randomly picked from a list and placed at "..minetest.pos_to_string(p_top), 4)
spawned = true
end
elseif objtype == "string" and
minetest.registered_nodes[nodes_or_function_or_model] then
local fdir = nil
if biome.random_facedir then
fdir = math.random(biome.random_facedir[1], biome.random_facedir[2])
end
minetest.swap_node(p_top, { name = nodes_or_function_or_model, param2 = fdir })
biome_lib.dbg("Node \""..nodes_or_function_or_model.."\" was placed at "..minetest.pos_to_string(p_top), 4)
spawned = true
elseif objtype == "function" then
nodes_or_function_or_model(pos)
biome_lib.dbg("A function was run on surface node at "..minetest.pos_to_string(pos), 4)
spawned = true
elseif objtype == "string" and pcall(loadstring(("return %s(...)"):
format(nodes_or_function_or_model)),pos) then
spawned = true
biome_lib.dbg("An obsolete string-specified function was run on surface node at "..minetest.pos_to_string(p_top), 4)
else
biome_lib.dbg("Warning: Ignored invalid definition for object "..dump(nodes_or_function_or_model).." that was pointed at {"..dump(pos).."}", 2)
end
else
tries = tries + 1
end
end
if spawned then items_added = items_added + 1 end
end
return items_added
end
-- Primary log read-out/mapgen spawner
local function confirm_block_surroundings(p)
local n=minetest.get_node_or_nil(p)
if not n or n.name == "ignore" then return false end
for x = -32,32,64 do -- step of 64 causes it to only check the 8 corner blocks
for y = -32,32,64 do
for z = -32,32,64 do
local n=minetest.get_node_or_nil({x=p.x + x, y=p.y + y, z=p.z + z})
if not n or n.name == "ignore" then return false end
end
end
end
return true
end
function biome_lib.generate_block(shutting_down)
if shutting_down then
if #biome_lib.block_recheck_list > 0 then
for i = 1, #biome_lib.block_recheck_list do
biome_lib.block_log[#biome_lib.block_log + 1] = biome_lib.block_recheck_list[i]
end
biome_lib.block_recheck_list = {}
end
biome_lib.run_block_recheck_list = false
else
if biome_lib.run_block_recheck_list
and not biome_lib.block_recheck_list[1] then
biome_lib.run_block_recheck_list = false
end
end
local blocklog = biome_lib.run_block_recheck_list
and biome_lib.block_recheck_list
or biome_lib.block_log
if not blocklog[1] then return end
local minp = blocklog[1][1]
local maxp = blocklog[1][2]
local airflag = blocklog[1][3]
local pos_hash = minetest.hash_node_position(minp)
if not biome_lib.pos_hash then -- we need to read the maplock and get the surfaces list
local now = minetest.get_us_time()
biome_lib.pos_hash = {}
minetest.load_area(minp)
if not confirm_block_surroundings(minp)
and not shutting_down
and (blocklog[1][4] + biome_lib.block_timeout) > now then -- if any neighbors appear not to be loaded and the block hasn't expired yet, defer it
if biome_lib.run_block_recheck_list then
biome_lib.block_log[#biome_lib.block_log + 1] = table.copy(biome_lib.block_recheck_list[1])
table.remove(biome_lib.block_recheck_list, 1)
else
biome_lib.block_recheck_list[#biome_lib.block_recheck_list + 1] = table.copy(biome_lib.block_log[1])
table.remove(biome_lib.block_log, 1)
end
biome_lib.pos_hash = nil
biome_lib.dbg("Mapblock at "..minetest.pos_to_string(minp)..
" had a neighbor not fully emerged, skipped it for now.", 4)
return
else
biome_lib.pos_hash.surface_node_list = airflag
and minetest.find_nodes_in_area_under_air(minp, maxp, biome_lib.surfaceslist_aircheck)
or minetest.find_nodes_in_area(minp, maxp, biome_lib.surfaceslist_no_aircheck)
biome_lib.pos_hash.action_index = 1
if #biome_lib.pos_hash.surface_node_list > 0 then
biome_lib.dbg("Mapblock at "..minetest.pos_to_string(minp)..
" has "..#biome_lib.pos_hash.surface_node_list..
" surface nodes to work on (airflag="..dump(airflag)..")", 4)
end
end
elseif not (airflag and biome_lib.actionslist_aircheck[biome_lib.pos_hash.action_index])
and not (not airflag and biome_lib.actionslist_no_aircheck[biome_lib.pos_hash.action_index]) then
-- the block is finished, remove it
if #biome_lib.pos_hash.surface_node_list > 0 then
biome_lib.dbg("Deleted mapblock "..minetest.pos_to_string(minp).." from the block log", 4)
end
table.remove(blocklog, 1)
biome_lib.pos_hash = nil
else
-- below, [1] is biome, [2] is the thing to be added
local added = 0
if airflag then
if biome_lib.actionslist_aircheck[biome_lib.pos_hash.action_index] then
added = biome_lib.populate_surfaces(
biome_lib.actionslist_aircheck[biome_lib.pos_hash.action_index][1],
biome_lib.actionslist_aircheck[biome_lib.pos_hash.action_index][2],
biome_lib.pos_hash.surface_node_list, true)
biome_lib.pos_hash.action_index = biome_lib.pos_hash.action_index + 1
end
else
if biome_lib.actionslist_no_aircheck[biome_lib.pos_hash.action_index] then
added = biome_lib.populate_surfaces(
biome_lib.actionslist_no_aircheck[biome_lib.pos_hash.action_index][1],
biome_lib.actionslist_no_aircheck[biome_lib.pos_hash.action_index][2],
biome_lib.pos_hash.surface_node_list, false)
biome_lib.pos_hash.action_index = biome_lib.pos_hash.action_index + 1
end
end
if added > 0 then
biome_lib.dbg("biome_lib.populate_surfaces ran on mapblock at "..
minetest.pos_to_string(minp)..". Entry #"..
(biome_lib.pos_hash.action_index-1).." added "..added.." items.", 4)
end
end
end
-- "Play" them back, populating them with new stuff in the process
minetest.register_globalstep(function(dtime)
if not biome_lib.block_log[1] then return end -- the block log is empty
if math.random(100) > biome_lib.queue_run_ratio then return end
for s = 1, biome_lib.entries_per_step do
biome_lib.generate_block()
end
end)
-- Periodically wake-up the queue to give old blocks a chance to time-out
-- if the player isn't currently exploring (i.e. they're just playing in one area)
function biome_lib.wake_up_queue()
if #biome_lib.block_recheck_list > 1
and #biome_lib.block_log == 0 then
biome_lib.block_log[#biome_lib.block_log + 1] =
table.copy(biome_lib.block_recheck_list[#biome_lib.block_recheck_list])
biome_lib.block_recheck_list[#biome_lib.block_recheck_list] = nil
biome_lib.run_block_recheck_list = true
biome_lib.dbg("Woke-up the map queue to give old blocks a chance to time-out.", 3)
end
minetest.after(biome_lib.block_queue_wakeup_time, biome_lib.wake_up_queue)
end
biome_lib.wake_up_queue()
-- Play out the entire log all at once on shutdown
-- to prevent unpopulated map areas
local function format_time(t)
if t > 59999999 then
return os.date("!%M minutes and %S seconds", math.ceil(t/1000000))
else
return os.date("!%S seconds", math.ceil(t/1000000))
end
end
function biome_lib.check_remaining_time()
if minetest.get_us_time() > (biome_lib.shutdown_last_timestamp + 10000000) then -- report progress every 10s
biome_lib.shutdown_last_timestamp = minetest.get_us_time()
local entries_remaining = #biome_lib.block_log + #biome_lib.block_recheck_list
local total_purged = biome_lib.starting_count - entries_remaining
local elapsed_time = biome_lib.shutdown_last_timestamp - biome_lib.shutdown_start_time
biome_lib.dbg(string.format("%i entries, approximately %s remaining.",
entries_remaining, format_time(elapsed_time/total_purged * entries_remaining)))
end
end
minetest.register_on_shutdown(function()
biome_lib.shutdown_start_time = minetest.get_us_time()
biome_lib.shutdown_last_timestamp = minetest.get_us_time()+1
biome_lib.starting_count = #biome_lib.block_log + #biome_lib.block_recheck_list
if biome_lib.starting_count == 0 then
return
end
biome_lib.dbg("Stand by, purging the mapblock log "..
"(there are "..(#biome_lib.block_log + #biome_lib.block_recheck_list).." entries) ...", 0)
while #biome_lib.block_log > 0 do
biome_lib.generate_block(true)
biome_lib.check_remaining_time()
end
if #biome_lib.block_recheck_list > 0 then
biome_lib.block_log = table.copy(biome_lib.block_recheck_list)
while #biome_lib.block_log > 0 do
biome_lib.generate_block(true)
biome_lib.check_remaining_time()
end
end
biome_lib.dbg("Log purge completed after "..
format_time(minetest.get_us_time() - biome_lib.shutdown_start_time)..".", 0)
end)
-- The spawning ABM
function biome_lib:spawn_on_surfaces(sd,sp,sr,sc,ss,sa)
local biome = {}
if type(sd) ~= "table" then
biome.spawn_delay = sd -- old api expects ABM interval param here.
biome.spawn_plants = {sp}
biome.avoid_radius = sr
biome.spawn_chance = sc
biome.spawn_surfaces = {ss}
biome.avoid_nodes = sa
else
biome = sd
end
if biome.spawn_delay*time_scale >= 1 then
biome.interval = biome.spawn_delay*time_scale
else
biome.interval = 1
end
biome_lib:set_defaults(biome)
biome.spawn_plants_count = #(biome.spawn_plants)
local n
if type(biome.spawn_plants) == "table" then
n = "random: "..biome.spawn_plants[1]..", ..."
else
n = biome.spawn_plants
end
biome.label = biome.label or "biome_lib spawn_on_surfaces(): "..n
minetest.register_abm({
nodenames = biome.spawn_surfaces,
interval = biome.interval,
chance = biome.spawn_chance,
neighbors = biome.neighbors,
label = biome.label,
action = function(pos, node, active_object_count, active_object_count_wider)
local p_top = { x = pos.x, y = pos.y + 1, z = pos.z }
local n_top = minetest.get_node(p_top)
local perlin_fertile_area = minetest.get_perlin(biome.seed_diff, perlin_octaves, perlin_persistence, perlin_scale)
local fertility, temperature, humidity = get_biome_data(pos, perlin_fertile_area)
local pos_biome_ok = pos.y >= biome.min_elevation and pos.y <= biome.max_elevation
and fertility > biome.plantlife_limit
and temperature <= biome.temp_min and temperature >= biome.temp_max
and humidity <= biome.humidity_min and humidity >= biome.humidity_max
and biome_lib:is_node_loaded(p_top)
if not pos_biome_ok then
return -- Outside of biome
end
local n_light = minetest.get_node_light(p_top, nil)
if n_light < biome.light_min or n_light > biome.light_max then
return -- Too dark or too bright
end
if biome.avoid_nodes and biome.avoid_radius and minetest.find_node_near(
p_top, biome.avoid_radius + math.random(-1.5,2), biome.avoid_nodes) then
return -- Nodes to avoid are nearby
end
if biome.neighbors and biome.ncount and
#minetest.find_nodes_in_area(
{x=pos.x-1, y=pos.y, z=pos.z-1},
{x=pos.x+1, y=pos.y, z=pos.z+1},
biome.neighbors
) <= biome.ncount then
return -- Near neighbour nodes are not present
end
local NEAR_DST = biome.near_nodes_size
if biome.near_nodes and biome.near_nodes_count and biome.near_nodes_size and
#minetest.find_nodes_in_area(
{x=pos.x-NEAR_DST, y=pos.y-biome.near_nodes_vertical, z=pos.z-NEAR_DST},
{x=pos.x+NEAR_DST, y=pos.y+biome.near_nodes_vertical, z=pos.z+NEAR_DST},
biome.near_nodes
) < biome.near_nodes_count then
return -- Far neighbour nodes are not present
end
if (biome.air_count and biome.air_size) and
#minetest.find_nodes_in_area(
{x=p_top.x-biome.air_size, y=p_top.y, z=p_top.z-biome.air_size},
{x=p_top.x+biome.air_size, y=p_top.y, z=p_top.z+biome.air_size},
"air"
) < biome.air_count then
return -- Not enough air
end
local walldir = biome_lib:find_adjacent_wall(p_top, biome.verticals_list, biome.choose_random_wall)
if biome.alt_wallnode and walldir then
if n_top.name == "air" then
minetest.swap_node(p_top, { name = biome.alt_wallnode, param2 = walldir })
end
return
end
local currentsurface = minetest.get_node(pos).name
if biome_lib.default_water_nodes[currentsurface] and
#minetest.find_nodes_in_area(
{x=pos.x, y=pos.y-biome.depth_max-1, z=pos.z},
vector.new(pos),
biome_lib.default_wet_surfaces
) == 0 then
return -- On water but no ground nearby
end
local rnd = math.random(1, biome.spawn_plants_count)
local plant_to_spawn = biome.spawn_plants[rnd]
local fdir = biome.facedir
if biome.random_facedir then
fdir = math.random(biome.random_facedir[1],biome.random_facedir[2])
end
if type(biome.spawn_plants) == "string" then
assert(loadstring(biome.spawn_plants.."(...)"))(pos)
elseif not biome.spawn_on_side and not biome.spawn_on_bottom and not biome.spawn_replace_node then
if n_top.name == "air" then
minetest.swap_node(p_top, { name = plant_to_spawn, param2 = fdir })
end
elseif biome.spawn_replace_node then
minetest.swap_node(pos, { name = plant_to_spawn, param2 = fdir })
elseif biome.spawn_on_side then
local onside = biome_lib:find_open_side(pos)
if onside then
minetest.swap_node(onside.newpos, { name = plant_to_spawn, param2 = onside.facedir })
end
elseif biome.spawn_on_bottom then
if minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" then
minetest.swap_node({x=pos.x, y=pos.y-1, z=pos.z}, { name = plant_to_spawn, param2 = fdir} )
end
end
end
})
end
-- Function to decide how to replace a plant - either grow it, replace it with
-- a tree, run a function, or die with an error.
function biome_lib:replace_object(pos, replacement, grow_function, walldir, seeddiff)
local growtype = type(grow_function)
if growtype == "table" then
minetest.swap_node(pos, biome_lib.air)
biome_lib:grow_tree(pos, grow_function)
return
elseif growtype == "function" then
local perlin_fertile_area = minetest.get_perlin(seeddiff, perlin_octaves, perlin_persistence, perlin_scale)
local fertility, temperature, _ = get_biome_data(pos, perlin_fertile_area)
grow_function(pos, fertility, temperature, walldir)
return
elseif growtype == "string" then
local perlin_fertile_area = minetest.get_perlin(seeddiff, perlin_octaves, perlin_persistence, perlin_scale)
local fertility, temperature, _ = get_biome_data(pos, perlin_fertile_area)
assert(loadstring(grow_function.."(...)"))(pos, fertility, temperature, walldir)
return
elseif growtype == "nil" then
minetest.swap_node(pos, { name = replacement, param2 = walldir})
return
elseif growtype ~= "nil" and growtype ~= "string" and growtype ~= "table" then
error("Invalid grow function "..dump(grow_function).." used on object at ("..dump(pos)..")")
end
end
-- the actual important stuff starts here ;-)
dofile(biome_lib.modpath .. "/api.lua")
dofile(biome_lib.modpath .. "/search_functions.lua")
assert(loadfile(biome_lib.modpath .. "/growth.lua"))(time_scale)
dofile(biome_lib.modpath .. "/growth.lua")
dofile(biome_lib.modpath .. "/compat.lua")
-- Check for infinite stacks
minetest.after(0.01, function()
-- report the final registration results and enable the active block queue stuff
if minetest.get_modpath("unified_inventory") or not minetest.settings:get_bool("creative_mode") then
biome_lib.expect_infinite_stacks = false
else
biome_lib.expect_infinite_stacks = true
end
local n = #biome_lib.actionslist_aircheck + #biome_lib.actionslist_no_aircheck
-- read a field from a node's definition
biome_lib.dbg("All mapgen registrations completed.", 0)
function biome_lib:get_nodedef_field(nodename, fieldname)
if not minetest.registered_nodes[nodename] then
return nil
end
return minetest.registered_nodes[nodename][fieldname]
end
if biome_lib.debug_log_level >= 3 then
biome_lib.last_count = 0
function biome_lib.show_pending_block_count()
if biome_lib.last_count ~= #biome_lib.block_log then
biome_lib.dbg(string.format("Pending block counts - ready to process: %-8icurrently deferred: %i",
#biome_lib.block_log, #biome_lib.block_recheck_list), 3)
biome_lib.last_count = #biome_lib.block_log
biome_lib.queue_idle_flag = false
elseif not biome_lib.queue_idle_flag then
if #biome_lib.block_recheck_list > 0 then
biome_lib.dbg("Mapblock queue only contains blocks that can't yet be processed.", 3)
biome_lib.dbg("Idling the queue until new blocks arrive or the next wake-up call occurs.", 3)
if n > 0 then
biome_lib.dbg("Total items/actions to handle manually: "..n.." ("..#biome_lib.actionslist_no_aircheck.." without air checks)", 0)
biome_lib.dbg("Total surface types to handle manually: "..#biome_lib.surfaceslist_aircheck + #biome_lib.surfaceslist_no_aircheck, 0)
else
biome_lib.dbg("Mapblock queue has run dry.", 3)
biome_lib.dbg("Idling the queue until new blocks arrive.", 3)
end
biome_lib.queue_idle_flag = true
end
minetest.after(1, biome_lib.show_pending_block_count)
biome_lib.dbg("There are no \"handle manually\" items/actions registered,", 0)
biome_lib.dbg("so the mapblock queue will not be not used this session.", 0)
end
biome_lib.show_pending_block_count()
end
biome_lib.dbg("Items sent to the engine's decorations handler: "..#biome_lib.registered_decorations, 0)
biome_lib.dbg("Elevation range: "..biome_lib.mapgen_elevation_limit.min.." to "..string.format("%+d", biome_lib.mapgen_elevation_limit.max).." meters.", 0)
minetest.after(0, function()
biome_lib.dbg("Registered a total of "..(#biome_lib.surfaceslist_aircheck)+(#biome_lib.surfaceslist_no_aircheck).." surface types to be evaluated, spread", 0)
biome_lib.dbg("across "..#biome_lib.actionslist_aircheck.." actions with air-checking and "..#biome_lib.actionslist_no_aircheck.." actions without.", 0)
if n > 0 then
dofile(biome_lib.modpath .. "/block_queue_checks.lua")
end
end)
biome_lib.dbg("[Biome Lib] Loaded", 0)

View file

@ -2,7 +2,7 @@
-- function to decide if a node has a wall that's in verticals_list{}
-- returns wall direction of valid node, or nil if invalid.
function biome_lib:find_adjacent_wall(pos, verticals, randomflag)
function biome_lib.find_adjacent_wall(pos, verticals, randomflag)
local verts = dump(verticals)
if randomflag then
local walltab = {}
@ -27,7 +27,7 @@ end
-- node that matches the ground table. Returns the new position, or nil if
-- height limit is exceeded before finding it.
function biome_lib:search_downward(pos, heightlimit, ground)
function biome_lib.search_downward(pos, heightlimit, ground)
for i = 0, heightlimit do
if string.find(dump(ground), minetest.get_node({x=pos.x, y=pos.y-i, z = pos.z}).name) then
return {x=pos.x, y=pos.y-i, z = pos.z}
@ -36,7 +36,7 @@ function biome_lib:search_downward(pos, heightlimit, ground)
return false
end
function biome_lib:find_open_side(pos)
function biome_lib.find_open_side(pos)
if minetest.get_node({ x=pos.x-1, y=pos.y, z=pos.z }).name == "air" then
return {newpos = { x=pos.x-1, y=pos.y, z=pos.z }, facedir = 2}
end
@ -51,25 +51,3 @@ function biome_lib:find_open_side(pos)
end
return nil
end
-- "Record" the map chunks being generated by the core mapgen,
-- split into individual mapblocks to reduce lag
minetest.register_on_generated(function(minp, maxp, blockseed)
local timestamp = minetest.get_us_time()
for x = 0, 4 do
local minx = minp.x + x*16
for y = 0, 4 do
local miny = minp.y + y*16
for z = 0, 4 do
local minz = minp.z + z*16
local bmin = {x=minx, y=miny, z=minz}
local bmax = {x=minx + 15, y=miny + 15, z=minz + 15}
biome_lib.block_log[#biome_lib.block_log + 1] = { bmin, bmax, true, timestamp }
biome_lib.block_log[#biome_lib.block_log + 1] = { bmin, bmax, false, timestamp }
end
end
end
biome_lib.run_block_recheck_list = true
end)

View file

@ -28,7 +28,7 @@ biome_lib_default_ground_nodes (List of default root nodes) string default:dirt_
# that many actions are executed on every single tick, skipping none.
# More negative means more throughput, at the expense of lag. On fast PC's,
# a setting of between -500 and -2000 might be good.
biome_lib_queue_run_ratio (Queue run ratio) int -100
biome_lib_queue_ratio (Queue run ratio) int -200
# Minetest's map generator allows neighboring areas to overflow into one
# another, to create smooth terrain, but it often hands the map blocks that

View file

@ -618,51 +618,51 @@ minetest.register_craft({
-- bonemeal (from bone)
minetest.register_craft({
type = "shapeless",
-- type = "shapeless",
output = "bonemeal:bonemeal 2",
recipe = {"group:bone"}
recipe = {{"group:bone"}}
})
-- bonemeal (from player bones)
minetest.register_craft({
type = "shapeless",
-- type = "shapeless",
output = "bonemeal:bonemeal 4",
recipe = {"bones:bones"}
recipe = {{"bones:bones"}}
})
-- bonemeal (from coral skeleton)
minetest.register_craft({
type = "shapeless",
-- type = "shapeless",
output = "bonemeal:bonemeal 2",
recipe = {"default:coral_skeleton"}
recipe = {{"default:coral_skeleton"}}
})
-- mulch
minetest.register_craft({
type = "shapeless",
-- type = "shapeless",
output = "bonemeal:mulch 4",
recipe = {
"group:tree", "group:leaves", "group:leaves",
"group:leaves", "group:leaves", "group:leaves",
"group:leaves", "group:leaves", "group:leaves"
{"group:tree", "group:leaves", "group:leaves"},
{"group:leaves", "group:leaves", "group:leaves"},
{"group:leaves", "group:leaves", "group:leaves"}
}
})
minetest.register_craft({
type = "shapeless",
-- type = "shapeless",
output = "bonemeal:mulch",
recipe = {
"group:seed", "group:seed", "group:seed",
"group:seed", "group:seed", "group:seed",
"group:seed", "group:seed", "group:seed"
{"group:seed", "group:seed", "group:seed"},
{"group:seed", "group:seed", "group:seed"},
{"group:seed", "group:seed", "group:seed"}
}
})
-- fertiliser
minetest.register_craft({
type = "shapeless",
-- type = "shapeless",
output = "bonemeal:fertiliser 2",
recipe = {"bonemeal:bonemeal", "bonemeal:mulch"}
recipe = {{"bonemeal:bonemeal", "bonemeal:mulch"}}
})

View file

@ -1,26 +1,18 @@
-- Minetest: builtin/item_entity.lua
-- override ice to make slippery for 0.4.16
if not minetest.raycast then
minetest.override_item("default:ice", {
groups = {cracky = 3, puts_out_fire = 1, cools_lava = 1, slippery = 3}})
end
function core.spawn_item(pos, item)
local stack = ItemStack(item)
local obj = core.add_entity(pos, "__builtin:item")
if obj then
obj:get_luaentity():set_item(stack:to_string())
obj:get_luaentity():set_item(ItemStack(item):to_string())
end
return obj
end
-- If item_entity_ttl is not set, enity will have default life time
-- If item_entity_ttl is not set, entity will have default life time
-- Setting it to -1 disables the feature
local time_to_live = tonumber(core.settings:get("item_entity_ttl")) or 900
local gravity = tonumber(core.settings:get("movement_gravity")) or 9.81
@ -78,8 +70,7 @@ local function quick_flow_logic(node, pos_testing, direction)
param2 = 0
end
if minetest.registered_nodes[node_testing.name].liquidtype ~= "flowing"
and minetest.registered_nodes[node_testing.name].liquidtype ~= "source" then
if minetest.registered_nodes[node_testing.name].liquidtype ~= "flowing" then
return 0
end
@ -108,7 +99,7 @@ end
local function quick_flow(pos, node)
local x, z = 0.0, 0.0
local x, z = 0, 0
x = x + quick_flow_logic(node, {x = pos.x - 1, y = pos.y, z = pos.z},-1)
x = x + quick_flow_logic(node, {x = pos.x + 1, y = pos.y, z = pos.z}, 1)
@ -135,19 +126,14 @@ local function add_effects(pos)
maxexptime = 3,
minsize = 1,
maxsize = 4,
texture = "tnt_smoke.png",
texture = "tnt_smoke.png"
})
end
-- print vector, helpful when debugging
local function vec_print(head, vec)
print(head, vec.x, vec.y, vec.z)
end
local water_force = tonumber(minetest.settings:get("builtin_item.waterflow_force") or 1.6)
local water_drag = tonumber(minetest.settings:get("builtin_item.waterflow_drag") or 0.8)
local dry_friction = tonumber(minetest.settings:get("builtin_item.friction_dry") or 2.5)
local dry_friction = tonumber(minetest.settings:get("builtin_item.friction_dry") or 2.6)
local air_drag = tonumber(minetest.settings:get("builtin_item.air_drag") or 0.4)
local items_collect_on_slippery = tonumber(
minetest.settings:get("builtin_item.items_collect_on_slippery") or 1) ~= 0
@ -194,7 +180,7 @@ core.register_entity(":__builtin:item", {
local col_height = size * 0.75
local def = core.registered_nodes[itemname]
local glow = def and def.light_source
local c1, c2 = "",""
local c1, c2 = "", ""
if not(stack:get_count() == 1) then
c1 = " x" .. tostring(stack:get_count())
@ -225,23 +211,20 @@ core.register_entity(":__builtin:item", {
glow = glow,
infotext = name .. c1 .. "\n(" .. itemname .. c2 .. ")"
})
end,
get_staticdata = function(self)
local data = {
return core.serialize({
itemstring = self.itemstring,
age = self.age,
dropped_by = self.dropped_by
}
return core.serialize(data)
})
end,
on_activate = function(self, staticdata, dtime_s)
if string.sub(staticdata, 1, string.len("return")) == "return" then
if string.sub(staticdata, 1, 6) == "return" then
local data = core.deserialize(staticdata)
@ -351,11 +334,9 @@ core.register_entity(":__builtin:item", {
step_node_inside_checks = function(self)
local pos = self.object:get_pos()
local node = self.node_inside
local def = self.def_inside
-- Delete in 'ignore' nodes
if node and node.name == "ignore" then
if self.node_inside and self.node_inside.name == "ignore" then
self.itemstring = ""
self.object:remove()
@ -363,6 +344,8 @@ core.register_entity(":__builtin:item", {
return true
end
local def = self.def_inside
-- item inside block, move to vacant space
if def and (def.walkable == nil or def.walkable == true)
and (def.collision_box == nil or def.collision_box.type == "regular")
@ -384,7 +367,7 @@ core.register_entity(":__builtin:item", {
pos = pos,
max_hear_distance = 6,
gain = 0.5
})
}, true)
self.itemstring = ""
self.object:remove()
@ -401,17 +384,16 @@ core.register_entity(":__builtin:item", {
-- don't check for slippery ground if we're not on
-- any ground to begin with
local node = self.node_under
local def = self.def_under
if self.falling_state or not self.node_under then
if self.falling_state or not node then
self.slippery_state = false
return
end
if node and def and def.walkable then
if self.node_under and self.def_under and self.def_under.walkable then
local slippery = core.get_item_group(node.name, "slippery")
local slippery = core.get_item_group(self.node_under.name, "slippery")
self.slippery_state = slippery ~= 0
end
@ -419,17 +401,16 @@ core.register_entity(":__builtin:item", {
step_water_physics = function(self)
local pos = self.object:get_pos()
local vel = self.object:get_velocity()
local node = self.node_inside
local def = self.def_inside
self.waterflow_state = def and def.liquidtype == "flowing"
self.waterflow_state = self.def_inside and
self.def_inside.liquidtype == "flowing"
if self.waterflow_state then
local pos = self.object:get_pos()
local vel = self.object:get_velocity()
-- get flow velocity
local flow_vel = quick_flow(pos, node)
local flow_vel = quick_flow(pos, self.node_inside)
-- calculate flow force and drag
local flow_force_x = flow_vel.x * water_force
@ -444,17 +425,6 @@ core.register_entity(":__builtin:item", {
end
end,
step_air_drag_physics = function(self)
local vel = self.object:get_velocity()
-- apply air drag
if self.falling_state or (self.slippery_state and not self.waterflow_state) then
self.accel.x = self.accel.x - vel.x * air_drag
self.accel.z = self.accel.z - vel.z * air_drag
end
end,
step_gravity = function(self)
if self.falling_state then
@ -473,12 +443,10 @@ core.register_entity(":__builtin:item", {
if self.slippery_state then
local node = self.node_under
-- apply slip factor (tiny friction that depends on the actual block type)
if (abs(vel.x) > 0.2 or abs(vel.z) > 0.2) then
if abs(vel.x) > 0.2 or abs(vel.z) > 0.2 then
local slippery = core.get_item_group(node.name, "slippery")
local slippery = core.get_item_group(self.node_under.name, "slippery")
local slip_factor = 4.0 / (slippery + 4)
self.accel.x = self.accel.x - vel.x * slip_factor
@ -497,17 +465,15 @@ core.register_entity(":__builtin:item", {
step_check_timeout = function(self, dtime)
local pos = self.object:get_pos()
self.age = self.age + dtime
if time_to_live > 0 and self.age > time_to_live then
add_effects(self.object:get_pos())
self.itemstring = ""
self.object:remove()
add_effects(pos)
return true
end
@ -516,14 +482,13 @@ core.register_entity(":__builtin:item", {
step_check_custom_step = function(self, dtime, moveresult)
local pos = self.object:get_pos()
-- do custom step function
local name = ItemStack(self.itemstring):get_name() or ""
local custom = core.registered_items[name]
and core.registered_items[name].dropped_step
if custom and custom(self, pos, dtime, moveresult) == false then
if custom
and custom(self, self.object:get_pos(), dtime, moveresult) == false then
return true -- skip further checks if false
end
@ -532,8 +497,6 @@ core.register_entity(":__builtin:item", {
step_try_collect = function(self)
local self_pos = self.object:get_pos()
-- Don't collect items if falling
if self.falling_state then
return
@ -551,6 +514,7 @@ core.register_entity(":__builtin:item", {
return
end
local self_pos = self.object:get_pos()
local objects = core.get_objects_inside_radius(self_pos, 1.0)
for _, obj in pairs(objects) do
@ -574,6 +538,18 @@ core.register_entity(":__builtin:item", {
end
end,
step_air_drag_physics = function(self)
local vel = self.object:get_velocity()
-- apply air drag
if self.falling_state
or (self.slippery_state and not self.waterflow_state) then
self.accel.x = self.accel.x - vel.x * air_drag
self.accel.z = self.accel.z - vel.z * air_drag
end
end,
on_step = function(self, dtime, moveresult)
-- reset acceleration
@ -602,7 +578,7 @@ core.register_entity(":__builtin:item", {
self:step_water_physics()
self:step_ground_friction()
self:step_gravity()
self:step_air_drag_physics()
self:step_apply_forces()
-- do item checks
@ -618,12 +594,14 @@ core.register_entity(":__builtin:item", {
local left = inv:add_item("main", self.itemstring)
if left and not left:is_empty() then
self:set_item(left)
return
end
end
self.itemstring = ""
self.object:remove()
end,
end
})

View file

@ -9,8 +9,8 @@ local pillar = {
}
if minetest.get_modpath("ethereal") then
pillar[7] = {"mushroomtrunk", "Mushroom Trunk", "mushroom_trunk", "ethereal:mushroom_trunk"}
pillar[8] = {"icebrick", "Ice Brick", "brick_ice", "ethereal:icebrick"}
pillar[7] = {"mushroomtrunk", "Mushroom Trunk", "ethereal_mushroom_trunk", "ethereal:mushroom_trunk"}
pillar[8] = {"icebrick", "Ice Brick", "ethereal_brick_ice", "ethereal:icebrick"}
end
local grp = {cracky = 3}

View file

@ -5,9 +5,9 @@ minetest.register_node("castle:light",{
sunlight_propagates = true,
light_source = 12,
tiles = {"castle_street_light.png"},
groups = {cracky=2, oddly_breakable_by_hand = 3},
groups = {cracky = 2, oddly_breakable_by_hand = 3},
sounds = default.node_sound_glass_defaults(),
paramtype = "light",
paramtype = "light"
})
minetest.register_craft({
@ -15,7 +15,7 @@ minetest.register_craft({
recipe = {
{"default:stick", "default:glass", "default:stick"},
{"default:glass", "default:torch", "default:glass"},
{"default:stick", "default:glass", "default:stick"},
{"default:stick", "default:glass", "default:stick"}
}
})
@ -25,13 +25,13 @@ minetest.register_node("castle:dungeon_stone", {
tiles = {"castle_dungeon_stone.png"},
groups = {cracky = 2},
paramtype = "light",
sounds = default.node_sound_stone_defaults(),
sounds = default.node_sound_stone_defaults()
})
minetest.register_craft({
type = "shapeless",
--type = "shapeless",
output = "castle:dungeon_stone",
recipe = {"default:stonebrick", "default:obsidian"},
recipe = {{"default:stonebrick", "default:obsidian"}}
})
minetest.register_node("castle:crate", {
@ -40,7 +40,8 @@ minetest.register_node("castle:crate", {
tiles = {
"castle_crate_top.png", "castle_crate_top.png",
"castle_crate.png", "castle_crate.png",
"castle_crate.png", "castle_crate.png"},
"castle_crate.png", "castle_crate.png"
},
groups = {choppy = 3},
paramtype = "light",
sounds = default.node_sound_wood_defaults(),
@ -70,14 +71,14 @@ minetest.register_node("castle:crate", {
local inv = meta:get_inventory()
return inv:is_empty("main")
end,
end
})
minetest.register_craft({
output = "castle:crate",
recipe = {
{"group:wood", "group:wood", "group:wood"},
{"group:wood", "default:steel_ingot", "group:wood"},
{"group:wood", "default:steel_ingot", "group:wood"}
}
})
@ -88,20 +89,17 @@ minetest.register_node("castle:ropes",{
tiles = {"castle_ropes.png"},
groups = {choppy = 3, snappy = 3, oddly_breakable_by_hand = 3,flammable = 1},
paramtype = "light",
use_texture_alpha = "clip",
paramtype2 = "facedir",
climbable = true,
walkable = false,
node_box = {
type = "fixed",
fixed = {
{-1/16, -8/16, -1/16, 1/16, 8/16, 1/16},
},
fixed = {{-1/16, -8/16, -1/16, 1/16, 8/16, 1/16}}
},
selection_box = {
type = "fixed",
fixed = {
{-1/16, -8/16, -1/16, 1/16, 8/16, 1/16},
},
fixed = {{-1/16, -8/16, -1/16, 1/16, 8/16, 1/16}}
}
})
@ -110,6 +108,6 @@ minetest.register_craft({
recipe = {
{"farming:string"},
{"farming:string"},
{"farming:string"},
{"farming:string"}
}
})

View file

@ -14,52 +14,78 @@ doors = {
registered_trapdoors = {}
}
-- returns an object to a door object or nil
function doors.get(pos)
local node_name = minetest.get_node(pos).name
if doors.registered_doors[node_name] then
-- A normal upright door
return {
pos = pos,
open = function(self, player)
if self:state() then
return false
end
return doors.door_toggle(self.pos, nil, player)
end,
close = function(self, player)
if not self:state() then
return false
end
return doors.door_toggle(self.pos, nil, player)
end,
toggle = function(self, player)
return doors.door_toggle(self.pos, nil, player)
end,
state = function(self)
local state = minetest.get_meta(self.pos):get_int("state")
return state %2 == 1
end
}
elseif doors.registered_trapdoors[node_name] then
-- A trapdoor
return {
pos = pos,
open = function(self, player)
if self:state() then
return false
end
return doors.trapdoor_toggle(self.pos, nil, player)
end,
close = function(self, player)
if not self:state() then
return false
end
return doors.trapdoor_toggle(self.pos, nil, player)
end,
toggle = function(self, player)
return doors.trapdoor_toggle(self.pos, nil, player)
end,
state = function(self)
return minetest.get_node(self.pos).name:sub(-5) == "_open"
end
@ -69,6 +95,7 @@ function doors.get(pos)
end
end
-- this hidden node is placed on top of the bottom, and prevents
-- nodes from being placed in the top half of the door.
minetest.register_node("doors:hidden", {
@ -79,6 +106,7 @@ minetest.register_node("doors:hidden", {
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
use_texture_alpha = "clip",
-- has to be walkable for falling nodes to stop falling.
walkable = true,
pointable = false,
@ -92,51 +120,57 @@ minetest.register_node("doors:hidden", {
-- 1px transparent block inside door hinge near node top.
node_box = {
type = "fixed",
fixed = {-15/32, 13/32, -15/32, -13/32, 1/2, -13/32},
fixed = {-15/32, 13/32, -15/32, -13/32, 1/2, -13/32}
},
-- collision_box needed otherise selection box would be full node size
collision_box = {
type = "fixed",
fixed = {-15/32, 13/32, -15/32, -13/32, 1/2, -13/32},
},
fixed = {-15/32, 13/32, -15/32, -13/32, 1/2, -13/32}
}
})
-- table used to aid door opening/closing
local transform = {
{
{ v = "_a", param2 = 3 },
{ v = "_a", param2 = 0 },
{ v = "_a", param2 = 1 },
{ v = "_a", param2 = 2 },
{ v = "_a", param2 = 2 }
},
{
{ v = "_b", param2 = 1 },
{ v = "_b", param2 = 2 },
{ v = "_b", param2 = 3 },
{ v = "_b", param2 = 0 },
{ v = "_b", param2 = 0 }
},
{
{ v = "_b", param2 = 1 },
{ v = "_b", param2 = 2 },
{ v = "_b", param2 = 3 },
{ v = "_b", param2 = 0 },
{ v = "_b", param2 = 0 }
},
{
{ v = "_a", param2 = 3 },
{ v = "_a", param2 = 0 },
{ v = "_a", param2 = 1 },
{ v = "_a", param2 = 2 },
},
{ v = "_a", param2 = 2 }
}
}
function doors.door_toggle(pos, node, clicker)
local meta = minetest.get_meta(pos) ; if not meta then return false end
node = node or minetest.get_node(pos)
local def = minetest.registered_nodes[node.name]
local name = def.door.name
local state = meta:get_string("state")
if state == "" then
-- fix up lvm-placed right-hinged doors, default closed
if node.name:sub(-2) == "_b" then
state = 2
@ -148,8 +182,10 @@ function doors.door_toggle(pos, node, clicker)
end
if clicker and not minetest.check_player_privs(clicker, "protection_bypass") then
local owner = meta:get_string("doors_owner")
local prot = meta:get_string("doors_protected")
if prot ~= "" then
if minetest.is_protected(pos, clicker:get_player_name()) then
@ -165,6 +201,7 @@ function doors.door_toggle(pos, node, clicker)
end
local old = state
-- until Lua-5.2 we have no bitwise operators :(
if state % 2 == 1 then
state = state - 1
@ -182,15 +219,19 @@ function doors.door_toggle(pos, node, clicker)
end
if state % 2 == 0 then
minetest.sound_play(def.door.sounds[1], {pos = pos, gain = 0.3, max_hear_distance = 10})
minetest.sound_play(def.door.sounds[1],
{pos = pos, gain = 0.3, max_hear_distance = 10})
else
minetest.sound_play(def.door.sounds[2], {pos = pos, gain = 0.3, max_hear_distance = 10})
minetest.sound_play(def.door.sounds[2],
{pos = pos, gain = 0.3, max_hear_distance = 10})
end
minetest.swap_node(pos, {
name = name .. transform[state + 1][dir+1].v,
param2 = transform[state + 1][dir+1].param2
name = name .. transform[state + 1][dir + 1].v,
param2 = transform[state + 1][dir + 1].param2
})
meta:set_int("state", state)
return true
@ -198,32 +239,50 @@ end
local function on_place_node(place_to, newnode, placer, oldnode, itemstack, pointed_thing)
-- Run script hook
local _, callback
for _, callback in pairs(minetest.registered_on_placenodes) do
-- Deepcopy pos, node and pointed_thing because callback can modify them
local place_to_copy = {x = place_to.x, y = place_to.y, z = place_to.z}
local newnode_copy = {name = newnode.name, param1 = newnode.param1, param2 = newnode.param2}
local oldnode_copy = {name = oldnode.name, param1 = oldnode.param1, param2 = oldnode.param2}
local newnode_copy = {
name = newnode.name,
param1 = newnode.param1,
param2 = newnode.param2
}
local oldnode_copy = {
name = oldnode.name,
param1 = oldnode.param1,
param2 = oldnode.param2
}
local pointed_thing_copy = {
type = pointed_thing.type,
above = vector.new(pointed_thing.above),
under = vector.new(pointed_thing.under),
ref = pointed_thing.ref,
ref = pointed_thing.ref
}
callback(place_to_copy, newnode_copy, placer, oldnode_copy, itemstack, pointed_thing_copy)
callback(place_to_copy, newnode_copy, placer, oldnode_copy, itemstack,
pointed_thing_copy)
end
end
local function can_dig_door(pos, digger)
local digger_name = digger and digger:get_player_name()
if digger_name and minetest.get_player_privs(digger_name).protection_bypass then
return true
end
return minetest.get_meta(pos):get_string("doors_owner") == digger_name
end
function doors.register(name, def)
if not name:find(":") then
name = "doors:" .. name
end
@ -232,7 +291,9 @@ function doors.register(name, def)
minetest.register_lbm({
name = ":doors:replace_" .. name:gsub(":", "_"),
nodenames = {name.."_b_1", name.."_b_2"},
action = function(pos, node)
local l = tonumber(node.name:sub(-1))
local meta = minetest.get_meta(pos)
local h = meta:get_int("right") + 1
@ -242,21 +303,27 @@ function doors.register(name, def)
{ { type = "b", state = 1 }, { type = "b", state = 2 } }
}
local new = replace[l][h]
-- retain infotext and doors_owner fields
minetest.swap_node(pos, {name = name .. "_" .. new.type, param2 = p2})
meta:set_int("state", new.state)
-- properly place doors:hidden at the right spot
local p3 = p2
if new.state >= 2 then
p3 = (p3 + 3) % 4
end
if new.state % 2 == 1 then
if new.state >= 2 then
p3 = (p3 + 1) % 4
else
p3 = (p3 + 3) % 4
end
end
-- wipe meta on top node as it's unused
minetest.set_node({x = pos.x, y = pos.y + 1, z = pos.z},
{name = "doors:hidden", param2 = p3})
@ -269,6 +336,7 @@ function doors.register(name, def)
groups = table.copy(def.groups),
on_place = function(itemstack, placer, pointed_thing)
local pos = nil
if not pointed_thing.type == "node" then
@ -277,9 +345,12 @@ function doors.register(name, def)
local node = minetest.get_node(pointed_thing.under)
local pdef = minetest.registered_nodes[node.name]
if pdef and pdef.on_rightclick and
not (placer and placer:is_player() and
placer:get_player_control().sneak) then
if pdef
and pdef.on_rightclick
and not (placer and placer:is_player()
and placer:get_player_control().sneak) then
return pdef.on_rightclick(pointed_thing.under,
node, placer, itemstack, pointed_thing)
end
@ -290,6 +361,7 @@ function doors.register(name, def)
pos = pointed_thing.above
node = minetest.get_node(pos)
pdef = minetest.registered_nodes[node.name]
if not pdef or not pdef.buildable_to then
return itemstack
end
@ -304,6 +376,7 @@ function doors.register(name, def)
end
local pn = placer and placer:get_player_name() or ""
if minetest.is_protected(pos, pn) or minetest.is_protected(above, pn) then
return itemstack
end
@ -314,16 +387,17 @@ function doors.register(name, def)
{ x = -1, y = 0, z = 0 },
{ x = 0, y = 0, z = 1 },
{ x = 1, y = 0, z = 0 },
{ x = 0, y = 0, z = -1 },
{ x = 0, y = 0, z = -1 }
}
local aside = {
x = pos.x + ref[dir + 1].x,
y = pos.y + ref[dir + 1].y,
z = pos.z + ref[dir + 1].z,
z = pos.z + ref[dir + 1].z
}
local state = 0
if minetest.get_item_group(minetest.get_node(aside).name, "door") == 1 then
state = state + 2
minetest.set_node(pos, {name = name .. "_b", param2 = dir})
@ -334,10 +408,13 @@ function doors.register(name, def)
end
local meta = minetest.get_meta(pos)
meta:set_int("state", state)
if def.protected then
local pn = placer:get_player_name()
meta:set_string("doors_owner", pn)
meta:set_string("infotext", "Owned by " .. pn)
end
@ -346,19 +423,23 @@ function doors.register(name, def)
itemstack:take_item()
end
on_place_node(pos, minetest.get_node(pos), placer, node, itemstack, pointed_thing)
on_place_node(pos, minetest.get_node(pos), placer, node, itemstack,
pointed_thing)
return itemstack
end
})
def.inventory_image = nil
if def.recipe then
minetest.register_craft({
output = name,
recipe = def.recipe,
})
end
def.recipe = nil
if not def.sounds then
@ -378,17 +459,23 @@ function doors.register(name, def)
def.drop = name
def.door = {
name = name,
sounds = { def.sound_close, def.sound_open },
sounds = { def.sound_close, def.sound_open }
}
def.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
doors.door_toggle(pos, node, clicker)
return itemstack
end
def.after_dig_node = function(pos, node, meta, digger)
minetest.remove_node({x = pos.x, y = pos.y + 1, z = pos.z})
minetest.check_for_falling({x = pos.x, y = pos.y + 1, z = pos.z})
end
def.on_rotate = false
if def.protected then
@ -396,9 +483,12 @@ function doors.register(name, def)
def.on_blast = function() end
else
def.on_blast = function(pos, intensity)
minetest.remove_node(pos)
-- hidden node doesn't get blasted away.
minetest.remove_node({x = pos.x, y = pos.y + 1, z = pos.z})
return {name}
end
end
@ -411,6 +501,7 @@ function doors.register(name, def)
def.paramtype = "light"
def.paramtype2 = "facedir"
def.sunlight_propagates = true
def.use_texture_alpha = "clip"
def.walkable = true
def.is_ground_content = false
def.buildable_to = false
@ -427,15 +518,16 @@ function doors.register(name, def)
doors.registered_doors[name .. "_b"] = true
end
doors.register("door_wood", {
tiles = {{ name = "doors_door_wood.png", backface_culling = true }},
description = "Wooden Door",
inventory_image = "doors_item_wood.png",
groups = { choppy = 2, oddly_breakable_by_hand = 2, flammable = 2 },
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
recipe = {
{"group:wood", "group:wood"},
{"group:wood", "group:wood"},
{"group:wood", "group:wood"},
{"group:wood", "group:wood"}
}
})
@ -444,62 +536,70 @@ doors.register("door_steel", {
description = "Steel Door",
inventory_image = "doors_item_steel.png",
protected = true,
groups = { cracky = 1, level = 2 },
groups = {cracky = 1, level = 2},
sounds = default.node_sound_stone_defaults(),
sound_open = "doors_steel_door_open",
sound_close = "doors_steel_door_close",
recipe = {
{"default:steel_ingot", "default:steel_ingot"},
{"default:steel_ingot", "default:steel_ingot"},
{"default:steel_ingot", "default:steel_ingot"},
{"default:steel_ingot", "default:steel_ingot"}
}
})
doors.register("door_glass", {
tiles = { "doors_door_glass.png"},
description = "Glass Door",
inventory_image = "doors_item_glass.png",
groups = { cracky = 3, oddly_breakable_by_hand = 3 },
groups = {cracky = 3, oddly_breakable_by_hand = 3},
sounds = default.node_sound_glass_defaults(),
sound_open = "doors_glass_door_open",
sound_close = "doors_glass_door_close",
recipe = {
{"default:glass", "default:glass"},
{"default:glass", "default:glass"},
{"default:glass", "default:glass"},
{"default:glass", "default:glass"}
}
})
doors.register("door_obsidian_glass", {
tiles = { "doors_door_obsidian_glass.png" },
description = "Obsidian Glass Door",
inventory_image = "doors_item_obsidian_glass.png",
groups = { cracky = 3 },
groups = {cracky = 3},
sounds = default.node_sound_glass_defaults(),
sound_open = "doors_glass_door_open",
sound_close = "doors_glass_door_close",
recipe = {
{"default:obsidian_glass", "default:obsidian_glass"},
{"default:obsidian_glass", "default:obsidian_glass"},
{"default:obsidian_glass", "default:obsidian_glass"},
},
{"default:obsidian_glass", "default:obsidian_glass"}
}
})
-- Capture mods using the old API as best as possible.
function doors.register_door(name, def)
if def.only_placer_can_open then
def.protected = true
end
def.only_placer_can_open = nil
local i = name:find(":")
local modname = name:sub(1, i - 1)
if not def.tiles then
if def.protected then
def.tiles = {{name = "doors_door_steel.png", backface_culling = true}}
else
def.tiles = {{name = "doors_door_wood.png", backface_culling = true}}
end
minetest.log("warning", modname .. " registered door \"" .. name .. "\" " ..
"using deprecated API method \"doors.register_door()\" but " ..
"did not provide the \"tiles\" parameter. A fallback tiledef " ..
@ -512,11 +612,15 @@ end
----trapdoor----
function doors.trapdoor_toggle(pos, node, clicker)
node = node or minetest.get_node(pos)
if clicker and not minetest.check_player_privs(clicker, "protection_bypass") then
local meta = minetest.get_meta(pos) ; if not meta then return false end
local owner = meta:get_string("doors_owner")
local prot = meta:get_string("doors_protected")
if prot ~= "" then
if minetest.is_protected(pos, clicker:get_player_name()) then
@ -534,15 +638,28 @@ function doors.trapdoor_toggle(pos, node, clicker)
local def = minetest.registered_nodes[node.name]
if string.sub(node.name, -5) == "_open" then
minetest.sound_play(def.sound_close, {pos = pos, gain = 0.3, max_hear_distance = 10})
minetest.swap_node(pos, {name = string.sub(node.name, 1, string.len(node.name) - 5), param1 = node.param1, param2 = node.param2})
minetest.sound_play(def.sound_close,
{pos = pos, gain = 0.3, max_hear_distance = 10})
minetest.swap_node(pos, {
name = string.sub(node.name, 1, string.len(node.name) - 5),
param1 = node.param1, param2 = node.param2
})
else
minetest.sound_play(def.sound_open, {pos = pos, gain = 0.3, max_hear_distance = 10})
minetest.swap_node(pos, {name = node.name .. "_open", param1 = node.param1, param2 = node.param2})
minetest.sound_play(def.sound_open,
{pos = pos, gain = 0.3, max_hear_distance = 10})
minetest.swap_node(pos, {
name = node.name .. "_open",
param1 = node.param1, param2 = node.param2
})
end
end
function doors.register_trapdoor(name, def)
if not name:find(":") then
name = "doors:" .. name
end
@ -551,7 +668,9 @@ function doors.register_trapdoor(name, def)
local name_opened = name.."_open"
def.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
doors.trapdoor_toggle(pos, node, clicker)
return itemstack
end
@ -559,13 +678,17 @@ function doors.register_trapdoor(name, def)
def.drawtype = "nodebox"
def.paramtype = "light"
def.paramtype2 = "facedir"
def.use_texture_alpha = "clip"
def.is_ground_content = false
if def.protected then
def.can_dig = can_dig_door
def.after_place_node = function(pos, placer, itemstack, pointed_thing)
local pn = placer:get_player_name()
local meta = minetest.get_meta(pos)
meta:set_string("doors_owner", pn)
meta:set_string("infotext", "Owned by "..pn)
@ -575,7 +698,9 @@ function doors.register_trapdoor(name, def)
def.on_blast = function() end
else
def.on_blast = function(pos, intensity)
minetest.remove_node(pos)
return { name }
end
end
@ -638,13 +763,14 @@ function doors.register_trapdoor(name, def)
doors.registered_trapdoors[name_closed] = true
end
doors.register_trapdoor("doors:trapdoor", {
description = "Trapdoor",
inventory_image = "doors_trapdoor.png",
wield_image = "doors_trapdoor.png",
tile_front = "doors_trapdoor.png",
tile_side = "doors_trapdoor_side.png",
groups = { choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, door = 1 },
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, door = 1}
})
doors.register_trapdoor("doors:trapdoor_steel", {
@ -656,7 +782,7 @@ doors.register_trapdoor("doors:trapdoor_steel", {
protected = true,
sound_open = "doors_steel_door_open",
sound_close = "doors_steel_door_close",
groups = { cracky = 1, level = 2, door = 1 },
groups = {cracky = 1, level = 2, door = 1}
})
minetest.register_craft({
@ -664,7 +790,7 @@ minetest.register_craft({
recipe = {
{"group:wood", "group:wood", "group:wood"},
{"group:wood", "group:wood", "group:wood"},
{"", "", ""},
{"", "", ""}
}
})
@ -672,11 +798,10 @@ minetest.register_craft({
output = "doors:trapdoor_steel",
recipe = {
{"default:steel_ingot", "default:steel_ingot"},
{"default:steel_ingot", "default:steel_ingot"},
{"default:steel_ingot", "default:steel_ingot"}
}
})
-----key tool-----
minetest.register_tool("doors:key", {
@ -754,7 +879,7 @@ minetest.register_craft({
recipe = {
{"", "", "default:steel_ingot"},
{"default:steel_ingot", "default:steel_ingot", ""},
{"default:steel_ingot", "default:steel_ingot", ""},
{"default:steel_ingot", "default:steel_ingot", ""}
}
})
@ -766,6 +891,7 @@ minetest.register_craft({
----fence gate----
function doors.register_fencegate(name, def)
local fence = {
description = def.description,
drawtype = "mesh",
@ -787,8 +913,8 @@ function doors.register_fencegate(name, def)
end,
selection_box = {
type = "fixed",
fixed = {-1/2, -1/2, -1/4, 1/2, 1/2, 1/4},
},
fixed = {-1/2, -1/2, -1/4, 1/2, 1/2, 1/4}
}
}
if not fence.sounds then
@ -798,15 +924,17 @@ function doors.register_fencegate(name, def)
fence.groups.fence = 1
local fence_closed = table.copy(fence)
fence_closed.mesh = "doors_fencegate_closed.obj"
fence_closed.gate = name .. "_open"
fence_closed.sound = "doors_fencegate_open"
fence_closed.collision_box = {
type = "fixed",
fixed = {-1/2, -1/2, -1/4, 1/2, 1/2, 1/4},
fixed = {-1/2, -1/2, -1/4, 1/2, 1/2, 1/4}
}
local fence_open = table.copy(fence)
fence_open.mesh = "doors_fencegate_open.obj"
fence_open.gate = name .. "_closed"
fence_open.sound = "doors_fencegate_close"
@ -829,6 +957,7 @@ function doors.register_fencegate(name, def)
})
end
doors.register_fencegate("doors:gate_wood", {
description = "Wooden Fence Gate",
texture = "default_wood.png",
@ -864,47 +993,46 @@ doors.register_fencegate("doors:gate_aspen_wood", {
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}
})
----fuels----
minetest.register_craft({
type = "fuel",
recipe = "doors:trapdoor",
burntime = 7,
burntime = 7
})
minetest.register_craft({
type = "fuel",
recipe = "doors:door_wood",
burntime = 14,
burntime = 14
})
minetest.register_craft({
type = "fuel",
recipe = "doors:gate_wood_closed",
burntime = 7,
burntime = 7
})
minetest.register_craft({
type = "fuel",
recipe = "doors:gate_acacia_wood_closed",
burntime = 8,
burntime = 8
})
minetest.register_craft({
type = "fuel",
recipe = "doors:gate_junglewood_closed",
burntime = 9,
burntime = 9
})
minetest.register_craft({
type = "fuel",
recipe = "doors:gate_pine_wood_closed",
burntime = 6,
burntime = 6
})
minetest.register_craft({
type = "fuel",
recipe = "doors:gate_aspen_wood_closed",
burntime = 5,
burntime = 5
})

View file

@ -28,11 +28,10 @@ minetest.register_craftitem("farming:barley", {
-- flour
minetest.register_craft({
type = "shapeless",
output = "farming:flour",
recipe = {
"farming:barley", "farming:barley", "farming:barley",
"farming:barley", "farming:mortar_pestle"
{"farming:barley", "farming:barley", "farming:barley"},
{"farming:barley", "farming:mortar_pestle", ""}
},
replacements = {{"group:food_mortar_pestle", "farming:mortar_pestle"}}
})

View file

@ -81,9 +81,7 @@ minetest.register_craftitem("farming:beans", {
-- beans can be used for green dye
minetest.register_craft({
output = "dye:green",
recipe = {
{"farming:beans"}
}
recipe = {{"farming:beans"}}
})
-- beanpole

View file

@ -21,20 +21,17 @@ minetest.register_craftitem("farming:beetroot_soup", {
})
minetest.register_craft({
type = "shapeless",
output = "farming:beetroot_soup",
recipe = {
"group:food_beetroot", "group:food_beetroot",
"group:food_beetroot", "group:food_beetroot",
"group:food_beetroot", "group:food_beetroot","group:food_bowl"
{"group:food_beetroot", "group:food_beetroot", "group:food_beetroot"},
{"group:food_beetroot", "group:food_bowl", "group:food_beetroot"}
}
})
-- red dye
minetest.register_craft({
type = "shapeless",
output = "dye:red",
recipe = {"group:food_beetroot"}
recipe = {{"group:food_beetroot"}}
})
local def = {

View file

@ -36,10 +36,9 @@ minetest.register_craftitem("farming:blueberry_pie", {
minetest.register_craft({
output = "farming:blueberry_pie",
type = "shapeless",
recipe = {
"group:food_flour", "group:food_sugar",
"group:food_blueberries", "group:food_baking_tray"
{"group:food_flour", "group:food_sugar", "group:food_blueberries"},
{"group:food_baking_tray", "", ""}
},
replacements = {{"group:food_baking_tray", "farming:baking_tray"}}
})
@ -79,7 +78,7 @@ def.drop = {
items = {
{items = {"farming:blueberries 2"}, rarity = 1},
{items = {"farming:blueberries"}, rarity = 2},
{items = {"farming:blueberries"}, rarity = 3},
{items = {"farming:blueberries"}, rarity = 3}
}
}
minetest.register_node("farming:blueberry_4", table.copy(def))

View file

@ -27,9 +27,10 @@ minetest.register_craftitem("farming:carrot_juice", {
minetest.register_craft({
output = "farming:carrot_juice",
type = "shapeless",
recipe = {
"vessels:drinking_glass", "group:food_carrot", "farming:juicer"
{"group:food_carrot"},
{"farming:juicer"},
{"vessels:drinking_glass"}
},
replacements = {
{"group:food_juicer", "farming:juicer"}

View file

@ -20,20 +20,17 @@ minetest.register_craftitem("farming:chili_bowl", {
})
minetest.register_craft({
type = "shapeless",
output = "farming:chili_bowl",
recipe = {
"group:food_chili_pepper", "group:food_barley",
"group:food_tomato", "group:food_beans", "group:food_bowl"
{"group:food_chili_pepper", "group:food_rice", "group:food_tomato"},
{"group:food_beans", "group:food_bowl", ""}
}
})
-- chili can be used for red dye
minetest.register_craft({
output = "dye:red",
recipe = {
{"farming:chili_pepper"}
}
recipe = {{"farming:chili_pepper"}}
})
-- chili definition

View file

@ -75,9 +75,7 @@ minetest.register_craftitem("farming:cocoa_beans", {
minetest.register_craft( {
output = "dye:brown 2",
recipe = {
{ "farming:cocoa_beans" }
}
recipe = {{"farming:cocoa_beans"}}
})
-- chocolate cookie
@ -128,9 +126,7 @@ minetest.register_craft({
minetest.register_craft({
output = "farming:chocolate_dark 9",
recipe = {
{"farming:chocolate_block"}
}
recipe = {{"farming:chocolate_block"}}
})
-- cocoa definition

View file

@ -34,10 +34,10 @@ minetest.register_alias("farming:drinking_cup", "vessels:drinking_glass")
minetest.register_craft( {
output = "farming:coffee_cup",
type = "shapeless",
recipe = {
"vessels:drinking_glass", "group:food_coffee",
"group:water_bucket", "group:food_saucepan"},
{"group:food_saucepan", "group:food_coffee", "group:water_bucket"},
{"", "vessels:drinking_glass", ""}
},
replacements = {
{"group:water_bucket", "bucket:bucket_empty"},
{"group:food_saucepan", "farming:saucepan"}
@ -47,10 +47,10 @@ minetest.register_craft( {
if minetest.get_modpath("bucket_wooden") then
minetest.register_craft( {
output = "farming:coffee_cup",
type = "shapeless",
recipe = {
"vessels:drinking_glass", "group:food_coffee",
"group:water_bucket_wooden", "group:food_saucepan"},
{"group:food_saucepan", "group:food_coffee", "group:water_bucket_wooden"},
{"", "vessels:drinking_glass", ""}
},
replacements = {
{"group:water_bucket_wooden", "bucket_wooden:bucket_empty"},
{"group:food_saucepan", "farming:saucepan"}

View file

@ -47,7 +47,7 @@ minetest.register_craft({
},
replacements = {
{"group:food_mortar_pestle", "farming:mortar_pestle"},
{"group:food_baking_tray", "farming:baking_tray"},
{"group:food_baking_tray", "farming:baking_tray"}
}
})
@ -72,9 +72,9 @@ minetest.register_node("farming:bottle_ethanol", {
minetest.register_craft( {
output = "farming:bottle_ethanol",
recipe = {
{ "vessels:glass_bottle", "group:food_corn", "group:food_corn"},
{ "group:food_corn", "group:food_corn", "group:food_corn"},
{ "group:food_corn", "group:food_corn", "group:food_corn"}
{"group:food_corn", "group:food_corn", "group:food_corn"},
{"group:food_corn", "vessels:glass_bottle", "group:food_corn"},
{"group:food_corn", "group:food_corn", "group:food_corn"}
}
})
@ -82,7 +82,7 @@ minetest.register_craft({
type = "fuel",
recipe = "farming:bottle_ethanol",
burntime = 80,
replacements = {{ "farming:bottle_ethanol", "vessels:glass_bottle"}}
replacements = {{"farming:bottle_ethanol", "vessels:glass_bottle"}}
})
-- corn definition

View file

@ -76,9 +76,7 @@ minetest.register_craftitem("farming:grapes", {
-- grapes can be used for violet dye
minetest.register_craft({
output = "dye:violet",
recipe = {
{"farming:grapes"}
}
recipe = {{"farming:grapes"}}
})
-- trellis

View file

@ -65,7 +65,7 @@ minetest.register_craft({
type = "fuel",
recipe = "farming:hemp_oil",
burntime = 20,
replacements = {{ "farming:hemp_oil", "vessels:glass_bottle"}}
replacements = {{"farming:hemp_oil", "vessels:glass_bottle"}}
})
-- hemp fibre

View file

@ -48,7 +48,7 @@ def.groups.growing = nil
def.drop = {
items = {
{items = {'farming:lettuce 2'}, rarity = 1},
{items = {'farming:lettuce 1'}, rarity = 2},
{items = {'farming:lettuce 1'}, rarity = 2}
}
}
minetest.register_node("farming:lettuce_5", table.copy(def))

View file

@ -21,9 +21,8 @@ minetest.register_craft({
})
minetest.register_craft({
type = "shapeless",
output = "farming:melon_slice 4",
recipe = {"farming:melon_8", "farming:cutting_board"},
recipe = {{"farming:cutting_board", "farming:melon_8"}},
replacements = {{"farming:cutting_board", "farming:cutting_board"}}
})
@ -74,14 +73,19 @@ minetest.register_node("farming:melon_7", table.copy(def))
-- stage 8 (final)
def.drawtype = "nodebox"
def.description = S("Melon")
def.tiles = {"farming_melon_top.png", "farming_melon_top.png", "farming_melon_side.png"}
def.tiles = {
"farming_melon_top.png", "farming_melon_bottom.png", "farming_melon_side.png"
}
def.selection_box = {-.5, -.5, -.5, .5, .5, .5}
def.walkable = true
def.buildable_to = false
def.paramtype2 = "facedir"
def.groups = {
food_melon = 1, snappy = 2, oddly_breakable_by_hand = 1,
flammable = 2, plant = 1
}
def.drop = "farming:melon_8"
def.on_place = minetest.rotate_node
minetest.register_node("farming:melon_8", table.copy(def))
-- add to registered_plants

View file

@ -29,11 +29,9 @@ minetest.register_craftitem("farming:mint_tea", {
minetest.register_craft({
output = "farming:mint_tea",
type = "shapeless",
recipe = {
"vessels:drinking_glass", "group:food_mint",
"group:food_mint", "group:food_mint",
"farming:juicer", "group:water_bucket"
{"group:food_mint", "group:food_mint", "group:food_mint"},
{"group:water_bucket", "farming:juicer", "vessels:drinking_glass"}
},
replacements = {
{"group:food_juicer", "farming:juicer"},
@ -44,11 +42,9 @@ minetest.register_craft({
if minetest.get_modpath("bucket_wooden") then
minetest.register_craft({
output = "farming:mint_tea",
type = "shapeless",
recipe = {
"vessels:drinking_glass", "group:food_mint",
"group:food_mint", "group:food_mint",
"farming:juicer", "group:water_bucket_wooden"
{"group:food_mint", "group:food_mint", "group:food_mint"},
{"group:water_bucket_wooden", "farming:juicer", "vessels:drinking_glass"}
},
replacements = {
{"group:food_juicer", "farming:juicer"},
@ -92,7 +88,7 @@ def.drop = {
{items = {"farming:mint_leaf 2"}, rarity = 1},
{items = {"farming:mint_leaf 2"}, rarity = 2},
{items = {"farming:seed_mint 1"}, rarity = 1},
{items = {"farming:seed_mint 2"}, rarity = 2},
{items = {"farming:seed_mint 2"}, rarity = 2}
}
}
minetest.register_node("farming:mint_4", table.copy(def))

View file

@ -27,12 +27,11 @@ minetest.register_craftitem("farming:onion_soup", {
})
minetest.register_craft({
type = "shapeless",
output = "farming:onion_soup",
recipe = {
"group:food_onion", "group:food_onion", "group:food_pot",
"group:food_onion", "group:food_onion",
"group:food_onion", "group:food_onion", "group:food_bowl"
{"group:food_onion", "group:food_onion", "group:food_onion"},
{"group:food_onion", "group:food_pot", "group:food_onion"},
{"", "group:food_bowl", ""}
},
replacements = {{"farming:pot", "farming:pot"}}
})
@ -81,7 +80,7 @@ def.drop = {
{items = {"farming:onion"}, rarity = 1},
{items = {"farming:onion"}, rarity = 2},
{items = {"farming:onion"}, rarity = 2},
{items = {"farming:onion"}, rarity = 5},
{items = {"farming:onion"}, rarity = 5}
}
}
minetest.register_node("farming:onion_5", table.copy(def))

View file

@ -21,9 +21,8 @@ minetest.register_craftitem("farming:peas", {
})
minetest.register_craft({
type = "shapeless",
output = "farming:peas",
recipe = {"farming:pea_pod"}
recipe = {{"farming:pea_pod"}}
})
-- pea soup
@ -35,9 +34,12 @@ minetest.register_craftitem("farming:pea_soup", {
})
minetest.register_craft({
type = "shapeless",
output = "farming:pea_soup",
recipe = {"group:food_peas", "group:food_peas", "group:food_bowl"}
recipe = {
{"group:food_peas"},
{"group:food_peas"},
{"group:food_bowl"}
}
})
local def = {

View file

@ -30,7 +30,7 @@ minetest.register_craftitem("farming:pepper_yellow", {
description = S("Yellow Pepper"),
inventory_image = "crops_pepper_yellow.png",
on_use = minetest.item_eat(3),
groups = {food_pepper = 1, flammable = 3},
groups = {food_pepper = 1, flammable = 3}
})
-- red pepper
@ -38,13 +38,12 @@ minetest.register_craftitem("farming:pepper_red", {
description = S("Red Pepper"),
inventory_image = "crops_pepper_red.png",
on_use = minetest.item_eat(4),
groups = {food_pepper = 1, flammable = 3},
groups = {food_pepper = 1, flammable = 3}
})
minetest.register_craft({
type = "shapeless",
output = "farming:peppercorn",
recipe = {"group:food_pepper"}
recipe = {{"group:food_pepper"}}
})
-- ground pepper
@ -69,8 +68,11 @@ minetest.register_node("farming:pepper_ground", {
minetest.register_craft( {
output = "farming:pepper_ground",
type = "shapeless",
recipe = {"group:food_peppercorn", "vessels:glass_bottle", "farming:mortar_pestle"},
recipe = {
{"group:food_peppercorn"},
{"farming:mortar_pestle"},
{"vessels:glass_bottle"}
},
replacements = {{"group:food_mortar_pestle", "farming:mortar_pestle"}}
})
@ -124,9 +126,9 @@ minetest.register_node("farming:pepper_5", table.copy(def))
def.tiles = {"crops_pepper_plant_6.png"}
def.drop = {
max_items = 2, items = {
{items = {'farming:pepper_yellow 2'}, rarity = 1},
{items = {'farming:pepper_yellow'}, rarity = 2},
{items = {'farming:pepper_yellow'}, rarity = 3},
{items = {"farming:pepper_yellow 2"}, rarity = 1},
{items = {"farming:pepper_yellow"}, rarity = 2},
{items = {"farming:pepper_yellow"}, rarity = 3}
}
}
minetest.register_node("farming:pepper_6", table.copy(def))
@ -136,9 +138,9 @@ def.tiles = {"crops_pepper_plant_7.png"}
def.groups.growing = nil
def.drop = {
max_items = 2, items = {
{items = {'farming:pepper_red 2'}, rarity = 1},
{items = {'farming:pepper_red'}, rarity = 2},
{items = {'farming:pepper_red'}, rarity = 3},
{items = {"farming:pepper_red 2"}, rarity = 1},
{items = {"farming:pepper_red"}, rarity = 2},
{items = {"farming:pepper_red"}, rarity = 3}
}
}
minetest.register_node("farming:pepper_7", table.copy(def))

View file

@ -38,8 +38,7 @@ minetest.register_craftitem("farming:pineapple_ring", {
minetest.register_craft( {
output = "farming:pineapple_ring 5",
type = "shapeless",
recipe = {"group:food_pineapple"},
recipe = {{"group:food_pineapple"}},
replacements = {{"farming:pineapple", "farming:pineapple_top"}}
})
@ -53,11 +52,12 @@ minetest.register_craftitem("farming:pineapple_juice", {
minetest.register_craft({
output = "farming:pineapple_juice",
type = "shapeless",
recipe = {
"vessels:drinking_glass", "group:food_pineapple_ring",
"group:food_pineapple_ring", "group:food_pineapple_ring",
"farming:juicer"},
{"group:food_pineapple_ring", "group:food_pineapple_ring",
"group:food_pineapple_ring"},
{"", "farming:juicer", ""},
{"", "vessels:drinking_glass", ""}
},
replacements = {
{"group:food_juicer", "farming:juicer"}
}
@ -65,10 +65,10 @@ minetest.register_craft({
minetest.register_craft({
output = "farming:pineapple_juice 2",
type = "shapeless",
recipe = {
"vessels:drinking_glass", "vessels:drinking_glass",
"group:food_pineapple", "farming:juicer"
{"group:food_pineapple", ""},
{"farming:juicer", ""},
{"vessels:drinking_glass", "vessels:drinking_glass"}
},
replacements = {
{"group:food_juicer", "farming:juicer"}

View file

@ -25,9 +25,8 @@ minetest.register_craft({
})
minetest.register_craft({
type = "shapeless",
output = "farming:pumpkin_slice 4",
recipe = {"farming:pumpkin", "farming:cutting_board"},
recipe = {{"farming:cutting_board", "farming:pumpkin"}},
replacements = {{"farming:cutting_board", "farming:cutting_board"}}
})
@ -122,8 +121,9 @@ minetest.register_craftitem("farming:pumpkin_dough", {
minetest.register_craft({
output = "farming:pumpkin_dough",
type = "shapeless",
recipe = {"group:food_flour", "group:food_pumpkin_slice", "group:food_pumpkin_slice"}
recipe = {
{"group:food_pumpkin_slice", "group:food_flour", "group:food_pumpkin_slice"}
}
})
minetest.register_craft({

View file

@ -45,7 +45,7 @@ local def = {
},
sounds = default.node_sound_leaves_defaults(),
minlight = 10,
maxlight = 12,
maxlight = 12
}
-- stage 1

View file

@ -19,11 +19,10 @@ minetest.override_item("farming:rye", {
})
minetest.register_craft({
type = "shapeless",
output = "farming:flour",
recipe = {
"farming:rye", "farming:rye", "farming:rye", "farming:rye",
"farming:mortar_pestle"
{"farming:rye", "farming:rye", "farming:rye"},
{"farming:rye", "farming:mortar_pestle", ""}
},
replacements = {{"group:food_mortar_pestle", "farming:mortar_pestle"}}
})
@ -44,11 +43,10 @@ minetest.override_item("farming:oat", {
})
minetest.register_craft({
type = "shapeless",
output = "farming:flour",
recipe = {
"farming:oat", "farming:oat", "farming:oat", "farming:oat",
"farming:mortar_pestle"
{"farming:oat", "farming:oat", "farming:oat"},
{"farming:oat", "farming:mortar_pestle", ""}
},
replacements = {{"group:food_mortar_pestle", "farming:mortar_pestle"}}
})
@ -82,11 +80,10 @@ minetest.register_craftitem("farming:rice_flour", {
})
minetest.register_craft({
type = "shapeless",
output = "farming:rice_flour",
recipe = {
"farming:rice", "farming:rice", "farming:rice", "farming:rice",
"farming:mortar_pestle"
{"farming:rice", "farming:rice", "farming:rice"},
{"farming:rice", "farming:mortar_pestle", ""}
},
replacements = {{"group:food_mortar_pestle", "farming:mortar_pestle"}}
})

View file

@ -19,9 +19,8 @@ minetest.register_craftitem("farming:soy_beans", {
})
minetest.register_craft({
type = "shapeless",
output = "farming:soy_beans",
recipe = {"farming:soy_pod"}
recipe = {{"farming:soy_pod"}}
})
-- soy sauce
@ -44,11 +43,11 @@ minetest.register_node("farming:soy_sauce", {
})
minetest.register_craft( {
type = "shapeless",
output = "farming:soy_sauce",
recipe = {
"group:food_soy", "group:food_soy", "group:food_juicer",
"bucket:bucket_river_water", "vessels:glass_bottle", "group:food_salt"
{"group:food_soy", "group:food_salt", "group:food_soy"},
{"", "group:food_juicer", ""},
{"", "bucket:bucket_river_water", "vessels:glass_bottle"}
},
replacements = {
{"bucket:bucket_river_water", "bucket:bucket_empty"},
@ -78,11 +77,10 @@ minetest.register_node("farming:soy_milk", {
})
minetest.register_craft( {
type = "shapeless",
output = "farming:soy_milk",
recipe = {
"group:food_soy", "group:food_soy", "group:food_soy",
"farming:vanilla_extract", "bucket:bucket_water", "vessels:drinking_glass"
{"group:food_soy", "group:food_soy", "group:food_soy"},
{"farming:vanilla_extract", "bucket:bucket_water", "vessels:drinking_glass"}
},
replacements = {
{"bucket:bucket_water", "bucket:bucket_empty"},
@ -100,10 +98,9 @@ minetest.register_craftitem("farming:tofu", {
minetest.register_craft({
output = "farming:tofu",
type = "shapeless",
recipe = {
"farming:baking_tray", "group:food_soy", "group:food_soy",
"group:food_soy", "group:food_soy", "group:food_soy",
{"farming:baking_tray", "group:food_soy", "group:food_soy"},
{"group:food_soy", "group:food_soy", "group:food_soy"}
},
replacements = {{"farming:baking_tray", "farming:baking_tray"}}
})
@ -163,7 +160,7 @@ minetest.register_node("farming:soy_4", table.copy(def))
def.tiles = {"farming_soy_5.png"}
def.drop = {
max_items = 1, items = {
{items = {'farming:soy_pod'}, rarity = 1},
{items = {"farming:soy_pod"}, rarity = 1},
}
}
minetest.register_node("farming:soy_5", table.copy(def))
@ -172,9 +169,9 @@ minetest.register_node("farming:soy_5", table.copy(def))
def.tiles = {"farming_soy_6.png"}
def.drop = {
max_items = 3, items = {
{items = {'farming:soy_pod'}, rarity = 1},
{items = {'farming:soy_pod'}, rarity = 2},
{items = {'farming:soy_pod'}, rarity = 3},
{items = {"farming:soy_pod"}, rarity = 1},
{items = {"farming:soy_pod"}, rarity = 2},
{items = {"farming:soy_pod"}, rarity = 3},
}
}
minetest.register_node("farming:soy_6", table.copy(def))
@ -184,11 +181,11 @@ def.tiles = {"farming_soy_7.png"}
def.groups.growing = nil
def.drop = {
max_items = 5, items = {
{items = {'farming:soy_pod'}, rarity = 1},
{items = {'farming:soy_pod'}, rarity = 2},
{items = {'farming:soy_pod'}, rarity = 3},
{items = {'farming:soy_pod'}, rarity = 4},
{items = {'farming:soy_pod'}, rarity = 5}
{items = {"farming:soy_pod"}, rarity = 1},
{items = {"farming:soy_pod"}, rarity = 2},
{items = {"farming:soy_pod"}, rarity = 3},
{items = {"farming:soy_pod"}, rarity = 4},
{items = {"farming:soy_pod"}, rarity = 5}
}
}
minetest.register_node("farming:soy_7", table.copy(def))

View file

@ -17,6 +17,23 @@ minetest.register_craftitem("farming:tomato", {
on_use = minetest.item_eat(4)
})
-- tomato soup
minetest.register_craftitem("farming:tomato_soup", {
description = S("Tomato Soup"),
inventory_image = "farming_tomato_soup.png",
groups = {flammable = 2},
on_use = minetest.item_eat(8, "farming:bowl")
})
minetest.register_craft({
output = "farming:tomato_soup",
recipe = {
{"group:food_tomato"},
{"group:food_tomato"},
{"group:food_bowl"}
}
})
-- tomato definition
local def = {
drawtype = "plantlike",

View file

@ -8,7 +8,7 @@ minetest.register_craftitem("farming:vanilla", {
on_place = function(itemstack, placer, pointed_thing)
return farming.place_seed(itemstack, placer, pointed_thing, "farming:vanilla_1")
end,
on_use = minetest.item_eat(1),
on_use = minetest.item_eat(1)
})
-- crop definition
@ -49,8 +49,8 @@ minetest.register_node("farming:vanilla_extract", {
minetest.register_craft( {
output = "farming:vanilla_extract",
recipe = {
{ "group:food_vanilla", "group:food_vanilla", "group:food_vanilla"},
{ "group:food_vanilla", "farming:bottle_ethanol", "bucket:bucket_water"},
{"group:food_vanilla", "group:food_vanilla", "group:food_vanilla"},
{"group:food_vanilla", "farming:bottle_ethanol", "bucket:bucket_water"},
},
replacements = {
{"bucket:bucket_water", "bucket:bucket_empty"},
@ -61,7 +61,7 @@ minetest.register_craft({
type = "fuel",
recipe = "farming:vanilla_extract",
burntime = 25,
replacements = {{ "farming:vanilla_extract", "vessels:glass_bottle" }}
replacements = {{"farming:vanilla_extract", "vessels:glass_bottle"}}
})
-- stage 1
@ -92,9 +92,9 @@ minetest.register_node("farming:vanilla_6", table.copy(def))
def.tiles = {"farming_vanilla_7.png"}
def.drop = {
items = {
{items = {'farming:vanilla'}, rarity = 1},
{items = {'farming:vanilla'}, rarity = 2},
{items = {'farming:vanilla'}, rarity = 3}
{items = {"farming:vanilla"}, rarity = 1},
{items = {"farming:vanilla"}, rarity = 2},
{items = {"farming:vanilla"}, rarity = 3}
}
}
minetest.register_node("farming:vanilla_7", table.copy(def))
@ -104,10 +104,10 @@ def.tiles = {"farming_vanilla_8.png"}
def.groups.growing = nil
def.drop = {
items = {
{items = {'farming:vanilla 2'}, rarity = 1},
{items = {'farming:vanilla 2'}, rarity = 2},
{items = {'farming:vanilla 2'}, rarity = 2},
{items = {'farming:vanilla 2'}, rarity = 3}
{items = {"farming:vanilla 2"}, rarity = 1},
{items = {"farming:vanilla 2"}, rarity = 2},
{items = {"farming:vanilla 2"}, rarity = 2},
{items = {"farming:vanilla 2"}, rarity = 3}
}
}
minetest.register_node("farming:vanilla_8", table.copy(def))

View file

@ -46,9 +46,7 @@ minetest.register_craft({
minetest.register_craft({
output = "farming:wheat 3",
recipe = {
{"farming:straw"}
}
recipe = {{"farming:straw"}}
})
-- check and register stairs
@ -80,11 +78,10 @@ minetest.register_craftitem("farming:flour", {
})
minetest.register_craft({
type = "shapeless",
output = "farming:flour",
recipe = {
"farming:wheat", "farming:wheat", "farming:wheat",
"farming:wheat", "farming:mortar_pestle"
{"farming:wheat", "farming:wheat", "farming:wheat"},
{"farming:wheat", "farming:mortar_pestle", ""}
},
replacements = {{"group:food_mortar_pestle", "farming:mortar_pestle"}}
})
@ -113,9 +110,8 @@ minetest.register_craftitem("farming:bread_slice", {
})
minetest.register_craft({
type = "shapeless",
output = "farming:bread_slice 5",
recipe = {"farming:bread", "group:food_cutting_board"},
recipe = {{"group:food_cutting_board", "farming:bread"}},
replacements = {{"group:food_cutting_board", "farming:cutting_board"}}
})

View file

@ -117,9 +117,11 @@ minetest.register_node("farming:salt_crystal", {
},
})
minetest.register_craft({
type = "shapeless",
-- type = "shapeless",
output = "farming:salt 9",
recipe = {"farming:salt_crystal", "farming:mortar_pestle"},
recipe = {
{"farming:salt_crystal", "farming:mortar_pestle"}
},
replacements = {{"farming:mortar_pestle", "farming:mortar_pestle"}}
})
@ -211,9 +213,11 @@ minetest.register_craftitem("farming:garlic_bread", {
})
minetest.register_craft({
type = "shapeless",
-- type = "shapeless",
output = "farming:garlic_bread",
recipe = {"group:food_toast", "group:food_garlic_clove", "group:food_garlic_clove"}
recipe = {
{"group:food_toast", "group:food_garlic_clove", "group:food_garlic_clove"}
}
})
--= Donuts (thanks to Bockwurst for making the donut images)
@ -270,11 +274,11 @@ minetest.register_craftitem("farming:porridge", {
})
minetest.register_craft({
type = "shapeless",
-- type = "shapeless",
output = "farming:porridge",
recipe = {
"group:food_oats", "group:food_oats", "group:food_oats",
"group:food_oats", "group:food_bowl", "group:food_milk_glass"
{"group:food_oats", "group:food_oats", "group:food_oats"},
{"group:food_oats", "group:food_bowl", "group:food_milk_glass"}
},
replacements = {
{"mobs:glass_milk", "vessels:drinking_glass"},
@ -291,12 +295,12 @@ minetest.register_craftitem("farming:jaffa_cake", {
})
minetest.register_craft({
type = "shapeless",
-- type = "shapeless",
output = "farming:jaffa_cake",
recipe = {
"farming:baking_tray", "group:food_egg", "group:food_sugar",
"group:food_flour", "group:food_cocoa", "group:food_orange",
"group:food_milk"
{"farming:baking_tray", "group:food_egg", "group:food_sugar"},
{"group:food_flour", "group:food_cocoa", "group:food_orange"},
{"group:food_milk", "", ""}
},
replacements = {
{"farming:baking_tray", "farming:baking_tray"},
@ -314,10 +318,9 @@ minetest.register_craftitem("farming:apple_pie", {
minetest.register_craft({
output = "farming:apple_pie",
type = "shapeless",
recipe = {
"group:food_flour", "group:food_sugar",
"group:food_apple", "group:food_baking_tray"
{"group:food_flour", "group:food_sugar", "group:food_apple"},
{"", "group:food_baking_tray", ""}
},
replacements = {{"group:food_baking_tray", "farming:baking_tray"}}
})
@ -342,11 +345,11 @@ minetest.register_craftitem("farming:cactus_juice", {
})
minetest.register_craft({
output = "farming:cactus_juice 2",
type = "shapeless",
output = "farming:cactus_juice",
recipe = {
"vessels:drinking_glass", "vessels:drinking_glass",
"default:cactus", "farming:juicer"
{"default:cactus"},
{"farming:juicer"},
{"vessels:drinking_glass"}
},
replacements = {
{"group:food_juicer", "farming:juicer"}
@ -363,20 +366,16 @@ minetest.register_craftitem("farming:pasta", {
minetest.register_craft({
output = "farming:pasta",
type = "shapeless",
recipe = {
"group:food_flour", "group:food_mixing_bowl",
"group:food_butter"
{"group:food_flour", "group:food_butter", "group:food_mixing_bowl"}
},
replacements = {{"group:food_mixing_bowl", "farming:mixing_bowl"}}
})
minetest.register_craft({
output = "farming:pasta",
type = "shapeless",
recipe = {
"group:food_flour", "group:food_mixing_bowl",
"group:food_oil"
{"group:food_flour", "group:food_oil", "group:food_mixing_bowl"}
},
replacements = {
{"group:food_mixing_bowl", "farming:mixing_bowl"},
@ -394,10 +393,9 @@ minetest.register_craftitem("farming:spaghetti", {
minetest.register_craft({
output = "farming:spaghetti",
type = "shapeless",
recipe = {
"group:food_pasta", "group:food_saucepan",
"group:food_tomato", "group:food_garlic_clove", "group:food_garlic_clove"
{"group:food_pasta", "group:food_saucepan", "group:food_tomato"},
{"group:food_garlic_clove", "group:food_garlic_clove", ""}
},
replacements = {{"group:food_saucepan", "farming:saucepan"}}
})
@ -412,11 +410,10 @@ minetest.register_craftitem("farming:bibimbap", {
minetest.register_craft({
output = "farming:bibimbap",
type = "shapeless",
recipe = {
"group:food_skillet", "group:food_bowl", "group:food_egg", "group:food_rice",
"group:food_chicken_raw", "group:food_cabbage", "group:food_carrot",
"group:food_chili_pepper"
{"group:food_skillet", "group:food_bowl", "group:food_egg"},
{"group:food_rice", "group:food_chicken_raw", "group:food_cabbage"},
{"group:food_carrot", "group:food_chili_pepper", ""}
},
replacements = {{"group:food_skillet", "farming:skillet"}}
})
@ -441,12 +438,11 @@ minetest.register_craftitem("farming:burger", {
})
minetest.register_craft({
type = "shapeless",
output = "farming:burger",
recipe = {
"farming:bread", "group:food_meat", "group:food_cheese",
"group:food_tomato", "group:food_cucumber", "group:food_onion",
"group:food_lettuce"
{"farming:bread", "group:food_meat", "group:food_cheese"},
{"group:food_tomato", "group:food_cucumber", "group:food_onion"},
{"group:food_lettuce", "", ""}
}
})
@ -464,7 +460,7 @@ minetest.register_craft({
recipe = {
"group:food_bowl", "group:food_tomato", "group:food_cucumber",
"group:food_lettuce", "group:food_oil"
},
}
})
-- Triple Berry Smoothie
@ -510,7 +506,7 @@ minetest.register_craft({
minetest.register_craftitem("farming:potato_omelet", {
description = S("Potato omelet"),
inventory_image = "farming_potato_omelet.png",
on_use = minetest.item_eat(6, "farming:bowl"),
on_use = minetest.item_eat(6, "farming:bowl")
})
minetest.register_craft({
@ -549,11 +545,10 @@ minetest.register_craftitem("farming:flan", {
})
minetest.register_craft({
type = "shapeless",
output = "farming:flan",
recipe = {
"group:food_sugar", "group:food_milk", "farming:caramel",
"group:food_egg", "group:food_egg", "farming:vanilla_extract"
{"group:food_sugar", "group:food_milk", "farming:caramel"},
{"group:food_egg", "group:food_egg", "farming:vanilla_extract"}
},
replacements = {
{"cucina_vegana:soy_milk", "vessels:drinking_glass"},
@ -568,17 +563,16 @@ minetest.register_craftitem("farming:cheese_vegan", {
description = S("Vegan Cheese"),
inventory_image = "farming_cheese_vegan.png",
on_use = minetest.item_eat(2),
groups = {food_cheese = 1, flammable = 2},
groups = {food_cheese = 1, flammable = 2}
})
minetest.register_craft({
type = "shapeless",
output = "farming:cheese_vegan",
recipe = {
"farming:soy_milk", "farming:soy_milk", "farming:soy_milk",
"group:food_salt", "group:food_peppercorn", "farming:bottle_ethanol",
"group:food_gelatin", "group:food_pot"
{"farming:soy_milk", "farming:soy_milk", "farming:soy_milk"},
{"group:food_salt", "group:food_peppercorn", "farming:bottle_ethanol"},
{"group:food_gelatin", "group:food_pot", ""}
},
replacements = {
{"farming:soy_milk", "vessels:drinking_glass 3"},
@ -588,16 +582,15 @@ minetest.register_craft({
})
minetest.register_craft({
type = "shapeless",
output = "farming:cheese_vegan",
recipe = {
"farming:soy_milk", "farming:soy_milk", "farming:soy_milk",
"group:food_salt", "group:food_peppercorn", "group:food_lemon",
"group:food_gelatin", "group:food_pot"
{"farming:soy_milk", "farming:soy_milk", "farming:soy_milk"},
{"group:food_salt", "group:food_peppercorn", "group:food_lemon"},
{"group:food_gelatin", "group:food_pot", ""}
},
replacements = {
{"farming:soy_milk", "vessels:drinking_glass 3"},
{"farming:pot", "farming:pot"},
{"farming:pot", "farming:pot"}
}
})
@ -607,14 +600,14 @@ minetest.register_craftitem("farming:onigiri", {
description = S("Onirigi"),
inventory_image = "farming_onigiri.png",
on_use = minetest.item_eat(2),
groups = {flammable = 2},
groups = {flammable = 2}
})
minetest.register_craft({
type = "shapeless",
output = "farming:onigiri",
recipe = {
"group:food_rice", "group:food_rice", "group:food_seaweed", "group:food_salt"
{"group:food_rice", "group:food_salt", "group:food_rice"},
{"", "group:food_seaweed", ""}
}
})
@ -624,16 +617,16 @@ minetest.register_craftitem("farming:gyoza", {
description = S("Gyoza"),
inventory_image = "farming_gyoza.png",
on_use = minetest.item_eat(4),
groups = {flammable = 2},
groups = {flammable = 2}
})
minetest.register_craft({
type = "shapeless",
output = "farming:gyoza 4",
recipe = {
"group:food_cabbage", "group:food_garlic_clove", "group:food_onion",
"group:food_meat_raw", "group:food_salt", "group:food_skillet",
"group:food_flour"
{"group:food_cabbage", "group:food_garlic_clove", "group:food_onion"},
{"group:food_meat_raw", "group:food_salt", "group:food_flour"},
{"", "group:food_skillet", ""}
},
replacements = {
{"group:food_skillet", "farming:skillet"}
@ -646,15 +639,15 @@ minetest.register_craftitem("farming:mochi", {
description = S("Mochi"),
inventory_image = "farming_mochi.png",
on_use = minetest.item_eat(3),
groups = {flammable = 2},
groups = {flammable = 2}
})
minetest.register_craft({
type = "shapeless",
output = "farming:mochi",
recipe = {
"group:food_mortar_pestle", "group:food_rice", "group:food_rice",
"group:food_sugar", "bucket:bucket_river_water"
{"group:food_rice", "group:food_sugar", "group:food_rice"},
{"", "group:food_mortar_pestle", ""},
{"", "bucket:bucket_river_water", ""}
},
replacements = {
{"group:food_mortar_pestle", "farming:mortar_pestle"},

View file

@ -63,6 +63,11 @@ Created by VanessaE (License: CC BY 3.0):
farming_cotton_7.png
farming_cotton_8.png
Created by 7eventy7 (https://www.planetminecraft.com/member/7eventy7/)
farming_melon_top.png
farming_melon_side.png
farming_melon_bottom.png
Created by Doc (License: CC BY 3.0):
farming_cucumber.png
farming_cucumber_1.png
@ -164,3 +169,7 @@ Created by Felfa (CC0)
Created by gorlock (CC0)
farming_salt_crystal.png
Created by sirrobzeroone (CC0)
farming_gyoza.png
farming_pineapple_ring.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 B

After

Width:  |  Height:  |  Size: 179 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 272 B

After

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 B

After

Width:  |  Height:  |  Size: 155 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 B

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 132 B

After

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 B

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 158 B

After

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 166 B

After

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 164 B

After

Width:  |  Height:  |  Size: 449 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 B

View file

@ -20,7 +20,7 @@ minetest.register_craft({
minetest.register_craft({
type = "fuel",
recipe = "farming:bowl",
burntime = 10,
burntime = 10
})
-- saucepan
@ -155,9 +155,6 @@ minetest.register_craft({
})
minetest.register_craft( {
type = "shapeless",
output = "vessels:glass_fragments",
recipe = {
"farming:mixing_bowl"
}
recipe = {{"farming:mixing_bowl"}}
})

View file

@ -3,6 +3,7 @@ minetest.register_alias("computer:shefriendSOO_off", "computers:shefriendSOO
minetest.register_alias("computer:vanio", "computers:vanio")
minetest.register_alias("computer:vanio_off", "computers:vanio_off")
minetest.register_alias("computer:slaystation", "computers:slaystation")
minetest.register_alias("computer:slaystation_off", "computers:slaystation_off")
minetest.register_alias("computer:slaystation2", "computers:slaystation2")
minetest.register_alias("computer:slaystation2_off", "computers:slaystation2_off")
minetest.register_alias("computer:specter", "computers:specter")

View file

@ -283,7 +283,7 @@ for _, mat in ipairs(counter_materials) do
})
homedecor.kitchen_convert_nodes[#homedecor.kitchen_convert_nodes + 1] = "homedecor:kitchen_cabinet"..material
homedecor.kitchen_convert_nodes[#homedecor.kitchen_convert_nodes + 1] = "homedecor:kitchen_cabinet_locked"..material
homedecor.kitchen_convert_nodes[#homedecor.kitchen_convert_nodes + 1] = "homedecor:kitchen_cabinet"..material.."_locked"
end

View file

@ -15,7 +15,8 @@ local shoes = {
["mobs:horseshoe_steel"] = {7, 4, 2, "mobs_horseshoe_steelo.png"},
["mobs:horseshoe_bronze"] = {7, 4, 4, "mobs_horseshoe_bronzeo.png"},
["mobs:horseshoe_mese"] = {9, 5, 8, "mobs_horseshoe_meseo.png"},
["mobs:horseshoe_diamond"] = {10, 6, 6, "mobs_horseshoe_diamondo.png"}
["mobs:horseshoe_diamond"] = {10, 6, 6, "mobs_horseshoe_diamondo.png"},
["mobs:horseshoe_crystal"] = {11, 6, 9, "mobs_horseshoe_crystalo.png"}
}
-- rideable horse
@ -292,6 +293,25 @@ minetest.register_craft({
}
})
-- crystal horseshoes
if minetest.get_modpath("ethereal") then
minetest.register_craftitem(":mobs:horseshoe_crystal", {
description = S("Crystal HorseShoes (use on horse to apply)"),
inventory_image = "mobs_horseshoe_crystal.png",
})
minetest.register_craft({
output = "mobs:horseshoe_crystal",
recipe = {
{"", "ethereal:crystal_block", ""},
{"ethereal:crystal_ingot", "", "ethereal:crystal_ingot"},
{"ethereal:crystal_ingot", "", "ethereal:crystal_ingot"},
}
})
end
-- lucky blocks
if minetest.get_modpath("lucky_block") then
@ -300,6 +320,7 @@ lucky_block:add_blocks({
{"dro", {"mobs:horseshoe_bronze"}},
{"dro", {"mobs:horseshoe_mese"}},
{"dro", {"mobs:horseshoe_diamond"}},
{"dro", {"mobs:horseshoe_crystal"}}
})
end

View file

@ -9,10 +9,10 @@ Horses can be tamed with 10x wheat, apple, barley, oats of corn which then allow
---
### Horseshoes
Horseshoes can be crafted using steel, bronze, mese and diamond (4x ingots - 2 down either side with 1x block top middle) and placed on a horse by right clicking with the item. These can make horses run faster or jump higher while riding depending on tier.
Horseshoes can be crafted using steel, bronze, mese, diamond and crystal (4x ingots - 2 down either side with 1x block top middle) and placed on a horse by right clicking with the item. These can make horses run faster or jump higher while riding depending on tier.
---
### Dead Horse
When riding a horse monsters will generally attack the horse first to get to player riding it, when horse dies the player is dismounted and it will drop any shoes or saddles in use as well as some horse meat.
#### Lucky Blocks: 4
#### Lucky Blocks: 5

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 B

View file

@ -172,9 +172,9 @@ minetest.register_craft({
minetest.register_craft({
output = "mobs:leather",
type = "shapeless",
-- type = "shapeless",
recipe = {
"mobs:rabbit_hide", "mobs:rabbit_hide",
"mobs:rabbit_hide", "mobs:rabbit_hide"
{"mobs:rabbit_hide", "mobs:rabbit_hide"},
{"mobs:rabbit_hide", "mobs:rabbit_hide"}
}
})

View file

@ -174,26 +174,26 @@ minetest.register_craftitem(":mobs:glass_milk", {
})
minetest.register_craft({
type = "shapeless",
-- type = "shapeless",
output = "mobs:glass_milk 4",
recipe = {
"vessels:drinking_glass", "vessels:drinking_glass",
"vessels:drinking_glass", "vessels:drinking_glass",
"mobs:bucket_milk"
{"vessels:drinking_glass", "vessels:drinking_glass"},
{"vessels:drinking_glass", "vessels:drinking_glass"},
{"mobs:bucket_milk", ""}
},
replacements = { {"mobs:bucket_milk", "bucket:bucket_empty"} }
})
minetest.register_craft({
type = "shapeless",
-- type = "shapeless",
output = "mobs:bucket_milk",
recipe = {
"group:food_milk_glass", "group:food_milk_glass",
"group:food_milk_glass", "group:food_milk_glass",
"bucket:bucket_empty"
{"group:food_milk_glass", "group:food_milk_glass"},
{"group:food_milk_glass", "group:food_milk_glass"},
{"bucket:bucket_empty", ""}
},
replacements = {
{"group:food_milk_glass", "vessels:drinking_glass 4"},
{"group:food_milk_glass", "vessels:drinking_glass 4"}
}
})
@ -203,7 +203,7 @@ minetest.register_craftitem(":mobs:butter", {
description = S("Butter"),
inventory_image = "mobs_butter.png",
on_use = minetest.item_eat(1),
groups = {food_butter = 1, flammable = 2},
groups = {food_butter = 1, flammable = 2}
})
if minetest.get_modpath("farming") and farming and farming.mod then

View file

@ -53,7 +53,8 @@ stepheight = 1.1,
stoodup_end = 0,
},
follow = {
"mobs:rat", "group:food_fish_raw", "mobs_fish:tropical", "xocean:fish_edible"
"mobs_animal:rat", "group:food_fish_raw",
"mobs_fish:tropical", "xocean:fish_edible"
},
view_range = 8,

View file

@ -92,12 +92,12 @@ minetest.register_craftitem(":mobs:rat_cooked", {
description = S("Cooked Rat"),
inventory_image = "mobs_cooked_rat.png",
on_use = minetest.item_eat(3),
groups = {food_rat = 1, flammable = 2},
groups = {food_rat = 1, flammable = 2}
})
minetest.register_craft({
type = "cooking",
output = "mobs:rat_cooked",
recipe = "mobs_animal:rat",
cooktime = 5,
cooktime = 5
})

View file

@ -0,0 +1,88 @@
local S = mobs.intllib
-- Fire Spirit
mobs:register_mob("mobs_monster:fire_spirit", {
type = "monster",
passive = false,
attack_type = "dogfight",
pathfinding = true,
reach = 2,
damage = 4,
hp_min = 25,
hp_max = 45,
armor = 100,
collisionbox = {-0.1, -0.1, -0.1, 0.1, 0.1, 0.1},
visual_scale = {x = 0.5, y = 0.5, z = 0.5},
visual = "sprite",
textures = {
{"mobs_fire_spirit.png"}
},
glow = 14,
blood_texture = "fire_basic_flame.png",
immune_to = {
{"all"}
},
makes_footstep_sound = false,
sounds = {
random = "fire_fire",
damage = "fire_extinguish_flame",
death = "fire_extinguish_flame"
},
view_range = 14,
walk_velocity = 2,
run_velocity = 3,
jump = true,
drops = {
{name = "fireflies:firefly", chance = 2, min = 1, max = 1}
},
water_damage = 1,
lava_damage = 0,
fire_damage = 0,
light_damage = 0,
fall_damage = false,
fear_height = 8,
animation = {},
on_die = function(self, pos)
mobs:effect(pos, 20, "tnt_smoke.png", 3, 5, 2, 0.5, nil, false)
self.object:remove()
end,
do_custom = function(self, dtime)
self.flame_timer = (self.flame_timer or 0) + dtime
if self.flame_timer < 0.5 then
return
end
self.flame_timer = 0
local pos = self.object:get_pos()
-- pos, amount, texture, min_size, max_size, radius, gravity, glow, fall
mobs:effect(pos, 5, "fire_basic_flame.png", 1, 2, 0.5, 0.5, 14, nil)
end
})
--[[
if not mobs.custom_spawn_monster then
mobs:spawn({
name = "mobs_monster:dirt_monster",
nodes = {"default:dirt_with_grass", "ethereal:gray_dirt", "ethereal:dry_dirt"},
min_light = 0,
max_light = 7,
chance = 6000,
active_object_count = 2,
min_height = 0,
day_toggle = false,
})
end
]]
mobs:register_egg("mobs_monster:fire_spirit", S("Fire Spirit"), "fire_basic_flame.png", 1)

View file

@ -29,6 +29,7 @@ dofile(path .. "lava_flan.lua") -- Zeg9
dofile(path .. "mese_monster.lua")
dofile(path .. "spider.lua") -- AspireMint
dofile(path .. "land_guard.lua")
dofile(path .. "fire_spirit.lua")
-- Load custom spawning

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 B

View file

@ -4,8 +4,12 @@ local S = mobs.intllib
-- Igor by TenPlus1
mobs.igor_drops = {
"vessels:glass_bottle", "mobs:meat_raw", "default:sword_steel",
"farming:bread", "bucket:bucket_water"
"vessels:glass_bottle", "mobs:meat_raw", {"default:sword_steel", 2},
"farming:bread", {"bucket:bucket_water", 2}, "flowers:mushroom_red",
"default:jungletree", {"fire:flint_and_steel", 3}, "mobs:leather",
"default:acacia_sapling", {"fireflies:bug_net", 3}, "default:clay_lump",
"default:ice", "default:coral_brown", "default:iron_lump",
"default:obsidian_shard", "default:mossycobble", {"default:obsidian", 2}
}
mobs:register_mob("mobs_npc:igor", {
@ -31,7 +35,7 @@ mobs:register_mob("mobs_npc:igor", {
{"mobs_igor5.png"},
{"mobs_igor6.png"},
{"mobs_igor7.png"},
{"mobs_igor8.png"},
{"mobs_igor8.png"}
},
makes_footstep_sound = true,
sounds = {},
@ -42,7 +46,7 @@ mobs:register_mob("mobs_npc:igor", {
jump = true,
drops = {
{name = "mobs:meat_raw", chance = 1, min = 1, max = 2},
{name = "default:gold_lump", chance = 3, min = 1, max = 1},
{name = "default:gold_lump", chance = 3, min = 1, max = 1}
},
water_damage = 1,
lava_damage = 3,
@ -51,7 +55,6 @@ mobs:register_mob("mobs_npc:igor", {
view_range = 15,
owner = "",
order = "follow",
-- model animation
animation = {
speed_normal = 30,
speed_run = 30,
@ -62,8 +65,9 @@ mobs:register_mob("mobs_npc:igor", {
run_start = 168,
run_end = 187,
punch_start = 200,
punch_end = 219,
punch_end = 219
},
-- right clicking with raw meat will give Igor more health
on_rightclick = function(self, clicker)
@ -84,40 +88,60 @@ mobs:register_mob("mobs_npc:igor", {
end
local pos = self.object:get_pos()
pos.y = pos.y + 0.5
local drops = self.igor_drops or mobs.igor_drops
local drop = drops[math.random(#drops)]
local chance = 1
minetest.add_item(pos, {
name = drops[math.random(1, #drops)]
})
if type(drop) == "table" then
chance = drop[2]
drop = drop[1]
end
minetest.chat_send_player(name, S("NPC dropped you an item for gold!"))
if not minetest.registered_items[drop]
or math.random(chance) > 1 then
drop = "default:coal_lump"
end
local obj = minetest.add_item(pos, {name = drop})
local dir = clicker:get_look_dir()
obj:set_velocity({x = -dir.x, y = 1.5, z = -dir.z})
--minetest.chat_send_player(name, S("NPC dropped you an item for gold!"))
return
end
-- if owner switch between follow and stand
-- by right-clicking owner can switch npc between follow, wander and stand
if self.owner and self.owner == name then
if self.order == "follow" then
self.attack = nil
self.order = "wander"
minetest.chat_send_player(name, S("NPC will wander."))
elseif self.order == "wander" then
self.order = "stand"
self.state = "stand"
self.attack = nil
self:set_animation("stand")
self:set_velocity(0)
minetest.chat_send_player(name, S("NPC stands still."))
else
elseif self.order == "stand" then
self.order = "follow"
minetest.chat_send_player(name, S("NPC will follow you."))
end
end
end,
end
})
-- register spawn egg
mobs:register_egg("mobs_npc:igor", S("Igor"), "mobs_meat_raw.png", 1)
-- compatibility

View file

@ -5,7 +5,6 @@ if minetest.get_modpath("lucky_block") then
{"spw", "mobs:npc", 1, true, true},
{"spw", "mobs:igor", 1, true, true, 5, "Igor"},
{"spw", "mobs:trader", 1, false, false},
{"lig", "fire:permanent_flame"},
{"lig", "fire:permanent_flame"}
})
end

View file

@ -4,8 +4,12 @@ local S = mobs.intllib
-- Npc by TenPlus1
mobs.npc_drops = {
"default:pick_steel", "mobs:meat", "default:sword_steel",
"default:shovel_steel", "farming:bread", "bucket:bucket_water"
{"default:pick_steel", 2}, "mobs:meat", {"default:sword_steel", 2},
{"default:shovel_steel", 2}, "farming:bread", "bucket:bucket_water",
"default:sapling", "default:tree", "mobs:leather", "default:coral_orange",
{"default:mese_crystal_fragment", 3}, "default:clay", {"default:sign_wall", 2},
"default:ladder", "default:copper_lump", "default:blueberries",
"default:aspen_sapling", "default:permafrost_with_moss"
}
mobs:register_mob("mobs_npc:npc", {
@ -27,9 +31,11 @@ mobs:register_mob("mobs_npc:npc", {
textures = {
{"mobs_npc.png"},
{"mobs_npc2.png"}, -- female by nuttmeg20
{"mobs_npc3.png"}, -- male by swagman181818
{"mobs_npc4.png"} -- female by Sapphire16
},
child_texture = {
{"mobs_npc_baby.png"}, -- derpy baby by AmirDerAssassine
{"mobs_npc_baby.png"} -- derpy baby by AmirDerAssassine
},
makes_footstep_sound = true,
sounds = {},
@ -39,7 +45,7 @@ mobs:register_mob("mobs_npc:npc", {
drops = {
{name = "default:wood", chance = 1, min = 1, max = 3},
{name = "default:apple", chance = 2, min = 1, max = 2},
{name = "default:axe_stone", chance = 5, min = 1, max = 1},
{name = "default:axe_stone", chance = 5, min = 1, max = 1}
},
water_damage = 0,
lava_damage = 2,
@ -59,7 +65,7 @@ mobs:register_mob("mobs_npc:npc", {
run_start = 168,
run_end = 187,
punch_start = 200,
punch_end = 219,
punch_end = 219
},
on_rightclick = function(self, clicker)
@ -85,39 +91,58 @@ mobs:register_mob("mobs_npc:npc", {
end
local pos = self.object:get_pos()
pos.y = pos.y + 0.5
local drops = self.npc_drops or mobs.npc_drops
local drop = drops[math.random(#drops)]
local chance = 1
minetest.add_item(pos, {
name = drops[math.random(1, #drops)]
})
if type(drop) == "table" then
chance = drop[2]
drop = drop[1]
end
minetest.chat_send_player(name, S("NPC dropped you an item for gold!"))
if not minetest.registered_items[drop]
or math.random(chance) > 1 then
drop = "default:clay_lump"
end
local obj = minetest.add_item(pos, {name = drop})
local dir = clicker:get_look_dir()
obj:set_velocity({x = -dir.x, y = 1.5, z = -dir.z})
--minetest.chat_send_player(name, S("NPC dropped you an item for gold!"))
return
end
-- by right-clicking owner can switch npc between follow and stand
-- by right-clicking owner can switch npc between follow, wander and stand
if self.owner and self.owner == name then
if self.order == "follow" then
self.attack = nil
self.order = "wander"
minetest.chat_send_player(name, S("NPC will wander."))
elseif self.order == "wander" then
self.order = "stand"
self.state = "stand"
self.attack = nil
self:set_animation("stand")
self:set_velocity(0)
minetest.chat_send_player(name, S("NPC stands still."))
else
elseif self.order == "stand" then
self.order = "follow"
minetest.chat_send_player(name, S("NPC will follow you."))
end
end
end,
end
})
if not mobs.custom_spawn_npc then
@ -129,7 +154,7 @@ mobs:spawn({
chance = 10000,
active_object_count = 1,
min_height = 0,
day_toggle = true,
day_toggle = true
})
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 870 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 686 B

View file

@ -8,7 +8,7 @@ local use_cmi = minetest.global_exists("cmi")
mobs = {
mod = "redo",
version = "20210407",
version = "20210515",
intllib = S,
invis = minetest.global_exists("invisibility") and invisibility or {}
}
@ -224,10 +224,10 @@ function mob_class:collision()
for _,object in ipairs(minetest.get_objects_inside_radius(pos, width)) do
if object:is_player()
or (object:get_luaentity()
and object:get_luaentity()._cmi_is_mob == true
and object ~= self.object) then
if object:is_player() then
-- or (object:get_luaentity()
-- and object:get_luaentity()._cmi_is_mob == true
-- and object ~= self.object) then
local pos2 = object:get_pos()
local vec = {x = pos.x - pos2.x, z = pos.z - pos2.z}
@ -1070,7 +1070,11 @@ function mob_class:do_env_damage()
end
-- particle appears at random mob height
pos.y = pos.y + random(self.collisionbox[2], self.collisionbox[5])
local py = {
x = pos.x,
y = pos.y + random(self.collisionbox[2], self.collisionbox[5]),
z = pos.z
}
local nodef = minetest.registered_nodes[self.standing_in]
@ -1080,7 +1084,7 @@ function mob_class:do_env_damage()
self.health = self.health - self.water_damage
effect(pos, 5, "bubble.png", nil, nil, 1, nil)
effect(py, 5, "bubble.png", nil, nil, 1, nil)
if self:check_for_death({type = "environment",
pos = pos, node = self.standing_in}) then
@ -1093,7 +1097,7 @@ function mob_class:do_env_damage()
self.health = self.health - self.lava_damage
effect(pos, 15, "fire_basic_flame.png", 1, 5, 1, 0.2, 15, true)
effect(py, 15, "fire_basic_flame.png", 1, 5, 1, 0.2, 15, true)
if self:check_for_death({type = "environment", pos = pos,
node = self.standing_in, hot = true}) then
@ -1106,7 +1110,7 @@ function mob_class:do_env_damage()
self.health = self.health - self.fire_damage
effect(pos, 15, "fire_basic_flame.png", 1, 5, 1, 0.2, 15, true)
effect(py, 15, "fire_basic_flame.png", 1, 5, 1, 0.2, 15, true)
if self:check_for_death({type = "environment", pos = pos,
node = self.standing_in, hot = true}) then
@ -1115,11 +1119,11 @@ function mob_class:do_env_damage()
-- damage_per_second node check (not fire and lava)
elseif nodef.damage_per_second ~= 0
and nodef.groups.lava == 0 and nodef.groups.fire == 0 then
and nodef.groups.lava == nil and nodef.groups.fire == nil then
self.health = self.health - nodef.damage_per_second
effect(pos, 5, "tnt_smoke.png")
effect(py, 5, "tnt_smoke.png")
if self:check_for_death({type = "environment",
pos = pos, node = self.standing_in}) then
@ -1132,7 +1136,7 @@ function mob_class:do_env_damage()
self.health = self.health - self.air_damage
effect(pos, 3, "bubble.png", 1, 1, 1, 0.2)
effect(py, 3, "bubble.png", 1, 1, 1, 0.2)
if self:check_for_death({type = "environment",
pos = pos, node = self.standing_in}) then
@ -1150,7 +1154,7 @@ function mob_class:do_env_damage()
self.health = self.health - self.light_damage
effect(pos, 5, "tnt_smoke.png")
effect(py, 5, "tnt_smoke.png")
if self:check_for_death({type = "light"}) then
return true
@ -2648,9 +2652,11 @@ function mob_class:do_states(dtime)
self.attack = attached
end
local dgroup = self.damage_group or "fleshy"
self.attack:punch(self.object, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = self.damage}
damage_groups = {[dgroup] = self.damage}
}, nil)
end
end
@ -2911,22 +2917,17 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir, damage)
-- only play hit sound and show blood effects if damage is 1 or over
if damage >= 1 then
local snd
-- weapon sounds
if weapon_def.sounds then
local s = random(0, #weapon_def.sounds)
minetest.sound_play(weapon_def.sounds[s], {
object = self.object,
max_hear_distance = 8
}, true)
snd = weapon_def.sounds[random(#weapon_def.sounds)]
else
minetest.sound_play("default_punch", {
object = self.object,
max_hear_distance = 5
}, true)
snd = "default_punch"
end
minetest.sound_play(snd, {object = self.object, max_hear_distance = 8}, true)
-- blood_particles
if not disable_blood and self.blood_amount > 0 then
@ -2934,8 +2935,7 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir, damage)
local blood = self.blood_texture
local amount = self.blood_amount
pos.y = pos.y + (-self.collisionbox[2]
+ self.collisionbox[5]) * .5
pos.y = pos.y + (-self.collisionbox[2] + self.collisionbox[5]) * .5
-- lots of damage = more blood :)
if damage > 10 then
@ -2948,7 +2948,6 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir, damage)
end
effect(pos, amount, blood, 1, 2, 1.75, nil, nil, true)
end
-- do damage
@ -2958,8 +2957,7 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir, damage)
local hot = tool_capabilities and tool_capabilities.damage_groups
and tool_capabilities.damage_groups.fire
if self:check_for_death({type = "punch",
puncher = hitter, hot = hot}) then
if self:check_for_death({type = "punch", puncher = hitter, hot = hot}) then
return true
end
@ -2979,8 +2977,7 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir, damage)
end -- END if damage
-- knock back effect (only on full punch)
if self.knock_back
and tflp >= punch_interval then
if self.knock_back and tflp >= punch_interval then
local v = self.object:get_velocity()
@ -3590,6 +3587,8 @@ minetest.register_entity(name, setmetatable({
walk_velocity = def.walk_velocity,
run_velocity = def.run_velocity,
damage = max(0, (def.damage or 0) * difficulty),
damage_group = def.damage_group,
damage_texture_modifier = def.damage_texture_modifier,
light_damage = def.light_damage,
light_damage_min = def.light_damage_min,
light_damage_max = def.light_damage_max,
@ -4123,7 +4122,10 @@ function mobs:register_arrow(name, def)
minetest.register_entity(name, {
physical = false,
physical = def.physical or false,
collide_with_objects = def.collide_with_objects or false,
static_save = false,
visual = def.visual,
visual_size = def.visual_size,
textures = def.textures,
@ -4282,7 +4284,7 @@ function mobs:boom(self, pos, radius)
radius = radius,
damage_radius = radius,
sound = self.sounds and self.sounds.explode,
explode_center = true,
explode_center = true
})
else
mobs:safe_boom(self, pos, radius)
@ -4614,7 +4616,8 @@ function mobs:protect(self, clicker)
return true
end
if self.protected then
if (self.protected and tool_name == "mobs:protector")
or (self.protected == 2 and tool_name == "mobs:protector2") then
minetest.chat_send_player(name, S("Already protected!"))
return true
end
@ -4820,14 +4823,13 @@ function mobs:alias_mob(old_name, new_name)
-- entity
minetest.register_entity(":" .. old_name, {
physical = false,
physical = false, static_save = false,
on_activate = function(self, staticdata)
if minetest.registered_entities[new_name] then
minetest.add_entity(self.object:get_pos(),
new_name, staticdata)
minetest.add_entity(self.object:get_pos(), new_name, staticdata)
end
remove_mob(self)

View file

@ -56,6 +56,8 @@ functions needed for the mob to work properly which contains the following:
'view_range' how many nodes in distance the mob can see a player.
'damage' how many health points the mob does to a player or another
mob when melee attacking.
'damage_group' group in which damage is dealt, dedaults to "fleshy".
'damage_texture_modifier' applies texture modifier on hit e.g "^[brighten"
'knock_back' when true has mobs falling backwards when hit, the greater
the damage the more they move back.
'fear_height' is how high a cliff or edge has to be before the mob stops
@ -465,6 +467,8 @@ This function registers a arrow for mobs with the attack type shoot.
'visual' same is in minetest.register_entity()
'visual_size' same is in minetest.register_entity()
'textures' same is in minetest.register_entity()
'physical' same is in minetest.register_entity() [default: false]
'collide_with_objects' same as above
'velocity' the velocity of the arrow
'drop' if set to true any arrows hitting a node will drop as item
'hit_player' a function that is called when the arrow hits a player;

View file

@ -10,9 +10,9 @@ minetest.register_craftitem("mobs:nametag", {
if minetest.get_modpath("dye") and minetest.get_modpath("farming") then
minetest.register_craft({
type = "shapeless",
-- type = "shapeless",
output = "mobs:nametag",
recipe = {"default:paper", "dye:black", "farming:string"}
recipe = {{"default:paper", "dye:black", "farming:string"}}
})
end
@ -299,12 +299,18 @@ minetest.register_tool(":mobs:mob_reset_stick", {
tex_obj = obj
-- get base texture
local bt = tex_obj:get_luaentity().base_texture[1]
if type(bt) ~= "string" then
bt = ""
end
local name = user:get_player_name()
local tex = ""
minetest.show_formspec(name, "mobs_texture", "size[8,4]"
.. "field[0.5,1;7.5,0;name;"
.. minetest.formspec_escape(S("Enter texture:")) .. ";" .. tex .. "]"
.. minetest.formspec_escape(S("Enter texture:")) .. ";" .. bt .. "]"
.. "button_exit[2.5,3.5;3,1;mob_texture_change;"
.. minetest.formspec_escape(S("Change")) .. "]")
end
@ -362,10 +368,10 @@ minetest.register_node("mobs:meatblock", {
minetest.register_craft({
output = "mobs:meatblock",
type = "shapeless",
-- type = "shapeless",
recipe = {
"group:food_meat", "group:food_meat", "group:food_meat",
"group:food_meat", "group:food_meat", "group:food_meat",
"group:food_meat", "group:food_meat", "group:food_meat"
{"group:food_meat", "group:food_meat", "group:food_meat"},
{"group:food_meat", "group:food_meat", "group:food_meat"},
{"group:food_meat", "group:food_meat", "group:food_meat"}
}
})

View file

@ -31,12 +31,12 @@ local ocorner_cbox = {
}
}
local moretrees_slopes = { --Material , Description , Item, Image
{"willow" , "Willow Wood" , "ethereal:willow_wood", "willow"},
{"redwood", "RedWood Wood", "ethereal:redwood_wood", "redwood"},
{"frost", "Frost Wood", "ethereal:frost_wood", "frost"},
{"yellow", "Healing Tree Wood", "ethereal:yellow_wood", "yellow"},
{"willow" , "Willow Wood" , "ethereal:willow_wood", "ethereal_willow"},
{"redwood", "RedWood Wood", "ethereal:redwood_wood", "ethereal_redwood"},
{"frost", "Frost Wood", "ethereal:frost_wood", "ethereal_frost"},
{"yellow", "Healing Tree Wood", "ethereal:yellow_wood", "ethereal_yellow"},
{"palm", "Palm Wood", "ethereal:palm_wood", "moretrees_palm"},
{"banana", "Banana Wood", "ethereal:banana_wood", "banana"},
{"banana", "Banana Wood", "ethereal:banana_wood", "ethereal_banana"},
{"birch", "Birch Wood", "ethereal:birch_wood", "moretrees_birch"},
}

View file

@ -97,6 +97,7 @@ local register_pie = function(pie, desc)
minetest.register_node("pie:" .. pie .. "_0", {
description = desc,
paramtype = "light",
use_texture_alpha = "clip",
sunlight_propagates = false,
tiles = {
pie .. "_top.png", pie .. "_bottom.png", pie .. "_side.png",
@ -107,18 +108,19 @@ local register_pie = function(pie, desc)
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {{-0.45, -0.5, -0.45, 0.45, 0, 0.45}},
fixed = {{-0.45, -0.5, -0.45, 0.45, 0, 0.45}}
},
on_punch = function(pos, node, puncher, pointed_thing)
replace_pie(node, puncher, pos)
end,
end
})
-- 3/4 pie
minetest.register_node("pie:" .. pie .. "_1", {
description = "3/4" .. desc,
paramtype = "light",
use_texture_alpha = "clip",
sunlight_propagates = true,
tiles = {
pie .. "_top.png", pie .. "_bottom.png", pie .. "_side.png",
@ -129,18 +131,19 @@ local register_pie = function(pie, desc)
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {{-0.45, -0.5, -0.25, 0.45, 0, 0.45}},
fixed = {{-0.45, -0.5, -0.25, 0.45, 0, 0.45}}
},
on_punch = function(pos, node, puncher, pointed_thing)
replace_pie(node, puncher, pos)
end,
end
})
-- 1/2 pie
minetest.register_node("pie:" .. pie .. "_2", {
description = "Half " .. desc,
paramtype = "light",
use_texture_alpha = "clip",
sunlight_propagates = true,
tiles = {
pie .. "_top.png", pie .. "_bottom.png", pie .. "_side.png",
@ -151,18 +154,19 @@ local register_pie = function(pie, desc)
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {{-0.45, -0.5, 0.0, 0.45, 0, 0.45}},
fixed = {{-0.45, -0.5, 0.0, 0.45, 0, 0.45}}
},
on_punch = function(pos, node, puncher, pointed_thing)
replace_pie(node, puncher, pos)
end,
end
})
-- 1/4 pie
minetest.register_node("pie:" .. pie .. "_3", {
description = "Piece of " .. desc,
paramtype = "light",
use_texture_alpha = "clip",
sunlight_propagates = true,
tiles = {
pie .. "_top.png", pie .. "_bottom.png", pie .. "_side.png",
@ -173,14 +177,13 @@ local register_pie = function(pie, desc)
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {{-0.45, -0.5, 0.25, 0.45, 0, 0.45}},
fixed = {{-0.45, -0.5, 0.25, 0.45, 0, 0.45}}
},
on_punch = function(pos, node, puncher, pointed_thing)
replace_pie(node, puncher, pos)
end,
end
})
end
@ -192,7 +195,7 @@ minetest.register_craft({
recipe = {
{"group:food_sugar", "group:food_milk", "group:food_sugar"},
{"group:food_sugar", "group:food_egg", "group:food_sugar"},
{"group:food_wheat", "group:food_flour", "group:food_wheat"},
{"group:food_wheat", "group:food_flour", "group:food_wheat"}
},
replacements = {{ "mobs:bucket_milk", "bucket:bucket_empty"}}
})
@ -206,7 +209,7 @@ minetest.register_craft({
recipe = {
{"group:food_cocoa", "group:food_milk", "group:food_cocoa"},
{"group:food_sugar", "group:food_egg", "group:food_sugar"},
{"group:food_wheat", "group:food_flour", "group:food_wheat"},
{"group:food_wheat", "group:food_flour", "group:food_wheat"}
},
replacements = {{ "mobs:bucket_milk", "bucket:bucket_empty"}}
})
@ -220,7 +223,7 @@ minetest.register_craft({
recipe = {
{"group:food_strawberry", "group:food_milk", "group:food_strawberry"},
{"group:food_sugar", "group:food_egg", "group:food_sugar"},
{"group:food_wheat", "group:food_flour", "group:food_wheat"},
{"group:food_wheat", "group:food_flour", "group:food_wheat"}
},
replacements = {{ "mobs:bucket_milk", "bucket:bucket_empty"}}
})
@ -234,7 +237,7 @@ minetest.register_craft({
recipe = {
{"group:food_coffee", "group:food_milk", "group:food_coffee"},
{"group:food_sugar", "group:food_egg", "group:food_sugar"},
{"group:food_wheat", "group:food_flour", "group:food_wheat"},
{"group:food_wheat", "group:food_flour", "group:food_wheat"}
},
replacements = {{ "mobs:bucket_milk", "bucket:bucket_empty"}}
})
@ -248,7 +251,7 @@ minetest.register_craft({
recipe = {
{"group:food_cocoa", "group:food_milk", "dye:red"},
{"group:food_sugar", "group:food_egg", "group:food_sugar"},
{"group:food_flour", "group:food_cheese", "group:food_flour"},
{"group:food_flour", "group:food_cheese", "group:food_flour"}
},
replacements = {{ "mobs:bucket_milk", "bucket:bucket_empty"}}
})
@ -261,8 +264,8 @@ minetest.register_craft({
output = "pie:meat_0",
recipe = {
{"group:food_meat_raw", "group:food_egg", "group:food_meat_raw"},
{"group:food_wheat", "group:food_wheat", "group:food_wheat"},
},
{"group:food_wheat", "group:food_wheat", "group:food_wheat"}
}
})
@ -274,7 +277,7 @@ minetest.register_craft({
recipe = {
{"group:food_banana", "group:food_milk", "group:food_banana"},
{"group:food_sugar", "group:food_egg", "group:food_sugar"},
{"group:food_wheat", "group:food_flour", "group:food_wheat"},
{"group:food_wheat", "group:food_flour", "group:food_wheat"}
},
replacements = {{ "mobs:bucket_milk", "bucket:bucket_empty"}}
})
@ -288,7 +291,7 @@ minetest.register_craft({
recipe = {
{"group:food_bread", "group:food_milk", "group:food_bread"},
{"group:food_sugar", "group:food_egg", "group:food_sugar"},
{"group:food_wheat", "group:food_flour", "group:food_wheat"},
{"group:food_wheat", "group:food_flour", "group:food_wheat"}
},
replacements = {{ "mobs:bucket_milk", "bucket:bucket_empty"}}
})
@ -302,7 +305,7 @@ minetest.register_craft({
recipe = {
{"group:food_orange", "group:food_milk", "group:food_orange"},
{"group:food_sugar", "group:food_egg", "group:food_sugar"},
{"group:food_wheat", "group:food_flour", "group:food_wheat"},
{"group:food_wheat", "group:food_flour", "group:food_wheat"}
},
replacements = {{ "mobs:bucket_milk", "bucket:bucket_empty"}}
})
@ -322,7 +325,7 @@ lucky_block:add_blocks({
{"tro", "pie:orange_0", "default_place_node_hard", true},
{"nod", "pie:brpd_0", 0},
{"nod", "pie:meat_0", 0},
{"lig"},
{"lig"}
})
end

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