summaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_mapgen.cpp
diff options
context:
space:
mode:
authorparamat <paramat@users.noreply.github.com>2017-10-08 21:08:52 +0100
committerparamat <mat.gregory@virginmedia.com>2017-10-09 18:27:17 +0100
commit0c9ca27ffce7d53ede74bd6ccbf590d1cbe94b7b (patch)
treeb0e569ad1509bce616083e38794a64cf4017c226 /src/script/lua_api/l_mapgen.cpp
parent17016090e38cc44e58517129278c28dd7943b4cc (diff)
downloadminetest-0c9ca27ffce7d53ede74bd6ccbf590d1cbe94b7b.tar.gz
minetest-0c9ca27ffce7d53ede74bd6ccbf590d1cbe94b7b.tar.bz2
minetest-0c9ca27ffce7d53ede74bd6ccbf590d1cbe94b7b.zip
Simple decorations: Add 'param2_max' parameter for random param2
If 'param2_max' is not used, parameter 'param2' works as before for compatibility. If 'param2_max' is used, 'param2' and 'param2_max' become the lower and upper bounds of a per-decoration random param2.
Diffstat (limited to 'src/script/lua_api/l_mapgen.cpp')
-rw-r--r--src/script/lua_api/l_mapgen.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp
index b179ac407..f475a8f7f 100644
--- a/src/script/lua_api/l_mapgen.cpp
+++ b/src/script/lua_api/l_mapgen.cpp
@@ -981,6 +981,7 @@ bool read_deco_simple(lua_State *L, DecoSimple *deco)
{
int index = 1;
int param2;
+ int param2_max;
deco->deco_height = getintfield_default(L, index, "height", 1);
deco->deco_height_max = getintfield_default(L, index, "height_max", 0);
@@ -993,6 +994,7 @@ bool read_deco_simple(lua_State *L, DecoSimple *deco)
size_t nnames = getstringlistfield(L, index, "decoration", &deco->m_nodenames);
deco->m_nnlistsizes.push_back(nnames);
+
if (nnames == 0) {
errorstream << "register_decoration: no decoration nodes "
"defined" << std::endl;
@@ -1000,12 +1002,16 @@ bool read_deco_simple(lua_State *L, DecoSimple *deco)
}
param2 = getintfield_default(L, index, "param2", 0);
- if ((param2 < 0) || (param2 > 255)) {
- errorstream << "register_decoration: param2 out of bounds (0-255)"
+ param2_max = getintfield_default(L, index, "param2_max", 0);
+
+ if (param2 < 0 || param2 > 255 || param2_max < 0 || param2_max > 255) {
+ errorstream << "register_decoration: param2 or param2_max out of bounds (0-255)"
<< std::endl;
return false;
}
+
deco->deco_param2 = (u8)param2;
+ deco->deco_param2_max = (u8)param2_max;
return true;
}