aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2015-09-15 21:28:16 -0400
committerkwolekr <kwolekr@minetest.net>2015-09-17 03:04:50 -0400
commitdcbb95338a9b0e2c5c95fcfc6eeceb9d6d93f320 (patch)
tree1234b8308040a7ce297457951c817cec904c4996 /src/script/lua_api
parent6c81be51ffd26ec7dee1ecb887a8743a8b6a6ce4 (diff)
downloadminetest-dcbb95338a9b0e2c5c95fcfc6eeceb9d6d93f320.tar.gz
minetest-dcbb95338a9b0e2c5c95fcfc6eeceb9d6d93f320.tar.bz2
minetest-dcbb95338a9b0e2c5c95fcfc6eeceb9d6d93f320.zip
Ore: Add puff ore type
Diffstat (limited to 'src/script/lua_api')
-rw-r--r--src/script/lua_api/l_mapgen.cpp53
1 files changed, 38 insertions, 15 deletions
diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp
index 9050816bb..dcb611f47 100644
--- a/src/script/lua_api/l_mapgen.cpp
+++ b/src/script/lua_api/l_mapgen.cpp
@@ -70,6 +70,7 @@ struct EnumString ModApiMapgen::es_OreType[] =
{
{ORE_SCATTER, "scatter"},
{ORE_SHEET, "sheet"},
+ {ORE_PUFF, "puff"},
{ORE_BLOB, "blob"},
{ORE_VEIN, "vein"},
{0, NULL},
@@ -880,7 +881,7 @@ int ModApiMapgen::l_register_ore(lua_State *L)
"ore_type", es_OreType, ORE_SCATTER);
Ore *ore = oremgr->create(oretype);
if (!ore) {
- errorstream << "register_ore: ore_type " << oretype << " not implemented";
+ errorstream << "register_ore: ore_type " << oretype << " not implemented\n";
return 0;
}
@@ -938,20 +939,42 @@ int ModApiMapgen::l_register_ore(lua_State *L)
lua_pop(L, 1);
//// Get type-specific parameters
- if (oretype == ORE_SHEET) {
- OreSheet *oresheet = (OreSheet *)ore;
-
- oresheet->column_height_min = getintfield_default(L, index,
- "column_height_min", 1);
- oresheet->column_height_max = getintfield_default(L, index,
- "column_height_max", ore->clust_size);
- oresheet->column_midpoint_factor = getfloatfield_default(L, index,
- "column_midpoint_factor", 0.5f);
- } else if (oretype == ORE_VEIN) {
- OreVein *orevein = (OreVein *)ore;
-
- orevein->random_factor = getfloatfield_default(L, index,
- "random_factor", 1.f);
+ switch (oretype) {
+ case ORE_SHEET: {
+ OreSheet *oresheet = (OreSheet *)ore;
+
+ oresheet->column_height_min = getintfield_default(L, index,
+ "column_height_min", 1);
+ oresheet->column_height_max = getintfield_default(L, index,
+ "column_height_max", ore->clust_size);
+ oresheet->column_midpoint_factor = getfloatfield_default(L, index,
+ "column_midpoint_factor", 0.5f);
+
+ break;
+ }
+ case ORE_PUFF: {
+ OrePuff *orepuff = (OrePuff *)ore;
+
+ lua_getfield(L, index, "np_puff_top");
+ read_noiseparams(L, -1, &orepuff->np_puff_top);
+ lua_pop(L, 1);
+
+ lua_getfield(L, index, "np_puff_bottom");
+ read_noiseparams(L, -1, &orepuff->np_puff_bottom);
+ lua_pop(L, 1);
+
+ break;
+ }
+ case ORE_VEIN: {
+ OreVein *orevein = (OreVein *)ore;
+
+ orevein->random_factor = getfloatfield_default(L, index,
+ "random_factor", 1.f);
+
+ break;
+ }
+ default:
+ break;
}
ObjDefHandle handle = oremgr->add(ore);