forked from Mirrorlandia_minetest/minetest
A few initialization cleanups
This commit is contained in:
parent
aa3cf400e2
commit
f105bc8dc2
@ -178,7 +178,7 @@ void Client::loadMods()
|
|||||||
infostream << mod.name << " ";
|
infostream << mod.name << " ";
|
||||||
infostream << std::endl;
|
infostream << std::endl;
|
||||||
|
|
||||||
// Load and run "mod" scripts
|
// Load "mod" scripts
|
||||||
for (const ModSpec &mod : m_mods) {
|
for (const ModSpec &mod : m_mods) {
|
||||||
if (!string_allowed(mod.name, MODNAME_ALLOWED_CHARS)) {
|
if (!string_allowed(mod.name, MODNAME_ALLOWED_CHARS)) {
|
||||||
throw ModError("Error loading mod \"" + mod.name +
|
throw ModError("Error loading mod \"" + mod.name +
|
||||||
@ -188,7 +188,7 @@ void Client::loadMods()
|
|||||||
scanModIntoMemory(mod.name, mod.path);
|
scanModIntoMemory(mod.name, mod.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load and run "mod" scripts
|
// Run them
|
||||||
for (const ModSpec &mod : m_mods)
|
for (const ModSpec &mod : m_mods)
|
||||||
m_script->loadModFromMemory(mod.name);
|
m_script->loadModFromMemory(mod.name);
|
||||||
|
|
||||||
@ -197,10 +197,14 @@ void Client::loadMods()
|
|||||||
|
|
||||||
// Run a callback when mods are loaded
|
// Run a callback when mods are loaded
|
||||||
m_script->on_mods_loaded();
|
m_script->on_mods_loaded();
|
||||||
|
|
||||||
|
// Create objects if they're ready
|
||||||
if (m_state == LC_Ready)
|
if (m_state == LC_Ready)
|
||||||
m_script->on_client_ready(m_env.getLocalPlayer());
|
m_script->on_client_ready(m_env.getLocalPlayer());
|
||||||
if (m_camera)
|
if (m_camera)
|
||||||
m_script->on_camera_ready(m_camera);
|
m_script->on_camera_ready(m_camera);
|
||||||
|
if (m_minimap)
|
||||||
|
m_script->on_minimap_ready(m_minimap);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Client::checkBuiltinIntegrity()
|
bool Client::checkBuiltinIntegrity()
|
||||||
|
@ -1407,8 +1407,11 @@ bool Game::createClient(const std::string &playername,
|
|||||||
}
|
}
|
||||||
|
|
||||||
mapper = client->getMinimap();
|
mapper = client->getMinimap();
|
||||||
if (mapper)
|
if (mapper) {
|
||||||
mapper->setMinimapMode(MINIMAP_MODE_OFF);
|
mapper->setMinimapMode(MINIMAP_MODE_OFF);
|
||||||
|
if (client->modsLoaded())
|
||||||
|
client->getScript()->on_minimap_ready(mapper);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -55,9 +55,6 @@ ClientScripting::ClientScripting(Client *client):
|
|||||||
InitializeModApi(L, top);
|
InitializeModApi(L, top);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
|
||||||
if (client->getMinimap())
|
|
||||||
LuaMinimap::create(L, client->getMinimap());
|
|
||||||
|
|
||||||
// Push builtin initialization type
|
// Push builtin initialization type
|
||||||
lua_pushstring(L, "client");
|
lua_pushstring(L, "client");
|
||||||
lua_setglobal(L, "INIT");
|
lua_setglobal(L, "INIT");
|
||||||
@ -94,3 +91,8 @@ void ClientScripting::on_camera_ready(Camera *camera)
|
|||||||
{
|
{
|
||||||
LuaCamera::create(getStack(), camera);
|
LuaCamera::create(getStack(), camera);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClientScripting::on_minimap_ready(Minimap *minimap)
|
||||||
|
{
|
||||||
|
LuaMinimap::create(getStack(), minimap);
|
||||||
|
}
|
||||||
|
@ -28,6 +28,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
class Client;
|
class Client;
|
||||||
class LocalPlayer;
|
class LocalPlayer;
|
||||||
class Camera;
|
class Camera;
|
||||||
|
class Minimap;
|
||||||
|
|
||||||
class ClientScripting:
|
class ClientScripting:
|
||||||
virtual public ScriptApiBase,
|
virtual public ScriptApiBase,
|
||||||
public ScriptApiSecurity,
|
public ScriptApiSecurity,
|
||||||
@ -38,6 +40,7 @@ public:
|
|||||||
ClientScripting(Client *client);
|
ClientScripting(Client *client);
|
||||||
void on_client_ready(LocalPlayer *localplayer);
|
void on_client_ready(LocalPlayer *localplayer);
|
||||||
void on_camera_ready(Camera *camera);
|
void on_camera_ready(Camera *camera);
|
||||||
|
void on_minimap_ready(Minimap *minimap);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void InitializeModApi(lua_State *L, int top);
|
virtual void InitializeModApi(lua_State *L, int top);
|
||||||
|
Loading…
Reference in New Issue
Block a user