From 96a37aed31cfb9c131e46eda80bdbe3d2289a546 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Thu, 13 May 2021 17:21:13 +0200 Subject: Add minetest.get_send_speed --- src/script/cpp_api/s_client.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/script/cpp_api/s_client.cpp') diff --git a/src/script/cpp_api/s_client.cpp b/src/script/cpp_api/s_client.cpp index 5990c4df2..b0e7a073e 100644 --- a/src/script/cpp_api/s_client.cpp +++ b/src/script/cpp_api/s_client.cpp @@ -365,6 +365,27 @@ void ScriptApiClient::open_enderchest() lua_pcall(L, 0, 0, error_handler); } +v3f ScriptApiClient::get_send_speed(v3f speed) +{ + SCRIPTAPI_PRECHECKHEADER + + PUSH_ERROR_HANDLER(L); + int error_handler = lua_gettop(L) - 1; + lua_insert(L, error_handler); + + lua_getglobal(L, "core"); + lua_getfield(L, -1, "get_send_speed"); + if (lua_isfunction(L, -1)) { + speed /= BS; + push_v3f(L, speed); + lua_pcall(L, 1, 1, error_handler); + speed = read_v3f(L, -1); + speed *= BS; + } + + return speed; +} + void ScriptApiClient::set_node_def(const ContentFeatures &f) { SCRIPTAPI_PRECHECKHEADER -- cgit v1.2.3