diff options
author | Auke Kok <sofar@foo-projects.org> | 2016-12-06 16:39:33 -0800 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2016-12-07 04:17:17 +0000 |
commit | 2e69711613c18e1075f245d196823ea23675f027 (patch) | |
tree | 9f77dc11cae07da7bb6348c253ebbe5fd4f6d629 /src | |
parent | 075833e39368e63e06889f21140f816420e83541 (diff) | |
download | minetest-2e69711613c18e1075f245d196823ea23675f027.tar.gz minetest-2e69711613c18e1075f245d196823ea23675f027.tar.bz2 minetest-2e69711613c18e1075f245d196823ea23675f027.zip |
Simple deco: Allow setting param2 value on placement
Schematics can already be placed with a param2 value, but not
simple 1-node plant decorations of the simple type.
This adds a `param2` field to the simple deco type that is
checked to be between 0 and 255, and put to the placed node
at mapgen.
This can be used to put a degrotate value in, or e.g. a fill
value for leveltype nodes, or a place_param2 value at mapgen
placement, or vary the shape of meshoptions plantlike drawtype.
Diffstat (limited to 'src')
-rw-r--r-- | src/mg_decoration.cpp | 2 | ||||
-rw-r--r-- | src/mg_decoration.h | 1 | ||||
-rw-r--r-- | src/script/lua_api/l_mapgen.cpp | 7 |
3 files changed, 9 insertions, 1 deletions
diff --git a/src/mg_decoration.cpp b/src/mg_decoration.cpp index 92483abc3..51e4fbbcc 100644 --- a/src/mg_decoration.cpp +++ b/src/mg_decoration.cpp @@ -315,7 +315,7 @@ size_t DecoSimple::generate(MMVManip *vm, PcgRandom *pr, v3s16 p) !force_placement) break; - vm->m_data[vi] = MapNode(c_place); + vm->m_data[vi] = MapNode(c_place, 0, deco_param2); } return 1; diff --git a/src/mg_decoration.h b/src/mg_decoration.h index be0ba44d7..986328ec3 100644 --- a/src/mg_decoration.h +++ b/src/mg_decoration.h @@ -100,6 +100,7 @@ public: std::vector<content_t> c_decos; s16 deco_height; s16 deco_height_max; + u8 deco_param2; }; class DecoSchematic : public Decoration { diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp index da8e71cdc..cefea3da9 100644 --- a/src/script/lua_api/l_mapgen.cpp +++ b/src/script/lua_api/l_mapgen.cpp @@ -975,6 +975,7 @@ bool read_deco_simple(lua_State *L, DecoSimple *deco) deco->deco_height = getintfield_default(L, index, "height", 1); deco->deco_height_max = getintfield_default(L, index, "height_max", 0); + deco->deco_param2 = getintfield_default(L, index, "param2", 0); if (deco->deco_height <= 0) { errorstream << "register_decoration: simple decoration height" @@ -990,6 +991,12 @@ bool read_deco_simple(lua_State *L, DecoSimple *deco) return false; } + if ((deco->deco_param2 < 0) || (deco->deco_param2 > 255)) { + errorstream << "register_decoration: param2 out of bounds (0-255)" + << std::endl; + return false; + } + return true; } |