]>
git.r.bdr.sh - rbdr/pico-engine/blob - LuaScript.h
96c588c54b2acd231ec51cc7af175ea5f8db44aa
1 // ---------------------------------------------------------------------------
2 // FILE NAME : LuaScript.h
3 // ---------------------------------------------------------------------------
6 // Scripting base class
8 // ---------------------------------------------------------------------------
11 // AUTHOR : Richard Shephard
12 // ---------------------------------------------------------------------------
13 // LIBRARY INCLUDE FILES
15 #ifndef __LUA_SCRIPT_BASE_H__
16 #define __LUA_SCRIPT_BASE_H__
19 #include "luavirtualmachine.h"
24 CLuaScript (CLuaVirtualMachine
& vm
);
25 virtual ~CLuaScript (void);
27 // Compile script into Virtual Machine
28 bool CompileFile (const char *strFilename
);
29 bool CompileBuffer (unsigned char *pbBuffer
, size_t szLen
);
31 // Register function with Lua
32 int RegisterFunction (const char *strFuncName
);
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
);
40 // Runs the loaded script
41 bool Go (int nReturns
= 0);
43 // Checks on Virtual Machine script
44 bool ScriptHasFunction (const char *strScriptName
);
46 // Method indexing check
47 int methods (void) { return m_nMethods
; }
50 // When the script calls a class method, this is called
51 virtual int ScriptCalling (CLuaVirtualMachine
& vm
, int iFunctionNumber
) = 0;
53 // When the script function has returns
54 virtual void HandleReturns (CLuaVirtualMachine
& vm
, const char *strFunc
) = 0;
56 CLuaVirtualMachine
& vm (void) { return m_vm
; }
60 CLuaVirtualMachine
& m_vm
;
63 const char *m_strFunctionName
;
67 #endif // __LUA_SCRIPT_BASE_H__