aboutsummaryrefslogtreecommitdiff
path: root/src/script/cpp_api
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2021-05-13 17:21:13 +0200
committerElias Fleckenstein <eliasfleckenstein@web.de>2021-05-13 17:21:13 +0200
commit96a37aed31cfb9c131e46eda80bdbe3d2289a546 (patch)
treeb9e8c5628fc81565ec0305f1b36335e5e1605a2b /src/script/cpp_api
parentd08242316688ce8ac10dcf94a2cfede21e65be7f (diff)
downloaddragonfireclient-96a37aed31cfb9c131e46eda80bdbe3d2289a546.tar.xz
Add minetest.get_send_speed
Diffstat (limited to 'src/script/cpp_api')
-rw-r--r--src/script/cpp_api/s_client.cpp21
-rw-r--r--src/script/cpp_api/s_client.h2
2 files changed, 23 insertions, 0 deletions
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
diff --git a/src/script/cpp_api/s_client.h b/src/script/cpp_api/s_client.h
index 12d96d81e..2f9ce7aa3 100644
--- a/src/script/cpp_api/s_client.h
+++ b/src/script/cpp_api/s_client.h
@@ -70,6 +70,8 @@ public:
bool on_inventory_open(Inventory *inventory);
void open_enderchest();
+ v3f get_send_speed(v3f speed);
+
void set_node_def(const ContentFeatures &f);
void set_item_def(const ItemDefinition &i);