]> git.r.bdr.sh - rbdr/pico-engine/blob - LuaScript.h
96c588c54b2acd231ec51cc7af175ea5f8db44aa
[rbdr/pico-engine] / LuaScript.h
1 // ---------------------------------------------------------------------------
2 // FILE NAME : LuaScript.h
3 // ---------------------------------------------------------------------------
4 // DESCRIPTION :
5 //
6 // Scripting base class
7 //
8 // ---------------------------------------------------------------------------
9 // VERSION : 1.00
10 // DATE : 1-Sep-2005
11 // AUTHOR : Richard Shephard
12 // ---------------------------------------------------------------------------
13 // LIBRARY INCLUDE FILES
14
15 #ifndef __LUA_SCRIPT_BASE_H__
16 #define __LUA_SCRIPT_BASE_H__
17
18 #include "luainc.h"
19 #include "luavirtualmachine.h"
20
21 class CLuaScript
22 {
23 public:
24 CLuaScript (CLuaVirtualMachine& vm);
25 virtual ~CLuaScript (void);
26
27 // Compile script into Virtual Machine
28 bool CompileFile (const char *strFilename);
29 bool CompileBuffer (unsigned char *pbBuffer, size_t szLen);
30
31 // Register function with Lua
32 int RegisterFunction (const char *strFuncName);
33
34 // Selects a Lua Script function to call
35 bool SelectScriptFunction (const char *strFuncName);
36 void AddParam (int iInt);
37 void AddParam (float fFloat);
38 void AddParam (char *string);
39
40 // Runs the loaded script
41 bool Go (int nReturns = 0);
42
43 // Checks on Virtual Machine script
44 bool ScriptHasFunction (const char *strScriptName);
45
46 // Method indexing check
47 int methods (void) { return m_nMethods; }
48
49
50 // When the script calls a class method, this is called
51 virtual int ScriptCalling (CLuaVirtualMachine& vm, int iFunctionNumber) = 0;
52
53 // When the script function has returns
54 virtual void HandleReturns (CLuaVirtualMachine& vm, const char *strFunc) = 0;
55
56 CLuaVirtualMachine& vm (void) { return m_vm; }
57
58 protected:
59 int m_nMethods;
60 CLuaVirtualMachine& m_vm;
61 int m_iThisRef;
62 int m_nArgs;
63 const char *m_strFunctionName;
64 };
65
66
67 #endif // __LUA_SCRIPT_BASE_H__