K3dLua.h

Go to the documentation of this file.
00001 
00013 /***************************************************************************
00014  *   Copyright (C) 2007 by Jan Koci   *
00015  *   honza.koci@email.cz   *
00016  *   http://kengine.sourceforge.net/tutorial/
00017  *                                                                         *
00018  *   This program is free software; you can redistribute it and/or modify  *
00019  *   it under the terms of the GNU General Public License as published by  *
00020  *   the Free Software Foundation; either version 2 of the License, or     *
00021  *   (at your option) any later version.                                   *
00022  *                                                                         *
00023  *   This program is distributed in the hope that it will be useful,       *
00024  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00025  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00026  *   GNU General Public License for more details.                          *
00027  *                                                                         *
00028  *   You should have received a copy of the GNU General Public License     *
00029  *   along with this program; if not, write to the                         *
00030  *   Free Software Foundation, Inc.,                                       *
00031  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00032  ***************************************************************************/
00033 
00034 #pragma once
00035 
00036 extern "C"
00037 {
00038 #include <lua.h>
00039 #include <lualib.h>
00040 #include <lauxlib.h>
00041 
00042         // Need for Lua 5.1.1
00043 #include <luaconf.h>
00044 #include <lua.hpp>
00045 }
00046 
00047 
00048 #include <iostream>
00049 using namespace std;
00050 #include "../System/K3dString.h"
00051 #include "../System/GameData/K3dGameData.h"
00052 
00053 class K3dLua
00054 {
00055                 K3dGameData *m_pGameData;       
00056                 lua_State *m_pLua;                      
00057                 lua_Debug *m_pLuaDebug;         
00058                 //lua_State *m_pLuaThread;      ///< Lua thread
00059 
00060                 void StackDump();
00061 
00062         public:
00063                 K3dLua ( K3dGameData *_pGameData );
00064                 ~K3dLua();
00065 
00066                 void InitLua();
00067                 void DeleteLua();
00068                 void ResetLua();
00069                 bool LuaLoadFile ( const char *_strFilename );
00070                 int LuaPCall ( const int _iNumArgs,const int _iNumResults,const int _iErrFunc );
00071                 void LuaError ( const char *_strFmt, ... );
00072                 void LuaRegister ( const char *_strName, lua_CFunction _f );
00073                 const char *LuaToString ( const int _id );
00074                 double LuaToNumber ( const int _id );
00075                 int LuaToBoolean ( const int _id );
00076                 void LuaGetGlobal ( const char *_strVarName );
00077                 int LuaIsNumber ( const int _id );
00078                 int LuaIsBoolean ( const int _id );
00079                 int LuaIsString ( const int _id );
00080                 void LuaPushString ( const char *_strKey );
00081                 void LuaPop ( const int _id );
00082                 void LuaGetTable ( const int _id );
00083                 double LuaGetFieldNumber ( const char * _strKey );
00084                 bool LuaGetFieldBool ( const char * _strKey );
00085                 const char *LuaGetFieldString ( const char * _strKey );
00086                 int LuaIsTable ( const int _id );
00087                 bool LuaCheckStack ( const int _iNum );
00088                 bool LuaCheckStack ( lua_State *_pState, const int _iNum );
00089 
00090                 lua_State *GetLuaState()
00091                 {
00092                         return m_pLua;
00093                 }
00094 };

Generated on Thu Aug 16 23:53:27 2007 for K3dEngine by  doxygen 1.5.0