Expose mapgen chunksize in on_mapgen_init callbacks
This commit is contained in:
parent
df0ca45ee2
commit
8fe1d3fc2e
|
@ -61,7 +61,7 @@ void ScriptApiEnv::environment_Step(float dtime)
|
||||||
void ScriptApiEnv::player_event(ServerActiveObject* player, std::string type)
|
void ScriptApiEnv::player_event(ServerActiveObject* player, std::string type)
|
||||||
{
|
{
|
||||||
SCRIPTAPI_PRECHECKHEADER
|
SCRIPTAPI_PRECHECKHEADER
|
||||||
|
|
||||||
if (player == NULL)
|
if (player == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -82,28 +82,31 @@ void ScriptApiEnv::player_event(ServerActiveObject* player, std::string type)
|
||||||
void ScriptApiEnv::environment_OnMapgenInit(MapgenParams *mgparams)
|
void ScriptApiEnv::environment_OnMapgenInit(MapgenParams *mgparams)
|
||||||
{
|
{
|
||||||
SCRIPTAPI_PRECHECKHEADER
|
SCRIPTAPI_PRECHECKHEADER
|
||||||
|
|
||||||
// Get core.registered_on_mapgen_inits
|
// Get core.registered_on_mapgen_inits
|
||||||
lua_getglobal(L, "core");
|
lua_getglobal(L, "core");
|
||||||
lua_getfield(L, -1, "registered_on_mapgen_inits");
|
lua_getfield(L, -1, "registered_on_mapgen_inits");
|
||||||
|
|
||||||
// Call callbacks
|
// Call callbacks
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
|
|
||||||
lua_pushstring(L, mgparams->mg_name.c_str());
|
lua_pushstring(L, mgparams->mg_name.c_str());
|
||||||
lua_setfield(L, -2, "mgname");
|
lua_setfield(L, -2, "mgname");
|
||||||
|
|
||||||
lua_pushinteger(L, mgparams->seed);
|
lua_pushinteger(L, mgparams->seed);
|
||||||
lua_setfield(L, -2, "seed");
|
lua_setfield(L, -2, "seed");
|
||||||
|
|
||||||
lua_pushinteger(L, mgparams->water_level);
|
lua_pushinteger(L, mgparams->water_level);
|
||||||
lua_setfield(L, -2, "water_level");
|
lua_setfield(L, -2, "water_level");
|
||||||
|
|
||||||
|
lua_pushinteger(L, mgparams->chunksize);
|
||||||
|
lua_setfield(L, -2, "chunksize");
|
||||||
|
|
||||||
std::string flagstr = writeFlagString(mgparams->flags,
|
std::string flagstr = writeFlagString(mgparams->flags,
|
||||||
flagdesc_mapgen, (u32)-1);
|
flagdesc_mapgen, (u32)-1);
|
||||||
lua_pushstring(L, flagstr.c_str());
|
lua_pushstring(L, flagstr.c_str());
|
||||||
lua_setfield(L, -2, "flags");
|
lua_setfield(L, -2, "flags");
|
||||||
|
|
||||||
script_run_callbacks(L, 1, RUN_CALLBACKS_MODE_FIRST);
|
script_run_callbacks(L, 1, RUN_CALLBACKS_MODE_FIRST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue