summaryrefslogtreecommitdiffstats
path: root/src/Bindings/ManualBindings.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-05-11 10:39:45 +0200
committerMattes D <github@xoft.cz>2015-05-11 10:39:45 +0200
commit7d66162e3c339e82d56e5144d466cab97eca82ab (patch)
tree5f3f1a00f704c7def6fc18b98c296e964f218815 /src/Bindings/ManualBindings.cpp
parentMerge pull request #1977 from mc-server/warnings (diff)
parentAPIDump: Added linkification to hook return values. (diff)
downloadcuberite-7d66162e3c339e82d56e5144d466cab97eca82ab.tar
cuberite-7d66162e3c339e82d56e5144d466cab97eca82ab.tar.gz
cuberite-7d66162e3c339e82d56e5144d466cab97eca82ab.tar.bz2
cuberite-7d66162e3c339e82d56e5144d466cab97eca82ab.tar.lz
cuberite-7d66162e3c339e82d56e5144d466cab97eca82ab.tar.xz
cuberite-7d66162e3c339e82d56e5144d466cab97eca82ab.tar.zst
cuberite-7d66162e3c339e82d56e5144d466cab97eca82ab.zip
Diffstat (limited to 'src/Bindings/ManualBindings.cpp')
-rw-r--r--src/Bindings/ManualBindings.cpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index 9b3c1555d..bfe280f51 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -5,6 +5,7 @@
#undef TOLUA_TEMPLATE_BIND
#include <sstream>
#include <iomanip>
+#include <array>
#include "tolua++/include/tolua++.h"
#include "polarssl/md5.h"
#include "polarssl/sha1.h"
@@ -33,9 +34,10 @@
#include "../CompositeChat.h"
#include "../StringCompression.h"
#include "../Broadcaster.h"
+#include "../CommandOutput.h"
+
-#include <array>
// Better error reporting for Lua
@@ -2000,6 +2002,40 @@ static int tolua_cPluginManager_CallPlugin(lua_State * tolua_S)
+static int tolua_cPluginManager_ExecuteConsoleCommand(lua_State * tolua_S)
+{
+ /*
+ Function signature:
+ cPluginManager:ExecuteConsoleCommand(EntireCommandStr) -> OutputString
+ */
+
+ // Check params:
+ cLuaState L(tolua_S);
+ if (
+ !L.CheckParamUserTable(1, "cPluginManager") ||
+ !L.CheckParamString(2) ||
+ !L.CheckParamEnd(3)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString Command;
+ L.GetStackValues(2, Command);
+ auto Split = StringSplit(Command, " ");
+
+ // Store the command output in a string:
+ cStringAccumCommandOutputCallback CommandOutput;
+ L.Push(cPluginManager::Get()->ExecuteConsoleCommand(Split, CommandOutput, Command));
+ L.Push(CommandOutput.GetAccum());
+ return 2;
+}
+
+
+
+
+
static int tolua_cPluginManager_FindPlugins(lua_State * tolua_S)
{
// API function no longer exists:
@@ -3906,6 +3942,7 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_function(tolua_S, "BindConsoleCommand", tolua_cPluginManager_BindConsoleCommand);
tolua_function(tolua_S, "CallPlugin", tolua_cPluginManager_CallPlugin);
tolua_function(tolua_S, "DoWithPlugin", tolua_StaticDoWith<cPluginManager, cPlugin, &cPluginManager::DoWithPlugin>);
+ tolua_function(tolua_S, "ExecuteConsoleCommand", tolua_cPluginManager_ExecuteConsoleCommand);
tolua_function(tolua_S, "FindPlugins", tolua_cPluginManager_FindPlugins);
tolua_function(tolua_S, "ForEachCommand", tolua_cPluginManager_ForEachCommand);
tolua_function(tolua_S, "ForEachConsoleCommand", tolua_cPluginManager_ForEachConsoleCommand);