summaryrefslogtreecommitdiffstats
path: root/src/Bindings/ManualBindings.cpp
diff options
context:
space:
mode:
authornshah25 <68348722+nshah25@users.noreply.github.com>2021-05-03 22:07:09 +0200
committerGitHub <noreply@github.com>2021-05-03 22:07:09 +0200
commit8be1dd54bb17b3ba3e20960aa3c3f696d09facf7 (patch)
tree334cf9a2c9f781816f8278c933d66a71bf5c7d88 /src/Bindings/ManualBindings.cpp
parentStyle: specify include relativity (#5217) (diff)
downloadcuberite-8be1dd54bb17b3ba3e20960aa3c3f696d09facf7.tar
cuberite-8be1dd54bb17b3ba3e20960aa3c3f696d09facf7.tar.gz
cuberite-8be1dd54bb17b3ba3e20960aa3c3f696d09facf7.tar.bz2
cuberite-8be1dd54bb17b3ba3e20960aa3c3f696d09facf7.tar.lz
cuberite-8be1dd54bb17b3ba3e20960aa3c3f696d09facf7.tar.xz
cuberite-8be1dd54bb17b3ba3e20960aa3c3f696d09facf7.tar.zst
cuberite-8be1dd54bb17b3ba3e20960aa3c3f696d09facf7.zip
Diffstat (limited to '')
-rw-r--r--src/Bindings/ManualBindings.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index cd5e69b22..f06f4da37 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -4348,6 +4348,69 @@ static int tolua_cEntity_GetSpeed(lua_State * tolua_S)
+static int tolua_get_StatisticsManager_Custom(lua_State * tolua_S)
+{
+ // Check the params:
+ cLuaState L(tolua_S);
+ if (!L.CheckParamNumber(2))
+ {
+ return 0;
+ }
+
+ // Get the params:
+ lua_pushstring(tolua_S, ".self");
+ lua_rawget(tolua_S, 1);
+ StatisticsManager * Self = static_cast<StatisticsManager *>(lua_touserdata(tolua_S, -1));
+ CustomStatistic Statistic;
+ if (!L.GetStackValue(2, Statistic))
+ {
+ return L.ApiParamError("Expected a valid custom statistic ID");
+ }
+
+ // Push result if statistic exists:
+ if (const auto Result = Self->Custom.find(Statistic); Result != Self->Custom.end())
+ {
+ L.Push(Result->second);
+ return 1;
+ }
+
+ return 0;
+}
+
+
+
+
+
+static int tolua_set_StatisticsManager_Custom(lua_State * tolua_S)
+{
+ // Check the params:
+ cLuaState L(tolua_S);
+ if (!L.CheckParamNumber(2))
+ {
+ return 0;
+ }
+
+ // Get the params:
+ lua_pushstring(tolua_S, ".self");
+ lua_rawget(tolua_S, 1);
+ StatisticsManager * Self = static_cast<StatisticsManager *>(lua_touserdata(tolua_S, -1));
+ CustomStatistic Statistic;
+ StatisticsManager::StatValue Value;
+ if (!L.GetStackValues(2, Statistic, Value))
+ {
+ return L.ApiParamError("Expected a valid custom statistic ID and value");
+ }
+
+ // Set the value:
+ Self->Custom[Statistic] = Value;
+
+ return 0;
+}
+
+
+
+
+
void cManualBindings::Bind(lua_State * tolua_S)
{
tolua_beginmodule(tolua_S, nullptr);
@@ -4357,10 +4420,12 @@ void cManualBindings::Bind(lua_State * tolua_S)
tolua_usertype(tolua_S, "cLineBlockTracer");
tolua_usertype(tolua_S, "cStringCompression");
tolua_usertype(tolua_S, "cUrlParser");
+ // StatisticsManager was already created by cPlayer::GetStatistics' autogenerated bindings.
tolua_cclass(tolua_S, "cCryptoHash", "cCryptoHash", "", nullptr);
tolua_cclass(tolua_S, "cLineBlockTracer", "cLineBlockTracer", "", nullptr);
tolua_cclass(tolua_S, "cStringCompression", "cStringCompression", "", nullptr);
tolua_cclass(tolua_S, "cUrlParser", "cUrlParser", "", nullptr);
+ tolua_cclass(tolua_S, "StatisticsManager", "StatisticsManager", "", nullptr);
// Globals:
tolua_function(tolua_S, "Clamp", tolua_Clamp);
@@ -4592,6 +4657,10 @@ void cManualBindings::Bind(lua_State * tolua_S)
tolua_variable(tolua_S, "PostParams", tolua_get_HTTPRequest_PostParams, nullptr);
tolua_endmodule(tolua_S);
+ tolua_beginmodule(tolua_S, "StatisticsManager");
+ tolua_array(tolua_S, "Custom", tolua_get_StatisticsManager_Custom, tolua_set_StatisticsManager_Custom);
+ tolua_endmodule(tolua_S);
+
BindNetwork(tolua_S);
BindRankManager(tolua_S);
BindWorld(tolua_S);