NoiseParams *read_noiseparams(lua_State *L, int index)
{
	NoiseParams *np = new NoiseParams;

	if (!read_noiseparams_nc(L, index, np)) {
		delete np;
		np = NULL;
	}

	return np;
}
Exemple #2
0
// minetest.set_noiseparam_defaults({np1={noise params}, ...})
// set default values for noise parameters if not present in global settings
int ModApiMapgen::l_set_noiseparam_defaults(lua_State *L)
{
	NoiseParams np;
	std::string val, name;

	if (!lua_istable(L, 1))
		return 0;

	lua_pushnil(L);
	while (lua_next(L, 1)) {
		if (read_noiseparams_nc(L, -1, &np)) {
			if (!serializeStructToString(&val, NOISEPARAMS_FMT_STR, &np))
				continue;
			if (!lua_isstring(L, -2))
				continue;

			name = lua_tostring(L, -2);
			g_settings->setDefault(name, val);
		}
		lua_pop(L, 1);
	}

	return 0;
}