diff options
| author | Ben Beltran <ben@nsovocal.com> | 2012-04-16 09:39:52 -0500 |
|---|---|---|
| committer | Ben Beltran <ben@nsovocal.com> | 2012-04-16 09:39:52 -0500 |
| commit | 10a0e290ac07524dc129cc2b227b0f9e95df0f8e (patch) | |
| tree | ed518c45c45d96e37e28640f745496fffb8e1325 /LuaScript.h | |
first commit
Diffstat (limited to 'LuaScript.h')
| -rw-r--r-- | LuaScript.h | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/LuaScript.h b/LuaScript.h new file mode 100644 index 0000000..96c588c --- /dev/null +++ b/LuaScript.h @@ -0,0 +1,67 @@ +// ---------------------------------------------------------------------------
+// FILE NAME : LuaScript.h
+// ---------------------------------------------------------------------------
+// DESCRIPTION :
+//
+// Scripting base class
+//
+// ---------------------------------------------------------------------------
+// VERSION : 1.00
+// DATE : 1-Sep-2005
+// AUTHOR : Richard Shephard
+// ---------------------------------------------------------------------------
+// LIBRARY INCLUDE FILES
+
+#ifndef __LUA_SCRIPT_BASE_H__
+#define __LUA_SCRIPT_BASE_H__
+
+#include "luainc.h"
+#include "luavirtualmachine.h"
+
+class CLuaScript
+{
+public:
+ CLuaScript (CLuaVirtualMachine& vm);
+ virtual ~CLuaScript (void);
+
+ // Compile script into Virtual Machine
+ bool CompileFile (const char *strFilename);
+ bool CompileBuffer (unsigned char *pbBuffer, size_t szLen);
+
+ // Register function with Lua
+ int RegisterFunction (const char *strFuncName);
+
+ // Selects a Lua Script function to call
+ bool SelectScriptFunction (const char *strFuncName);
+ void AddParam (int iInt);
+ void AddParam (float fFloat);
+ void AddParam (char *string);
+
+ // Runs the loaded script
+ bool Go (int nReturns = 0);
+
+ // Checks on Virtual Machine script
+ bool ScriptHasFunction (const char *strScriptName);
+
+ // Method indexing check
+ int methods (void) { return m_nMethods; }
+
+
+ // When the script calls a class method, this is called
+ virtual int ScriptCalling (CLuaVirtualMachine& vm, int iFunctionNumber) = 0;
+
+ // When the script function has returns
+ virtual void HandleReturns (CLuaVirtualMachine& vm, const char *strFunc) = 0;
+
+ CLuaVirtualMachine& vm (void) { return m_vm; }
+
+protected:
+ int m_nMethods;
+ CLuaVirtualMachine& m_vm;
+ int m_iThisRef;
+ int m_nArgs;
+ const char *m_strFunctionName;
+};
+
+
+#endif // __LUA_SCRIPT_BASE_H__
\ No newline at end of file |