Cleanup and licensing

This commit is contained in:
Juraj Vajda 2023-04-24 10:56:28 -04:00
parent f30395040c
commit 072096dcc2
113 changed files with 5887 additions and 2689 deletions

15
.cdb.json Normal file
View File

@ -0,0 +1,15 @@
{
"type": "MOD",
"title": "Spawners",
"name": "spawners",
"short_description": "Adds multiple spawner blocks. There ara no ABM's used and this modpack is developed with focus on the best multiplayer online server performace.",
"dev_state": "MAINTENANCE_ONLY",
"tags": [
"decorative",
"survival"
],
"license": "LGPL-2.1-or-later",
"media_license": "CC-BY-SA-4.0",
"repo": "https://bitbucket.org/minetest_gamers/spawners/src/master/",
"issue_tracker": "https://bitbucket.org/minetest_gamers/spawners/issues?status=new&status=open"
}

12
.editorconfig Normal file
View File

@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

16
.gitattributes vendored Normal file
View File

@ -0,0 +1,16 @@
# Creating an archive
.* export-ignore
assets export-ignore
scripts export-ignore
bin export-ignore
docs export-ignore
types export-ignore
*.zip export-ignore
bitbucket-pipelines.yml export-ignore
package.json export-ignore
package-lock.json export-ignore
screenshot*.png export-ignore
i18n.py export-ignore
config.ld export-ignore
schematic_tables.txt export-ignore

2
.gitignore vendored
View File

@ -5,5 +5,5 @@ docs/build
*.old *.old
node_modules node_modules
*.log *.log
logs
*.mtl *.mtl
logs

82
.luacheckrc Normal file
View File

@ -0,0 +1,82 @@
unused_args = false
allow_defined_top = true
max_line_length = false
exclude_files = {
'./scripts',
'./bin',
'./logs',
'./node_modules',
'./sounds',
'./textures',
'./models',
'./docs',
'./locale',
'./types',
}
globals = {
'XBows',
'XBowsQuiver',
'XBowsEntityDefBase',
'XBowsEntityDefCustom'
}
read_globals = {
"DIR_DELIM", "INIT",
"minetest", "core",
"dump", "dump2",
"Raycast",
"Settings",
"PseudoRandom",
"PerlinNoise",
"VoxelManip",
"SecureRandom",
"VoxelArea",
"PerlinNoiseMap",
"PcgRandom",
"ItemStack",
"AreaStore",
"unpack",
"vector",
table = {
fields = {
"copy",
"indexof",
"insert_all",
"key_value_swap",
"shuffle",
}
},
string = {
fields = {
"split",
"trim",
}
},
math = {
fields = {
"hypot",
"sign",
"factorial",
"round",
}
},
"player_monoids",
"playerphysics",
"hb",
"mesecon",
"armor",
"default",
"spawners_ores",
"spawners_env",
"spawners_mobs",
"mobs"
}

1
.npmrc Normal file
View File

@ -0,0 +1 @@
engine-strict=true

1
.nvmrc Normal file
View File

@ -0,0 +1 @@
v16.13.2

112
README.md
View File

@ -1,8 +1,7 @@
# Spawners Modpack # # Spawners Modpack #
This MOD for Minetest adds multiple spawner blocks. There ara no ABM's used and this modpack is developed with focus on the best multiplayer online server performace. Adds multiple spawner blocks. There ara no ABM's used and this modpack is developed with focus on the best multiplayer online server performace.
Easy to implement new mob mods just look in to config.lua. Easy to implement new mob mods just look in to config.lua.
New features can be enabled/disabled in settings.txt file.
Currently it works with [Mobs Redo](https://forum.minetest.net/viewtopic.php?f=11&t=9917) and [Creatures](https://forum.minetest.net/viewtopic.php?f=11&t=8638) but other mob mods can be easily added to config.lua Currently it works with [Mobs Redo](https://forum.minetest.net/viewtopic.php?f=11&t=9917) and [Creatures](https://forum.minetest.net/viewtopic.php?f=11&t=8638) but other mob mods can be easily added to config.lua
@ -10,121 +9,20 @@ Currently it works with [Mobs Redo](https://forum.minetest.net/viewtopic.php?f=1
![Spawners Ores](spawners_ores/screenshot.png) ![Spawners Ores](spawners_ores/screenshot.png)
This MOD for Minetest let the player craft ore Spawners. Ores are spawning randomly in a short intervals and you get 10% more ores from inputed ingots. Ores are spawning only in default:stone so make sure there is one around. This MOD is giving the option of creating lumps back from ingots. Let the player craft ore Spawners. Ores are spawning randomly in a short intervals and you get 10% more ores from inputed ingots. Ores are spawning only in default:stone so make sure there is one around. This MOD is giving the option of creating lumps back from ingots.
### Mod dependencies ###
* default
## Spawners Mobs ## ## Spawners Mobs ##
This MOD for Minetest let the player craft Mob Spawners. Mobs are spawning randomly in a short intervals. This MOD is giving the option of creating mob farms and grinders. Let the player craft Mob Spawners. Mobs are spawning randomly in a short intervals. This MOD is giving the option of creating mob farms and grinders.
![Spawners Mobs](spawners_mobs/screenshot.png) ![Spawners Mobs](spawners_mobs/screenshot.png)
### Mod dependencies ###
* default
* fire?
* xpanes?
* mobs?
* creatures?
* bones?
fake_fire, xpanes for recipes
bones are for mob drops only
## Spawners Environmental ## ## Spawners Environmental ##
This MOD for Minetest adds environmental spawners to the map. When enabled, the spawners will be added to newly generated Dungeons (Uruk Hai) and Temples (Spider). They are dropping a real mob spawner by change (very small chance). Adds environmental spawners to the map. When enabled, the spawners will be added to newly generated Dungeons (Uruk Hai) and Temples (Spider). They are dropping a real mob spawner by change (very small chance).
![Spawners Mobs](spawners_env/screenshot.png) ![Spawners Mobs](spawners_env/screenshot.png)
### Mod dependencies ###
* default
## Links ##
[[Mod]Minetest Forum Page](https://forum.minetest.net/viewtopic.php?f=11&t=13857)
[[Server]Minetest Forum Page](https://forum.minetest.net/viewtopic.php?f=10&t=13727) - try this MOD on this server
[G+ Collection](https://plus.google.com/collection/06fEx)
[G+ Community](https://plus.google.com/communities/105201070842404099845)
## License ## ## License ##
![WTFPL](http://www.wtfpl.net/wp-content/uploads/2012/12/wtfpl-badge-1.png)
## Changelog ## See included license files.
### 1.0 ###
* refactored Spawners Ores - best multiplayer performance usable on online servers
* refactored Spawners Mobs - best multiplayer performance usable on online servers
* refactored Spawners Env - best multiplayer performance usable on online servers
### 0.6 ###
* inherited BlockMen Pyramid mod, so now Spawners can spawn Pyramids in desert (mapgen v6)
* spawning Pyramids work independently from BlockMen Pyramids mod (can be removed) but works also besides BlockMen Pyramid mod
* added more various loot (default) in pyramids chests and higher up the chance of spawning more loot
* added new environmental spawners
* added generation of environmental spawners for default mapgen v6 temples and dungeons
* addend new config parameter 'disable' for night_only attribute in config file
* added new attribute 'env' in config file for defining environmental spawners
* added settings.txt file for enable/disable new features (pyramids, mapgen spawners..)
* fixed abm catch_up (disabled), now it works
### 0.5.1 ###
* added mobs redo stone monster spawner (re-done from BlockMen Pyramids)
### 0.5 ###
* new mobs redo sheep textures
* added mobs redo spider spawner
* added oerrki spawner for creatures mod
* added screenshot and description for MODs in-game tab
* added pyramids mod to optional dependencies
### 0.4 ###
* NEW added ore spawners - iron, gold and copper
* ore spawners have chance to spawn 2 ores from 1 ingot
* ore spawners have formspec
* new sounds for ore spawners
* added particle effect for ore spawners
* re-done all textures from scratch (mob and ore spawners)
* adjusted mob spawners ABM
* added maximum stacked items for spawners to max 1
* mob spawners fixed name conflicts in config file warthog vs. pumba
### 0.3 ###
* new folder and file structure
* more convenient disable/enable, add/remove new MODs in config.lua file - added property for custom sounds
* added sound for bunny
* fixed sound for pyramids:mummy
* added footsteps and dug sounds for the spawners
* shorter and more effective code, easier to read, fixed variable namings
* ABM tweak - longer delay to trigger but bigger chance for spawn entity
* disabled ABM catch_up
* added normal map texture for default spawner
### 0.2 ###
* support pyramids mod - mummy
* support creatures mod
* shorten the code - more effecient
### 0.1 ###
* Initial Release
* detects only 6 nodes for 'air' around the spawner [top, bottom, left, right, front, back] afterwards it will check the node above and below the found 'air' node - so there is enough space to spawn someone
* always picks random side from where the mob will spawn
* detects for light and time of day - spawn mobs only at night if 'only_night' set to true
* status 'waiting' - blue sparkles, for not enough light (day spawners) or too much light for night spawners
* status 'default/inactive' i.e. if the spawner is closed from each side or there is no space to spawn mob
* status 'active' when spawner is active and is spawning mobs
* status 'overheat' when there is too much 'max_objects_per_block' (prevents from server errors), max value is taken from minetest.conf
* easy to configure, add and remove MODs for mobs
* only [Mobs Redo](https://github.com/tenplus1/mobs) from tenplus1 is added for now
* added recipes for all spawners, it's expensive so it will not get overcrowded on the server only with spawners
* almost everything is done dynamically
* spawners emit small amount of light
* active and overheated spawner can cause fire to flammable nodes around it
* spawners are active only if player is in radius (21)
* spawners are diggable only with steel pickaxe and above, so no noob griefers can raid your base too easy
* mobs play sound when spawned
* animated textures

77
bitbucket-pipelines.yml Normal file
View File

@ -0,0 +1,77 @@
image: atlassian/default-image:3
pipelines:
pull-requests:
"**":
- step:
name: Install Node Dependencies
caches:
- node-modules
- npm
- nvm
script:
- nvm install v17.2.0
- npm i -g npm@8
- npm ci
# - parallel:
- step:
name: Lua Check
script:
- apt-get update
- apt-get -y install lua5.1
- apt-get -y install luarocks
- luarocks install luacheck
- luacheck .
# - step:
# name: Lua Diagnostics
# caches:
# - node-modules
# - npm
# - nvm
# script:
# - nvm use v17.2.0
# - npm run lua-diagnostics
tags:
"*":
- step:
name: Install Node Dependencies
caches:
- node-modules
- npm
- nvm
script:
- nvm install v17.2.0
- npm i -g npm@8
- npm ci
# - parallel:
- step:
name: Lua Check
script:
- apt-get update
- apt-get -y install lua5.1
- apt-get -y install luarocks
- luarocks install luacheck
- luacheck .
# - step:
# name: Lua Diagnostics
# caches:
# - node-modules
# - npm
# - nvm
# script:
# - nvm use v17.2.0
# - npm run lua-diagnostics
- step:
name: Deploy to ContentDB
caches:
- node-modules
- npm
- nvm
script:
- nvm use v17.2.0
- npm run push:ci -- --token=$CONTENT_DB_SPAWNERS_TOKEN --title=$BITBUCKET_TAG
definitions:
caches:
node-modules: ./node_modules
npm: ~/.npm
nvm: ~/.nvm

File diff suppressed because it is too large Load Diff

6
modpack.conf Normal file
View File

@ -0,0 +1,6 @@
name = spawners
description = Adds multiple spawner blocks. There ara no ABMs used and this modpack is developed with focus on the best multiplayer online server performace.
depends =
optional_depends =
supported_games =
min_minetest_version =

View File

34
package.json Normal file
View File

@ -0,0 +1,34 @@
{
"name": "spawners",
"version": "1.0.0",
"description": "Adds bow and arrows to Minetest.",
"main": "index.js",
"type": "module",
"directories": {
"doc": "docs"
},
"engines": {
"node": ">=16.0.0",
"npm": ">=8.0.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"push:ci": "node ./scripts/deploy",
"lua-diagnostics": "node ./scripts/lls-check"
},
"repository": {
"type": "git",
"url": "git+https://juraj_vajda@bitbucket.org/minetest_gamers/spawners.git"
},
"author": "SaKeL",
"license": "LGPL-2.1-or-later",
"bugs": {
"url": "https://bitbucket.org/minetest_gamers/spawners/issues"
},
"homepage": "https://bitbucket.org/minetest_gamers/spawners#readme",
"devDependencies": {
"jaguar": "^6.0.1",
"node-fetch": "^3.2.10",
"yargs": "^17.6.1"
}
}

568
spawners_env/LICENSE.txt Normal file
View File

@ -0,0 +1,568 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 2016 - 2023 SaKeL <juraj.vajda@gmail.com>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
### Code
GNU Lesser General Public License v2.1 or later (see included LICENSE file)
### Textures
**CC-BY-SA-4.0, by SaKeL**
- spawners_mobs_balrog.png
- spawners_mobs_black_skull.png
- spawners_mobs_evil_bunny_egg.png
- spawners_mobs_evil_bunny.png
- spawners_mobs_firebolt.png
- spawners_mobs_flame_particle_2.png
- spawners_mobs_flame_particle.png
- spawners_mobs_galvornsword.png
- spawners_mobs_mummy.png
- spawners_mobs_sandstone_carved_bird.png
- spawners_mobs_sandstone_carved_eye.png
- spawners_mobs_sandstone_carved_men.png
- spawners_mobs_sandstone_carved_sun.png
- spawners_mobs_smoke_particle_2.png
- spawners_mobs_smoke_particle.png
- spawners_mobs_spawner_16.png
- spawners_mobs_spawner_animated.png
- spawners_mobs_spawner_rusty.png
- spawners_mobs_spawner_waiting_animated_16.png
- spawners_mobs_spawner_waiting_animated.png
- spawners_mobs_spawner.png
- spawners_mobs_trans.png
- spawners_mobs_uruk_hai_1.png
- spawners_mobs_uruk_hai_2.png
- spawners_mobs_uruk_hai_3.png
- spawners_mobs_uruk_hai_egg.png
- spawners_mobs_uruk_hai.png
### Sounds
**CC-BY-SA-4.0, by SaKeL**
- spawners_mobs_balrog_neutral.ogg
- spawners_mobs_balrog_attack.1.ogg
- spawners_mobs_balrog_attack.2.ogg
- spawners_mobs_balrog_attack.3.ogg
- spawners_mobs_balrog_attack.4.ogg
- spawners_mobs_balrog_attack.5.ogg
- spawners_mobs_balrog_attack.ogg
- spawners_mobs_balrog_death.ogg
- spawners_mobs_balrog_fireball.ogg
- spawners_mobs_balrog_hit.1.ogg
- spawners_mobs_balrog_hit.2.ogg
- spawners_mobs_balrog_hit.3.ogg
- spawners_mobs_balrog_hit.4.ogg
- spawners_mobs_balrog_hit.5.ogg
- spawners_mobs_balrog_hit.ogg
- spawners_mobs_balrog_neutral.1.ogg
- spawners_mobs_balrog_neutral.2.ogg
- spawners_mobs_bunny.ogg
- spawners_mobs_mummy_attack.1.ogg
- spawners_mobs_mummy_attack.2.ogg
- spawners_mobs_mummy_attack.3.ogg
- spawners_mobs_mummy_attack.4.ogg
- spawners_mobs_mummy_attack.5.ogg
- spawners_mobs_mummy_attack.ogg
- spawners_mobs_mummy_death.1.ogg
- spawners_mobs_mummy_death.2.ogg
- spawners_mobs_mummy_death.3.ogg
- spawners_mobs_mummy_death.ogg
- spawners_mobs_mummy_hit.1.ogg
- spawners_mobs_mummy_hit.2.ogg
- spawners_mobs_mummy_hit.3.ogg
- spawners_mobs_mummy_hit.4.ogg
- spawners_mobs_mummy_hit.ogg
- spawners_mobs_mummy_neutral.1.ogg
- spawners_mobs_mummy_neutral.2.ogg
- spawners_mobs_mummy_neutral.ogg
- spawners_mobs_mummy_spell.1.ogg
- spawners_mobs_mummy_spell.2.ogg
- spawners_mobs_mummy_spell.3.ogg
- spawners_mobs_mummy_spell.4.ogg
- spawners_mobs_mummy_spell.ogg
- spawners_mobs_teleport.ogg
- spawners_mobs_uruk_hai_attack.1.ogg
- spawners_mobs_uruk_hai_attack.2.ogg
- spawners_mobs_uruk_hai_attack.3.ogg
- spawners_mobs_uruk_hai_attack.4.ogg
- spawners_mobs_uruk_hai_attack.ogg
- spawners_mobs_uruk_hai_death.1.ogg
- spawners_mobs_uruk_hai_death.2.ogg
- spawners_mobs_uruk_hai_death.3.ogg
- spawners_mobs_uruk_hai_death.4.ogg
- spawners_mobs_uruk_hai_death.ogg
- spawners_mobs_uruk_hai_hit.1.ogg
- spawners_mobs_uruk_hai_hit.2.ogg
- spawners_mobs_uruk_hai_hit.3.ogg
- spawners_mobs_uruk_hai_hit.4.ogg
- spawners_mobs_uruk_hai_hit.5.ogg
- spawners_mobs_uruk_hai_hit.ogg
- spawners_mobs_uruk_hai_neutral.1.ogg
- spawners_mobs_uruk_hai_neutral.2.ogg
- spawners_mobs_uruk_hai_neutral.3.ogg
- spawners_mobs_uruk_hai_neutral.4.ogg
- spawners_mobs_uruk_hai_neutral.ogg
### Models
**CC-BY-SA-4.0, by SaKeL**
- spawners_mobs_balrog.b3d
- spawners_mobs_character.b3d
- spawners_mobs_evil_bunny.b3d
- spawners_mobs_mummy.b3d

View File

@ -1,28 +1,52 @@
--[[
Adds environmental spawners to the map. When enabled, the spawners will be added to newly generated Dungeons (Uruk Hai) and Temples (Spider). They are dropping a real mob spawner by change (very small chance).
Copyright (C) 2016 - 2023 SaKeL <juraj.vajda@gmail.com>
This library is free software; you can redistribute it and/or
modify it pos the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to juraj.vajda@gmail.com
--]]
-- main tables -- main tables
spawners_env = {} spawners_env = {
ENABLED_MODS = {},
MOBS_PROPS = {}
}
spawners_env.mob_tables = {} spawners_env.mob_tables = {}
-- check if mods exists and build tables function spawners_env.register_spawners()
for k, mob_mod in ipairs(ENABLED_MODS) do -- check if mods exists and build tables
for k, mob_mod in ipairs(spawners_env.ENABLED_MODS) do
local modpath = minetest.get_modpath(mob_mod) local modpath = minetest.get_modpath(mob_mod)
-- list of mobs and their info -- list of mobs and their info
if (modpath) then if (modpath) then
for j, mob in ipairs(MOBS_PROPS[mob_mod]) do for j, mob in ipairs(spawners_env.MOBS_PROPS[mob_mod]) do
local mob_egg = nil -- local mob_egg = nil
-- create only environmental spawners -- create only environmental spawners
if mob.env then if mob.env then
table.insert(spawners_env.mob_tables, {name=mob.name, mod_prefix=mob_mod, egg_name_custom=mob.egg_name_custom, dummy_size=mob.dummy_size, dummy_offset=mob.dummy_offset, dummy_mesh=mob.dummy_mesh, dummy_texture=mob.dummy_texture, night_only=mob.night_only, sound_custom=mob.sound_custom, env=mob.env, boss=mob.boss}) table.insert(spawners_env.mob_tables, { name = mob.name, mod_prefix = mob_mod, egg_name_custom = mob.egg_name_custom, dummy_size = mob.dummy_size, dummy_offset = mob.dummy_offset, dummy_mesh = mob.dummy_mesh, dummy_texture = mob.dummy_texture, night_only = mob.night_only, sound_custom = mob.sound_custom, env = mob.env, boss = mob.boss })
-- use custom egg or create a default egg -- use custom egg or create a default egg
if mob.egg_name_custom ~= "" then -- if mob.egg_name_custom ~= '' then
mob_egg = mob.egg_name_custom -- mob_egg = mob.egg_name_custom
else -- else
mob_egg = mob_mod..":"..mob.name -- mob_egg = mob_mod .. ':' .. mob.name
end -- end
end end
end end
else end
-- print something ?
end end
end end
@ -34,22 +58,22 @@ function spawners_env.start_spawning(pos, how_many, mob_name, mod_prefix, sound_
end end
-- remove 'spawners_env:' from the string -- remove 'spawners_env:' from the string
local mob_name = string.sub(mob_name,14) local _mob_name = string.sub(mob_name, 14)
local sound_name local sound_name
-- use custom sounds -- use custom sounds
if sound_custom ~= "" then if sound_custom ~= '' then
sound_name = sound_custom sound_name = sound_custom
else else
sound_name = mod_prefix.."_"..mob_name sound_name = mod_prefix .. '_' .. _mob_name
end end
if how_many == nil then if how_many == nil then
how_many = math.random(1,2) how_many = math.random(1, 2)
end end
for i=1,how_many do for i = 1, how_many do
pos.y = pos.y+1 pos.y = pos.y + 1
local obj = minetest.add_entity(pos, mod_prefix..":"..mob_name) local obj = minetest.add_entity(pos, mod_prefix .. ':' .. _mob_name)
if obj then if obj then
if sound_name then if sound_name then
@ -66,7 +90,6 @@ end
function spawners_env.check_around_radius(pos) function spawners_env.check_around_radius(pos)
local player_near = false local player_near = false
local radius = 21 local radius = 21
local node_ore_pos = nil
for _,obj in ipairs(minetest.get_objects_inside_radius(pos, radius)) do for _,obj in ipairs(minetest.get_objects_inside_radius(pos, radius)) do
if obj:is_player() then if obj:is_player() then
@ -81,7 +104,7 @@ function spawners_env.check_node_status(pos, mob, night_only, boss)
local player_near = spawners_env.check_around_radius(pos) local player_near = spawners_env.check_around_radius(pos)
if player_near or boss then if player_near or boss then
local random_pos = false local random_pos
local min_node_light = 10 local min_node_light = 10
local tod = minetest.get_timeofday() * 24000 local tod = minetest.get_timeofday() * 24000
local node_light = minetest.get_node_light(pos) local node_light = minetest.get_node_light(pos)
@ -91,51 +114,51 @@ function spawners_env.check_node_status(pos, mob, night_only, boss)
end end
local spawn_positions = {} local spawn_positions = {}
local right = minetest.get_node({x=pos.x+1, y=pos.y, z=pos.z}) local right = minetest.get_node({ x = pos.x + 1, y = pos.y, z = pos.z })
local front = minetest.get_node({x=pos.x, y=pos.y, z=pos.z+1}) local front = minetest.get_node({ x = pos.x, y = pos.y, z = pos.z + 1 })
local left = minetest.get_node({x=pos.x-1, y=pos.y, z=pos.z}) local left = minetest.get_node({ x = pos.x - 1, y = pos.y, z = pos.z })
local back = minetest.get_node({x=pos.x, y=pos.y, z=pos.z-1}) local back = minetest.get_node({ x = pos.x, y = pos.y, z = pos.z - 1 })
local top = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}) local top = minetest.get_node({ x = pos.x, y = pos.y + 1, z = pos.z })
local bottom = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}) local bottom = minetest.get_node({ x = pos.x, y = pos.y - 1, z = pos.z })
-- make sure that at least one side of the spawner is open -- make sure that at least one side of the spawner is open
if right.name == "air" then if right.name == 'air' then
table.insert(spawn_positions, {x=pos.x+1.5, y=pos.y, z=pos.z}) table.insert(spawn_positions, { x = pos.x + 1.5, y = pos.y, z = pos.z })
end end
if front.name == "air" then if front.name == 'air' then
table.insert(spawn_positions, {x=pos.x, y=pos.y, z=pos.z+1.5}) table.insert(spawn_positions, { x = pos.x, y = pos.y, z = pos.z + 1.5 })
end end
if left.name == "air" then if left.name == 'air' then
table.insert(spawn_positions, {x=pos.x-1.5, y=pos.y, z=pos.z}) table.insert(spawn_positions, { x = pos.x - 1.5, y = pos.y, z = pos.z })
end end
if back.name == "air" then if back.name == 'air' then
table.insert(spawn_positions, {x=pos.x, y=pos.y, z=pos.z-1.5}) table.insert(spawn_positions, { x = pos.x, y = pos.y, z = pos.z - 1.5 })
end end
if top.name == "air" then if top.name == 'air' then
table.insert(spawn_positions, {x=pos.x, y=pos.y+1.5, z=pos.z}) table.insert(spawn_positions, { x = pos.x, y = pos.y + 1.5, z = pos.z })
end end
if bottom.name == "air" then if bottom.name == 'air' then
table.insert(spawn_positions, {x=pos.x, y=pos.y-1.5, z=pos.z}) table.insert(spawn_positions, { x = pos.x, y = pos.y - 1.5, z = pos.z })
end end
-- spawner is closed from all sides -- spawner is closed from all sides
if #spawn_positions < 1 then if #spawn_positions < 1 then
return false return false
-- find random position in all posible places
else else
-- find random position in all posible places
local possible_spawn_pos = {} local possible_spawn_pos = {}
local pick_random_key local pick_random_key
-- get a position value from the picked/random key -- get a position value from the picked/random key
for k, v in pairs (spawn_positions) do for k, v in pairs(spawn_positions) do
local node_above = minetest.get_node({x=v.x, y=v.y+1, z=v.z}).name local node_above = minetest.get_node({ x = v.x, y = v.y + 1, z = v.z }).name
local node_below = minetest.get_node({x=v.x, y=v.y-1, z=v.z}).name local node_below = minetest.get_node({ x = v.x, y = v.y - 1, z = v.z }).name
-- make super sure there is enough place to spawn mob and collect all possible spawn points -- make super sure there is enough place to spawn mob and collect all possible spawn points
if node_above == "air" or node_below == "air" then if node_above == 'air' or node_below == 'air' then
table.insert(possible_spawn_pos, v) table.insert(possible_spawn_pos, v)
-- print("possible pos: "..minetest.pos_to_string(v)) -- print('possible pos: ' .. minetest.pos_to_string(v))
end end
end end
@ -143,20 +166,20 @@ function spawners_env.check_node_status(pos, mob, night_only, boss)
if #possible_spawn_pos < 1 then if #possible_spawn_pos < 1 then
return false return false
-- only one possible position ?
elseif #possible_spawn_pos == 1 then elseif #possible_spawn_pos == 1 then
-- only one possible position ?
pick_random_key = #possible_spawn_pos pick_random_key = #possible_spawn_pos
-- pick random from the possible open sides
else else
pick_random_key = math.random(1,#possible_spawn_pos) -- pick random from the possible open sides
pick_random_key = math.random(1, #possible_spawn_pos)
end end
random_pos = possible_spawn_pos[pick_random_key] random_pos = possible_spawn_pos[pick_random_key]
-- print(minetest.pos_to_string(random_pos)) -- print(minetest.pos_to_string(random_pos))
end end
if night_only ~= "disable" then if night_only ~= 'disable' then
-- spawn only at day -- spawn only at day
if not night_only and node_light < min_node_light then if not night_only and node_light < min_node_light then
return false, true return false, true
@ -178,73 +201,3 @@ function spawners_env.check_node_status(pos, mob, night_only, boss)
return false, true return false, true
end end
end end
local chest_stuff = {
{name="default:apple", max = 3},
{name="default:torch", max = 10},
{name="default:aspen_sapling", max = 5},
{name="farming:bread", max = 3},
{name="default:steel_ingot", max = 2},
{name="default:gold_ingot", max = 2},
{name="default:bronze_ingot", max = 2},
{name="default:copper_ingot", max = 2},
{name="default:diamond", max = 1},
{name="default:pick_steel", max = 1},
{name="default:pick_diamond", max = 1},
{name="default:pick_bronze", max = 1},
{name="default:pick_mese", max = 1},
{name="default:pick_stone", max = 1},
{name="default:pick_wood", max = 1},
{name="default:sword_bronze", max = 1},
{name="default:sword_diamond", max = 1},
{name="default:sword_mese", max = 1},
{name="default:sword_steel", max = 1},
{name="default:sword_stone", max = 1},
{name="default:sword_wood", max = 1},
{name="default:shovel_bronze", max = 1},
{name="default:shovel_diamond", max = 1},
{name="default:shovel_mese", max = 1},
{name="default:shovel_steel", max = 1},
{name="default:shovel_stone", max = 1},
{name="default:shovel_wood", max = 1},
{name="default:axe_bronze", max = 1},
{name="default:axe_diamond", max = 1},
{name="default:axe_mese", max = 1},
{name="default:axe_steel", max = 1},
{name="default:axe_stone", max = 1},
{name="default:axe_wood", max = 1},
{name="obsidianmese:mese_apple", max = 1},
}
function spawners_env.fill_chest(pos)
minetest.after(2, function()
local n = minetest.get_node(pos)
if n and n.name and n.name == "default:chest" then
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
-- if math.random(1,10) < 5 then return end
for i=0,2,1 do
local stuff = chest_stuff[math.random(1,#chest_stuff)]
if stuff.name == "farming:bread" and not minetest.get_modpath("farming") then
stuff = chest_stuff[1]
end
if stuff.name == "obsidianmese:mese_apple" and not minetest.get_modpath("obsidianmese") then
stuff = chest_stuff[1]
end
local stack = {name=stuff.name, count = math.random(1,stuff.max)}
if not inv:contains_item("main", stack) then
inv:set_stack("main", math.random(1,32), stack)
end
end
end
end)
end

View File

@ -1,3 +1,21 @@
--[[
Adds environmental spawners to the map. When enabled, the spawners will be added to newly generated Dungeons (Uruk Hai) and Temples (Spider). They are dropping a real mob spawner by change (very small chance).
Copyright (C) 2016 - 2023 SaKeL <juraj.vajda@gmail.com>
This library is free software; you can redistribute it and/or
modify it pos the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to juraj.vajda@gmail.com
--]]
-- * [name : string] - Name of the mob used in the mod. -- * [name : string] - Name of the mob used in the mod.
-- [egg_name_custom : string] - Custom name for the egg item. If empty default name will be used i.e. 'mobs:chicken'. -- [egg_name_custom : string] - Custom name for the egg item. If empty default name will be used i.e. 'mobs:chicken'.
@ -10,173 +28,172 @@
-- * [dummy_texture : table] - Textures used for the mob. -- * [dummy_texture : table] - Textures used for the mob.
-- * [night_only : boolean : string] - If true mobs will spawn "only" during the night or in dark areas, default:true. Writing "disable" will disable light check and it will spawn in both states (night and day) -- * [night_only : boolean : string] - If true mobs will spawn 'only' during the night or in dark areas, default:true. Writing 'disable' will disable light check and it will spawn in both states (night and day)
-- [sound_custom : string] - Custom name for the sound file name if differ from default: i.e 'mobs_cow'. -- [sound_custom : string] - Custom name for the sound file name if differ from default: i.e 'mobs_cow'.
-- [*] -> MANDATORY - has to be filled in! -- [*] -> MANDATORY - has to be filled in!
-- mods what should be enabled and loded, remove/add the one you want to load -- mods what should be enabled and loded, remove/add the one you want to load
ENABLED_MODS = {"mobs", "creatures"} spawners_env.ENABLED_MODS = { 'mobs', 'creatures' }
-- mobs properties - setup all you mobs here -- mobs properties - setup all you mobs here
MOBS_PROPS = { spawners_env.MOBS_PROPS = {
["mobs"] = { -- MOBS REDO CONFIG ['mobs'] = { -- MOBS REDO CONFIG
{ {
name = "sheep_white", name = 'sheep_white',
egg_name_custom = "", egg_name_custom = '',
dummy_size = {x = 0.52, y = 0.52}, dummy_size = { x = 0.52, y = 0.52 },
dummy_offset = 0.2, dummy_offset = 0.2,
dummy_mesh = "mobs_sheep.b3d", dummy_mesh = 'mobs_sheep.b3d',
dummy_texture = {"mobs_sheep_wool.png^mobs_sheep_base.png"}, dummy_texture = { 'mobs_sheep_wool.png^mobs_sheep_base.png' },
night_only = false, night_only = false,
sound_custom = "mobs_sheep" sound_custom = 'mobs_sheep'
}, },
{ {
name = "cow", name = 'cow',
egg_name_custom = "", egg_name_custom = '',
dummy_size = {x = 0.3, y = 0.3}, dummy_size = { x = 0.3, y = 0.3 },
dummy_offset = -0.3, dummy_offset = -0.3,
dummy_mesh = "mobs_cow.x", dummy_mesh = 'mobs_cow.x',
dummy_texture = {"mobs_cow.png"}, dummy_texture = { 'mobs_cow.png' },
night_only = false, night_only = false,
sound_custom = "" sound_custom = ''
}, },
{ {
name = "chicken", name = 'chicken',
egg_name_custom = "", egg_name_custom = '',
dummy_size = {x = 0.9, y = 0.9}, dummy_size = { x = 0.9, y = 0.9 },
dummy_offset = 0.2, dummy_offset = 0.2,
dummy_mesh = "mobs_chicken.x", dummy_mesh = 'mobs_chicken.x',
dummy_texture = {"mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png"}, dummy_texture = { 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png' },
night_only = false, night_only = false,
sound_custom = "" sound_custom = ''
}, },
{ {
name = "pumba", name = 'pumba',
egg_name_custom = "", egg_name_custom = '',
dummy_size = {x = 0.62, y = 0.62}, dummy_size = { x = 0.62, y = 0.62 },
dummy_offset = -0.3, dummy_offset = -0.3,
dummy_mesh = "mobs_pumba.x", dummy_mesh = 'mobs_pumba.x',
dummy_texture = {"mobs_pumba.png"}, dummy_texture = { 'mobs_pumba.png' },
night_only = false, night_only = false,
sound_custom = "mobs_pig" sound_custom = 'mobs_pig'
}, },
-- { -- {
-- name = "bunny", -- name = 'bunny',
-- egg_name_custom = "", -- egg_name_custom = '',
-- dummy_size = {x = 1, y = 1}, -- dummy_size = { x = 1, y = 1},
-- dummy_offset = 0.2, -- dummy_offset = 0.2,
-- dummy_mesh = "mobs_bunny.b3d", -- dummy_mesh = 'mobs_bunny.b3d',
-- dummy_texture = {"mobs_bunny_brown.png"}, -- dummy_texture = { 'mobs_bunny_brown.png' },
-- night_only = false, -- night_only = false,
-- sound_custom = "spawners_mobs_bunny" -- sound_custom = 'spawners_mobs_bunny'
-- }, -- },
-- { -- {
-- name = "kitten", -- name = 'kitten',
-- egg_name_custom = "", -- egg_name_custom = '',
-- dummy_size = {x = 0.32, y = 0.32}, -- dummy_size = { x = 0.32, y = 0.32},
-- dummy_offset = 0, -- dummy_offset = 0,
-- dummy_mesh = "mobs_kitten.b3d", -- dummy_mesh = 'mobs_kitten.b3d',
-- dummy_texture = {"mobs_kitten_ginger.png"}, -- dummy_texture = { 'mobs_kitten_ginger.png' },
-- night_only = false, -- night_only = false,
-- sound_custom = "" -- sound_custom = ''
-- }, -- },
{ {
name = "spider", name = 'spider',
egg_name_custom = "", egg_name_custom = '',
dummy_size = {x = 2, y = 2}, dummy_size = { x = 2, y = 2 },
dummy_offset = -0.2, dummy_offset = -0.2,
dummy_mesh = "mobs_spider.x", dummy_mesh = 'mobs_spider.x',
dummy_texture = {"mobs_spider.png"}, dummy_texture = { 'mobs_spider.png' },
night_only = true, night_only = true,
sound_custom = "",
env = true, env = true,
sound_custom = "mobs_spider_neutral" sound_custom = 'mobs_spider_neutral'
}, },
{ {
name = "stone_monster", name = 'stone_monster',
egg_name_custom = "", egg_name_custom = '',
dummy_size = {x = 0.5, y = 0.5}, dummy_size = { x = 0.5, y = 0.5 },
dummy_offset = 0.05, dummy_offset = 0.05,
dummy_mesh = "mobs_stone_monster.b3d", dummy_mesh = 'mobs_stone_monster.b3d',
dummy_texture = {"mobs_stone_monster.png"}, dummy_texture = { 'mobs_stone_monster.png' },
night_only = true, night_only = true,
sound_custom = "mobs_stonemonster_neutral" sound_custom = 'mobs_stonemonster_neutral'
}, },
{ {
name = "oerkki", name = 'oerkki',
egg_name_custom = "", egg_name_custom = '',
dummy_size = {x = 0.5, y = 0.5}, dummy_size = { x = 0.5, y = 0.5 },
dummy_offset = 0.05, dummy_offset = 0.05,
dummy_mesh = "mobs_oerkki.b3d", dummy_mesh = 'mobs_oerkki.b3d',
dummy_texture = {"mobs_oerkki.png"}, dummy_texture = { 'mobs_oerkki.png' },
night_only = true, night_only = true,
sound_custom = "" sound_custom = ''
}, },
{ {
name = "tree_monster", name = 'tree_monster',
egg_name_custom = "", egg_name_custom = '',
dummy_size = {x = 0.4, y = 0.4}, dummy_size = { x = 0.4, y = 0.4 },
dummy_offset = 0.05, dummy_offset = 0.05,
dummy_mesh = "mobs_tree_monster.b3d", dummy_mesh = 'mobs_tree_monster.b3d',
dummy_texture = {"mobs_tree_monster.png"}, dummy_texture = { 'mobs_tree_monster.png' },
night_only = true, night_only = true,
sound_custom = "mobs_treemonster_neutral" sound_custom = 'mobs_treemonster_neutral'
} }
}, },
["creatures"] = { -- CREATURES MOD CONFIG ['creatures'] = { -- CREATURES MOD CONFIG
{ {
name = "chicken", name = 'chicken',
egg_name_custom = "creatures:chicken_spawn_egg", egg_name_custom = 'creatures:chicken_spawn_egg',
dummy_size = {x = 0.9, y = 0.9}, dummy_size = { x = 0.9, y = 0.9 },
dummy_offset = -0.3, dummy_offset = -0.3,
dummy_mesh = "creatures_chicken.b3d", dummy_mesh = 'creatures_chicken.b3d',
dummy_texture = {"creatures_chicken.png"}, dummy_texture = { 'creatures_chicken.png' },
night_only = false, night_only = false,
sound_custom = "" sound_custom = ''
}, },
{ {
name = "ghost", name = 'ghost',
egg_name_custom = "creatures:ghost_spawn_egg", egg_name_custom = 'creatures:ghost_spawn_egg',
dummy_size = {x = 0.7, y = 0.7}, dummy_size = { x = 0.7, y = 0.7 },
dummy_offset = -0.5, dummy_offset = -0.5,
dummy_mesh = "creatures_ghost.b3d", dummy_mesh = 'creatures_ghost.b3d',
dummy_texture = {"creatures_ghost.png"}, dummy_texture = { 'creatures_ghost.png' },
night_only = true, night_only = true,
sound_custom = "" sound_custom = ''
}, },
{ {
name = "sheep", name = 'sheep',
egg_name_custom = "creatures:sheep_spawn_egg", egg_name_custom = 'creatures:sheep_spawn_egg',
dummy_size = {x = 0.6, y = 0.6}, dummy_size = { x = 0.6, y = 0.6 },
dummy_offset = -0.3, dummy_offset = -0.3,
dummy_mesh = "creatures_sheep.b3d", dummy_mesh = 'creatures_sheep.b3d',
dummy_texture = {"creatures_sheep.png^creatures_sheep_white.png"}, dummy_texture = { 'creatures_sheep.png^creatures_sheep_white.png' },
night_only = false, night_only = false,
sound_custom = "" sound_custom = ''
}, },
{ {
name = "zombie", name = 'zombie',
egg_name_custom = "creatures:zombie_spawn_egg", egg_name_custom = 'creatures:zombie_spawn_egg',
dummy_size = {x = 0.5, y = 0.5}, dummy_size = { x = 0.5, y = 0.5 },
dummy_offset = -0.5, dummy_offset = -0.5,
dummy_mesh = "creatures_zombie.b3d", dummy_mesh = 'creatures_zombie.b3d',
dummy_texture = {"creatures_zombie.png"}, dummy_texture = { 'creatures_zombie.png' },
night_only = false, night_only = false,
sound_custom = "" sound_custom = ''
}, },
{ {
name = "oerrki", name = 'oerrki',
egg_name_custom = "creatures:oerrki_spawn_egg", egg_name_custom = 'creatures:oerrki_spawn_egg',
dummy_size = {x = 0.4, y = 0.4}, dummy_size = { x = 0.4, y = 0.4 },
dummy_offset = -0.5, dummy_offset = -0.5,
dummy_mesh = "creatures_oerrki.b3d", dummy_mesh = 'creatures_oerrki.b3d',
dummy_texture = {"creatures_oerrki.png"}, dummy_texture = { 'creatures_oerrki.png' },
night_only = false, night_only = false,
sound_custom = "creatures_oerrki_idle" sound_custom = 'creatures_oerrki_idle'
} }
} }
} }
@ -186,54 +203,56 @@ MOBS_PROPS = {
-- --
-- include mummy mobs redo addon (spawner) -- include mummy mobs redo addon (spawner)
if minetest.get_modpath("mobs") ~= nil then if minetest.get_modpath('mobs') ~= nil then
-- enable spawner -- enable spawner
table.insert(ENABLED_MODS, "spawners_mobs") table.insert(spawners_env.ENABLED_MODS, 'spawners_mobs')
-- configure spawner -- configure spawner
MOBS_PROPS["spawners_mobs"] = { spawners_env.MOBS_PROPS['spawners_mobs'] = {
{ {
name = "mummy", name = 'mummy',
egg_name_custom = "", egg_name_custom = '',
dummy_size = {x = 0.4, y = 0.4}, dummy_size = { x = 0.4, y = 0.4 },
dummy_offset = 0, dummy_offset = 0,
dummy_mesh = "spawners_mobs_mummy.b3d", dummy_mesh = 'spawners_mobs_mummy.b3d',
dummy_texture = {"spawners_mobs_mummy.png"}, dummy_texture = { 'spawners_mobs_mummy.png' },
night_only = true, night_only = true,
sound_custom = "spawners_mobs_mummy_neutral" sound_custom = 'spawners_mobs_mummy_neutral'
}, },
{ {
name = "bunny_evil", name = 'bunny_evil',
egg_name_custom = "", egg_name_custom = '',
dummy_size = {x = 1, y = 1}, dummy_size = { x = 1, y = 1 },
dummy_offset = 0.2, dummy_offset = 0.2,
dummy_mesh = "spawners_mobs_evil_bunny.b3d", dummy_mesh = 'spawners_mobs_evil_bunny.b3d',
dummy_texture = {"spawners_mobs_evil_bunny.png"}, dummy_texture = { 'spawners_mobs_evil_bunny.png' },
night_only = true, night_only = true,
sound_custom = "spawners_mobs_bunny" sound_custom = 'spawners_mobs_bunny'
}, },
{ {
name = "uruk_hai", name = 'uruk_hai',
egg_name_custom = "", egg_name_custom = '',
dummy_size = {x = 0.5, y = 0.5}, dummy_size = { x = 0.5, y = 0.5 },
dummy_offset = 0, dummy_offset = 0,
dummy_mesh = "spawners_mobs_character.b3d", dummy_mesh = 'spawners_mobs_character.b3d',
dummy_texture = {"spawners_mobs_uruk_hai.png", "spawners_mobs_trans.png","spawners_mobs_galvornsword.png", "spawners_mobs_trans.png"}, dummy_texture = { 'spawners_mobs_uruk_hai.png', 'spawners_mobs_trans.png', 'spawners_mobs_galvornsword.png', 'spawners_mobs_trans.png' },
night_only = true, night_only = true,
sound_custom = "spawners_mobs_uruk_hai_neutral", sound_custom = 'spawners_mobs_uruk_hai_neutral',
env = true env = true
}, },
{ {
name = "balrog", name = 'balrog',
egg_name_custom = "", egg_name_custom = '',
dummy_size = {x = 0.2, y = 0.2}, dummy_size = { x = 0.2, y = 0.2 },
dummy_offset = 0, dummy_offset = 0,
dummy_mesh = "spawners_mobs_balrog.b3d", dummy_mesh = 'spawners_mobs_balrog.b3d',
dummy_texture = {"spawners_mobs_balrog.png"}, dummy_texture = { 'spawners_mobs_balrog.png' },
night_only = "disable", night_only = 'disable',
sound_custom = "spawners_mobs_balrog_neutral", sound_custom = 'spawners_mobs_balrog_neutral',
env = true, env = true,
boss = true boss = true
} }
} }
end end
spawners_env.register_spawners()

View File

@ -1 +0,0 @@
default

View File

@ -1,13 +1,34 @@
MOD_NAME = minetest.get_current_modname() --[[
Adds environmental spawners to the map. When enabled, the spawners will be added to newly generated Dungeons (Uruk Hai) and Temples (Spider). They are dropping a real mob spawner by change (very small chance).
Copyright (C) 2016 - 2023 SaKeL <juraj.vajda@gmail.com>
-- Spawners configurations This library is free software; you can redistribute it and/or
dofile(minetest.get_modpath(MOD_NAME).."/config.lua") modify it pos the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to juraj.vajda@gmail.com
--]]
local mod_start_time = minetest.get_us_time()
local path = minetest.get_modpath('spawners_env')
-- API -- API
dofile(minetest.get_modpath(MOD_NAME).."/api.lua") dofile(path .. '/api.lua')
-- Spawners configurations
dofile(path .. '/config.lua')
-- Spawners for mobs -- Spawners for mobs
dofile(minetest.get_modpath(MOD_NAME).."/spawners_env.lua") dofile(path .. '/spawners_env.lua')
dofile(minetest.get_modpath(MOD_NAME).."/spawners_gen.lua") dofile(path .. '/spawners_gen.lua')
print ("[Mod] Spawners Environmental Loaded.") local mod_end_time = (minetest.get_us_time() - mod_start_time) / 1000000
print('[Mod] Spawners Environmental Loaded. [' .. mod_end_time .. 's]')

6
spawners_env/mod.conf Normal file
View File

@ -0,0 +1,6 @@
name = spawners_env
description = Adds environmental spawners to the map. When enabled, the spawners will be added to newly generated Dungeons (Uruk Hai) and Temples (Spider). They are dropping a real mob spawner by change (very small chance).
depends = default, mobs
optional_depends = creatures
supported_games =
min_minetest_version = 5.4

View File

@ -1,3 +0,0 @@
SPAWN_PYRAMIDS = false
SPAWNERS_GENERATE = true
CHESTS_GENERATE = false

View File

@ -1,3 +1,21 @@
--[[
Adds environmental spawners to the map. When enabled, the spawners will be added to newly generated Dungeons (Uruk Hai) and Temples (Spider). They are dropping a real mob spawner by change (very small chance).
Copyright (C) 2016 - 2023 SaKeL <juraj.vajda@gmail.com>
This library is free software; you can redistribute it and/or
modify it pos the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to juraj.vajda@gmail.com
--]]
-- --
-- * CREATE ALL SPAWNERS NODES * -- * CREATE ALL SPAWNERS NODES *
-- --
@ -11,21 +29,21 @@ function spawners_env.create(mob_name, mod_prefix, size, offset, mesh, texture,
local dummy_definition = { local dummy_definition = {
hp_max = 1, hp_max = 1,
physical = true, physical = true,
collisionbox = {0,0,0,0,0,0}, collisionbox = { 0, 0, 0, 0, 0, 0 },
visual = "mesh", visual = 'mesh',
visual_size = size, visual_size = size,
mesh = mesh, mesh = mesh,
textures = texture, textures = texture,
makes_footstep_sound = false, makes_footstep_sound = false,
timer = 0, timer = 0,
automatic_rotate = math.pi * -3, automatic_rotate = math.pi * -3,
m_name = "dummy" m_name = 'dummy'
} }
dummy_definition.on_activate = function(self) dummy_definition.on_activate = function(self)
self.object:set_velocity({x=0, y=0, z=0}) self.object:set_velocity({ x = 0, y = 0, z = 0 })
self.object:set_acceleration({x=0, y=0, z=0}) self.object:set_acceleration({ x = 0, y = 0, z = 0 })
self.object:set_armor_groups({immortal=1}) self.object:set_armor_groups({ immortal = 1 })
end end
-- remove dummy after dug up the spawner -- remove dummy after dug up the spawner
@ -33,33 +51,33 @@ function spawners_env.create(mob_name, mod_prefix, size, offset, mesh, texture,
self.timer = self.timer + dtime self.timer = self.timer + dtime
local n = minetest.get_node_or_nil(self.object:get_pos()) local n = minetest.get_node_or_nil(self.object:get_pos())
if self.timer > 2 then if self.timer > 2 then
if n and n.name and n.name ~= "spawners_env:"..mod_prefix.."_"..mob_name.."_spawner_active" then if n and n.name and n.name ~= 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_active' then
self.object:remove() self.object:remove()
end end
end end
end end
minetest.register_entity("spawners_env:dummy_"..mod_prefix.."_"..mob_name, dummy_definition) minetest.register_entity('spawners_env:dummy_' .. mod_prefix .. '_' .. mob_name, dummy_definition)
-- --
-- ACTIVE SPAWNER ENV -- ACTIVE SPAWNER ENV
-- --
minetest.register_node("spawners_env:"..mod_prefix.."_"..mob_name.."_spawner_active", { minetest.register_node('spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_active', {
description = mod_prefix.."_"..mob_name.." spawner active env", description = mod_prefix .. '_' .. mob_name .. ' spawner active env',
paramtype = "light", paramtype = 'light',
light_source = 4, light_source = 4,
paramtype2 = "glasslikeliquidlevel", paramtype2 = 'glasslikeliquidlevel',
drawtype = "glasslike_framed_optional", drawtype = 'glasslike_framed_optional',
walkable = true, walkable = true,
sounds = default.node_sound_metal_defaults(), sounds = default.node_sound_metal_defaults(),
damage_per_second = 4, damage_per_second = 4,
sunlight_propagates = true, sunlight_propagates = true,
tiles = { tiles = {
{ {
name = "spawners_env_spawner_animated_16.png", name = 'spawners_env_spawner_animated_16.png',
animation = { animation = {
type = "vertical_frames", type = 'vertical_frames',
aspect_w = 16, aspect_w = 16,
aspect_h = 16, aspect_h = 16,
length = 2.0 length = 2.0
@ -67,7 +85,13 @@ function spawners_env.create(mob_name, mod_prefix, size, offset, mesh, texture,
} }
}, },
is_ground_content = true, is_ground_content = true,
groups = {cracky=1,level=2,igniter=1,not_in_creative_inventory=1}, groups = {
-- MTG
cracky = 1,
level = 2,
igniter = 1,
not_in_creative_inventory = 1
},
on_timer = function(pos, elapsed) on_timer = function(pos, elapsed)
spawners_env.check_for_spawning_timer(pos, mob_name, night_only, mod_prefix, sound_custom, env, boss) spawners_env.check_for_spawning_timer(pos, mob_name, night_only, mod_prefix, sound_custom, env, boss)
return false return false
@ -75,12 +99,12 @@ function spawners_env.create(mob_name, mod_prefix, size, offset, mesh, texture,
drop = { drop = {
max_items = 1, max_items = 1,
items = { items = {
{items = {"spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner"}, rarity = 20} { items = { 'spawners_mobs:' .. mod_prefix .. '_' .. mob_name .. '_spawner' }, rarity = 20 }
} }
}, },
on_construct = function(pos) on_construct = function(pos)
pos.y = pos.y + offset pos.y = pos.y + offset
minetest.add_entity(pos,"spawners_env:dummy_"..mod_prefix.."_"..mob_name) minetest.add_entity(pos, 'spawners_env:dummy_' .. mod_prefix .. '_' .. mob_name)
end, end,
}) })
@ -89,20 +113,20 @@ function spawners_env.create(mob_name, mod_prefix, size, offset, mesh, texture,
-- --
-- waiting for light - everything is ok but too much light or not enough light -- waiting for light - everything is ok but too much light or not enough light
minetest.register_node("spawners_env:"..mod_prefix.."_"..mob_name.."_spawner_waiting", { minetest.register_node('spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_waiting', {
description = mod_prefix.."_"..mob_name.." spawner waiting env", description = mod_prefix .. '_' .. mob_name .. ' spawner waiting env',
paramtype = "light", paramtype = 'light',
light_source = 2, light_source = 2,
paramtype2 = "glasslikeliquidlevel", paramtype2 = 'glasslikeliquidlevel',
drawtype = "glasslike_framed_optional", drawtype = 'glasslike_framed_optional',
walkable = true, walkable = true,
sounds = default.node_sound_metal_defaults(), sounds = default.node_sound_metal_defaults(),
sunlight_propagates = true, sunlight_propagates = true,
tiles = { tiles = {
{ {
name = "spawners_env_spawner_waiting_animated_16.png", name = 'spawners_env_spawner_waiting_animated_16.png',
animation = { animation = {
type = "vertical_frames", type = 'vertical_frames',
aspect_w = 16, aspect_w = 16,
aspect_h = 16, aspect_h = 16,
length = 2.0 length = 2.0
@ -110,7 +134,12 @@ function spawners_env.create(mob_name, mod_prefix, size, offset, mesh, texture,
} }
}, },
is_ground_content = true, is_ground_content = true,
groups = {cracky=1,level=2,not_in_creative_inventory=1}, groups = {
-- MTG
cracky = 1,
level = 2,
not_in_creative_inventory = 1
},
on_timer = function(pos, elapsed) on_timer = function(pos, elapsed)
spawners_env.check_for_spawning_timer(pos, mob_name, night_only, mod_prefix, sound_custom, env, boss) spawners_env.check_for_spawning_timer(pos, mob_name, night_only, mod_prefix, sound_custom, env, boss)
return false return false
@ -118,7 +147,7 @@ function spawners_env.create(mob_name, mod_prefix, size, offset, mesh, texture,
drop = { drop = {
max_items = 1, max_items = 1,
items = { items = {
{items = {"spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner"}, rarity = 20} { items = { 'spawners_mobs:' .. mod_prefix .. '_' .. mob_name .. '_spawner' }, rarity = 20 }
} }
}, },
}) })
@ -127,22 +156,27 @@ function spawners_env.create(mob_name, mod_prefix, size, offset, mesh, texture,
-- INACTIVE SPAWNER (DEFAULT) ENV -- INACTIVE SPAWNER (DEFAULT) ENV
-- --
minetest.register_node("spawners_env:"..mod_prefix.."_"..mob_name.."_spawner", { minetest.register_node('spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner', {
description = mod_prefix.."_"..mob_name.." spawner env", description = mod_prefix .. '_' .. mob_name .. ' spawner env',
paramtype = "light", paramtype = 'light',
paramtype2 = "glasslikeliquidlevel", paramtype2 = 'glasslikeliquidlevel',
drawtype = "glasslike_framed_optional", drawtype = 'glasslike_framed_optional',
walkable = true, walkable = true,
sounds = default.node_sound_metal_defaults(), sounds = default.node_sound_metal_defaults(),
sunlight_propagates = true, sunlight_propagates = true,
tiles = {"spawners_env_spawner_16.png"}, tiles = { 'spawners_env_spawner_16.png' },
is_ground_content = true, is_ground_content = true,
groups = {cracky=1,level=2,not_in_creative_inventory=0}, groups = {
-- MTG
cracky = 1,
level = 2,
not_in_creative_inventory = 0
},
stack_max = 1, stack_max = 1,
drop = { drop = {
max_items = 1, max_items = 1,
items = { items = {
{items = {"spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner"}, rarity = 20} { items = { 'spawners_mobs:' .. mod_prefix .. '_' .. mob_name .. '_spawner' }, rarity = 20 }
} }
}, },
on_construct = function(pos) on_construct = function(pos)
@ -155,11 +189,11 @@ function spawners_env.create(mob_name, mod_prefix, size, offset, mesh, texture,
-- --
minetest.register_lbm({ minetest.register_lbm({
name = "spawners_env:check_for_spawning_timer", name = 'spawners_env:check_for_spawning_timer',
nodenames = { nodenames = {
"spawners_env:"..mod_prefix.."_"..mob_name.."_spawner", 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner',
"spawners_env:"..mod_prefix.."_"..mob_name.."_spawner_active", 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_active',
"spawners_env:"..mod_prefix.."_"..mob_name.."_spawner_waiting" 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_waiting'
}, },
action = function(pos) action = function(pos)
spawners_env.check_for_spawning_timer(pos, mob_name, night_only, mod_prefix, sound_custom, env, boss) spawners_env.check_for_spawning_timer(pos, mob_name, night_only, mod_prefix, sound_custom, env, boss)
@ -172,14 +206,14 @@ end
-- --
function spawners_env.check_for_spawning_timer(pos, mob_name, night_only, mod_prefix, sound_custom, env, boss) function spawners_env.check_for_spawning_timer(pos, mob_name, night_only, mod_prefix, sound_custom, env, boss)
local random_pos, waiting = spawners_env.check_node_status(pos, mob_name, night_only, boss) local random_pos = spawners_env.check_node_status(pos, mob_name, night_only, boss)
local node = minetest.get_node_or_nil(pos) local node = minetest.get_node_or_nil(pos)
-- minetest.log("action", "[Mod][Spawners] checking for: "..mob_name.." at "..minetest.pos_to_string(pos)) -- minetest.log('action', '[Mod][Spawners] checking for: ' .. mob_name .. ' at ' .. minetest.pos_to_string(pos))
if random_pos then if random_pos then
-- print('try to spawn another mob at: '..minetest.pos_to_string(random_pos)) -- print('try to spawn another mob at: ' .. minetest.pos_to_string(random_pos))
local mobs_counter_table = {} local mobs_counter_table = {}
local mobs_check_radius local mobs_check_radius
@ -195,16 +229,16 @@ function spawners_env.check_for_spawning_timer(pos, mob_name, night_only, mod_pr
end end
-- collect all spawned mobs around area -- collect all spawned mobs around area
for _,obj in ipairs(minetest.get_objects_inside_radius(pos, mobs_check_radius)) do for _, obj in ipairs(minetest.get_objects_inside_radius(pos, mobs_check_radius)) do
if obj:get_luaentity() ~= nil then if obj:get_luaentity() ~= nil then
-- get entity name -- get entity name
local name_split = string.split(obj:get_luaentity().name, ":") local name_split = string.split(obj:get_luaentity().name, ':')
if name_split[2] == mob_name then if name_split[2] == mob_name then
mobs_counter_table[mob_name]=mobs_counter_table[mob_name]+1 mobs_counter_table[mob_name] = mobs_counter_table[mob_name] + 1
end end
@ -212,34 +246,34 @@ function spawners_env.check_for_spawning_timer(pos, mob_name, night_only, mod_pr
end end
-- print(mob_name.." : "..mobs_counter_table[mob_name]) -- print(mob_name .. ' : ' .. mobs_counter_table[mob_name])
-- enough place to spawn more mobs -- enough place to spawn more mobs
if mobs_counter_table[mob_name] < mobs_max then if mobs_counter_table[mob_name] < mobs_max then
-- make sure the right node status is shown -- make sure the right node status is shown
if node.name ~= "spawners_env:"..mod_prefix.."_"..mob_name.."_spawner_active" then if node.name ~= 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_active' then
minetest.set_node(pos, {name="spawners_env:"..mod_prefix.."_"..mob_name.."_spawner_active"}) minetest.set_node(pos, { name = 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_active' })
end end
if boss then if boss then
-- color: deep orange -- color: deep orange
minetest.chat_send_all(minetest.colorize("#FF5722", "Balrog has spawned to this World!")) minetest.chat_send_all(minetest.colorize('#FF5722', 'Balrog has spawned to this World!'))
end end
spawners_env.start_spawning(random_pos, 1, "spawners_env:"..mob_name, mod_prefix, sound_custom) spawners_env.start_spawning(random_pos, 1, 'spawners_env:' .. mob_name, mod_prefix, sound_custom)
else else
-- print("too many mobs: waiting") -- print('too many mobs: waiting')
-- waiting status -- waiting status
if node.name ~= "spawners_env:"..mod_prefix.."_"..mob_name.."_spawner_waiting" then if node.name ~= 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_waiting' then
minetest.set_node(pos, {name="spawners_env:"..mod_prefix.."_"..mob_name.."_spawner_waiting"}) minetest.set_node(pos, { name = 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_waiting' })
end end
end end
else else
-- print("no random_pos found: waiting") -- print('no random_pos found: waiting')
-- waiting status -- waiting status
if node.name ~= "spawners_env:"..mod_prefix.."_"..mob_name.."_spawner_waiting" then if node.name ~= 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_waiting' then
minetest.set_node(pos, {name="spawners_env:"..mod_prefix.."_"..mob_name.."_spawner_waiting"}) minetest.set_node(pos, { name = 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_waiting' })
end end
end end
-- 6 hours = 21600 seconds -- 6 hours = 21600 seconds

View File

@ -1,33 +1,24 @@
-- Place chests in dungeons and temples --[[
local function place_chest(param) Adds environmental spawners to the map. When enabled, the spawners will be added to newly generated Dungeons (Uruk Hai) and Temples (Spider). They are dropping a real mob spawner by change (very small chance).
local skip = math.random(0,1) Copyright (C) 2016 - 2023 SaKeL <juraj.vajda@gmail.com>
-- skip chest This library is free software; you can redistribute it and/or
if skip == 1 then modify it pos the terms of the GNU Lesser General Public
return License as published by the Free Software Foundation; either
end version 2.1 of the License, or (at your option) any later version.
local tab = param This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
local pos = tab[math.random(1, (#tab or 4))] You should have received a copy of the GNU Lesser General Public
pos.y = pos.y - 1 License along with this library; if not, write to juraj.vajda@gmail.com
--]]
local n = minetest.get_node_or_nil(pos)
if n and n.name ~= "air" then
pos.y = pos.y + 1
minetest.log("action", "[Mod][Spawners] Chest placed at: "..minetest.pos_to_string(pos))
minetest.set_node(pos, {name = "default:chest"})
spawners_env.fill_chest(pos)
end
end
-- Place spawners in dungeons -- Place spawners in dungeons
local function place_spawner(param) local function place_spawner(param)
local skip = math.random(0,1) local skip = math.random(0, 1)
-- skip spawner -- skip spawner
if skip == 1 then if skip == 1 then
@ -41,43 +32,39 @@ local function place_spawner(param)
pos.y = pos.y - 1 pos.y = pos.y - 1
local n = minetest.get_node_or_nil(pos) local n = minetest.get_node_or_nil(pos)
local n2 = minetest.get_node_or_nil({x=pos.x, y=pos.y+1, z=pos.z}) local n2 = minetest.get_node_or_nil({ x = pos.x, y = pos.y + 1, z = pos.z })
if n and n.name ~= "air" then if n and n.name ~= 'air' then
pos.y = pos.y + 1 pos.y = pos.y + 1
-- pos the same as chest, putting spawner above the chest -- pos the same as chest, putting spawner above the chest
if n2 and n2.name == "default:chest" then if n2 and n2.name == 'default:chest' then
-- print("pos the same as chest, putting spawner above the chest") -- print('pos the same as chest, putting spawner above the chest')
pos.y = pos.y + 1 pos.y = pos.y + 1
end end
if gen_obj == "dungeon" then if gen_obj == 'dungeon' then
minetest.log("action", "[Mod][Spawners] dungeon spawner placed at: "..minetest.pos_to_string(pos)) minetest.set_node(pos, { name = 'spawners_env:spawners_mobs_uruk_hai_spawner' })
minetest.log('action', '[Spawners] dungeon spawner placed at: ' .. minetest.pos_to_string(pos))
minetest.set_node(pos, {name = "spawners_env:spawners_mobs_uruk_hai_spawner"})
else else
minetest.log("action", "[Mod][Spawners] temple spawner placed at: "..minetest.pos_to_string(pos)) minetest.set_node(pos, { name = 'spawners_env:spawners_mobs_uruk_hai_spawner' })
minetest.log('action', '[Spawners] temple spawner placed at: ' .. minetest.pos_to_string(pos))
minetest.set_node(pos, {name = "spawners_env:mobs_spider_spawner"})
end end
end end
end end
minetest.set_gen_notify("dungeon") minetest.set_gen_notify('dungeon')
minetest.set_gen_notify("temple") minetest.set_gen_notify('temple')
minetest.register_on_generated(function(minp, maxp, blockseed) minetest.register_on_generated(function(minp, maxp, blockseed)
local notify = minetest.get_mapgen_object("gennotify") local notify = minetest.get_mapgen_object('gennotify')
if notify and notify.dungeon then if notify and notify.dungeon then
minetest.after(2, place_chest, table.copy(notify.dungeon)) minetest.after(3, place_spawner, { table.copy(notify.dungeon), 'dungeon' })
minetest.after(3, place_spawner, {table.copy(notify.dungeon), "dungeon"})
end end
if notify and notify.temple then if notify and notify.temple then
minetest.after(2, place_chest, table.copy(notify.temple)) minetest.after(3, place_spawner, { table.copy(notify.temple), 'temple' })
minetest.after(3, place_spawner, {table.copy(notify.temple), "temple"})
end end
end) end)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 364 B

After

Width:  |  Height:  |  Size: 362 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 254 B

After

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 413 B

After

Width:  |  Height:  |  Size: 410 B

567
spawners_mobs/LICENSE.txt Normal file
View File

@ -0,0 +1,567 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 2016 - 2023 SaKeL <juraj.vajda@gmail.com>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
### Code
GNU Lesser General Public License v2.1 or later (see included LICENSE file)
### Textures
**CC-BY-SA-4.0, by SaKeL**
- spawners_mobs_black_skull.png
- spawners_mobs_evil_bunny_egg.png
- spawners_mobs_galvornsword.png
- spawners_mobs_spawner_16.png
- spawners_mobs_spawner_animated.png
- spawners_mobs_spawner_rusty.png
- spawners_mobs_spawner_waiting_animated_16.png
- spawners_mobs_spawner_waiting_animated.png
- spawners_mobs_spawner.png
- spawners_mobs_trans.png
**CC-BY-SA-4.0, Pixel Perfection by XSSheep**, https://minecraft.curseforge.com/projects/pixel-perfection-freshly-updated
- spawners_mobs_firebolt.png
- spawners_mobs_flame_particle_2.png
- spawners_mobs_flame_particle.png
- spawners_mobs_smoke_particle_2.png
- spawners_mobs_smoke_particle.png
**WTFPL, by BlockMen**
- spawners_mobs_sandstone_carved_bird.png
- spawners_mobs_mummy.png
**CC-BY-SA-3.0, by bas080**
- spawners_mobs_sandstone_carved_eye.png
- spawners_mobs_sandstone_carved_men.png
- spawners_mobs_sandstone_carved_sun.png
**CC-BY-SA-3.0, by STHGOM**
- spawners_mobs_balrog.png
**CC-BY-SA-4.0, by fishyWET**
- spawners_mobs_uruk_hai_1.png
- spawners_mobs_uruk_hai_2.png
- spawners_mobs_uruk_hai_3.png
- spawners_mobs_uruk_hai_egg.png
- spawners_mobs_uruk_hai.png
**CC0-1.0, by ExeterDad**
- spawners_mobs_evil_bunny.png
### Sounds
**CC-BY-4.0, by efectirijillo**, https://freesound.org/people/efectirijillo/sounds/241979/
- spawners_mobs_mummy_hit.1.ogg
- spawners_mobs_mummy_hit.2.ogg
- spawners_mobs_mummy_hit.3.ogg
**CC0-1.0, by SnowFightStudios**, https://freesound.org/people/SnowFightStudios/sounds/669797/
- spawners_mobs_mummy_spell.3.ogg
- spawners_mobs_mummy_spell.2.ogg
- spawners_mobs_mummy_spell.1.ogg
**CC0-1.0, by SnowFightStudios**, https://freesound.org/people/SnowFightStudios/sounds/683281/
- spawners_mobs_mummy_neutral.3.ogg
- spawners_mobs_mummy_neutral.2.ogg
- spawners_mobs_mummy_neutral.1.ogg
**CC0-1.0, by SnowFightStudios**, https://freesound.org/people/SnowFightStudios/sounds/643684/
- spawners_mobs_mummy_death.3.ogg
- spawners_mobs_mummy_death.2.ogg
- spawners_mobs_mummy_death.1.ogg
- spawners_mobs_mummy_attack.3.ogg
- spawners_mobs_mummy_attack.2.ogg
- spawners_mobs_mummy_attack.1.ogg
**CC-BY-4.0, by EminYILDIRIM**, https://freesound.org/people/EminYILDIRIM/sounds/547565/
- spawners_mobs_teleport.1.ogg
- spawners_mobs_teleport.2.ogg
**CC-BY-4.0, by dobroide**, https://freesound.org/people/dobroide/sounds/84141/
- spawners_mobs_bunny.ogg
### Models
**Original model by MirceaKitsune (CC BY-SA 3.0).**
**Various alterations and fixes by kilbith, sofar, xunto, Rogier-5, TeTpaAka, Desour,**
**stujones11, An0n3m0us (CC BY-SA 3.0):**
- spawners_mobs_character.b3d
**WTFPL, by BlockMen**
- spawners_mobs_mummy.b3d
**CC0-1.0, by ExeterDad**
- spawners_mobs_evil_bunny.b3d
**CC-BY-SA-3.0, by STHGOM**
- spawners_mobs_balrog.b3d

View File

@ -1,21 +1,42 @@
--[[
Let the player craft Mob Spawners. Mobs are spawning randomly in a short intervals, giving the option of creating mob farms and grinders.
Copyright (C) 2016 - 2023 SaKeL <juraj.vajda@gmail.com>
This library is free software; you can redistribute it and/or
modify it pos the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to juraj.vajda@gmail.com
--]]
-- main tables -- main tables
spawners_mobs = {} spawners_mobs = {
ENABLED_MODS = {},
MOBS_PROPS = {}
}
spawners_mobs.mob_tables = {} spawners_mobs.mob_tables = {}
local max_obj_per_mapblock = tonumber(minetest.settings:get("max_objects_per_block")) local max_obj_per_mapblock = tonumber(minetest.settings:get('max_objects_per_block'))
local enable_particles = minetest.settings:get_bool("enable_particles") local enable_particles = minetest.settings:get_bool('enable_particles')
local tick_max = 40 local tick_max = 30
local tick_short_max = 40 local tick_short_max = 20
-- check if mods exists and build tables -- check if mods exists and build tables
for k, mob_mod in ipairs(ENABLED_MODS) do for k, mob_mod in ipairs(spawners_mobs.ENABLED_MODS) do
local modpath = minetest.get_modpath(mob_mod) local modpath = minetest.get_modpath(mob_mod)
-- list of mobs and their info -- list of mobs and their info
if (modpath) then if (modpath) then
for j, mob in ipairs(MOBS_PROPS[mob_mod]) do for j, mob in ipairs(spawners_mobs.MOBS_PROPS[mob_mod]) do
local mob_egg = nil local mob_egg
-- disabled extra check for mobs redo due to incompatibility with Lua 5.1, this method is available from Lua 5.2 -- disabled extra check for mobs redo due to incompatibility with Lua 5.1, this method is available from Lua 5.2
-- if mob_mod == "mobs" and not (mobs.mod == "redo") then goto continue end -- if mob_mod == 'mobs' and not (mobs.mod == 'redo') then goto continue end
table.insert(spawners_mobs.mob_tables, table.insert(spawners_mobs.mob_tables,
{ {
@ -31,22 +52,23 @@ for k, mob_mod in ipairs(ENABLED_MODS) do
} }
) )
-- use custom egg or create a default egg -- use custom egg or create a default egg
if mob.egg_name_custom ~= "" then if mob.egg_name_custom ~= '' then
mob_egg = mob.egg_name_custom mob_egg = mob.egg_name_custom
else else
mob_egg = mob_mod..":"..mob.name mob_egg = mob_mod .. ':' .. mob.name
end end
-- recipes -- recipes
minetest.register_craft({ minetest.register_craft({
output = "spawners_mobs:"..mob_mod.."_"..mob.name.."_spawner", output = 'spawners_mobs:' .. mob_mod .. '_' .. mob.name .. '_spawner',
recipe = { recipe = {
{"default:diamondblock", "fire:flint_and_steel", "default:diamondblock"}, { 'default:diamondblock', 'fire:flint_and_steel', 'default:diamondblock' },
{"xpanes:bar_flat", mob_egg, "xpanes:bar_flat"}, { 'xpanes:bar_flat', mob_egg, 'xpanes:bar_flat' },
{"default:diamondblock", "xpanes:bar_flat", "default:diamondblock"}, { 'default:diamondblock', 'xpanes:bar_flat', 'default:diamondblock' },
} }
}) })
-- Lua > 5.1
-- ::continue:: -- ::continue::
end end
end end
@ -61,19 +83,19 @@ function spawners_mobs.cloud_booom(pos)
minetest.add_particlespawner({ minetest.add_particlespawner({
amount = 5, amount = 5,
time = 2, time = 2,
minpos = vector.subtract({x=pos.x-0.3, y=pos.y, z=pos.z-0.3}, 0.3), minpos = vector.subtract({ x = pos.x - 0.3, y = pos.y, z = pos.z - 0.3 }, 0.3),
maxpos = vector.add({x=pos.x+0.3, y=pos.y, z=pos.z+0.3}, 0.3), maxpos = vector.add({ x= pos.x + 0.3, y = pos.y, z = pos.z + 0.3 }, 0.3),
minvel = {x=0.1, y=0.1, z=0.1}, minvel = { x = 0.1, y = 0.1, z = 0.1 },
maxvel = {x=0.2, y=0.2, z=0.2}, maxvel = { x = 0.2, y = 0.2, z = 0.2 },
minacc = vector.new({x=-0.1, y=0.3, z=-0.1}), minacc = vector.new({ x = -0.1, y = 0.3, z = -0.1 }),
maxacc = vector.new({x=0.1, y=0.6, z=0.1}), maxacc = vector.new({ x = 0.1, y = 0.6, z = 0.1 }),
minexptime = 2, minexptime = 2,
maxexptime = 3, maxexptime = 3,
minsize = 16, minsize = 16,
maxsize = 24, maxsize = 24,
texture = "spawners_mobs_smoke_particle_2.png", texture = 'spawners_mobs_smoke_particle_2.png',
animation = { animation = {
type = "vertical_frames", type = 'vertical_frames',
-- Width of a frame in pixels -- Width of a frame in pixels
aspect_w = 16, aspect_w = 16,
-- Height of a frame in pixels -- Height of a frame in pixels
@ -90,17 +112,17 @@ function spawners_mobs.add_flame_effects(pos)
return minetest.add_particlespawner({ return minetest.add_particlespawner({
amount = 6, amount = 6,
time = 0, time = 0,
minpos = vector.subtract({x=pos.x-0.001, y=pos.y-0.001, z=pos.z-0.001}, 0.5), minpos = vector.subtract({ x = pos.x - 0.001, y = pos.y - 0.001, z = pos.z - 0.001 }, 0.5),
maxpos = vector.add({x=pos.x+0.001, y=pos.y+0.001, z=pos.z+0.001}, 0.5), maxpos = vector.add({ x = pos.x + 0.001, y = pos.y + 0.001, z = pos.z + 0.001 }, 0.5),
minvel = {x=-0.1, y=-0.1, z=-0.1}, minvel = { x = -0.1, y = -0.1, z = -0.1 },
maxvel = {x=0.1, y=0.1, z=0.1}, maxvel = { x = 0.1, y = 0.1, z = 0.1 },
minacc = vector.new(), minacc = vector.new(),
maxacc = vector.new(), maxacc = vector.new(),
minexptime = 1, minexptime = 1,
maxexptime = 5, maxexptime = 5,
minsize = .5, minsize = 0.5,
maxsize = 2.5, maxsize = 2.5,
texture = "spawners_mobs_flame_particle_2.png", texture = 'spawners_mobs_flame_particle_2.png',
}) })
end end
@ -110,17 +132,17 @@ function spawners_mobs.add_smoke_effects(pos)
return minetest.add_particlespawner({ return minetest.add_particlespawner({
amount = 1, amount = 1,
time = 0, time = 0,
minpos = vector.subtract({x=pos.x-0.001, y=pos.y-0.001, z=pos.z-0.001}, 0.5), minpos = vector.subtract({ x = pos.x - 0.001, y = pos.y - 0.001, z = pos.z - 0.001 }, 0.5),
maxpos = vector.add({x=pos.x+0.001, y=pos.y+0.001, z=pos.z+0.001}, 0.5), maxpos = vector.add({ x = pos.x + 0.001, y = pos.y + 0.001, z = pos.z + 0.001 }, 0.5),
minvel = {x=-0.5, y=0.5, z=-0.5}, minvel = { x = -0.5, y = 0.5, z = -0.5 },
maxvel = {x=0.5, y=1.5, z=0.5}, maxvel = { x = 0.5, y = 1.5, z = 0.5 },
minacc = vector.new({x=-0.1, y=0.1, z=-0.1}), minacc = vector.new({ x = -0.1, y = 0.1, z = -0.1 }),
maxacc = vector.new({x=0.1, y=0.3, z=0.1}), maxacc = vector.new({ x = 0.1, y = 0.3, z = 0.1 }),
minexptime = .5, minexptime = 0.5,
maxexptime = 2, maxexptime = 2,
minsize = .5, minsize = 0.5,
maxsize = 2, maxsize = 2,
texture = "spawners_mobs_smoke_particle.png^[transform"..math.random(0,3), texture = 'spawners_mobs_smoke_particle.png^[transform' .. math.random(0, 3),
}) })
end end
@ -130,23 +152,24 @@ end
-- how often node timers for spawners will tick, +/- some random value -- how often node timers for spawners will tick, +/- some random value
function spawners_mobs.tick(pos) function spawners_mobs.tick(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local tick_counter = meta:get_int("tick") local tick_counter = meta:get_int('tick')
local owner = meta:get_string("owner") local owner = meta:get_string('owner')
local privs = minetest.get_player_privs(owner); local privs = minetest.get_player_privs(owner);
-- not for admin -- not for admin
if not privs.privs then if not privs.privs then
tick_counter = tick_counter + 1 tick_counter = tick_counter + 1
meta:set_int("tick", tick_counter) meta:set_int('tick', tick_counter)
end end
-- print("tick_counter: "..tick_counter.." at "..minetest.pos_to_string(pos)) -- print('tick_counter: ' .. tick_counter .. ' at ' .. minetest.pos_to_string(pos))
-- rusty spawner -- rusty spawner
if tick_counter >= tick_max then if tick_counter >= tick_max then
spawners_mobs.set_status(pos, "rusty") spawners_mobs.set_status(pos, 'rusty')
return return
end end
minetest.get_node_timer(pos):start(math.random(72, 193)) minetest.get_node_timer(pos):start(math.random(72, 193))
-- minetest.get_node_timer(pos):start(math.random(20, 30)) -- minetest.get_node_timer(pos):start(math.random(20, 30))
end end
@ -154,15 +177,15 @@ end
-- how often a spawn failure tick is retried (e.g. too dark) -- how often a spawn failure tick is retried (e.g. too dark)
function spawners_mobs.tick_short(pos) function spawners_mobs.tick_short(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local tick_short_counter = meta:get_int("tick_short") local tick_short_counter = meta:get_int('tick_short')
if tick_short_counter >= tick_short_max then if tick_short_counter >= tick_short_max then
spawners_mobs.tick(pos) spawners_mobs.tick(pos)
return return
else else
tick_short_counter = tick_short_counter + 1 tick_short_counter = tick_short_counter + 1
meta:set_int("tick_short", tick_short_counter) meta:set_int('tick_short', tick_short_counter)
-- print("tick_short_counter: "..tick_short_counter.." at "..minetest.pos_to_string(pos)) -- print('tick_short_counter: ' .. tick_short_counter .. ' at ' .. minetest.pos_to_string(pos))
end end
minetest.get_node_timer(pos):start(math.random(20, 60)) minetest.get_node_timer(pos):start(math.random(20, 60))
-- minetest.get_node_timer(pos):start(math.random(10, 20)) -- minetest.get_node_timer(pos):start(math.random(10, 20))
@ -173,18 +196,20 @@ end
-- --
-- start spawning mobs -- start spawning mobs
function spawners_mobs.start_spawning(spawn_area_random_pos, mob_name, mod_prefix, sound_custom) function spawners_mobs.start_spawning(spawn_area_random_pos, mob_name, mod_prefix, sound_custom)
if not (spawn_area_random_pos or how_many or mob_name) then return end if not (spawn_area_random_pos or mob_name) then
return
end
local sound_name = mod_prefix.."_"..mob_name local sound_name = mod_prefix .. '_' .. mob_name
-- use custom sounds -- use custom sounds
if sound_custom ~= "" then if sound_custom ~= '' then
sound_name = sound_custom sound_name = sound_custom
end end
-- use random colors for sheeps -- use random colors for sheeps
if mob_name == "sheep_white" then if mob_name == 'sheep_white' then
local sheep_colors = {"black", "blue", "brown", "cyan", "dark_green", "dark_grey", "green", "grey", "magenta", "orange", "pink", "red", "violet", "white", "yellow"} local sheep_colors = { 'black', 'blue', 'brown', 'cyan', 'dark_green', 'dark_grey', 'green', 'grey', 'magenta', 'orange', 'pink', 'red', 'violet', 'white', 'yellow' }
mob_name = "sheep_"..sheep_colors[math.random(#sheep_colors)] mob_name = 'sheep_' .. sheep_colors[math.random(#sheep_colors)]
end end
for i = 1, #spawn_area_random_pos do for i = 1, #spawn_area_random_pos do
@ -194,8 +219,8 @@ function spawners_mobs.start_spawning(spawn_area_random_pos, mob_name, mod_prefi
spawners_mobs.cloud_booom(spawn_area_random_pos[i]) spawners_mobs.cloud_booom(spawn_area_random_pos[i])
minetest.after(1, function() minetest.after(1, function()
-- minetest.set_node(spawn_area_random_pos[i], {name = "default:apple"}) -- minetest.set_node(spawn_area_random_pos[i], {name = 'default:apple' })
local obj = minetest.add_entity(spawn_area_random_pos[i], mod_prefix..":"..mob_name) local obj = minetest.add_entity(spawn_area_random_pos[i], mod_prefix .. ':' .. mob_name)
if obj then if obj then
if sound_name then if sound_name then
minetest.sound_play(sound_name, { minetest.sound_play(sound_name, {
@ -211,7 +236,7 @@ end
function spawners_mobs.on_timer(pos, elapsed) function spawners_mobs.on_timer(pos, elapsed)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local idx = meta:get_int("idx") or nil local idx = meta:get_int('idx') or nil
local mob_table = spawners_mobs.mob_tables[idx] or false local mob_table = spawners_mobs.mob_tables[idx] or false
if not mob_table then return end if not mob_table then return end
@ -223,7 +248,7 @@ function spawners_mobs.on_timer(pos, elapsed)
local entities_max = 6 local entities_max = 6
local node_light_min = 13 local node_light_min = 13
local owner = meta:get_string("owner") or "" local owner = meta:get_string('owner') or ''
local mod_prefix = mob_table.mod_prefix local mod_prefix = mob_table.mod_prefix
local mob_name = mob_table.name local mob_name = mob_table.name
local sound_custom = mob_table.sound_custom local sound_custom = mob_table.sound_custom
@ -235,34 +260,34 @@ function spawners_mobs.on_timer(pos, elapsed)
-- dark -- dark
if (not node_light or node_light < node_light_min) and not night_only then if (not node_light or node_light < node_light_min) and not night_only then
-- print("Too dark for mob ( "..mob_name.." ) to spawn. Waiting for day...") -- print('Too dark for mob ( ' .. mob_name .. ' ) to spawn. Waiting for day .. .')
spawners_mobs.set_status(pos, "waiting") spawners_mobs.set_status(pos, 'waiting')
-- set infotext -- set infotext
meta:set_string("infotext", mob_name.." spawner\nowner: "..owner.."\nToo dark for mob to spawn. Waiting for day...") meta:set_string('infotext', mob_name .. ' spawner\nowner: ' .. owner .. '\nToo dark for mob to spawn. Waiting for day .. .')
spawners_mobs.tick_short(pos) spawners_mobs.tick_short(pos)
return return
-- light
elseif node_light >= node_light_min and night_only then elseif node_light >= node_light_min and night_only then
-- print("Too much light for mob ( "..mob_name.." ) to spawn. Waiting for night...") -- light
spawners_mobs.set_status(pos, "waiting") -- print('Too much light for mob ( ' .. mob_name .. ' ) to spawn. Waiting for night .. .')
spawners_mobs.set_status(pos, 'waiting')
-- set infotext -- set infotext
meta:set_string("infotext", mob_name.." spawner\nowner: "..owner.."\nToo much light for mob to spawn. Waiting for night...") meta:set_string('infotext', mob_name .. ' spawner\nowner: ' .. owner .. '\nToo much light for mob to spawn. Waiting for night .. .')
spawners_mobs.tick_short(pos) spawners_mobs.tick_short(pos)
return return
end end
-- positions where mobs can spawn -- positions where mobs can spawn
local spawn_area_pos = minetest.find_nodes_in_area(posmin, posmax, "air") local spawn_area_pos = minetest.find_nodes_in_area(posmin, posmax, 'air')
-- check if there is enough place to spawn mob -- check if there is enough place to spawn mob
if #spawn_area_pos < 1 then if #spawn_area_pos < 1 then
spawners_mobs.set_status(pos, "waiting") spawners_mobs.set_status(pos, 'waiting')
-- set infotext -- set infotext
meta:set_string("infotext", mob_name.." spawner\nowner: "..owner.."\nNot enough place to spawn mob. Find more space!") meta:set_string('infotext', mob_name .. ' spawner\nowner: ' .. owner .. '\nNot enough place to spawn mob. Find more space!')
spawners_mobs.tick(pos) spawners_mobs.tick(pos)
return return
end end
@ -278,12 +303,12 @@ function spawners_mobs.on_timer(pos, elapsed)
local random_pos = spawn_area_pos[math.random(#spawn_area_pos)] local random_pos = spawn_area_pos[math.random(#spawn_area_pos)]
local random_pos_above = minetest.get_node({ x = random_pos.x, y = random_pos.y + 1, z = random_pos.z }).name local random_pos_above = minetest.get_node({ x = random_pos.x, y = random_pos.y + 1, z = random_pos.z }).name
if random_pos_above == "air" and not minetest.is_protected(random_pos, owner) then if random_pos_above == 'air' and not minetest.is_protected(random_pos, owner) then
table.insert(spawn_area_random_pos, random_pos) table.insert(spawn_area_random_pos, random_pos)
-- print("spawn_area_random_pos: "..#spawn_area_random_pos) -- print('spawn_area_random_pos: ' .. #spawn_area_random_pos)
else else
table.remove(spawn_area_pos, i) table.remove(spawn_area_pos, i)
-- print("spawn_area_pos: "..#spawn_area_pos) -- print('spawn_area_pos: ' .. #spawn_area_pos)
end end
end end
@ -293,10 +318,10 @@ function spawners_mobs.on_timer(pos, elapsed)
-- check if there is still enough place to spawn mob -- check if there is still enough place to spawn mob
if #spawn_area_random_pos < 1 then if #spawn_area_random_pos < 1 then
spawners_mobs.set_status(pos, "waiting") spawners_mobs.set_status(pos, 'waiting')
-- set infotext -- set infotext
meta:set_string("infotext", mob_name.." spawner\nowner: "..owner.."\nNot enough place to spawn mob. Searching for new location...") meta:set_string('infotext', mob_name .. ' spawner\nowner: ' .. owner .. '\nNot enough place to spawn mob. Searching for new location .. .')
spawners_mobs.tick_short(pos) spawners_mobs.tick_short(pos)
return return
end end
@ -306,10 +331,10 @@ function spawners_mobs.on_timer(pos, elapsed)
-- prevent object clutter on the map -- prevent object clutter on the map
if #activation_area > max_objects then if #activation_area > max_objects then
spawners_mobs.set_status(pos, "waiting") spawners_mobs.set_status(pos, 'waiting')
-- set infotext -- set infotext
meta:set_string("infotext", mob_name.." spawner\nowner: "..owner.."\nToo many objects in the area ("..#activation_area.."/"..max_objects.."), clean-up dropped objects first!") meta:set_string('infotext', mob_name .. ' spawner\nowner: ' .. owner .. '\nToo many objects in the area (' .. #activation_area .. '/' .. max_objects .. '), clean-up dropped objects first!')
spawners_mobs.tick_short(pos) spawners_mobs.tick_short(pos)
return return
end end
@ -318,48 +343,49 @@ function spawners_mobs.on_timer(pos, elapsed)
-- find player inside activation area -- find player inside activation area
if object:is_player() then if object:is_player() then
player_near = true player_near = true
-- print("found player: "..object:get_player_name()) -- print('found player: ' .. object:get_player_name())
end end
-- find entities inside activation area -- find entities inside activation area
if not object:is_player() and if not object:is_player()
object:get_luaentity() and and object:get_luaentity()
object:get_luaentity().name ~= "__builtin:item" then and object:get_luaentity().name ~= '__builtin:item'
local tmp_mob_name = string.split(object:get_luaentity().name, ":")[2] then
local tmp_mob_name = string.split(object:get_luaentity().name, ':')[2]
if tmp_mob_name ~= nil then if tmp_mob_name ~= nil then
-- sheeps have colors in names -- sheeps have colors in names
if string.find(tmp_mob_name, "sheep") and string.find(mob_name, "sheep") and not string.find(tmp_mob_name, "dummy") then if string.find(tmp_mob_name, 'sheep') and string.find(mob_name, 'sheep') and not string.find(tmp_mob_name, 'dummy') then
-- print("found entity: "..tmp_mob_name) -- print('found entity: ' .. tmp_mob_name)
entities_near = entities_near + 1 entities_near = entities_near + 1
elseif tmp_mob_name == mob_name then elseif tmp_mob_name == mob_name then
-- print("found entity: "..tmp_mob_name) -- print('found entity: ' .. tmp_mob_name)
entities_near = entities_near + 1 entities_near = entities_near + 1
end end
else else
minetest.log("warning", "[spawners_mobs] tmp_mob_name was nil, luaentity name was: "..object:get_luaentity().name.." at: "..minetest.pos_to_string(object:get_pos())) minetest.log('warning', '[spawners_mobs] tmp_mob_name was nil, luaentity name was: ' .. object:get_luaentity().name .. ' at: ' .. minetest.pos_to_string(object:get_pos()))
end end
end end
-- stop looping when met all conditions -- stop looping when met all conditions
if entities_near >= entities_max and player_near then if entities_near >= entities_max and player_near then
-- print("max entities reached "..entities_max.." and player_near found, breaking..") -- print('max entities reached ' .. entities_max .. ' and player_near found, breaking .. ')
break break
end end
end end
-- don't do anything and try again later when player not near or max entities reached -- don't do anything and try again later when player not near or max entities reached
if entities_near >= entities_max or not player_near then if entities_near >= entities_max or not player_near then
spawners_mobs.set_status(pos, "waiting") spawners_mobs.set_status(pos, 'waiting')
-- sheeps have color in the name -- sheeps have color in the name
local name = mob_name -- local name = mob_name
if string.find(mob_name, "sheep") then -- if string.find(mob_name, 'sheep') then
name = "sheep" -- name = 'sheep'
end -- end
meta:set_string("infotext", mob_name.." spawner\nowner: "..owner.."\nmax mobs reached: "..entities_near.."/"..entities_max) -- or player not near meta:set_string('infotext', mob_name .. ' spawner\nowner: ' .. owner .. '\nmax mobs reached: ' .. entities_near .. '/' .. entities_max) -- or player not near
spawners_mobs.tick_short(pos) spawners_mobs.tick_short(pos)
return return
end end
@ -367,11 +393,11 @@ function spawners_mobs.on_timer(pos, elapsed)
-- start spawning -- start spawning
spawners_mobs.start_spawning(spawn_area_random_pos, mob_name, mod_prefix, sound_custom) spawners_mobs.start_spawning(spawn_area_random_pos, mob_name, mod_prefix, sound_custom)
spawners_mobs.set_status(pos, "active") spawners_mobs.set_status(pos, 'active')
meta:set_string("infotext", mob_name.." spawner\nowner: "..owner.."\nspawner is active reached: "..entities_near.."/"..entities_max) meta:set_string('infotext', mob_name .. ' spawner\nowner: ' .. owner .. '\nspawner is active reached: ' .. entities_near .. '/' .. entities_max)
meta:set_int("tick", 0) meta:set_int('tick', 0)
meta:set_int("tick_short", 0) meta:set_int('tick_short', 0)
spawners_mobs.tick(pos) spawners_mobs.tick(pos)
end end
@ -381,7 +407,7 @@ end
-- --
function spawners_mobs.set_status(pos, set_status) function spawners_mobs.set_status(pos, set_status)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local idx = meta:get_int("idx") local idx = meta:get_int('idx')
local mob_table = spawners_mobs.mob_tables[idx] or false local mob_table = spawners_mobs.mob_tables[idx] or false
if not mob_table then return end if not mob_table then return end
@ -391,102 +417,101 @@ function spawners_mobs.set_status(pos, set_status)
local offset = mob_table.dummy_offset local offset = mob_table.dummy_offset
-- get meta -- get meta
local owner = meta:get_string("owner") local owner = meta:get_string('owner')
local meta_status = meta:get_string("status") local meta_status = meta:get_string('status')
local id_flame = meta:get_int("id_flame") local id_flame = meta:get_int('id_flame')
local id_smoke = meta:get_int("id_smoke") local id_smoke = meta:get_int('id_smoke')
-- --
-- active -- active
-- --
if set_status == "active" then if set_status == 'active' then
-- remove particles and add them again - keeps particles after server restart -- remove particles and add them again - keeps particles after server restart
-- delete particles -- delete particles
if id_flame ~= -1 and id_smoke ~= -1 then if id_flame ~= -1 and id_smoke ~= -1 then
-- print("#1 delete id_flame: "..id_flame.." at "..minetest.pos_to_string(pos)) -- print('#1 delete id_flame: ' .. id_flame .. ' at ' .. minetest.pos_to_string(pos))
-- print("#1 delete id_smoke: "..id_smoke.." at "..minetest.pos_to_string(pos)) -- print('#1 delete id_smoke: ' .. id_smoke .. ' at ' .. minetest.pos_to_string(pos))
minetest.delete_particlespawner(id_flame) minetest.delete_particlespawner(id_flame)
minetest.delete_particlespawner(id_smoke) minetest.delete_particlespawner(id_smoke)
meta:set_int("id_flame", -1) meta:set_int('id_flame', -1)
meta:set_int("id_smoke", -1) meta:set_int('id_smoke', -1)
end end
-- add particles -- add particles
id_flame = spawners_mobs.add_flame_effects(pos) id_flame = spawners_mobs.add_flame_effects(pos)
id_smoke = spawners_mobs.add_smoke_effects(pos) id_smoke = spawners_mobs.add_smoke_effects(pos)
meta:set_int("id_flame", id_flame) meta:set_int('id_flame', id_flame)
meta:set_int("id_smoke", id_smoke) meta:set_int('id_smoke', id_smoke)
-- print("#1 add id_flame: "..id_flame.." at "..minetest.pos_to_string(pos)) -- print('#1 add id_flame: ' .. id_flame .. ' at ' .. minetest.pos_to_string(pos))
-- print("#1 add id_smoke: "..id_smoke.." at "..minetest.pos_to_string(pos)) -- print('#1 add id_smoke: ' .. id_smoke .. ' at ' .. minetest.pos_to_string(pos))
if meta_status ~= set_status then if meta_status ~= set_status then
-- add dummy entity -- add dummy entity
minetest.add_entity({ x = pos.x, y = pos.y + offset, z = pos.z },"spawners_mobs:dummy_"..mod_prefix.."_"..mob_name) minetest.add_entity({ x = pos.x, y = pos.y + offset, z = pos.z },'spawners_mobs:dummy_' .. mod_prefix .. '_' .. mob_name)
meta:set_string("status", "active") meta:set_string('status', 'active')
minetest.swap_node(pos, {name="spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner"}) minetest.swap_node(pos, { name = 'spawners_mobs:' .. mod_prefix .. '_' .. mob_name .. '_spawner' })
end end
elseif set_status == 'waiting' and meta_status ~= set_status then
-- --
-- waiting -- waiting
-- --
elseif set_status == "waiting" and meta_status ~= set_status then
-- delete particles -- delete particles
if id_flame ~= -1 and id_smoke ~= -1 then if id_flame ~= -1 and id_smoke ~= -1 then
-- print("#2 delete id_flame: "..id_flame.." at "..minetest.pos_to_string(pos)) -- print('#2 delete id_flame: ' .. id_flame .. ' at ' .. minetest.pos_to_string(pos))
-- print("#2 delete id_smoke: "..id_smoke.." at "..minetest.pos_to_string(pos)) -- print('#2 delete id_smoke: ' .. id_smoke .. ' at ' .. minetest.pos_to_string(pos))
minetest.delete_particlespawner(id_flame) minetest.delete_particlespawner(id_flame)
minetest.delete_particlespawner(id_smoke) minetest.delete_particlespawner(id_smoke)
meta:set_int("id_flame", -1) meta:set_int('id_flame', -1)
meta:set_int("id_smoke", -1) meta:set_int('id_smoke', -1)
end end
-- remove dummy -- remove dummy
local objs = minetest.get_objects_inside_radius(pos, 0.5) local objs = minetest.get_objects_inside_radius(pos, 0.5)
if objs then if objs then
for _, obj in ipairs(objs) do for _, obj in ipairs(objs) do
if obj and obj:get_luaentity() and obj:get_luaentity().name == "spawners_mobs:dummy_"..mod_prefix.."_"..mob_name then if obj and obj:get_luaentity() and obj:get_luaentity().name == 'spawners_mobs:dummy_' .. mod_prefix .. '_' .. mob_name then
obj:remove() obj:remove()
end end
end end
end end
meta:set_string("status", "waiting") meta:set_string('status', 'waiting')
minetest.swap_node(pos, {name="spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_waiting"})
minetest.swap_node(pos, { name = 'spawners_mobs:' .. mod_prefix .. '_' .. mob_name .. '_spawner_waiting' })
elseif set_status == 'rusty' and meta_status ~= set_status then
-- --
-- rusty -- rusty
-- --
elseif set_status == "rusty" and meta_status ~= set_status then
-- delete particles -- delete particles
if id_flame ~= -1 and id_smoke ~= -1 then if id_flame ~= -1 and id_smoke ~= -1 then
-- print("#3 delete id_flame: "..id_flame.." at "..minetest.pos_to_string(pos)) -- print('#3 delete id_flame: ' .. id_flame .. ' at ' .. minetest.pos_to_string(pos))
-- print("#3 delete id_smoke: "..id_smoke.." at "..minetest.pos_to_string(pos)) -- print('#3 delete id_smoke: ' .. id_smoke .. ' at ' .. minetest.pos_to_string(pos))
minetest.delete_particlespawner(id_flame) minetest.delete_particlespawner(id_flame)
minetest.delete_particlespawner(id_smoke) minetest.delete_particlespawner(id_smoke)
meta:set_int("id_flame", -1) meta:set_int('id_flame', -1)
meta:set_int("id_smoke", -1) meta:set_int('id_smoke', -1)
end end
-- remove dummy -- remove dummy
local objs = minetest.get_objects_inside_radius(pos, 0.5) local objs = minetest.get_objects_inside_radius(pos, 0.5)
if objs then if objs then
for _, obj in ipairs(objs) do for _, obj in ipairs(objs) do
if obj and obj:get_luaentity() and obj:get_luaentity().name == "spawners_mobs:dummy_"..mod_prefix.."_"..mob_name then if obj and obj:get_luaentity() and obj:get_luaentity().name == 'spawners_mobs:dummy_' .. mod_prefix .. '_' .. mob_name then
obj:remove() obj:remove()
end end
end end
end end
meta:set_string("status", "rusty") meta:set_string('status', 'rusty')
minetest.swap_node(pos, {name="spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_rusty"}) minetest.swap_node(pos, { name = 'spawners_mobs:' .. mod_prefix .. '_' .. mob_name .. '_spawner_rusty' })
-- set infotext -- set infotext
meta:set_string("infotext", mob_name.." spawner\nowner: "..owner.."\nSpawner was searching for too long and got rusted! Dig up the spawner and place it again.") meta:set_string('infotext', mob_name .. ' spawner\nowner: ' .. owner .. '\nSpawner was searching for too long and got rusted! Dig up the spawner and place it again.')
return return
end end
end end

View File

@ -1,3 +1,21 @@
--[[
Let the player craft Mob Spawners. Mobs are spawning randomly in a short intervals, giving the option of creating mob farms and grinders.
Copyright (C) 2016 - 2023 SaKeL <juraj.vajda@gmail.com>
This library is free software; you can redistribute it and/or
modify it pos the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to juraj.vajda@gmail.com
--]]
-- * [name : string] - Name of the mob used in the mod. -- * [name : string] - Name of the mob used in the mod.
-- [egg_name_custom : string] - Custom name for the egg item. If empty default name will be used i.e. 'mobs:chicken'. -- [egg_name_custom : string] - Custom name for the egg item. If empty default name will be used i.e. 'mobs:chicken'.
@ -10,172 +28,170 @@
-- * [dummy_texture : table] - Textures used for the mob. -- * [dummy_texture : table] - Textures used for the mob.
-- * [night_only : boolean : string] - If true mobs will spawn only during the night or in dark areas, default:true. Writing "disable" will disable light check and it will spawn in both states (night and day) -- * [night_only : boolean : string] - If true mobs will spawn only during the night or in dark areas, default:true. Writing 'disable' will disable light check and it will spawn in both states (night and day)
-- [sound_custom : string] - Custom name for the sound file name if differ from default: i.e 'mobs_cow'. -- [sound_custom : string] - Custom name for the sound file name if differ from default: i.e 'mobs_cow'.
-- [*] -> MANDATORY - has to be filled in! -- [*] -> MANDATORY - has to be filled in!
-- mods what should be enabled and loded, remove/add the one you want to load -- mods what should be enabled and loded, remove/add the one you want to load
ENABLED_MODS = {"mobs", "creatures"} spawners_mobs.ENABLED_MODS = { 'mobs', 'creatures' }
-- mobs properties - setup all you mobs here -- mobs properties - setup all you mobs here
MOBS_PROPS = { spawners_mobs.MOBS_PROPS = {
['mobs'] = { -- MOBS REDO CONFIG
["mobs"] = { -- MOBS REDO CONFIG
{ {
name="sheep_white", name = 'sheep_white',
egg_name_custom="", egg_name_custom = '',
dummy_size={x=0.52,y=0.52}, dummy_size = { x = 0.52, y = 0.52 },
dummy_offset=0.2, dummy_offset = 0.2,
dummy_mesh="mobs_sheep.b3d", dummy_mesh = 'mobs_sheep.b3d',
dummy_texture={"mobs_sheep_wool.png^mobs_sheep_base.png"}, dummy_texture = { 'mobs_sheep_wool.png^mobs_sheep_base.png' },
night_only=false, night_only = false,
sound_custom="mobs_sheep" sound_custom = 'mobs_sheep'
}, },
{ {
name="cow", name = 'cow',
egg_name_custom="", egg_name_custom = '',
dummy_size={x=0.3,y=0.3}, dummy_size = { x = 0.3, y = 0.3 },
dummy_offset=-0.3, dummy_offset = -0.3,
dummy_mesh="mobs_cow.x", dummy_mesh = 'mobs_cow.x',
dummy_texture={"mobs_cow.png"}, dummy_texture={ 'mobs_cow.png' },
night_only=false, night_only = false,
sound_custom="" sound_custom = ''
}, },
{ {
name="chicken", name = 'chicken',
egg_name_custom="", egg_name_custom = '',
dummy_size={x=0.9,y=0.9}, dummy_size = { x = 0.9, y = 0.9 },
dummy_offset=0.2, dummy_offset = 0.2,
dummy_mesh="mobs_chicken.x", dummy_mesh = 'mobs_chicken.x',
dummy_texture={"mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png"}, dummy_texture = { 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png' },
night_only=false, night_only = false,
sound_custom="" sound_custom = ''
}, },
{ {
name="pumba", name = 'pumba',
egg_name_custom="", egg_name_custom = '',
dummy_size={x=0.62,y=0.62}, dummy_size = { x = 0.62, y = 0.62 },
dummy_offset=-0.3, dummy_offset = 0.3,
dummy_mesh="mobs_pumba.x", dummy_mesh = 'mobs_pumba.x',
dummy_texture={"mobs_pumba.png"}, dummy_texture = { 'mobs_pumba.png' },
night_only=false, night_only = false,
sound_custom="mobs_pig" sound_custom = 'mobs_pig'
}, },
{ {
name="bunny", name = 'bunny',
egg_name_custom="", egg_name_custom = '',
dummy_size={x=1,y=1}, dummy_size = { x = 1, y = 1 },
dummy_offset=0.2, dummy_offset = 0.2,
dummy_mesh="mobs_bunny.b3d", dummy_mesh = 'mobs_bunny.b3d',
dummy_texture={"mobs_bunny_brown.png"}, dummy_texture = { 'mobs_bunny_brown.png' },
night_only=false, night_only = false,
sound_custom="spawners_mobs_bunny" sound_custom = 'spawners_mobs_bunny'
}, },
{ {
name="kitten", name = 'kitten',
egg_name_custom="", egg_name_custom = '',
dummy_size={x=0.32,y=0.32}, dummy_size = { x = 0.32, y = 0.32 },
dummy_offset=0, dummy_offset = 0,
dummy_mesh="mobs_kitten.b3d", dummy_mesh = 'mobs_kitten.b3d',
dummy_texture={"mobs_kitten_ginger.png"}, dummy_texture = { 'mobs_kitten_ginger.png' },
night_only=false, night_only = false,
sound_custom="" sound_custom = ''
}, },
{ {
name="spider", name = 'spider',
egg_name_custom="", egg_name_custom = '',
dummy_size={x=2,y=2}, dummy_size = { x = 2, y = 2 },
dummy_offset=-0.2, dummy_offset = -0.2,
dummy_mesh="mobs_spider.x", dummy_mesh = 'mobs_spider.x',
dummy_texture={"mobs_spider.png"}, dummy_texture = { 'mobs_spider.png' },
night_only="disable", night_only = 'disable',
sound_custom="", sound_custom = '',
env=true env = true
}, },
{ {
name="stone_monster", name = 'stone_monster',
egg_name_custom="", egg_name_custom = '',
dummy_size={x=0.5,y=0.5}, dummy_size = { x = 0.5, y = 0.5 },
dummy_offset=0.05, dummy_offset = 0.05,
dummy_mesh="mobs_stone_monster.b3d", dummy_mesh = 'mobs_stone_monster.b3d',
dummy_texture={"mobs_stone_monster.png"}, dummy_texture = { 'mobs_stone_monster.png' },
night_only=true, night_only = true,
sound_custom="mobs_stonemonster" sound_custom = 'mobs_stonemonster'
}, },
{ {
name="oerkki", name = 'oerkki',
egg_name_custom="", egg_name_custom = '',
dummy_size={x=0.5,y=0.5}, dummy_size = { x = 0.5, y = 0.5 },
dummy_offset=0.05, dummy_offset = 0.05,
dummy_mesh="mobs_oerkki.b3d", dummy_mesh = 'mobs_oerkki.b3d',
dummy_texture={"mobs_oerkki.png"}, dummy_texture = { 'mobs_oerkki.png' },
night_only=true, night_only = true,
sound_custom="" sound_custom = ''
}, },
{ {
name="tree_monster", name = 'tree_monster',
egg_name_custom="", egg_name_custom = '',
dummy_size={x=0.4,y=0.4}, dummy_size = { x = 0.4, y = 0.4} ,
dummy_offset=0.05, dummy_offset = 0.05,
dummy_mesh="mobs_tree_monster.b3d", dummy_mesh = 'mobs_tree_monster.b3d',
dummy_texture={"mobs_tree_monster.png"}, dummy_texture = { 'mobs_tree_monster.png' },
night_only=true, night_only = true,
sound_custom="mobs_treemonster" sound_custom = 'mobs_treemonster'
} }
}, },
['creatures'] = { -- CREATURES MOD CONFIG
["creatures"] = { -- CREATURES MOD CONFIG
{ {
name="chicken", name = 'chicken',
egg_name_custom="creatures:chicken_spawn_egg", egg_name_custom = 'creatures:chicken_spawn_egg',
dummy_size={x=0.9,y=0.9}, dummy_size = { x = 0.9, y = 0.9 },
dummy_offset=-0.3, dummy_offset = -0.3,
dummy_mesh="creatures_chicken.b3d", dummy_mesh = 'creatures_chicken.b3d',
dummy_texture={"creatures_chicken.png"}, dummy_texture = { 'creatures_chicken.png' },
night_only=false, night_only = false,
sound_custom="" sound_custom = ''
}, },
{ {
name="ghost", name = 'ghost',
egg_name_custom="creatures:ghost_spawn_egg", egg_name_custom = 'creatures:ghost_spawn_egg',
dummy_size={x=0.7,y=0.7}, dummy_size = { x = 0.7, y = 0.7 },
dummy_offset=-0.5, dummy_offset = -0.5,
dummy_mesh="creatures_ghost.b3d", dummy_mesh = 'creatures_ghost.b3d',
dummy_texture={"creatures_ghost.png"}, dummy_texture = { 'creatures_ghost.png' },
night_only=true, night_only = true,
sound_custom="" sound_custom = ''
}, },
{ {
name="sheep", name = 'sheep',
egg_name_custom="creatures:sheep_spawn_egg", egg_name_custom = 'creatures:sheep_spawn_egg',
dummy_size={x=0.6,y=0.6}, dummy_size = { x = 0.6, y = 0.6 },
dummy_offset=-0.3, dummy_offset = -0.3,
dummy_mesh="creatures_sheep.b3d", dummy_mesh = 'creatures_sheep.b3d',
dummy_texture={"creatures_sheep.png^creatures_sheep_white.png"}, dummy_texture = { 'creatures_sheep.png^creatures_sheep_white.png' },
night_only=false, night_only = false,
sound_custom="" sound_custom = ''
}, },
{ {
name="zombie", name = 'zombie',
egg_name_custom="creatures:zombie_spawn_egg", egg_name_custom = 'creatures:zombie_spawn_egg',
dummy_size={x=0.5,y=0.5}, dummy_size = { x = 0.5, y = 0.5 },
dummy_offset=-0.5, dummy_offset = -0.5,
dummy_mesh="creatures_zombie.b3d", dummy_mesh = 'creatures_zombie.b3d',
dummy_texture={"creatures_zombie.png"}, dummy_texture = { 'creatures_zombie.png' },
night_only=false, night_only = false,
sound_custom="" sound_custom = ''
}, },
{ {
name="oerrki", name = 'oerrki',
egg_name_custom="creatures:oerrki_spawn_egg", egg_name_custom = 'creatures:oerrki_spawn_egg',
dummy_size={x=0.4,y=0.4}, dummy_size = { x = 0.4, y = 0.4 },
dummy_offset=-0.5, dummy_offset = -0.5,
dummy_mesh="creatures_oerrki.b3d", dummy_mesh = 'creatures_oerrki.b3d',
dummy_texture={"creatures_oerrki.png"}, dummy_texture = { 'creatures_oerrki.png' },
night_only=false, night_only = false,
sound_custom="creatures_oerrki_idle" sound_custom = 'creatures_oerrki_idle'
} }
} }
} }
@ -185,42 +201,42 @@ MOBS_PROPS = {
-- --
-- include mummy mobs redo addon (spawner) -- include mummy mobs redo addon (spawner)
if minetest.get_modpath("mobs") ~= nil then if minetest.get_modpath('mobs') ~= nil then
-- enable spawner -- enable spawner
table.insert(ENABLED_MODS, "spawners_mobs") table.insert(spawners_mobs.ENABLED_MODS, 'spawners_mobs')
-- configure spawner -- configure spawner
MOBS_PROPS["spawners_mobs"] = { spawners_mobs.MOBS_PROPS['spawners_mobs'] = {
{ {
name="mummy", name = 'mummy',
egg_name_custom="", egg_name_custom = '',
dummy_size={x=0.4,y=0.4}, dummy_size = { x = 0.4, y = 0.4 },
dummy_offset=0, dummy_offset = 0,
dummy_mesh="spawners_mobs_mummy.b3d", dummy_mesh = 'spawners_mobs_mummy.b3d',
dummy_texture={"spawners_mobs_mummy.png"}, dummy_texture = { 'spawners_mobs_mummy.png' },
night_only=true, night_only = true,
sound_custom="spawners_mobs_mummy" sound_custom = 'spawners_mobs_mummy'
}, },
{ {
name="bunny_evil", name = 'bunny_evil',
egg_name_custom="", egg_name_custom = '',
dummy_size={x=1,y=1}, dummy_size = { x = 1, y = 1 },
dummy_offset=0.2, dummy_offset = 0.2,
dummy_mesh="spawners_mobs_evil_bunny.b3d", dummy_mesh = 'spawners_mobs_evil_bunny.b3d',
dummy_texture={"spawners_mobs_evil_bunny.png"}, dummy_texture = { 'spawners_mobs_evil_bunny.png' },
night_only=true, night_only = true,
sound_custom="spawners_mobs_bunny" sound_custom = 'spawners_mobs_bunny'
}, },
{ {
name="uruk_hai", name = 'uruk_hai',
egg_name_custom="", egg_name_custom = '',
dummy_size={x=0.5,y=0.5}, dummy_size = { x = 0.5, y = 0.5 },
dummy_offset=0, dummy_offset = 0,
dummy_mesh="spawners_mobs_character.b3d", dummy_mesh = 'spawners_mobs_character.b3d',
dummy_texture={"spawners_mobs_uruk_hai.png", "spawners_mobs_trans.png","spawners_mobs_galvornsword.png", "spawners_mobs_trans.png"}, dummy_texture = { 'spawners_mobs_uruk_hai.png', 'spawners_mobs_trans.png','spawners_mobs_galvornsword.png', 'spawners_mobs_trans.png' },
night_only="disable", night_only = 'disable',
sound_custom="spawners_mobs_barbarian_yell2", sound_custom = 'spawners_mobs_barbarian_yell2',
env=true env = true
} }
} }
end end

View File

@ -1,3 +1,21 @@
--[[
Let the player craft Mob Spawners. Mobs are spawning randomly in a short intervals, giving the option of creating mob farms and grinders.
Copyright (C) 2016 - 2023 SaKeL <juraj.vajda@gmail.com>
This library is free software; you can redistribute it and/or
modify it pos the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to juraj.vajda@gmail.com
--]]
-- * [name : string] - Name of the mob used in the mod. -- * [name : string] - Name of the mob used in the mod.
-- [egg_name_custom : string] - Custom name for the egg item. If empty default name will be used i.e. 'mobs:chicken'. -- [egg_name_custom : string] - Custom name for the egg item. If empty default name will be used i.e. 'mobs:chicken'.
@ -10,173 +28,172 @@
-- * [dummy_texture : table] - Textures used for the mob. -- * [dummy_texture : table] - Textures used for the mob.
-- * [night_only : boolean : string] - If true mobs will spawn "only" during the night or in dark areas, default:true. Writing "disable" will disable light check and it will spawn in both states (night and day) -- * [night_only : boolean : string] - If true mobs will spawn 'only' during the night or in dark areas, default:true. Writing 'disable' will disable light check and it will spawn in both states (night and day)
-- [sound_custom : string] - Custom name for the sound file name if differ from default: i.e 'mobs_cow'. -- [sound_custom : string] - Custom name for the sound file name if differ from default: i.e 'mobs_cow'.
-- [*] -> MANDATORY - has to be filled in! -- [*] -> MANDATORY - has to be filled in!
-- mods what should be enabled and loded, remove/add the one you want to load -- mods what should be enabled and loded, remove/add the one you want to load
ENABLED_MODS = {"mobs", "creatures"} spawners_mobs.ENABLED_MODS = { 'mobs', 'creatures' }
-- mobs properties - setup all you mobs here -- mobs properties - setup all you mobs here
MOBS_PROPS = { spawners_mobs.MOBS_PROPS = {
["mobs"] = { -- MOBS REDO CONFIG ['mobs'] = { -- MOBS REDO CONFIG
{ {
name = "sheep_white", name = 'sheep_white',
egg_name_custom = "", egg_name_custom = '',
dummy_size = {x = 0.52, y = 0.52}, dummy_size = { x = 0.52, y = 0.52 },
dummy_offset = 0.2, dummy_offset = 0.2,
dummy_mesh = "mobs_sheep.b3d", dummy_mesh = 'mobs_sheep.b3d',
dummy_texture = {"mobs_sheep_wool.png^mobs_sheep_base.png"}, dummy_texture = { 'mobs_sheep_wool.png^mobs_sheep_base.png' },
night_only = false, night_only = false,
sound_custom = "mobs_sheep" sound_custom = 'mobs_sheep'
}, },
{ {
name = "cow", name = 'cow',
egg_name_custom = "", egg_name_custom = '',
dummy_size = {x = 0.3, y = 0.3}, dummy_size = { x = 0.3, y = 0.3 },
dummy_offset = -0.3, dummy_offset = -0.3,
dummy_mesh = "mobs_cow.x", dummy_mesh = 'mobs_cow.x',
dummy_texture = {"mobs_cow.png"}, dummy_texture = { 'mobs_cow.png' },
night_only = false, night_only = false,
sound_custom = "" sound_custom = ''
}, },
{ {
name = "chicken", name = 'chicken',
egg_name_custom = "", egg_name_custom = '',
dummy_size = {x = 0.9, y = 0.9}, dummy_size = { x = 0.9, y = 0.9 },
dummy_offset = 0.2, dummy_offset = 0.2,
dummy_mesh = "mobs_chicken.x", dummy_mesh = 'mobs_chicken.x',
dummy_texture = {"mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png"}, dummy_texture = { 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png' },
night_only = false, night_only = false,
sound_custom = "mobs_chicken" sound_custom = 'mobs_chicken'
}, },
{ {
name = "pumba", name = 'pumba',
egg_name_custom = "", egg_name_custom = '',
dummy_size = {x = 0.62, y = 0.62}, dummy_size = { x = 0.62, y = 0.62 },
dummy_offset = -0.3, dummy_offset = -0.3,
dummy_mesh = "mobs_pumba.x", dummy_mesh = 'mobs_pumba.x',
dummy_texture = {"mobs_pumba.png"}, dummy_texture = { 'mobs_pumba.png' },
night_only = false, night_only = false,
sound_custom = "mobs_pig" sound_custom = 'mobs_pig'
}, },
-- { -- {
-- name = "bunny", -- name = 'bunny',
-- egg_name_custom = "", -- egg_name_custom = '',
-- dummy_size = {x = 1, y = 1}, -- dummy_size = { x = 1, y = 1},
-- dummy_offset = 0.2, -- dummy_offset = 0.2,
-- dummy_mesh = "mobs_bunny.b3d", -- dummy_mesh = 'mobs_bunny.b3d',
-- dummy_texture = {"mobs_bunny_brown.png"}, -- dummy_texture = { 'mobs_bunny_brown.png' },
-- night_only = false, -- night_only = false,
-- sound_custom = "spawners_mobs_bunny" -- sound_custom = 'spawners_mobs_bunny'
-- }, -- },
-- { -- {
-- name = "kitten", -- name = 'kitten',
-- egg_name_custom = "", -- egg_name_custom = '',
-- dummy_size = {x = 0.32, y = 0.32}, -- dummy_size = { x = 0.32, y = 0.32},
-- dummy_offset = 0, -- dummy_offset = 0,
-- dummy_mesh = "mobs_kitten.b3d", -- dummy_mesh = 'mobs_kitten.b3d',
-- dummy_texture = {"mobs_kitten_ginger.png"}, -- dummy_texture = { 'mobs_kitten_ginger.png' },
-- night_only = false, -- night_only = false,
-- sound_custom = "" -- sound_custom = ''
-- }, -- },
{ {
name = "spider", name = 'spider',
egg_name_custom = "", egg_name_custom = '',
dummy_size = {x = 2, y = 2}, dummy_size = { x = 2, y = 2 },
dummy_offset = -0.2, dummy_offset = -0.2,
dummy_mesh = "mobs_spider.x", dummy_mesh = 'mobs_spider.x',
dummy_texture = {"mobs_spider.png"}, dummy_texture = { 'mobs_spider.png' },
night_only = true, night_only = true,
sound_custom = "",
env = true, env = true,
sound_custom = "mobs_spider_neutral" sound_custom = 'mobs_spider_neutral'
}, },
{ {
name = "stone_monster", name = 'stone_monster',
egg_name_custom = "", egg_name_custom = '',
dummy_size = {x = 0.5, y = 0.5}, dummy_size = { x = 0.5, y = 0.5 },
dummy_offset = 0.05, dummy_offset = 0.05,
dummy_mesh = "mobs_stone_monster.b3d", dummy_mesh = 'mobs_stone_monster.b3d',
dummy_texture = {"mobs_stone_monster.png"}, dummy_texture = { 'mobs_stone_monster.png' },
night_only = true, night_only = true,
sound_custom = "mobs_stonemonster_neutral" sound_custom = 'mobs_stonemonster_neutral'
}, },
{ {
name = "oerkki", name = 'oerkki',
egg_name_custom = "", egg_name_custom = '',
dummy_size = {x = 0.5, y = 0.5}, dummy_size = { x = 0.5, y = 0.5 },
dummy_offset = 0.05, dummy_offset = 0.05,
dummy_mesh = "mobs_oerkki.b3d", dummy_mesh = 'mobs_oerkki.b3d',
dummy_texture = {"mobs_oerkki.png"}, dummy_texture = { 'mobs_oerkki.png' },
night_only = true, night_only = true,
sound_custom = "" sound_custom = ''
}, },
{ {
name = "tree_monster", name = 'tree_monster',
egg_name_custom = "", egg_name_custom = '',
dummy_size = {x = 0.4, y = 0.4}, dummy_size = { x = 0.4, y = 0.4 },
dummy_offset = 0.05, dummy_offset = 0.05,
dummy_mesh = "mobs_tree_monster.b3d", dummy_mesh = 'mobs_tree_monster.b3d',
dummy_texture = {"mobs_tree_monster.png"}, dummy_texture = { 'mobs_tree_monster.png' },
night_only = true, night_only = true,
sound_custom = "mobs_treemonster_neutral" sound_custom = 'mobs_treemonster_neutral'
} }
}, },
["creatures"] = { -- CREATURES MOD CONFIG ['creatures'] = { -- CREATURES MOD CONFIG
{ {
name = "chicken", name = 'chicken',
egg_name_custom = "creatures:chicken_spawn_egg", egg_name_custom = 'creatures:chicken_spawn_egg',
dummy_size = {x = 0.9, y = 0.9}, dummy_size = { x = 0.9, y = 0.9 },
dummy_offset = -0.3, dummy_offset = -0.3,
dummy_mesh = "creatures_chicken.b3d", dummy_mesh = 'creatures_chicken.b3d',
dummy_texture = {"creatures_chicken.png"}, dummy_texture = { 'creatures_chicken.png' },
night_only = false, night_only = false,
sound_custom = "" sound_custom = ''
}, },
{ {
name = "ghost", name = 'ghost',
egg_name_custom = "creatures:ghost_spawn_egg", egg_name_custom = 'creatures:ghost_spawn_egg',
dummy_size = {x = 0.7, y = 0.7}, dummy_size = { x = 0.7, y = 0.7 },
dummy_offset = -0.5, dummy_offset = -0.5,
dummy_mesh = "creatures_ghost.b3d", dummy_mesh = 'creatures_ghost.b3d',
dummy_texture = {"creatures_ghost.png"}, dummy_texture = { 'creatures_ghost.png' },
night_only = true, night_only = true,
sound_custom = "" sound_custom = ''
}, },
{ {
name = "sheep", name = 'sheep',
egg_name_custom = "creatures:sheep_spawn_egg", egg_name_custom = 'creatures:sheep_spawn_egg',
dummy_size = {x = 0.6, y = 0.6}, dummy_size = { x = 0.6, y = 0.6 },
dummy_offset = -0.3, dummy_offset = -0.3,
dummy_mesh = "creatures_sheep.b3d", dummy_mesh = 'creatures_sheep.b3d',
dummy_texture = {"creatures_sheep.png^creatures_sheep_white.png"}, dummy_texture = { 'creatures_sheep.png^creatures_sheep_white.png' },
night_only = false, night_only = false,
sound_custom = "" sound_custom = ''
}, },
{ {
name = "zombie", name = 'zombie',
egg_name_custom = "creatures:zombie_spawn_egg", egg_name_custom = 'creatures:zombie_spawn_egg',
dummy_size = {x = 0.5, y = 0.5}, dummy_size = { x = 0.5, y = 0.5 },
dummy_offset = -0.5, dummy_offset = -0.5,
dummy_mesh = "creatures_zombie.b3d", dummy_mesh = 'creatures_zombie.b3d',
dummy_texture = {"creatures_zombie.png"}, dummy_texture = { 'creatures_zombie.png' },
night_only = false, night_only = false,
sound_custom = "" sound_custom = ''
}, },
{ {
name = "oerrki", name = 'oerrki',
egg_name_custom = "creatures:oerrki_spawn_egg", egg_name_custom = 'creatures:oerrki_spawn_egg',
dummy_size = {x = 0.4, y = 0.4}, dummy_size = { x = 0.4, y = 0.4 },
dummy_offset = -0.5, dummy_offset = -0.5,
dummy_mesh = "creatures_oerrki.b3d", dummy_mesh = 'creatures_oerrki.b3d',
dummy_texture = {"creatures_oerrki.png"}, dummy_texture = { 'creatures_oerrki.png' },
night_only = false, night_only = false,
sound_custom = "creatures_oerrki_idle" sound_custom = 'creatures_oerrki_idle'
} }
} }
} }
@ -186,52 +203,52 @@ MOBS_PROPS = {
-- --
-- include mummy mobs redo addon (spawner) -- include mummy mobs redo addon (spawner)
if minetest.get_modpath("mobs") ~= nil then if minetest.get_modpath('mobs') ~= nil then
-- enable spawner -- enable spawner
table.insert(ENABLED_MODS, "spawners_mobs") table.insert(spawners_mobs.ENABLED_MODS, 'spawners_mobs')
-- configure spawner -- configure spawner
MOBS_PROPS["spawners_mobs"] = { spawners_mobs.MOBS_PROPS['spawners_mobs'] = {
{ {
name = "mummy", name = 'mummy',
egg_name_custom = "", egg_name_custom = '',
dummy_size = {x = 0.4, y = 0.4}, dummy_size = { x = 0.4, y = 0.4 },
dummy_offset = 0, dummy_offset = 0,
dummy_mesh = "spawners_mobs_mummy.b3d", dummy_mesh = 'spawners_mobs_mummy.b3d',
dummy_texture = {"spawners_mobs_mummy.png"}, dummy_texture = { 'spawners_mobs_mummy.png' },
night_only = true, night_only = true,
sound_custom = "spawners_mobs_mummy_neutral" sound_custom = 'spawners_mobs_mummy_neutral'
}, },
{ {
name = "bunny_evil", name = 'bunny_evil',
egg_name_custom = "", egg_name_custom = '',
dummy_size = {x = 1, y = 1}, dummy_size = { x = 1, y = 1 },
dummy_offset = 0.2, dummy_offset = 0.2,
dummy_mesh = "spawners_mobs_evil_bunny.b3d", dummy_mesh = 'spawners_mobs_evil_bunny.b3d',
dummy_texture = {"spawners_mobs_evil_bunny.png"}, dummy_texture = { 'spawners_mobs_evil_bunny.png' },
night_only = true, night_only = true,
sound_custom = "spawners_mobs_bunny" sound_custom = 'spawners_mobs_bunny'
}, },
{ {
name = "uruk_hai", name = 'uruk_hai',
egg_name_custom = "", egg_name_custom = '',
dummy_size = {x = 0.5, y = 0.5}, dummy_size = { x = 0.5, y = 0.5 },
dummy_offset = 0, dummy_offset = 0,
dummy_mesh = "spawners_mobs_character.b3d", dummy_mesh = 'spawners_mobs_character.b3d',
dummy_texture = {"spawners_mobs_uruk_hai.png", "spawners_mobs_trans.png","spawners_mobs_galvornsword.png", "spawners_mobs_trans.png"}, dummy_texture = { 'spawners_mobs_uruk_hai.png', 'spawners_mobs_trans.png','spawners_mobs_galvornsword.png', 'spawners_mobs_trans.png' },
night_only = true, night_only = true,
sound_custom = "spawners_mobs_uruk_hai_neutral", sound_custom = 'spawners_mobs_uruk_hai_neutral',
env = true env = true
}, },
{ {
name = "balrog", name = 'balrog',
egg_name_custom = "", egg_name_custom = '',
dummy_size = {x = 0.2, y = 0.2}, dummy_size = { x = 0.2, y = 0.2 },
dummy_offset = 0, dummy_offset = 0,
dummy_mesh = "spawners_mobs_balrog.b3d", dummy_mesh = 'spawners_mobs_balrog.b3d',
dummy_texture = {"spawners_mobs_balrog.png"}, dummy_texture = { 'spawners_mobs_balrog.png' },
night_only = "disable", night_only = 'disable',
sound_custom = "spawners_mobs_balrog_neutral", sound_custom = 'spawners_mobs_balrog_neutral',
env = true, env = true,
boss = true boss = true
} }

View File

@ -1,7 +0,0 @@
default
x_default?
xpanes?
fire?
mobs?
creatures?
bones?

View File

@ -1 +0,0 @@
This MOD for Minetest let the player craft Mob Spawners. Mobs are spawning randomly in a short intervals. This MOD is giving the option of creating mob farms and grinders.

View File

@ -1,21 +1,42 @@
MOD_NAME = minetest.get_current_modname() --[[
Let the player craft Mob Spawners. Mobs are spawning randomly in a short intervals, giving the option of creating mob farms and grinders.
Copyright (C) 2016 - 2023 SaKeL <juraj.vajda@gmail.com>
-- Spawners configurations This library is free software; you can redistribute it and/or
dofile(minetest.get_modpath(MOD_NAME).."/config.lua") modify it pos the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to juraj.vajda@gmail.com
--]]
local mod_start_time = minetest.get_us_time()
local path = minetest.get_modpath('spawners_mobs')
-- API -- API
dofile(minetest.get_modpath(MOD_NAME).."/api.lua") dofile(path .. '/api.lua')
-- Spawners configurations
dofile(path .. '/config.lua')
-- Spawners for mobs -- Spawners for mobs
dofile(minetest.get_modpath(MOD_NAME).."/spawners_mobs.lua") dofile(path .. '/spawners_mobs.lua')
-- include mummy mobs redo addon (mob) -- include mummy mobs redo addon (mob)
if minetest.get_modpath("mobs") then if minetest.get_modpath('mobs') then
dofile(minetest.get_modpath(MOD_NAME).."/mob_mummy.lua") dofile(path .. '/mob_mummy.lua')
dofile(minetest.get_modpath(MOD_NAME).."/mob_bunny_evil.lua") dofile(path .. '/mob_bunny_evil.lua')
dofile(minetest.get_modpath(MOD_NAME).."/mob_uruk_hai.lua") dofile(path .. '/mob_uruk_hai.lua')
dofile(minetest.get_modpath(MOD_NAME).."/mob_balrog.lua") dofile(path .. '/mob_balrog.lua')
dofile(minetest.get_modpath(MOD_NAME).."/nodes_additional.lua") dofile(path .. '/nodes_additional.lua')
end end
print ("[Mod] Spawners Mobs Loaded.") local mod_end_time = (minetest.get_us_time() - mod_start_time) / 1000000
print ('[Mod] Spawners Mobs Loaded. [' .. mod_end_time .. 's]')

View File

@ -1,37 +1,55 @@
--[[
Let the player craft Mob Spawners. Mobs are spawning randomly in a short intervals, giving the option of creating mob farms and grinders.
Copyright (C) 2016 - 2023 SaKeL <juraj.vajda@gmail.com>
This library is free software; you can redistribute it and/or
modify it pos the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to juraj.vajda@gmail.com
--]]
-- modified Sand Monster by PilzAdam with Mummy by BlockMen -- modified Sand Monster by PilzAdam with Mummy by BlockMen
local balrog_def = { local balrog_def = {
type = "monster", type = 'monster',
passive = false, passive = false,
rotate = 180, rotate = 180,
hp_min = 1000, hp_min = 1000,
hp_max = 1250, hp_max = 1250,
pathfinding = false, pathfinding = false,
attack_type = "dogshoot", attack_type = 'dogshoot',
shoot_interval = 0.6, shoot_interval = 0.6,
dogshoot_switch = 1, dogshoot_switch = 1,
dogshoot_count_max = 10, dogshoot_count_max = 10,
shoot_offset = 1, shoot_offset = 1,
arrow = "spawners_mobs:balrog_firebolt", arrow = 'spawners_mobs:balrog_firebolt',
reach = 5, reach = 5,
damage = 10, damage = 10,
armor = 100, armor = 100,
collisionbox = {-0.8, -2.1, -0.8, 0.8, 2.6, 0.8}, collisionbox = { -0.8, -2.1, -0.8, 0.8, 2.6, 0.8 },
visual_size = {x=2, y=2}, visual_size = { x = 2, y = 2 },
visual = "mesh", visual = 'mesh',
mesh = "spawners_mobs_balrog.b3d", mesh = 'spawners_mobs_balrog.b3d',
drawtype = "front", drawtype = 'front',
textures = { textures = {
{"spawners_mobs_balrog.png"}, { 'spawners_mobs_balrog.png' },
}, },
blood_texture = "fire_basic_flame.png", blood_texture = 'fire_basic_flame.png',
makes_footstep_sound = true, makes_footstep_sound = true,
sounds = { sounds = {
death = "spawners_mobs_balrog_death", death = 'spawners_mobs_balrog_death',
attack = "spawners_mobs_balrog_attack", attack = 'spawners_mobs_balrog_attack',
shoot_attack = "spawners_mobs_balrog_fireball", shoot_attack = 'spawners_mobs_balrog_fireball',
damage = "spawners_mobs_balrog_hit", damage = 'spawners_mobs_balrog_hit',
random = "spawners_mobs_balrog_neutral", random = 'spawners_mobs_balrog_neutral',
distance = 15 distance = 15
}, },
walk_velocity = 3, walk_velocity = 3,
@ -40,72 +58,72 @@ local balrog_def = {
jump = true, jump = true,
floats = 1, floats = 1,
drops = { drops = {
{name = "default:diamondblock", chance = 2, min = 1, max = 8}, { name = 'default:diamondblock', chance = 2, min = 1, max = 8 },
{name = "default:diamondblock", chance = 2, min = 1, max = 8}, { name = 'default:diamondblock', chance = 2, min = 1, max = 8 },
{name = "default:diamondblock", chance = 2, min = 1, max = 4}, { name = 'default:diamondblock', chance = 2, min = 1, max = 4 },
{name = "default:diamondblock", chance = 2, min = 1, max = 4}, { name = 'default:diamondblock', chance = 2, min = 1, max = 4 },
{name = "default:diamondblock", chance = 2, min = 1, max = 4}, { name = 'default:diamondblock', chance = 2, min = 1, max = 4 },
{name = "default:diamond", chance = 2, min = 1, max = 8}, { name = 'default:diamond', chance = 2, min = 1, max = 8 },
{name = "default:diamond", chance = 2, min = 1, max = 8}, { name = 'default:diamond', chance = 2, min = 1, max = 8 },
{name = "default:diamond", chance = 2, min = 1, max = 4}, { name = 'default:diamond', chance = 2, min = 1, max = 4 },
{name = "default:diamond", chance = 2, min = 1, max = 4}, { name = 'default:diamond', chance = 2, min = 1, max = 4 },
{name = "default:diamond", chance = 2, min = 1, max = 4}, { name = 'default:diamond', chance = 2, min = 1, max = 4 },
{name = "default:mese", chance = 2, min = 1, max = 4}, { name = 'default:mese', chance = 2, min = 1, max = 4 },
{name = "default:mese_crystal", chance = 2, min = 1, max = 4}, { name = 'default:mese_crystal', chance = 2, min = 1, max = 4 },
{name = "default:mese", chance = 2, min = 1, max = 4}, { name = 'default:mese', chance = 2, min = 1, max = 4 },
{name = "default:mese_crystal", chance = 2, min = 1, max = 4}, { name = 'default:mese_crystal', chance = 2, min = 1, max = 4 },
{name = "default:mese", chance = 2, min = 1, max = 4}, { name = 'default:mese', chance = 2, min = 1, max = 4 },
{name = "default:mese_crystal", chance = 2, min = 1, max = 4}, { name = 'default:mese_crystal', chance = 2, min = 1, max = 4 },
{name = "default:mese", chance = 2, min = 1, max = 4}, { name = 'default:mese', chance = 2, min = 1, max = 4 },
{name = "default:mese_crystal", chance = 2, min = 1, max = 4}, { name = 'default:mese_crystal', chance = 2, min = 1, max = 4 },
{name = "default:mese", chance = 2, min = 1, max = 4}, { name = 'default:mese', chance = 2, min = 1, max = 4 },
{name = "default:mese_crystal", chance = 2, min = 1, max = 4}, { name = 'default:mese_crystal', chance = 2, min = 1, max = 4 },
{name = "3d_armor:boots_diamond", chance = 2, min = 1, max = 4}, { name = '3d_armor:boots_diamond', chance = 2, min = 1, max = 4 },
{name = "3d_armor:chestplate_diamond", chance = 2, min = 1, max = 1}, { name = '3d_armor:chestplate_diamond', chance = 2, min = 1, max = 1 },
{name = "3d_armor:helmet_diamond", chance = 2, min = 1, max = 1}, { name = '3d_armor:helmet_diamond', chance = 2, min = 1, max = 1 },
{name = "3d_armor:leggings_diamond", chance = 2, min = 1, max = 1}, { name = '3d_armor:leggings_diamond', chance = 2, min = 1, max = 1 },
{name = "3d_armor:chestplate_bronze", chance = 2, min = 1, max = 1}, { name = '3d_armor:chestplate_bronze', chance = 2, min = 1, max = 1 },
{name = "3d_armor:helmet_bronze", chance = 2, min = 1, max = 1}, { name = '3d_armor:helmet_bronze', chance = 2, min = 1, max = 1 },
{name = "3d_armor:leggings_bronze", chance = 2, min = 1, max = 1}, { name = '3d_armor:leggings_bronze', chance = 2, min = 1, max = 1 },
{name = "3d_armor:chestplate_gold", chance = 2, min = 1, max = 1}, { name = '3d_armor:chestplate_gold', chance = 2, min = 1, max = 1 },
{name = "3d_armor:helmet_gold", chance = 2, min = 1, max = 1}, { name = '3d_armor:helmet_gold', chance = 2, min = 1, max = 1 },
{name = "3d_armor:leggings_gold", chance = 2, min = 1, max = 1}, { name = '3d_armor:leggings_gold', chance = 2, min = 1, max = 1 },
{name = "3d_armor:helmet_magma", chance = 10, min = 1, max = 1}, { name = '3d_armor:helmet_magma', chance = 10, min = 1, max = 1 },
{name = "3d_armor:chestplate_magma", chance = 10, min = 1, max = 1}, { name = '3d_armor:chestplate_magma', chance = 10, min = 1, max = 1 },
{name = "3d_armor:leggings_magma", chance = 10, min = 1, max = 1}, { name = '3d_armor:leggings_magma', chance = 10, min = 1, max = 1 },
{name = "3d_armor:boots_magma", chance = 10, min = 1, max = 1}, { name = '3d_armor:boots_magma', chance = 10, min = 1, max = 1 },
{name = "obsidianmese:pick", chance = 2, min = 1, max = 1}, { name = 'obsidianmese:pick', chance = 2, min = 1, max = 1 },
{name = "obsidianmese:sword", chance = 2, min = 1, max = 1}, { name = 'obsidianmese:sword', chance = 2, min = 1, max = 1 },
{name = "default:pick_diamond", chance = 2, min = 1, max = 1}, { name = 'default:pick_diamond', chance = 2, min = 1, max = 1 },
{name = "default:sword_diamond", chance = 2, min = 1, max = 1}, { name = 'default:sword_diamond', chance = 2, min = 1, max = 1 },
{name = "default:shovel_diamond", chance = 2, min = 1, max = 1}, { name = 'default:shovel_diamond', chance = 2, min = 1, max = 1 },
{name = "default:axe_diamond", chance = 2, min = 1, max = 1}, { name = 'default:axe_diamond', chance = 2, min = 1, max = 1 },
{name = "default:hoe_diamond", chance = 2, min = 1, max = 1}, { name = 'default:hoe_diamond', chance = 2, min = 1, max = 1 },
{name = "default:pick_mese", chance = 2, min = 1, max = 1}, { name = 'default:pick_mese', chance = 2, min = 1, max = 1 },
{name = "default:sword_mese", chance = 2, min = 1, max = 1}, { name = 'default:sword_mese', chance = 2, min = 1, max = 1 },
{name = "default:shovel_mese", chance = 2, min = 1, max = 1}, { name = 'default:shovel_mese', chance = 2, min = 1, max = 1 },
{name = "default:axe_mese", chance = 2, min = 1, max = 1}, { name = 'default:axe_mese', chance = 2, min = 1, max = 1 },
{name = "default:hoe_mese", chance = 2, min = 1, max = 1}, { name = 'default:hoe_mese', chance = 2, min = 1, max = 1 },
{name = "default:pick_bronze", chance = 2, min = 1, max = 1}, { name = 'default:pick_bronze', chance = 2, min = 1, max = 1 },
{name = "default:sword_bronze", chance = 2, min = 1, max = 1}, { name = 'default:sword_bronze', chance = 2, min = 1, max = 1 },
{name = "default:shovel_bronze", chance = 2, min = 1, max = 1}, { name = 'default:shovel_bronze', chance = 2, min = 1, max = 1 },
{name = "default:axe_bronze", chance = 2, min = 1, max = 1}, { name = 'default:axe_bronze', chance = 2, min = 1, max = 1 },
{name = "default:hoe_bronze", chance = 2, min = 1, max = 1}, { name = 'default:hoe_bronze', chance = 2, min = 1, max = 1 },
{name = "farming:bread", chance = 2, min = 1, max = 3}, { name = 'farming:bread', chance = 2, min = 1, max = 3 },
{name = "farming:bread", chance = 2, min = 1, max = 3}, { name = 'farming:bread', chance = 2, min = 1, max = 3 },
{name = "farming:bread", chance = 2, min = 1, max = 3}, { name = 'farming:bread', chance = 2, min = 1, max = 3 },
{name = "farming:bread", chance = 2, min = 1, max = 3}, { name = 'farming:bread', chance = 2, min = 1, max = 3 },
{name = "farming:bread", chance = 2, min = 1, max = 3}, { name = 'farming:bread', chance = 2, min = 1, max = 3 },
{name = "farming:bread", chance = 2, min = 1, max = 3}, { name = 'farming:bread', chance = 2, min = 1, max = 3 },
{name = "farming:bread", chance = 2, min = 1, max = 3}, { name = 'farming:bread', chance = 2, min = 1, max = 3 },
{name = "farming:bread", chance = 2, min = 1, max = 3}, { name = 'farming:bread', chance = 2, min = 1, max = 3 },
{name = "farming:bread", chance = 2, min = 1, max = 3}, { name = 'farming:bread', chance = 2, min = 1, max = 3 },
{name = "farming:bread", chance = 2, min = 1, max = 3}, { name = 'farming:bread', chance = 2, min = 1, max = 3 },
{name = "obsidianmese:mese_apple", chance = 2, min = 1, max = 3}, { name = 'obsidianmese:mese_apple', chance = 2, min = 1, max = 3 },
{name = "obsidianmese:mese_apple", chance = 2, min = 1, max = 3}, { name = 'obsidianmese:mese_apple', chance = 2, min = 1, max = 3 },
{name = "obsidianmese:mese_apple", chance = 2, min = 1, max = 3}, { name = 'obsidianmese:mese_apple', chance = 2, min = 1, max = 3 },
{name = "obsidianmese:mese_apple", chance = 2, min = 1, max = 3}, { name = 'obsidianmese:mese_apple', chance = 2, min = 1, max = 3 },
{name = "obsidianmese:mese_apple", chance = 2, min = 1, max = 3}, { name = 'obsidianmese:mese_apple', chance = 2, min = 1, max = 3 },
}, },
water_damage = 0, water_damage = 0,
lava_damage = 0, lava_damage = 0,
@ -142,13 +160,12 @@ local balrog_def = {
local activation_area = minetest.get_objects_inside_radius(mob_pos, 20) local activation_area = minetest.get_objects_inside_radius(mob_pos, 20)
for k, object in ipairs(activation_area) do for k, object in ipairs(activation_area) do
if object:is_player() then if object:is_player() then
local player_pos = object:get_pos() -- local player_pos = object:get_pos()
local player_hp = object:get_hp() -- local player_hp = object:get_hp()
-- is in MMO Arena & health check -- is in MMO Arena & health check
if minetest.global_exists('x_default') and x_default:isInMMOArena(player_pos) and player_hp > 0 then -- if minetest.global_exists('x_default') and x_default:isInMMOArena(player_pos) and player_hp > 0 then
-- play sound minetest.sound_play('spawners_mobs_teleport', {
minetest.sound_play("spawners_mobs_teleport", {
object = object, object = object,
gain = 1.0, gain = 1.0,
max_hear_distance = 20 max_hear_distance = 20
@ -156,7 +173,7 @@ local balrog_def = {
-- teleport player -- teleport player
object:set_pos(mob_pos) object:set_pos(mob_pos)
end -- end
end end
end end
@ -164,11 +181,11 @@ local balrog_def = {
end end
} }
mobs:register_mob("spawners_mobs:balrog", balrog_def) mobs:register_mob('spawners_mobs:balrog', balrog_def)
-- mobs:spawn({ -- mobs:spawn({
-- name = "spawners_mobs:balrog", -- name = 'spawners_mobs:balrog',
-- nodes = {"default:desert_sand", "default:desert_stone", "default:sand", "default:sandstone", "default:silver_sand"}, -- nodes = { 'default:desert_sand', 'default:desert_stone', 'default:sand', 'default:sandstone', 'default:silver_sand' },
-- min_light = 0, -- min_light = 0,
-- max_light = 20, -- max_light = 20,
-- chance = 2000, -- chance = 2000,
@ -176,13 +193,13 @@ mobs:register_mob("spawners_mobs:balrog", balrog_def)
-- day_toggle = false, -- day_toggle = false,
-- }) -- })
mobs:register_egg("spawners_mobs:balrog", "balrog", "default_coal_block.png", 1, true) mobs:register_egg('spawners_mobs:balrog', 'balrog', 'default_coal_block.png', 1, true)
-- shooting -- shooting
mobs:register_arrow("spawners_mobs:balrog_firebolt", { mobs:register_arrow('spawners_mobs:balrog_firebolt', {
visual = "sprite", visual = 'sprite',
visual_size = {x = 1, y = 1}, visual_size = {x = 1, y = 1},
textures = {"spawners_mobs_firebolt.png"}, textures = { 'spawners_mobs_firebolt.png' },
velocity = 15, velocity = 15,
-- direct hit, no fire... just plenty of pain -- direct hit, no fire... just plenty of pain
@ -201,6 +218,6 @@ mobs:register_arrow("spawners_mobs:balrog_firebolt", {
end, end,
hit_node = function(self, pos, node) hit_node = function(self, pos, node)
-- minetest.set_node({x=pos.x, y=pos.y+1, z=pos.z}, {name="default:lava_flowing"}) -- minetest.set_node({x=pos.x, y=pos.y+1, z=pos.z}, { name='default:lava_flowing' })
end end
}) })

View File

@ -1,9 +1,27 @@
--[[
Let the player craft Mob Spawners. Mobs are spawning randomly in a short intervals, giving the option of creating mob farms and grinders.
Copyright (C) 2016 - 2023 SaKeL <juraj.vajda@gmail.com>
This library is free software; you can redistribute it and/or
modify it pos the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to juraj.vajda@gmail.com
--]]
-- Evil Bunny by ExeterDad -- Evil Bunny by ExeterDad
local bunny_evil_def = { local bunny_evil_def = {
type = "monster", type = 'monster',
passive = false, passive = false,
attack_type = "dogfight", attack_type = 'dogfight',
group_attack = true, group_attack = true,
pathfinding = false, pathfinding = false,
reach = 3, reach = 3,
@ -11,15 +29,15 @@ local bunny_evil_def = {
hp_min = 35, hp_min = 35,
hp_max = 65, hp_max = 65,
armor = 100, armor = 100,
collisionbox = {-0.268, -0.5, -0.268, 0.268, 0.167, 0.268}, collisionbox = { -0.268, -0.5, -0.268, 0.268, 0.167, 0.268 },
visual = "mesh", visual = 'mesh',
mesh = "spawners_mobs_evil_bunny.b3d", mesh = 'spawners_mobs_evil_bunny.b3d',
rotate = 0, rotate = 0,
textures = { textures = {
{"spawners_mobs_evil_bunny.png"}, { 'spawners_mobs_evil_bunny.png' },
}, },
sounds = { sounds = {
random = "spawners_mobs_bunny", random = 'spawners_mobs_bunny',
}, },
makes_footstep_sound = false, makes_footstep_sound = false,
walk_velocity = 1.5, walk_velocity = 1.5,
@ -28,7 +46,7 @@ local bunny_evil_def = {
jump = true, jump = true,
floats = 1, floats = 1,
drops = { drops = {
{name = "mobs:meat_raw", chance = 5, min = 1, max = 1}, { name = 'mobs:meat_raw', chance = 5, min = 1, max = 1 },
}, },
water_damage = 5, water_damage = 5,
lava_damage = 10, lava_damage = 10,
@ -43,7 +61,7 @@ local bunny_evil_def = {
punch_start = 16, punch_start = 16,
punch_end = 24, punch_end = 24,
}, },
-- follow = {"mobs:lava_orb"}, -- follow = {'mobs:lava_orb'},
-- on_rightclick = function(self, clicker) -- on_rightclick = function(self, clicker)
-- if mobs:feed_tame(self, clicker, 3, true, true) then -- if mobs:feed_tame(self, clicker, 3, true, true) then
@ -54,11 +72,11 @@ local bunny_evil_def = {
-- end, -- end,
} }
mobs:register_mob("spawners_mobs:bunny_evil", bunny_evil_def) mobs:register_mob('spawners_mobs:bunny_evil', bunny_evil_def)
mobs:spawn({ mobs:spawn({
name = "spawners_mobs:bunny_evil", name = 'spawners_mobs:bunny_evil',
nodes = {"default:snowblock", "default:dirt_with_snow", "default:ice"}, nodes = { 'default:snowblock', 'default:dirt_with_snow', 'default:ice' },
chance = 7000, chance = 7000,
min_light = 0, min_light = 0,
max_light = 14, max_light = 14,
@ -66,4 +84,4 @@ mobs:spawn({
day_toggle = false, day_toggle = false,
}) })
mobs:register_egg("spawners_mobs:bunny_evil", "Evil Bunny", "spawners_mobs_evil_bunny_egg.png", 0) mobs:register_egg('spawners_mobs:bunny_evil', 'Evil Bunny', 'spawners_mobs_evil_bunny_egg.png', 0)

View File

@ -1,34 +1,52 @@
--[[
Let the player craft Mob Spawners. Mobs are spawning randomly in a short intervals, giving the option of creating mob farms and grinders.
Copyright (C) 2016 - 2023 SaKeL <juraj.vajda@gmail.com>
This library is free software; you can redistribute it and/or
modify it pos the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to juraj.vajda@gmail.com
--]]
-- modified Sand Monster by PilzAdam with Mummy by BlockMen -- modified Sand Monster by PilzAdam with Mummy by BlockMen
local mummy_def = { local mummy_def = {
type = "monster", type = 'monster',
passive = false, passive = false,
pathfinding = false, pathfinding = false,
attack_type = "dogshoot", attack_type = 'dogshoot',
-- owner_loyal = true, -- owner_loyal = true,
shoot_interval = 2, shoot_interval = 2,
dogshoot_switch = 1, dogshoot_switch = 1,
dogshoot_count_max = 10, dogshoot_count_max = 10,
arrow = "spawners_mobs:black_skull", arrow = 'spawners_mobs:black_skull',
shoot_offset = 2, shoot_offset = 2,
reach = 3, reach = 3,
damage = 5, damage = 5,
hp_min = 60, hp_min = 60,
hp_max = 120, hp_max = 120,
armor = 100, armor = 100,
collisionbox = {-0.4, -1, -0.4, 0.4, 0.8, 0.4}, collisionbox = { -0.4, -1, -0.4, 0.4, 0.8, 0.4 },
visual = "mesh", visual = 'mesh',
mesh = "spawners_mobs_mummy.b3d", mesh = 'spawners_mobs_mummy.b3d',
textures = { textures = {
{"spawners_mobs_mummy.png"}, { 'spawners_mobs_mummy.png' },
}, },
makes_footstep_sound = true, makes_footstep_sound = true,
sounds = { sounds = {
random = "spawners_mobs_mummy_neutral", random = 'spawners_mobs_mummy_neutral',
damage = "spawners_mobs_mummy_hit", damage = 'spawners_mobs_mummy_hit',
shoot_attack = "spawners_mobs_mummy_spell", shoot_attack = 'spawners_mobs_mummy_spell',
attack = "spawners_mobs_mummy_attack", attack = 'spawners_mobs_mummy_attack',
death = "spawners_mobs_mummy_death", death = 'spawners_mobs_mummy_death',
distance = 15 distance = 15
}, },
walk_velocity = .75, walk_velocity = .75,
@ -37,14 +55,14 @@ local mummy_def = {
jump = true, jump = true,
floats = 1, floats = 1,
drops = { drops = {
{name = "default:sandstonebrick", chance = 5, min = 1, max = 2}, {name = 'default:sandstonebrick', chance = 5, min = 1, max = 2 },
{name = "spawners_mobs:deco_stone_eye", chance = 25, min = 1, max = 1}, {name = 'spawners_mobs:deco_stone_eye', chance = 25, min = 1, max = 1 },
{name = "spawners_mobs:deco_stone_men", chance = 25, min = 1, max = 1}, {name = 'spawners_mobs:deco_stone_men', chance = 25, min = 1, max = 1 },
{name = "spawners_mobs:deco_stone_sun", chance = 25, min = 1, max = 1}, {name = 'spawners_mobs:deco_stone_sun', chance = 25, min = 1, max = 1 },
{name = "spawners_mobs:deco_stone_bird", chance = 25, min = 1, max = 1}, {name = 'spawners_mobs:deco_stone_bird', chance = 25, min = 1, max = 1 },
{name = "default:diamond", chance = 3, min = 1, max = 2}, {name = 'default:diamond', chance = 3, min = 1, max = 2 },
{name = "default:mese_crystal", chance = 3, min = 1, max = 2}, {name = 'default:mese_crystal', chance = 3, min = 1, max = 2 },
{name = "spawners_mobs:mummy", chance = 25, min = 1, max = 1}, {name = 'spawners_mobs:mummy', chance = 25, min = 1, max = 1 },
}, },
water_damage = 5, water_damage = 5,
lava_damage = 10, lava_damage = 10,
@ -62,9 +80,9 @@ local mummy_def = {
punch_start = 74, punch_start = 74,
punch_end = 105, punch_end = 105,
}, },
-- follow = {"spawners_mobs:deco_stone_eye","spawners_mobs:deco_stone_men","spawners_mobs:deco_stone_sun","spawners_mobs:deco_stone_bird"}, -- follow = { 'spawners_mobs:deco_stone_eye','spawners_mobs:deco_stone_men','spawners_mobs:deco_stone_sun','spawners_mobs:deco_stone_bird' },
on_die = function(self, pos) on_die = function(self, pos)
minetest.sound_play("spawners_mobs_mummy_death", { minetest.sound_play('spawners_mobs_mummy_death', {
object = self.object, object = self.object,
pos = pos, pos = pos,
max_hear_distance = 8 max_hear_distance = 8
@ -78,14 +96,14 @@ local mummy_def = {
end end
if not self._random_trigger then if not self._random_trigger then
self._random_trigger = math.random(5, 20) self._random_trigger = math.random(5, 15)
end end
self._timer = self._timer + dtime self._timer = self._timer + dtime
if self._timer > self._random_trigger then if self._timer > self._random_trigger then
self._timer = 0 self._timer = 0
self._random_trigger = math.random(5, 20) self._random_trigger = math.random(5, 15)
if not self.attack then if not self.attack then
return return
@ -104,7 +122,7 @@ local mummy_def = {
-- health check -- health check
if self.attack:get_hp() > 0 then if self.attack:get_hp() > 0 then
-- play sound -- play sound
minetest.sound_play("spawners_mobs_teleport", { minetest.sound_play('spawners_mobs_teleport', {
object = self.object, object = self.object,
gain = 1.0, gain = 1.0,
max_hear_distance = 20 max_hear_distance = 20
@ -114,7 +132,7 @@ local mummy_def = {
player_look_dir.y = 1 player_look_dir.y = 1
local to_pos = vector.add(player_pos, player_look_dir) local to_pos = vector.add(player_pos, player_look_dir)
-- teleport player -- teleport to player
self.object:set_pos(to_pos) self.object:set_pos(to_pos)
end end
end end
@ -131,11 +149,11 @@ local mummy_def = {
-- end, -- end,
} }
mobs:register_mob("spawners_mobs:mummy", mummy_def) mobs:register_mob('spawners_mobs:mummy', mummy_def)
mobs:spawn({ mobs:spawn({
name = "spawners_mobs:mummy", name = 'spawners_mobs:mummy',
nodes = {"default:desert_sand", "default:sand"}, nodes = { 'default:desert_sand', 'default:sand' },
chance = 7000, chance = 7000,
min_light = 0, min_light = 0,
max_light = 14, max_light = 14,
@ -143,16 +161,16 @@ mobs:spawn({
day_toggle = false, day_toggle = false,
}) })
mobs:register_egg("spawners_mobs:mummy", "Mummy Monster", "default_sandstone_brick.png", 1) mobs:register_egg('spawners_mobs:mummy', 'Mummy Monster', 'default_sandstone_brick.png', 1)
-- black skull shooting -- black skull shooting
mobs:register_arrow("spawners_mobs:black_skull", { mobs:register_arrow('spawners_mobs:black_skull', {
visual = "sprite", visual = 'sprite',
visual_size = {x = 1, y = 1}, visual_size = { x = 1, y = 1 },
textures = {"spawners_mobs_black_skull.png"}, textures = { 'spawners_mobs_black_skull.png' },
velocity = 7, velocity = 7,
tail = 1, tail = 1,
tail_texture = "spawners_mobs_black_skull.png", tail_texture = 'spawners_mobs_black_skull.png',
glow = 5, glow = 5,
-- tail_size = 10, -- tail_size = 10,
@ -160,14 +178,14 @@ mobs:register_arrow("spawners_mobs:black_skull", {
hit_player = function(self, player) hit_player = function(self, player)
player:punch(self.object, 1.0, { player:punch(self.object, 1.0, {
full_punch_interval = 1.0, full_punch_interval = 1.0,
damage_groups = {fleshy = 8}, damage_groups = { fleshy = 8 },
}, nil) }, nil)
end, end,
hit_mob = function(self, player) hit_mob = function(self, player)
player:punch(self.object, 1.0, { player:punch(self.object, 1.0, {
full_punch_interval = 1.0, full_punch_interval = 1.0,
damage_groups = {fleshy = 8}, damage_groups = { fleshy = 8 },
}, nil) }, nil)
end, end,

View File

@ -1,33 +1,51 @@
--[[
Let the player craft Mob Spawners. Mobs are spawning randomly in a short intervals, giving the option of creating mob farms and grinders.
Copyright (C) 2016 - 2023 SaKeL <juraj.vajda@gmail.com>
This library is free software; you can redistribute it and/or
modify it pos the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to juraj.vajda@gmail.com
--]]
-- uruk_hai -- uruk_hai
local uruk_hai_def = { local uruk_hai_def = {
type = "monster", type = 'monster',
docile_by_day = true, docile_by_day = true,
passive = false, passive = false,
hp_min = 40, hp_min = 40,
hp_max = 65, hp_max = 65,
pathfinding = false, pathfinding = false,
attack_type = "dogfight", attack_type = 'dogfight',
group_attack = true, group_attack = true,
reach = 3, reach = 3,
damage = 6, damage = 6,
armor = 100, armor = 100,
collisionbox = {-0.3,-1.0,-0.3, 0.3,0.8,0.3}, collisionbox = { -0.3, -1.0, -0.3, 0.3, 0.8, 0.3 },
visual = "mesh", visual = 'mesh',
mesh = "spawners_mobs_character.b3d", mesh = 'spawners_mobs_character.b3d',
drawtype = "front", drawtype = 'front',
textures = { textures = {
{"spawners_mobs_uruk_hai.png", "spawners_mobs_trans.png","spawners_mobs_galvornsword.png", "spawners_mobs_trans.png"}, { 'spawners_mobs_uruk_hai.png', 'spawners_mobs_trans.png','spawners_mobs_galvornsword.png', 'spawners_mobs_trans.png' },
{"spawners_mobs_uruk_hai_1.png", "spawners_mobs_trans.png","spawners_mobs_galvornsword.png", "spawners_mobs_trans.png"}, { 'spawners_mobs_uruk_hai_1.png', 'spawners_mobs_trans.png','spawners_mobs_galvornsword.png', 'spawners_mobs_trans.png' },
{"spawners_mobs_uruk_hai_2.png", "spawners_mobs_trans.png","spawners_mobs_galvornsword.png", "spawners_mobs_trans.png"}, { 'spawners_mobs_uruk_hai_2.png', 'spawners_mobs_trans.png','spawners_mobs_galvornsword.png', 'spawners_mobs_trans.png' },
{"spawners_mobs_uruk_hai_3.png", "spawners_mobs_trans.png","spawners_mobs_galvornsword.png", "spawners_mobs_trans.png"}, { 'spawners_mobs_uruk_hai_3.png', 'spawners_mobs_trans.png','spawners_mobs_galvornsword.png', 'spawners_mobs_trans.png' },
}, },
makes_footstep_sound = true, makes_footstep_sound = true,
sounds = { sounds = {
random = "spawners_mobs_uruk_hai_neutral", random = 'spawners_mobs_uruk_hai_neutral',
death = "spawners_mobs_uruk_hai_death", death = 'spawners_mobs_uruk_hai_death',
attack = "spawners_mobs_uruk_hai_attack", attack = 'spawners_mobs_uruk_hai_attack',
damage = "spawners_mobs_uruk_hai_hit", damage = 'spawners_mobs_uruk_hai_hit',
distance = 15 distance = 15
}, },
walk_velocity = 2, walk_velocity = 2,
@ -36,15 +54,15 @@ local uruk_hai_def = {
jump = true, jump = true,
floats = 1, floats = 1,
drops = { drops = {
{name = "default:apple", chance = 3, min = 1, max = 2}, {name = 'default:apple', chance = 3, min = 1, max = 2 },
{name = "default:wood", chance = 4, min = 1, max = 2}, {name = 'default:wood', chance = 4, min = 1, max = 2 },
{name = "default:stick", chance = 2, min = 1, max = 2}, {name = 'default:stick', chance = 2, min = 1, max = 2 },
{name = "default:torch", chance = 3, min = 1, max = 2}, {name = 'default:torch', chance = 3, min = 1, max = 2 },
{name = "default:sword_bronze", chance = 5, min = 1, max = 1}, {name = 'default:sword_bronze', chance = 5, min = 1, max = 1 },
{name = "default:sword_mese", chance = 6, min = 1, max = 1}, {name = 'default:sword_mese', chance = 6, min = 1, max = 1 },
{name = "obsidianmese:sword_engraved", chance = 20, min = 1, max = 1}, {name = 'obsidianmese:sword_engraved', chance = 20, min = 1, max = 1 },
{name = "bones:bones", chance = 5, min = 1, max = 1}, {name = 'bones:bones', chance = 5, min = 1, max = 1 },
{name = "spawners_mobs:uruk_hai", chance = 20, min = 1, max = 1}, {name = 'spawners_mobs:uruk_hai', chance = 20, min = 1, max = 1 },
}, },
water_damage = 5, water_damage = 5,
lava_damage = 10, lava_damage = 10,
@ -64,11 +82,11 @@ local uruk_hai_def = {
}, },
} }
mobs:register_mob("spawners_mobs:uruk_hai", uruk_hai_def) mobs:register_mob('spawners_mobs:uruk_hai', uruk_hai_def)
-- mobs:spawn({ -- mobs:spawn({
-- name = "spawners_mobs:uruk_hai", -- name = 'spawners_mobs:uruk_hai',
-- nodes = {"default:desert_sand", "default:desert_stone", "default:sand", "default:sandstone", "default:silver_sand"}, -- nodes = { 'default:desert_sand', 'default:desert_stone', 'default:sand', 'default:sandstone', 'default:silver_sand' },
-- min_light = 0, -- min_light = 0,
-- max_light = 20, -- max_light = 20,
-- chance = 2000, -- chance = 2000,
@ -76,4 +94,4 @@ mobs:register_mob("spawners_mobs:uruk_hai", uruk_hai_def)
-- day_toggle = false, -- day_toggle = false,
-- }) -- })
mobs:register_egg("spawners_mobs:uruk_hai", "uruk_hai", "spawners_mobs_uruk_hai_egg.png", 0, true) mobs:register_egg('spawners_mobs:uruk_hai', 'uruk_hai', 'spawners_mobs_uruk_hai_egg.png', 0, true)

View File

@ -1 +1,6 @@
name = spawners_mobs name = spawners_mobs
description = Let the player craft Mob Spawners. Mobs are spawning randomly in a short intervals, giving the option of creating mob farms and grinders.
depends = default
optional_depends = mobs, creatures, xpanes, fire, bones
supported_games =
min_minetest_version = 5.4

View File

@ -1,15 +1,33 @@
--[[
Let the player craft Mob Spawners. Mobs are spawning randomly in a short intervals, giving the option of creating mob farms and grinders.
Copyright (C) 2016 - 2023 SaKeL <juraj.vajda@gmail.com>
This library is free software; you can redistribute it and/or
modify it pos the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to juraj.vajda@gmail.com
--]]
-- --
-- Decorative Carved Sand Stones -- Decorative Carved Sand Stones
-- --
local img = {"eye", "men", "sun", "bird"} local img = { 'eye', 'men', 'sun', 'bird' }
for i=1, #img do for i = 1, #img do
minetest.register_node("spawners_mobs:deco_stone_"..img[i], { minetest.register_node('spawners_mobs:deco_stone_' .. img[i], {
description = "Sandstone with "..img[i], description = 'Sandstone with ' .. img[i],
tiles = {"spawners_mobs_sandstone_carved_"..img[i]..".png"}, tiles = { 'spawners_mobs_sandstone_carved_' .. img[i] .. '.png' },
is_ground_content = false, is_ground_content = false,
groups = {cracky = 2}, groups = { cracky = 2 },
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
}) })
end end

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,3 +1,21 @@
--[[
Let the player craft Mob Spawners. Mobs are spawning randomly in a short intervals, giving the option of creating mob farms and grinders.
Copyright (C) 2016 - 2023 SaKeL <juraj.vajda@gmail.com>
This library is free software; you can redistribute it and/or
modify it pos the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to juraj.vajda@gmail.com
--]]
-- --
-- CREATE ALL SPAWNERS NODES -- CREATE ALL SPAWNERS NODES
-- --
@ -11,11 +29,11 @@ function spawners_mobs.create(mob_table, idx)
-- --
-- DUMMY INSIDE THE SPAWNER -- DUMMY INSIDE THE SPAWNER
-- --
minetest.register_entity("spawners_mobs:dummy_"..mod_prefix.."_"..mob_name, { minetest.register_entity('spawners_mobs:dummy_' .. mod_prefix .. '_' .. mob_name, {
hp_max = 1, hp_max = 1,
visual = "mesh", visual = 'mesh',
visual_size = size, visual_size = size,
collisionbox = {0,0,0,0,0,0}, collisionbox = { 0, 0, 0, 0, 0, 0 },
mesh = mesh, mesh = mesh,
textures = texture, textures = texture,
physical = false, physical = false,
@ -24,26 +42,26 @@ function spawners_mobs.create(mob_table, idx)
static_save = false, static_save = false,
on_activate = function(self, staticdata, dtime_s) on_activate = function(self, staticdata, dtime_s)
self.object:set_velocity({x = 0, y = 0, z = 0}) self.object:set_velocity({ x = 0, y = 0, z = 0 })
self.object:set_acceleration({x = 0, y = 0, z = 0}) self.object:set_acceleration({ x = 0, y = 0, z = 0 })
self.object:set_armor_groups({immortal = 1}) self.object:set_armor_groups({ immortal = 1 })
end end
}) })
-- --
-- DEFAULT SPAWNER -- DEFAULT SPAWNER
-- --
minetest.register_node("spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner", { minetest.register_node('spawners_mobs:' .. mod_prefix .. '_' .. mob_name .. '_spawner', {
description = mod_prefix.."_"..mob_name.." spawner", description = mod_prefix .. '_' .. mob_name .. ' spawner',
paramtype = "light", paramtype = 'light',
paramtype2 = "glasslikeliquidlevel", paramtype2 = 'glasslikeliquidlevel',
drawtype = "glasslike_framed_optional", drawtype = 'glasslike_framed_optional',
walkable = true, walkable = true,
sounds = default.node_sound_metal_defaults(), sounds = default.node_sound_metal_defaults(),
sunlight_propagates = true, sunlight_propagates = true,
tiles = {"spawners_mobs_spawner_16.png"}, tiles = { 'spawners_mobs_spawner_16.png' },
is_ground_content = false, is_ground_content = false,
groups = {cracky=1,level=2}, groups = { cracky = 1, level = 2 },
stack_max = 1, stack_max = 1,
light_source = 6, light_source = 6,
@ -52,43 +70,43 @@ function spawners_mobs.create(mob_table, idx)
on_construct = function(pos) on_construct = function(pos)
-- set meta -- set meta
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_int("idx", idx) meta:set_int('idx', idx)
meta:set_int("tick", 0) meta:set_int('tick', 0)
meta:set_int("tick_short", 0) meta:set_int('tick_short', 0)
spawners_mobs.set_status(pos, "active") spawners_mobs.set_status(pos, 'active')
spawners_mobs.tick_short(pos) spawners_mobs.tick_short(pos)
end, end,
after_place_node = function(pos, placer, itemstack, pointed_thing) after_place_node = function(pos, placer, itemstack, pointed_thing)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name()) meta:set_string('owner', placer:get_player_name())
meta:set_string("infotext", mob_name.." spawner\nowner: "..placer:get_player_name().."\nspawner is active") meta:set_string('infotext', mob_name .. ' spawner\nowner: ' .. placer:get_player_name() .. '\nspawner is active')
end, end,
on_destruct = function(pos) on_destruct = function(pos)
-- delete particles and remove dummy -- delete particles and remove dummy
spawners_mobs.set_status(pos, "waiting") spawners_mobs.set_status(pos, 'waiting')
end end
}) })
-- --
-- WAITING SPAWNER -- WAITING SPAWNER
-- --
minetest.register_node("spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_waiting", { minetest.register_node('spawners_mobs:' .. mod_prefix .. '_' .. mob_name .. '_spawner_waiting', {
description = mod_prefix.."_"..mob_name.." spawner waiting", description = mod_prefix .. '_' .. mob_name .. ' spawner waiting',
paramtype = "light", paramtype = 'light',
paramtype2 = "glasslikeliquidlevel", paramtype2 = 'glasslikeliquidlevel',
drawtype = "glasslike_framed_optional", drawtype = 'glasslike_framed_optional',
sounds = default.node_sound_metal_defaults(), sounds = default.node_sound_metal_defaults(),
walkable = true, walkable = true,
sunlight_propagates = true, sunlight_propagates = true,
tiles = { tiles = {
{ {
name = "spawners_mobs_spawner_waiting_animated_16.png", name = 'spawners_mobs_spawner_waiting_animated_16.png',
animation = { animation = {
type = "vertical_frames", type = 'vertical_frames',
aspect_w = 16, aspect_w = 16,
aspect_h = 16, aspect_h = 16,
length = 2.0 length = 2.0
@ -96,9 +114,9 @@ function spawners_mobs.create(mob_table, idx)
} }
}, },
is_ground_content = false, is_ground_content = false,
groups = {cracky=1,level=2,not_in_creative_inventory=1}, groups = { cracky = 1, level = 2, not_in_creative_inventory = 1 },
light_source = 4, light_source = 4,
drop = "spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner", drop = 'spawners_mobs:' .. mod_prefix .. '_' .. mob_name .. '_spawner',
on_timer = spawners_mobs.on_timer on_timer = spawners_mobs.on_timer
}) })
@ -106,26 +124,26 @@ function spawners_mobs.create(mob_table, idx)
-- --
-- RUSTY SPAWNER -- RUSTY SPAWNER
-- --
minetest.register_node("spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_rusty", { minetest.register_node('spawners_mobs:' .. mod_prefix .. '_' .. mob_name .. '_spawner_rusty', {
description = mod_prefix.."_"..mob_name.." spawner rusty", description = mod_prefix .. '_' .. mob_name .. ' spawner rusty',
paramtype = "light", paramtype = 'light',
paramtype2 = "glasslikeliquidlevel", paramtype2 = 'glasslikeliquidlevel',
drawtype = "glasslike_framed_optional", drawtype = 'glasslike_framed_optional',
sounds = default.node_sound_metal_defaults(), sounds = default.node_sound_metal_defaults(),
walkable = true, walkable = true,
sunlight_propagates = true, sunlight_propagates = true,
tiles = {"spawners_mobs_spawner_rusty.png"}, tiles = { 'spawners_mobs_spawner_rusty.png' },
is_ground_content = false, is_ground_content = false,
groups = {cracky=1,level=2,not_in_creative_inventory=1}, groups = { cracky = 1, level = 2, not_in_creative_inventory = 1 },
drop = "spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner" drop = 'spawners_mobs:' .. mod_prefix .. '_' .. mob_name .. '_spawner'
}) })
-- --
-- replacement LBM for pre-nodetimer spawners -- replacement LBM for pre-nodetimer spawners
-- --
minetest.register_lbm({ minetest.register_lbm({
name = "spawners_mobs:start_nodetimer_"..mod_prefix.."_"..mob_name.."_spawner", name = 'spawners_mobs:start_nodetimer_' .. mod_prefix .. '_' .. mob_name .. '_spawner',
nodenames = "spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner", nodenames = 'spawners_mobs:' .. mod_prefix .. '_' .. mob_name .. '_spawner',
action = function(pos) action = function(pos)
spawners_mobs.tick_short(pos) spawners_mobs.tick_short(pos)
end, end,
@ -134,7 +152,7 @@ function spawners_mobs.create(mob_table, idx)
-- --
-- COMPATIBILITY -- COMPATIBILITY
-- --
minetest.register_alias("spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_active", "spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner") minetest.register_alias('spawners_mobs:' .. mod_prefix .. '_' .. mob_name .. '_spawner_active', 'spawners_mobs:' .. mod_prefix .. '_' .. mob_name .. '_spawner')
end end
-- --

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 B

After

Width:  |  Height:  |  Size: 214 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 753 B

After

Width:  |  Height:  |  Size: 739 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 B

After

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 185 B

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 194 B

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1020 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 327 B

After

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 358 B

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 369 B

After

Width:  |  Height:  |  Size: 363 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 322 B

After

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 B

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 364 B

After

Width:  |  Height:  |  Size: 363 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 201 B

After

Width:  |  Height:  |  Size: 196 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 241 B

After

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 752 B

After

Width:  |  Height:  |  Size: 736 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 B

After

Width:  |  Height:  |  Size: 82 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 766 B

After

Width:  |  Height:  |  Size: 757 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 448 B

After

Width:  |  Height:  |  Size: 423 B

487
spawners_ores/LICENSE.txt Normal file
View File

@ -0,0 +1,487 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 2016 - 2023 SaKeL <juraj.vajda@gmail.com>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
### Code
GNU Lesser General Public License v2.1 or later (see included LICENSE file)
### Textures
**CC-BY-SA-4.0, by SaKeL**
- spawners_ores_stone_with_copper.png -- Derived from texture by Cisoun and Celeron55 (CC BY-SA 3.0)
- spawners_ores_stone_with_gold.png -- Derived from texture by Cisoun and Celeron55 (CC BY-SA 3.0)
- spawners_ores_stone_with_iron.png -- Derived from texture by Cisoun and Celeron55 (CC BY-SA 3.0)
- spawners_ores_stone_with_tin.png -- Derived from texture by Cisoun and Celeron55 (CC BY-SA 3.0)
- spawners_ores_ingot_slot.png
- spawners_ores_spawner_16.png
- spawners_ores_spawner_animated_16.png
- spawners_ores_spawner_animated_lava_16.png
- spawners_ores_spawner_animated_magma_16.png
- spawners_ores_spawner_animated.png
- spawners_ores_spawner_waiting_animated_16.png
- spawners_ores_spawner_waiting_animated.png
- spawners_ores_spawner.png
**CC-BY-SA-4.0, Pixel Perfection by XSSheep**, https://minecraft.curseforge.com/projects/pixel-perfection-freshly-updated
- spawners_ores_smoke_particle.png
### Sound
**CC0-1.0, JarredGibb**, https://freesound.org/people/JarredGibb/sounds/248237/
- spawners_ores_strike.ogg

View File

@ -1,3 +1,21 @@
--[[
Ore spawners let player craft ore spawneres and get back lumps from ingots.
Copyright (C) 2016 - 2023 SaKeL <juraj.vajda@gmail.com>
This library is free software; you can redistribute it and/or
modify it pos the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to juraj.vajda@gmail.com
--]]
-- main tables -- main tables
spawners_ores = {} spawners_ores = {}
local percent = 10 local percent = 10
@ -17,49 +35,48 @@ function spawners_ores.add_effects(pos, radius)
minetest.add_particlespawner({ minetest.add_particlespawner({
amount = 32, amount = 32,
time = 2, time = 2,
minpos = vector.subtract({x=pos.x, y=pos.y+1, z=pos.z}, radius / 2), minpos = vector.subtract({ x = pos.x, y = pos.y + 1, z = pos.z }, radius / 2),
maxpos = vector.add({x=pos.x, y=pos.y+1, z=pos.z}, radius / 2), maxpos = vector.add({ x = pos.x, y = pos.y + 1, z = pos.z }, radius / 2),
minvel = {x=-0.5, y=3, z=-0.5}, minvel = { x = -0.5, y = 3, z = -0.5 },
maxvel = {x=0.5, y=10, z=0.5}, maxvel = { x = 0.5, y = 10, z = 0.5 },
minacc = vector.new(), minacc = vector.new(),
maxacc = vector.new(), maxacc = vector.new(),
minexptime = 0.5, minexptime = 0.5,
maxexptime = 2, maxexptime = 2,
minsize = 0.5, minsize = 0.5,
maxsize = 8, maxsize = 8,
texture = "spawners_ores_smoke_particle.png^[transform"..math.random(0,3) texture = 'spawners_ores_smoke_particle.png^[transform' .. math.random(0, 3)
}) })
end end
-- start spawning ores -- start spawning ores
function spawners_ores.start_spawning_ores(pos, ore_name, how_many) function spawners_ores.start_spawning_ores(pos, ore_name, how_many)
if not pos or not ore_name then return end if not pos or not ore_name then return end
local player_near = false local _how_many = how_many or 1
local how_many = how_many or 1
for i=1, how_many do for i = 1, _how_many do
if i > 1 then if i > 1 then
pos = spawners_ores.get_available_node(pos, "default:stone") pos = spawners_ores.get_available_node(pos, 'default:stone')
if not pos then return end if not pos then return end
minetest.sound_play("spawners_ores_strike", { minetest.sound_play('spawners_ores_strike', {
pos = pos, pos = pos,
max_hear_distance = 16, max_hear_distance = 16,
gain = 10, gain = 10,
}) })
minetest.set_node(pos, {name=ore_name}) minetest.set_node(pos, { name = ore_name })
spawners_ores.add_effects(pos, 1) spawners_ores.add_effects(pos, 1)
else else
minetest.sound_play("spawners_ores_strike", { minetest.sound_play('spawners_ores_strike', {
pos = pos, pos = pos,
max_hear_distance = 16, max_hear_distance = 16,
gain = 10, gain = 10,
}) })
minetest.set_node(pos, {name=ore_name}) minetest.set_node(pos, { name = ore_name })
spawners_ores.add_effects(pos, 1) spawners_ores.add_effects(pos, 1)
end end
end end
@ -69,10 +86,10 @@ end
function spawners_ores.get_available_node(pos, check_node, radius) function spawners_ores.get_available_node(pos, check_node, radius)
if not pos then return end if not pos then return end
local check_node = check_node or "default:stone" local _check_node = check_node or 'default:stone'
local radius = radius or 2 local _radius = radius or 2
local node_ore_pos = minetest.find_node_near(pos, radius, {check_node}) local node_ore_pos = minetest.find_node_near(pos, _radius, { _check_node })
if node_ore_pos and node_ore_pos ~= nil then if node_ore_pos and node_ore_pos ~= nil then
return node_ore_pos return node_ore_pos
@ -84,17 +101,17 @@ end
-- build form for spawners -- build form for spawners
function spawners_ores.get_formspec(pos, table) function spawners_ores.get_formspec(pos, table)
-- Inizialize metadata and variables -- Inizialize metadata and variables
local table = table or {} local _table = table or {}
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local mineral = table.ore or meta:get_string("mineral") local mineral = _table.ore or meta:get_string('mineral')
local ingot = table.ore or meta:get_string("mineral") local ingot = _table.ore or meta:get_string('mineral')
local status = meta:get_string("status") local status = meta:get_string('status')
local inv = meta:get_inventory() local inv = meta:get_inventory()
local stack = inv:get_stack("fuel", 1) local stack = inv:get_stack('fuel', 1)
-- fix different Ingot namings -- fix different Ingot namings
if ingot == "iron" then if ingot == 'iron' then
ingot = "steel" ingot = 'steel'
end end
-- add extra ores based on percentage -- add extra ores based on percentage
@ -106,71 +123,71 @@ function spawners_ores.get_formspec(pos, table)
local extra_per = stack_per_obj.extra_per or 0 local extra_per = stack_per_obj.extra_per or 0
local colorize = { local colorize = {
gold = "^[colorize:#ffe4008C", gold = '^[colorize:#ffe4008C',
tin = "^[colorize:#d0d0d08C", tin = '^[colorize:#d0d0d08C',
iron = "^[colorize:#b66d498C", iron = '^[colorize:#b66d498C',
copper = "^[colorize:#b587528C", copper = '^[colorize:#b587528C',
} }
local colorize_arrow = "" local colorize_arrow = ''
local button = "" local button = ''
if status == "active" then if status == 'active' then
colorize_arrow = colorize[mineral] colorize_arrow = colorize[mineral]
elseif status == "waiting" then elseif status == 'waiting' then
button = "button[1.8,2.5;2,1.5;restart;RE-START]" button = 'button[1.8,2.5;2,1.5;restart;RE-START]'
end end
-- dynamic formspec -- dynamic formspec
local formspec = "size[8,8.5]".. local formspec = 'size[8,8.5]' ..
default.gui_bg.. default.gui_bg ..
default.gui_bg_img.. default.gui_bg_img ..
default.gui_slots.. default.gui_slots ..
"label[1.8,0.3;Input "..ingot.." Ingot]".. 'label[1.8,0.3;Input ' .. ingot .. ' Ingot]' ..
"list[current_name;fuel;1.8,1;1,1;]".. 'list[current_name;fuel;1.8,1;1,1;]' ..
"image[1.8,1;1,1;spawners_ores_ingot_slot.png]".. 'image[1.8,1;1,1;spawners_ores_ingot_slot.png]' ..
"list[current_player;main;0,4.25;8,1;]".. 'list[current_player;main;0,4.25;8,1;]' ..
"list[current_player;main;0,5.5;8,3;8]".. 'list[current_player;main;0,5.5;8,3;8]' ..
"image[2.9,1;1,1;gui_furnace_arrow_bg.png^[transformR270"..colorize_arrow.."]".. 'image[2.9,1;1,1;gui_furnace_arrow_bg.png^[transformR270' .. colorize_arrow .. ']' ..
"label[1.8,2;"..stack_per.." minerals ("..extra_per.." extra)]".. 'label[1.8,2;' .. stack_per .. ' minerals (' .. extra_per .. ' extra)]' ..
"image[4,1;1,1;spawners_ores_stone_with_"..mineral..".png]".. 'image[4,1;1,1;spawners_ores_stone_with_' .. mineral .. '.png]' ..
button.. button ..
"listring[current_name;fuel]".. 'listring[current_name;fuel]' ..
"listring[current_player;main]".. 'listring[current_player;main]' ..
default.get_hotbar_bg(0, 4.25) default.get_hotbar_bg(0, 4.25)
meta:set_string("formspec", formspec) meta:set_string('formspec', formspec)
-- infotext -- infotext
local infotext = mineral.." fuel: "..inv:get_stack("fuel", 1):get_count() local infotext = mineral .. ' fuel: ' .. inv:get_stack('fuel', 1):get_count()
if inv:is_empty("fuel") then if inv:is_empty('fuel') then
infotext = mineral.." ore spawner is empty." infotext = mineral .. ' ore spawner is empty.'
elseif status == "waiting" then elseif status == 'waiting' then
infotext = "Waiting - no default:stone was found near by, "..mineral.." fuel: "..inv:get_stack("fuel", 1):get_count() infotext = 'Waiting - no default:stone was found near by, ' .. mineral .. ' fuel: ' .. inv:get_stack('fuel', 1):get_count()
end end
meta:set_string("infotext", infotext) meta:set_string('infotext', infotext)
end end
-- check if is fuel empty in the node -- check if is fuel empty in the node
function spawners_ores.can_dig(pos, player) function spawners_ores.can_dig(pos, player)
local meta = minetest.get_meta(pos); local meta = minetest.get_meta(pos);
local inv = meta:get_inventory() local inv = meta:get_inventory()
return inv:is_empty("fuel") return inv:is_empty('fuel')
end end
-- add extra percentage on top of the stack -- add extra percentage on top of the stack
function spawners_ores.stack_per(table) function spawners_ores.stack_per(table)
local table = table or {} local _table = table or {}
local stack_count = table.stack_count or nil local stack_count = _table.stack_count or nil
local extra_per = (stack_count / 100) * percent local extra_per = (stack_count / 100) * percent
extra_per = math.floor(extra_per) extra_per = math.floor(extra_per)
local stack_per = extra_per + stack_count local stack_per = extra_per + stack_count
-- print(percent.."% from stack("..stack_count..") = "..stack_per.." ("..extra_per.." extra ore(s))") -- print(percent .. '% from stack(' .. stack_count .. ') = ' .. stack_per .. ' (' .. extra_per .. ' extra ore(s))')
return { return {
stack_per = stack_per, stack_per = stack_per,
@ -181,28 +198,27 @@ end
-- set status and update formspec/infotext -- set status and update formspec/infotext
function spawners_ores.on_timer(pos, elapsed) function spawners_ores.on_timer(pos, elapsed)
local available_node = spawners_ores.get_available_node(pos, "default:stone") local available_node = spawners_ores.get_available_node(pos, 'default:stone')
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
local stack = inv:get_stack("fuel", 1) local stack = inv:get_stack('fuel', 1)
local how_many = 1 local how_many = 1
local ore_name = meta:get_string("ore_name") local ore_name = meta:get_string('ore_name')
local mineral = meta:get_string("mineral") local status = meta:get_string('status')
local status = meta:get_string("status") local tick = meta:get_int('tick')
local tick = meta:get_int("tick")
-- --
-- active -- active
-- --
if available_node and inv:is_empty("fuel") ~= true then if available_node and inv:is_empty('fuel') ~= true then
-- make sure the right node status is shown -- make sure the right node status is shown
if status ~= "active" then if status ~= 'active' then
meta:set_string("status", "active") meta:set_string('status', 'active')
spawners_ores.get_formspec(pos) spawners_ores.get_formspec(pos)
minetest.swap_node(pos, {name="spawners_ores:"..ore_name.."_spawner_active"}) minetest.swap_node(pos, { name = 'spawners_ores:' .. ore_name .. '_spawner_active' })
end end
-- start spawning only on proper 'tick' -- start spawning only on proper 'tick'
@ -213,26 +229,26 @@ function spawners_ores.on_timer(pos, elapsed)
end end
-- enough place to spawn more ores -- enough place to spawn more ores
spawners_ores.start_spawning_ores(available_node, "default:"..ore_name, how_many) spawners_ores.start_spawning_ores(available_node, 'default:' .. ore_name, how_many)
-- take fuel -- take fuel
stack:take_item() stack:take_item()
inv:set_stack("fuel", 1, stack) inv:set_stack('fuel', 1, stack)
spawners_ores.get_formspec(pos) spawners_ores.get_formspec(pos)
end end
-- dont wait for proper 'tick' and change state after 1 sec. -- dont wait for proper 'tick' and change state after 1 sec.
local next_available_node = spawners_ores.get_available_node(pos, "default:stone") local next_available_node = spawners_ores.get_available_node(pos, 'default:stone')
if inv:is_empty("fuel") or next_available_node == false then if inv:is_empty('fuel') or next_available_node == false then
minetest.get_node_timer(pos):start(1.0) minetest.get_node_timer(pos):start(1.0)
return return
end end
if tick == 0 then if tick == 0 then
-- start new proper timer -- start new proper timer
meta:set_int("tick", 1) meta:set_int('tick', 1)
end end
-- start new proper timer -- start new proper timer
@ -240,11 +256,11 @@ function spawners_ores.on_timer(pos, elapsed)
-- --
-- default -- default
-- --
elseif inv:is_empty("fuel") then elseif inv:is_empty('fuel') then
-- empty / no fuel -- stop timer -- empty / no fuel -- stop timer
-- make sure that default status/node is shown -- make sure that default status/node is shown
meta:set_string("status", "") meta:set_string('status', '')
minetest.swap_node(pos, {name="spawners_ores:"..ore_name.."_spawner"}) minetest.swap_node(pos, { name = 'spawners_ores:' .. ore_name .. '_spawner' })
spawners_ores.get_formspec(pos) spawners_ores.get_formspec(pos)
return return
@ -253,15 +269,14 @@ function spawners_ores.on_timer(pos, elapsed)
-- waiting -- waiting
-- --
else else
-- stop timer and show "refresh" button in order to start timer again -- stop timer and show 'refresh' button in order to start timer again
-- make sure that waiting status/node is shown -- make sure that waiting status/node is shown
if status ~= "waiting" then if status ~= 'waiting' then
meta:set_string("status", "waiting") meta:set_string('status', 'waiting')
minetest.swap_node(pos, {name="spawners_ores:"..ore_name.."_spawner_waiting"}) minetest.swap_node(pos, { name = 'spawners_ores:' .. ore_name .. '_spawner_waiting' })
end end
spawners_ores.get_formspec(pos) spawners_ores.get_formspec(pos)
return return
end end
end end

View File

@ -1,3 +0,0 @@
default
xpanes?
fire?

View File

@ -1 +0,0 @@
This MOD for Minetest let the player craft ore Spawners. Ores are spawning randomly in a short intervals and you get 10% more ores from inputed ingots. This MOD is giving the option of creating lumps back from ingots.

View File

@ -1,9 +1,30 @@
MOD_NAME = minetest.get_current_modname() --[[
Ore spawners let player craft ore spawneres and get back lumps from ingots.
Copyright (C) 2016 - 2023 SaKeL <juraj.vajda@gmail.com>
This library is free software; you can redistribute it and/or
modify it pos the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to juraj.vajda@gmail.com
--]]
local mod_start_time = minetest.get_us_time()
local path = minetest.get_modpath('spawners_ores')
-- API -- API
dofile(minetest.get_modpath(MOD_NAME).."/api.lua") dofile(path .. '/api.lua')
-- Spawners for ores -- Spawners for ores
dofile(minetest.get_modpath(MOD_NAME).."/spawners_ores.lua") dofile(path .. '/spawners_ores.lua')
print ("[Mod] Spawners Ores Loaded.") local mod_end_time = (minetest.get_us_time() - mod_start_time) / 1000000
print('[Mod] Spawners Ores Loaded. [' .. mod_end_time .. 's]')

View File

@ -1 +1,6 @@
name = spawners_ores name = spawners_ores
description = Let the player craft ore Spawners. Ores are spawning randomly in a short intervals and you get 10% more ores from inputed ingots. This MOD is giving the option of creating lumps back from ingots.
depends = default
optional_depends = xpanes, fire
supported_games =
min_minetest_version = 5.4

View File

@ -1,12 +1,30 @@
--[[
Ore spawners let player craft ore spawneres and get back lumps from ingots.
Copyright (C) 2016 - 2023 SaKeL <juraj.vajda@gmail.com>
This library is free software; you can redistribute it and/or
modify it pos the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to juraj.vajda@gmail.com
--]]
-- --
-- Colorize HEX -- Colorize HEX
-- --
local colorize = { local colorize = {
stone_with_gold = "^[colorize:#ffe40033", stone_with_gold = '^[colorize:#ffe40033',
stone_with_tin = "^[colorize:#d0d0d040", stone_with_tin = '^[colorize:#d0d0d040',
stone_with_iron = "^[colorize:#b66d4940", stone_with_iron = '^[colorize:#b66d4940',
stone_with_copper = "^[colorize:#b5875240", stone_with_copper = '^[colorize:#b5875240',
} }
-- --
@ -21,13 +39,13 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player)
end end
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local mineral = meta:get_string("mineral") local mineral = meta:get_string('mineral')
if mineral == "iron" then if mineral == 'iron' then
mineral = "steel" mineral = 'steel'
end end
if stack:get_name() == "default:"..mineral.."_ingot" then if stack:get_name() == 'default:' .. mineral .. '_ingot' then
return stack:get_count() return stack:get_count()
else else
return 0 return 0
@ -45,14 +63,14 @@ end
local function on_metadata_inventory_put(pos) local function on_metadata_inventory_put(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_int("tick", 0) meta:set_int('tick', 0)
spawners_ores.get_formspec(pos) spawners_ores.get_formspec(pos)
minetest.get_node_timer(pos):start(1.0) minetest.get_node_timer(pos):start(1.0)
end end
local function on_metadata_inventory_take(pos) local function on_metadata_inventory_take(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_int("tick", 0) meta:set_int('tick', 0)
spawners_ores.get_formspec(pos) spawners_ores.get_formspec(pos)
minetest.get_node_timer(pos):start(1.0) minetest.get_node_timer(pos):start(1.0)
end end
@ -62,9 +80,8 @@ end
-- --
function spawners_ores.create(def) function spawners_ores.create(def)
local ore_name = def.ore_name or nil local ore_name = def.ore_name or nil
local size = def.size or {x = 0.33, y = 0.33} local size = def.size or { x = 0.33, y = 0.33 }
local offset = def.offset or 0 local offset = def.offset or 0
-- these must be defined -- these must be defined
@ -76,53 +93,59 @@ function spawners_ores.create(def)
local dummy_ore_definition = { local dummy_ore_definition = {
hp_max = 1, hp_max = 1,
physical = false, physical = false,
collisionbox = {0,0,0,0,0,0}, collisionbox = { 0, 0, 0, 0, 0, 0 },
visual = "wielditem", visual = 'wielditem',
visual_size = size, visual_size = size,
timer = 0, timer = 0,
textures={"default:"..ore_name}, textures = { 'default:' .. ore_name },
makes_footstep_sound = false, makes_footstep_sound = false,
automatic_rotate = math.pi * -3, automatic_rotate = math.pi * -3,
m_name = "dummy_ore" m_name = 'dummy_ore'
} }
local ore = string.split(ore_name, "_") local ore = string.split(ore_name, '_')
dummy_ore_definition.on_activate = function(self) dummy_ore_definition.on_activate = function(self)
self.object:set_velocity({x=0, y=0, z=0}) self.object:set_velocity({ x = 0, y = 0, z = 0 })
self.object:set_acceleration({x=0, y=0, z=0}) self.object:set_acceleration({ x = 0, y = 0, z = 0 })
self.object:set_armor_groups({immortal=1}) self.object:set_armor_groups({ immortal = 1 })
end end
-- remove dummy after dug up the spawner -- remove dummy after dug up the spawner
dummy_ore_definition.on_step = function(self, dtime) dummy_ore_definition.on_step = function(self, dtime)
self.timer = self.timer + dtime self.timer = self.timer + dtime
local n = minetest.get_node_or_nil(self.object:get_pos()) local n = minetest.get_node_or_nil(self.object:get_pos())
if self.timer > 2 then if self.timer > 2 then
if n and n.name and n.name ~= "spawners_ores:"..ore_name.."_spawner_active" and n.name ~= "spawners_ores:"..ore_name.."_spawner_waiting" and n.name ~= "spawners_ores:"..ore_name.."_spawner" then if n
and n.name
and n.name ~= 'spawners_ores:' .. ore_name .. '_spawner_active'
and n.name ~= 'spawners_ores:' .. ore_name .. '_spawner_waiting'
and n.name ~= 'spawners_ores:' .. ore_name .. '_spawner'
then
self.object:remove() self.object:remove()
end end
end end
end end
minetest.register_entity("spawners_ores:dummy_ore_"..ore_name, dummy_ore_definition) minetest.register_entity('spawners_ores:dummy_ore_' .. ore_name, dummy_ore_definition)
-- node spawner active -- node spawner active
minetest.register_node("spawners_ores:"..ore_name.."_spawner_active", { minetest.register_node('spawners_ores:' .. ore_name .. '_spawner_active', {
description = ore_name.." spawner active", description = ore_name .. ' spawner active',
paramtype = "light", paramtype = 'light',
light_source = 4, light_source = 4,
paramtype2 = "glasslikeliquidlevel", paramtype2 = 'glasslikeliquidlevel',
drawtype = "glasslike_framed_optional", drawtype = 'glasslike_framed_optional',
walkable = true, walkable = true,
sounds = default.node_sound_metal_defaults(), sounds = default.node_sound_metal_defaults(),
damage_per_second = 4, damage_per_second = 4,
sunlight_propagates = true, sunlight_propagates = true,
tiles = { tiles = {
{ {
name = "spawners_ores_spawner_animated_magma_16.png"..colorize[ore_name], name = 'spawners_ores_spawner_animated_magma_16.png' .. colorize[ore_name],
animation = { animation = {
type = "vertical_frames", type = 'vertical_frames',
aspect_w = 16, aspect_w = 16,
aspect_h = 16, aspect_h = 16,
length = 2.0 length = 2.0
@ -130,17 +153,21 @@ function spawners_ores.create(def)
} }
}, },
is_ground_content = true, is_ground_content = true,
groups = {cracky=1,level=2,igniter=1,not_in_creative_inventory=1}, groups = {
drop = "spawners_ores:"..ore_name.."_spawner", -- MTG
cracky = 1,
level = 2,
igniter = 1,
not_in_creative_inventory = 1
},
drop = 'spawners_ores:' .. ore_name .. '_spawner',
can_dig = spawners_ores.can_dig, can_dig = spawners_ores.can_dig,
on_timer = spawners_ores.on_timer, on_timer = spawners_ores.on_timer,
on_blast = function(pos) on_blast = function(pos)
local drops = {} local drops = {}
default.get_inventory_drops(pos, "fuel", drops) default.get_inventory_drops(pos, 'fuel', drops)
drops[#drops+1] = "spawners_ores:"..ore_name.."_spawner_active" drops[#drops + 1] = 'spawners_ores:' .. ore_name .. '_spawner_active'
minetest.remove_node(pos) minetest.remove_node(pos)
return drops return drops
end, end,
@ -151,20 +178,20 @@ function spawners_ores.create(def)
}) })
-- node spawner waiting - no stone around or no fuel -- node spawner waiting - no stone around or no fuel
minetest.register_node("spawners_ores:"..ore_name.."_spawner_waiting", { minetest.register_node('spawners_ores:' .. ore_name .. '_spawner_waiting', {
description = ore_name.." spawner waiting", description = ore_name .. ' spawner waiting',
paramtype = "light", paramtype = 'light',
light_source = 2, light_source = 2,
paramtype2 = "glasslikeliquidlevel", paramtype2 = 'glasslikeliquidlevel',
drawtype = "glasslike_framed_optional", drawtype = 'glasslike_framed_optional',
walkable = true, walkable = true,
sounds = default.node_sound_metal_defaults(), sounds = default.node_sound_metal_defaults(),
sunlight_propagates = true, sunlight_propagates = true,
tiles = { tiles = {
{ {
name = "spawners_ores_spawner_waiting_animated_16.png"..colorize[ore_name], name = 'spawners_ores_spawner_waiting_animated_16.png' .. colorize[ore_name],
animation = { animation = {
type = "vertical_frames", type = 'vertical_frames',
aspect_w = 32, aspect_w = 32,
aspect_h = 32, aspect_h = 32,
length = 2.0 length = 2.0
@ -172,17 +199,19 @@ function spawners_ores.create(def)
} }
}, },
is_ground_content = true, is_ground_content = true,
groups = {cracky=1,level=2,not_in_creative_inventory=1}, groups = {
drop = "spawners_ores:"..ore_name.."_spawner_waiting", -- MTG
cracky = 1,
level = 2,
not_in_creative_inventory = 1
},
drop = 'spawners_ores:' .. ore_name .. '_spawner_waiting',
can_dig = spawners_ores.can_dig, can_dig = spawners_ores.can_dig,
on_timer = spawners_ores.on_timer, on_timer = spawners_ores.on_timer,
on_blast = function(pos) on_blast = function(pos)
local drops = {} local drops = {}
default.get_inventory_drops(pos, "fuel", drops) default.get_inventory_drops(pos, 'fuel', drops)
drops[#drops+1] = "spawners_ores:"..ore_name.."_spawner" drops[#drops + 1] = 'spawners_ores:' .. ore_name .. '_spawner'
minetest.remove_node(pos) minetest.remove_node(pos)
return drops return drops
end, end,
@ -190,7 +219,7 @@ function spawners_ores.create(def)
on_receive_fields = function(pos, formname, fields, sender) on_receive_fields = function(pos, formname, fields, sender)
if fields.restart then if fields.restart then
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_int("tick", 0) meta:set_int('tick', 0)
spawners_ores.get_formspec(pos) spawners_ores.get_formspec(pos)
minetest.get_node_timer(pos):start(1.0) minetest.get_node_timer(pos):start(1.0)
end end
@ -203,46 +232,47 @@ function spawners_ores.create(def)
}) })
-- node spawner inactive (default) -- node spawner inactive (default)
minetest.register_node("spawners_ores:"..ore_name.."_spawner", { minetest.register_node('spawners_ores:' .. ore_name .. '_spawner', {
description = ore_name.." spawner", description = ore_name .. ' spawner',
paramtype = "light", paramtype = 'light',
paramtype2 = "glasslikeliquidlevel", paramtype2 = 'glasslikeliquidlevel',
drawtype = "glasslike_framed_optional", drawtype = 'glasslike_framed_optional',
walkable = true, walkable = true,
sounds = default.node_sound_metal_defaults(), sounds = default.node_sound_metal_defaults(),
sunlight_propagates = true, sunlight_propagates = true,
tiles = {"spawners_ores_spawner_16.png"..colorize[ore_name]}, tiles = { 'spawners_ores_spawner_16.png' .. colorize[ore_name] },
is_ground_content = true, is_ground_content = true,
groups = {cracky = 1, level = 2}, groups = {
-- MTG
cracky = 1,
level = 2
},
stack_max = 1, stack_max = 1,
can_dig = spawners_ores.can_dig, can_dig = spawners_ores.can_dig,
on_timer = spawners_ores.on_timer, on_timer = spawners_ores.on_timer,
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
spawners_ores.get_formspec(pos, {ore=ore[3]}) spawners_ores.get_formspec(pos, { ore = ore[3] })
-- Inizialize inventory -- Inizialize inventory
local inv = meta:get_inventory() local inv = meta:get_inventory()
inv:set_size('fuel', 1) inv:set_size('fuel', 1)
-- custom meta -- custom meta
meta:set_string("mineral", ore[3]) meta:set_string('mineral', ore[3])
meta:set_string("ore_name", ore_name) meta:set_string('ore_name', ore_name)
meta:set_string("status", "") meta:set_string('status', '')
meta:set_int("tick", 0) meta:set_int('tick', 0)
-- add spinning entity inside the spawner -- add spinning entity inside the spawner
pos.y = pos.y + offset pos.y = pos.y + offset
minetest.add_entity(pos,"spawners_ores:dummy_ore_"..ore_name) minetest.add_entity(pos,'spawners_ores:dummy_ore_' .. ore_name)
end, end,
on_blast = function(pos) on_blast = function(pos)
local drops = {} local drops = {}
default.get_inventory_drops(pos, "fuel", drops) default.get_inventory_drops(pos, 'fuel', drops)
drops[#drops+1] = "spawners_ores:"..ore_name.."_spawner" drops[#drops + 1] = 'spawners_ores:' .. ore_name .. '_spawner'
minetest.remove_node(pos) minetest.remove_node(pos)
return drops return drops
end, end,
@ -250,7 +280,7 @@ function spawners_ores.create(def)
after_place_node = function(pos, placer, itemstack, pointed_thing) after_place_node = function(pos, placer, itemstack, pointed_thing)
-- TODO: show owner in infotext/formspec -- TODO: show owner in infotext/formspec
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name()) meta:set_string('owner', placer:get_player_name())
end, end,
on_metadata_inventory_put = on_metadata_inventory_put, on_metadata_inventory_put = on_metadata_inventory_put,
@ -261,9 +291,9 @@ function spawners_ores.create(def)
-- replacement LBM for pre-nodetimer plants -- replacement LBM for pre-nodetimer plants
minetest.register_lbm({ minetest.register_lbm({
name = "spawners_ores:start_nodetimer_"..ore_name, name = 'spawners_ores:start_nodetimer_' .. ore_name,
nodenames = { nodenames = {
"spawners_ores:"..ore_name.."_spawner_active" 'spawners_ores:' .. ore_name .. '_spawner_active'
}, },
action = function(pos, node) action = function(pos, node)
spawners_ores.tick_short(pos) spawners_ores.tick_short(pos)
@ -277,29 +307,29 @@ end
-- default:stone_with_gold -- default:stone_with_gold
spawners_ores.create({ spawners_ores.create({
ore_name = "stone_with_gold", ore_name = 'stone_with_gold',
size = {x = 0.33, y = 0.33}, size = { x = 0.33, y = 0.33 },
offset = 0 offset = 0
}) })
-- default:stone_with_iron -- default:stone_with_iron
spawners_ores.create({ spawners_ores.create({
ore_name = "stone_with_iron", ore_name = 'stone_with_iron',
size = {x = 0.33, y = 0.33}, size = { x = 0.33, y = 0.33 },
offset = 0 offset = 0
}) })
-- default:stone_with_copper -- default:stone_with_copper
spawners_ores.create({ spawners_ores.create({
ore_name = "stone_with_copper", ore_name = 'stone_with_copper',
size = {x = 0.33, y = 0.33}, size = { x = 0.33, y = 0.33 },
offset = 0 offset = 0
}) })
-- default:stone_with_tin -- default:stone_with_tin
spawners_ores.create({ spawners_ores.create({
ore_name = "stone_with_tin", ore_name = 'stone_with_tin',
size = {x = 0.33, y = 0.33}, size = { x = 0.33, y = 0.33 },
offset = 0 offset = 0
}) })
@ -308,37 +338,37 @@ spawners_ores.create({
-- --
minetest.register_craft({ minetest.register_craft({
output = "spawners_ores:stone_with_gold_spawner", output = 'spawners_ores:stone_with_gold_spawner',
recipe = { recipe = {
{"default:diamondblock", "fire:flint_and_steel", "default:diamondblock"}, { 'default:diamondblock', 'fire:flint_and_steel', 'default:diamondblock' },
{"xpanes:bar_flat", "default:goldblock", "xpanes:bar_flat"}, { 'xpanes:bar_flat', 'default:goldblock', 'xpanes:bar_flat' },
{"default:diamondblock", "xpanes:bar_flat", "default:diamondblock"}, { 'default:diamondblock', 'xpanes:bar_flat', 'default:diamondblock' },
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "spawners_ores:stone_with_iron_spawner", output = 'spawners_ores:stone_with_iron_spawner',
recipe = { recipe = {
{"default:diamondblock", "fire:flint_and_steel", "default:diamondblock"}, { 'default:diamondblock', 'fire:flint_and_steel', 'default:diamondblock' },
{"xpanes:bar_flat", "default:steelblock", "xpanes:bar_flat"}, { 'xpanes:bar_flat', 'default:steelblock', 'xpanes:bar_flat' },
{"default:diamondblock", "xpanes:bar_flat", "default:diamondblock"}, { 'default:diamondblock', 'xpanes:bar_flat', 'default:diamondblock' },
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "spawners_ores:stone_with_copper_spawner", output = 'spawners_ores:stone_with_copper_spawner',
recipe = { recipe = {
{"default:diamondblock", "fire:flint_and_steel", "default:diamondblock"}, { 'default:diamondblock', 'fire:flint_and_steel', 'default:diamondblock' },
{"xpanes:bar_flat", "default:copperblock", "xpanes:bar_flat"}, { 'xpanes:bar_flat', 'default:copperblock', 'xpanes:bar_flat' },
{"default:diamondblock", "xpanes:bar_flat", "default:diamondblock"}, { 'default:diamondblock', 'xpanes:bar_flat', 'default:diamondblock' },
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "spawners_ores:stone_with_tin_spawner", output = 'spawners_ores:stone_with_tin_spawner',
recipe = { recipe = {
{"default:diamondblock", "fire:flint_and_steel", "default:diamondblock"}, { 'default:diamondblock', 'fire:flint_and_steel', 'default:diamondblock' },
{"xpanes:bar_flat", "default:tinblock", "xpanes:bar_flat"}, { 'xpanes:bar_flat', 'default:tinblock', 'xpanes:bar_flat' },
{"default:diamondblock", "xpanes:bar_flat", "default:diamondblock"}, { 'default:diamondblock', 'xpanes:bar_flat', 'default:diamondblock' },
} }
}) })

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