aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVincent Glize <vincentglize@hotmail.fr>2017-04-08 08:20:30 +0200
committerLoïc Blot <nerzhul@users.noreply.github.com>2017-04-08 08:20:30 +0200
commitf73534640a18709921519ee43110292cf658e67f (patch)
tree3a318762bb4768e4826ae216c1aa6e5ab026a437 /src
parentff4fef570e8df6ce44ceb1d9071f860474eb1f95 (diff)
downloadminetest-f73534640a18709921519ee43110292cf658e67f.tar.gz
minetest-f73534640a18709921519ee43110292cf658e67f.tar.bz2
minetest-f73534640a18709921519ee43110292cf658e67f.zip
[CSM] Add event on_connect player API lua (#5540)
* Add event on_connect player API lua
Diffstat (limited to 'src')
-rw-r--r--src/client.cpp4
-rw-r--r--src/script/cpp_api/s_client.cpp11
-rw-r--r--src/script/cpp_api/s_client.h2
3 files changed, 17 insertions, 0 deletions
diff --git a/src/client.cpp b/src/client.cpp
index e710624d5..3a3e33cfd 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -1864,6 +1864,10 @@ void Client::afterContentReceived(IrrlichtDevice *device)
m_state = LC_Ready;
sendReady();
+
+ if (g_settings->getBool("enable_client_modding"))
+ m_script->on_connect();
+
text = wgettext("Done!");
draw_load_screen(text, device, guienv, 0, 100);
infostream<<"Client::afterContentReceived() done"<<std::endl;
diff --git a/src/script/cpp_api/s_client.cpp b/src/script/cpp_api/s_client.cpp
index 666fd693d..a8a7d5e26 100644
--- a/src/script/cpp_api/s_client.cpp
+++ b/src/script/cpp_api/s_client.cpp
@@ -35,6 +35,17 @@ void ScriptApiClient::on_shutdown()
runCallbacks(0, RUN_CALLBACKS_MODE_FIRST);
}
+void ScriptApiClient::on_connect()
+{
+ SCRIPTAPI_PRECHECKHEADER
+
+ // get registered connect hooks
+ lua_getglobal(L, "core");
+ lua_getfield(L, -1, "registered_on_connect");
+ // Call callback
+ runCallbacks(0, RUN_CALLBACKS_MODE_FIRST);
+}
+
bool ScriptApiClient::on_sending_message(const std::string &message)
{
SCRIPTAPI_PRECHECKHEADER
diff --git a/src/script/cpp_api/s_client.h b/src/script/cpp_api/s_client.h
index 9afc66d61..50e5e0d8a 100644
--- a/src/script/cpp_api/s_client.h
+++ b/src/script/cpp_api/s_client.h
@@ -36,6 +36,8 @@ class ScriptApiClient : virtual public ScriptApiBase
public:
// Calls on_shutdown handlers
void on_shutdown();
+
+ void on_connect();
// Chat message handlers
bool on_sending_message(const std::string &message);