aboutsummaryrefslogtreecommitdiff
path: root/src/scriptapi.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/scriptapi.cpp')
-rw-r--r--src/scriptapi.cpp46
1 files changed, 44 insertions, 2 deletions
diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp
index 29494ff69..ddffbb0b7 100644
--- a/src/scriptapi.cpp
+++ b/src/scriptapi.cpp
@@ -30,6 +30,7 @@ extern "C" {
#include "settings.h" // For accessing g_settings
#include "main.h" // For g_settings
#include "biome.h"
+#include "emerge.h"
#include "script.h"
#include "rollback.h"
@@ -242,6 +243,14 @@ struct EnumString es_BiomeTerrainType[] =
{0, NULL},
};
+struct EnumString es_OreType[] =
+{
+ {ORE_SCATTER, "scatter"},
+ {ORE_SHEET, "sheet"},
+ {ORE_CLAYLIKE, "claylike"},
+ {0, NULL},
+};
+
/*****************************************************************************/
/* Parameters */
/*****************************************************************************/
@@ -612,8 +621,6 @@ static int l_register_biome_groups(lua_State *L)
{
luaL_checktype(L, 1, LUA_TTABLE);
int index = 1;
- if (!lua_istable(L, index))
- throw LuaError(L, "register_biome_groups: parameter is not a table");
BiomeDefManager *bmgr = get_server(L)->getBiomeDef();
if (!bmgr) {
@@ -686,6 +693,40 @@ static int l_register_biome(lua_State *L)
}
+static int l_register_ore(lua_State *L)
+{
+ int index = 1;
+ luaL_checktype(L, index, LUA_TTABLE);
+
+ IWritableNodeDefManager *ndef = get_server(L)->getWritableNodeDefManager();
+ EmergeManager *emerge = get_server(L)->getEmergeManager();
+
+ enum OreType oretype = (OreType)getenumfield(L, index,
+ "ore_type", es_OreType, ORE_SCATTER);
+ Ore *ore = createOre(oretype);
+
+ ore->ore_name = getstringfield_default(L, index, "ore", "");
+ ore->wherein_name = getstringfield_default(L, index, "wherein", "");
+ ore->clust_scarcity = getintfield_default(L, index, "clust_scarcity", 0);
+ ore->clust_num_ores = getintfield_default(L, index, "clust_num_ores", 0);
+ ore->clust_size = getintfield_default(L, index, "clust_size", 0);
+ ore->height_min = getintfield_default(L, index, "height_min", 0);
+ ore->height_max = getintfield_default(L, index, "height_max", 0);
+ ore->nthresh = getfloatfield_default(L, index, "noise_threshhold", 0.);
+
+ lua_getfield(L, index, "noise_params");
+ ore->np = read_noiseparams(L, -1);
+ lua_pop(L, 1);
+
+ ore->noise = NULL;
+
+ emerge->ores.push_back(ore);
+
+ verbosestream << "register_ore: ore '" << ore->ore_name
+ << "' registered" << std::endl;
+ return 0;
+}
+
// setting_set(name, value)
static int l_setting_set(lua_State *L)
@@ -1060,6 +1101,7 @@ static const struct luaL_Reg minetest_f [] = {
{"register_craft", l_register_craft},
{"register_biome", l_register_biome},
{"register_biome_groups", l_register_biome_groups},
+ {"register_ore", l_register_ore},
{"setting_set", l_setting_set},
{"setting_get", l_setting_get},
{"setting_getbool", l_setting_getbool},