1 | /* * ORXONOX - the hottest 3D action shooter ever to exist * > www.orxonox.net < * * * License notice: * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Author: * Benjamin Knecht * Co-authors: * ... * *//** |
---|
2 | @file script.h |
---|
3 | @brief Representation of an interface to lua |
---|
4 | @author Benjamin Knecht <beni_at_orxonox.net> |
---|
5 | */ |
---|
6 | |
---|
7 | #ifndef _Script_H__ |
---|
8 | #define _Script_H__ |
---|
9 | |
---|
10 | #include "CorePrereqs.h" |
---|
11 | |
---|
12 | extern "C" { |
---|
13 | #include <lua.h> |
---|
14 | } |
---|
15 | |
---|
16 | #include <list> |
---|
17 | #include <string> |
---|
18 | |
---|
19 | namespace orxonox // tolua_export |
---|
20 | { // tolua_export |
---|
21 | |
---|
22 | class Script // tolua_export |
---|
23 | { // tolua_export |
---|
24 | public: |
---|
25 | inline static Script* getInstance() { if (!Script::singletonRef) Script::singletonRef = new Script(); return Script::singletonRef; } // tolua_export |
---|
26 | inline ~Script() { Script::singletonRef = NULL; }; |
---|
27 | |
---|
28 | void loadFile(std::string filename, bool luaTags); |
---|
29 | //void init(lua_State *state_); |
---|
30 | //void xmlToLua(); |
---|
31 | void run(); |
---|
32 | void luaPrint(std::string str); // tolua_export |
---|
33 | |
---|
34 | #if LUA_VERSION_NUM != 501 |
---|
35 | inline static const char * lua_Chunkreader(lua_State *L, void *data, size_t *size) { return NULL;}; |
---|
36 | #endif |
---|
37 | |
---|
38 | inline lua_State* getLuaState() { return luaState_; }; |
---|
39 | inline std::string getLuaOutput() { return output_; }; |
---|
40 | //inline std::string* getFileString() { return &fileString_; }; |
---|
41 | |
---|
42 | unsigned int getNextQuote(const std::string& text, unsigned int start); |
---|
43 | std::string replaceLuaTags(const std::string& text); |
---|
44 | |
---|
45 | private: |
---|
46 | Script(); |
---|
47 | static Script* singletonRef; |
---|
48 | |
---|
49 | std::string luaSource_; |
---|
50 | std::string output_; |
---|
51 | lua_State* luaState_; |
---|
52 | |
---|
53 | }; // tolua_export |
---|
54 | } // tolua_export |
---|
55 | #endif /* _Script_H__ */ |
---|