-- ^ If absent, the parameter 'height' is used as a constant.
param2 = 0,
-- ^ Param2 value of placed decoration node.
+ -- ^ If param2_max is not 0, this is the lower bound of the randomly selected param2.
+ param2_max = 0,
+ -- ^ Upper bound of the randomly selected param2.
+ -- ^ If absent, the parameter 'param2' is used as a constant.
----- Schematic-type parameters
schematic = "foobar.mts",
s16 height = (deco_height_max > 0) ?
pr->range(deco_height, deco_height_max) : deco_height;
+ u8 param2 = (deco_param2_max > 0) ?
+ pr->range(deco_param2, deco_param2_max) : deco_param2;
+
bool force_placement = (flags & DECO_FORCE_PLACEMENT);
const v3s16 &em = vm->m_area.getExtent();
!force_placement)
break;
- vm->m_data[vi] = MapNode(c_place, 0, deco_param2);
+ vm->m_data[vi] = MapNode(c_place, 0, param2);
}
return 1;
{
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);
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;
}
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;
}