diff options
author | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-01-22 11:17:41 +0100 |
---|---|---|
committer | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-03-13 23:56:05 +0100 |
commit | 2c19d51409ca903021e0b508e5bc15299c4e51dc (patch) | |
tree | 8df932580abc289160aadbc40487099fd033c7d8 /src/script/cpp_api/s_client.cpp | |
parent | d7bc346981e189851e490f2417ed015a38bca79b (diff) | |
download | dragonfireclient-2c19d51409ca903021e0b508e5bc15299c4e51dc.tar.xz |
[CSM] sound_play & sound_stop support + client_lua_api doc (#5096)
* squashed: CSM: Implement register_globalstep
* Re-use fatal error mechanism from server to disconnect client on CSM error
* Little client functions cleanups
* squashed: CSM: add core.after function
* core.after is shared code between client & server
* ModApiUtil get_us_time feature enabled for client
Diffstat (limited to 'src/script/cpp_api/s_client.cpp')
-rw-r--r-- | src/script/cpp_api/s_client.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/script/cpp_api/s_client.cpp b/src/script/cpp_api/s_client.cpp index f0676f4c2..ce88d67e3 100644 --- a/src/script/cpp_api/s_client.cpp +++ b/src/script/cpp_api/s_client.cpp @@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "s_client.h" #include "s_internal.h" +#include "client.h" void ScriptApiClient::on_shutdown() { @@ -94,3 +95,20 @@ void ScriptApiClient::on_death() // Call callbacks runCallbacks(0, RUN_CALLBACKS_MODE_FIRST); } + +void ScriptApiClient::environment_step(float dtime) +{ + SCRIPTAPI_PRECHECKHEADER + + // Get core.registered_globalsteps + lua_getglobal(L, "core"); + lua_getfield(L, -1, "registered_globalsteps"); + // Call callbacks + lua_pushnumber(L, dtime); + try { + runCallbacks(1, RUN_CALLBACKS_MODE_FIRST); + } catch (LuaError &e) { + getClient()->setFatalError(std::string("Client environment_step: ") + e.what() + "\n" + + script_get_backtrace(L)); + } +} |