# when connecting to the server.
enable_remote_media_server (Connect to external media server) bool true
+# Enable Lua modding support on client.
+enable_client_modding (Client modding) bool false
+
# URL to the server list displayed in the Multiplayer Tab.
serverlist_url (Serverlist URL) string servers.minetest.net
# type: bool
# enable_remote_media_server = true
+# Enable Lua modding support on client.
+# This support is experimental and API can change.
+# type: bool
+enable_client_modding (Client modding) bool false
+
# URL to the server list displayed in the Multiplayer Tab.
# type: string
# serverlist_url = servers.minetest.net
m_recommended_send_interval(0.1),
m_removed_sounds_check_timer(0),
m_state(LC_Created),
- m_localdb(NULL)
+ m_localdb(NULL),
+ m_script(NULL)
{
// Add local player
m_env.setLocalPlayer(new LocalPlayer(this, playername));
g_settings->getBool("enable_bumpmapping") ||
g_settings->getBool("enable_parallax_occlusion"));
+ m_modding_enabled = g_settings->getBool("enable_client_modding");
m_script = new ClientScripting(this);
m_env.setScript(m_script);
}
{
m_script->loadMod(getBuiltinLuaPath() + DIR_DELIM "init.lua", BUILTIN_MOD_NAME);
+ // If modding is not enabled, don't load mods, just builtin
+ if (!m_modding_enabled) {
+ return;
+ }
+
ClientModConfiguration modconf(getClientModsLuaPath());
std::vector<ModSpec> mods = modconf.getMods();
std::vector<ModSpec> unsatisfied_mods = modconf.getUnsatisfiedMods();
void Client::Stop()
{
+ // Don't disable this part when modding is disabled, it's used in builtin
m_script->on_shutdown();
//request all client managed threads to stop
m_mesh_update_thread.stop();
}
ClientScripting *getScript() { return m_script; }
+ const bool moddingEnabled() const { return m_modding_enabled; }
inline void pushToEventQueue(const ClientEvent &event)
{
bool m_cache_use_tangent_vertices;
ClientScripting *m_script;
+ bool m_modding_enabled;
DISABLE_CLASS_COPY(Client);
};
}
}
- m_script->environment_step(dtime);
+ if (m_client->moddingEnabled()) {
+ m_script->environment_step(dtime);
+ }
/*
A quick draft of lava damage
settings->setDefault("curl_file_download_timeout", "300000");
settings->setDefault("curl_verify_cert", "true");
settings->setDefault("enable_remote_media_server", "true");
+ settings->setDefault("enable_client_modding", "false");
// Keymap
settings->setDefault("remote_port", "30000");
return;
}
}
+
+ // Don't disable this part when modding is disabled, it's used in builtin
m_client->getScript()->on_formspec_input(m_formname, fields);
}
for ( ; event.type != CE_NONE; event = client->getClientEvent()) {
- if (event.type == CE_PLAYER_DAMAGE &&
- client->getHP() != 0) {
- client->getScript()->on_damage_taken(event.player_damage.amount);
+ if (event.type == CE_PLAYER_DAMAGE && client->getHP() != 0) {
+ if (client->moddingEnabled()) {
+ client->getScript()->on_damage_taken(event.player_damage.amount);
+ }
*damage_flash += 95.0 + 3.2 * event.player_damage.amount;
*damage_flash = MYMIN(*damage_flash, 127.0);
cam->camera_yaw = event.player_force_move.yaw;
cam->camera_pitch = event.player_force_move.pitch;
} else if (event.type == CE_DEATHSCREEN) {
+ // This should be enabled for death formspec in builtin
client->getScript()->on_death();
/* Handle visualization */
if (!runData->digging) {
infostream << "Started digging" << std::endl;
- if (client->getScript()->on_punchnode(nodepos, n))
+ if (client->moddingEnabled() && client->getScript()->on_punchnode(nodepos, n))
return;
client->interact(0, pointed);
runData->digging = true;
} else {
infostream << "Digging completed" << std::endl;
client->setCrack(-1, v3s16(0, 0, 0));
-
+
runData->dig_time = 0;
runData->digging = false;
bool is_valid_position;
MapNode wasnode = map.getNodeNoEx(nodepos, &is_valid_position);
if (is_valid_position) {
- bool block = client->getScript()->on_dignode(nodepos, wasnode);
- if (block) {
- return;
+ if (client->moddingEnabled()) {
+ if (client->getScript()->on_dignode(nodepos, wasnode)) {
+ return;
+ }
}
client->removeNode(nodepos);
}
}
// If chat message not consummed by client lua API
- if (!m_script->on_receiving_message(wide_to_utf8(message))) {
+ if (!moddingEnabled() || !m_script->on_receiving_message(wide_to_utf8(message))) {
pushToChatQueue(message);
}
}
player->hp = hp;
- m_script->on_hp_modification(hp);
+ if (moddingEnabled()) {
+ m_script->on_hp_modification(hp);
+ }
if (hp < oldhp) {
// Add to ClientEvent queue
// Call functions
runCallbacks(2, RUN_CALLBACKS_MODE_OR);
- bool blocked = lua_toboolean(L, -1);
- return blocked;
+ return lua_toboolean(L, -1);
}
bool ScriptApiClient::on_punchnode(v3s16 p, MapNode node)