summaryrefslogtreecommitdiffstats
path: root/source/Plugin_NewLua.h
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-02-01 20:55:42 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-02-01 20:55:42 +0100
commit019c8b5bc71708e2d895a95757643406f75b4149 (patch)
tree47c5e399e562384a255d5d789d761d8857dff6af /source/Plugin_NewLua.h
parentRenamed HOOK_KILLED to HOOK_KILLING to match naming conventions. (diff)
downloadcuberite-019c8b5bc71708e2d895a95757643406f75b4149.tar
cuberite-019c8b5bc71708e2d895a95757643406f75b4149.tar.gz
cuberite-019c8b5bc71708e2d895a95757643406f75b4149.tar.bz2
cuberite-019c8b5bc71708e2d895a95757643406f75b4149.tar.lz
cuberite-019c8b5bc71708e2d895a95757643406f75b4149.tar.xz
cuberite-019c8b5bc71708e2d895a95757643406f75b4149.tar.zst
cuberite-019c8b5bc71708e2d895a95757643406f75b4149.zip
Diffstat (limited to '')
-rw-r--r--source/Plugin_NewLua.h22
1 files changed, 18 insertions, 4 deletions
diff --git a/source/Plugin_NewLua.h b/source/Plugin_NewLua.h
index 87b30b26d..604bcde93 100644
--- a/source/Plugin_NewLua.h
+++ b/source/Plugin_NewLua.h
@@ -4,6 +4,9 @@
#include "Plugin.h"
#include "WebPlugin.h"
+// Names for the global variables through which the plugin is identified in its LuaState
+#define LUA_PLUGIN_NAME_VAR_NAME "_MCServerInternal_PluginName"
+#define LUA_PLUGIN_INSTANCE_VAR_NAME "_MCServerInternal_PluginInstance"
@@ -63,6 +66,10 @@ public:
virtual bool OnUpdatingSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4, cPlayer * a_Player) override;
virtual bool OnWeatherChanged (cWorld * a_World) override;
+ virtual bool HandleCommand(const AStringVector & a_Split, cPlayer * a_Player) override;
+
+ virtual void ClearCommands(void) override;
+
virtual bool CanAddHook(cPluginManager::PluginHook a_Hook) override;
// cWebPlugin override
@@ -71,21 +78,28 @@ public:
// cWebPlugin and WebAdmin stuff
virtual AString HandleWebRequest( HTTPRequest * a_Request ) override;
bool AddWebTab(const AString & a_Title, lua_State * a_LuaState, int a_FunctionReference); // >> EXPORTED IN MANUALBINDINGS <<
+
+ /// Binds the command to call the function specified by a Lua function reference. Simply adds to CommandMap.
+ void BindCommand(const AString & a_Command, int a_FnRef);
lua_State* GetLuaState() { return m_LuaState; }
cCriticalSection & GetCriticalSection() { return m_CriticalSection; }
protected:
+ cCriticalSection m_CriticalSection;
+ lua_State * m_LuaState;
+
+ /// Maps command name into Lua function reference
+ typedef std::map<AString, int> CommandMap;
+
+ CommandMap m_Commands;
+
bool PushFunction(const char * a_FunctionName, bool a_bLogError = true);
bool CallFunction(int a_NumArgs, int a_NumResults, const char * a_FunctionName ); // a_FunctionName is only used for error messages, nothing else
/// Returns the name of Lua function that should handle the specified hook
const char * GetHookFnName(cPluginManager::PluginHook a_Hook);
-
- cCriticalSection m_CriticalSection;
-
- lua_State * m_LuaState;
} ; // tolua_export