2011-07-06 10:21:18 +00:00
|
|
|
/*
|
2012-01-23 06:36:15 +00:00
|
|
|
Copyright (C) 2010 Matt King, Birunthan Mohanathas
|
|
|
|
|
2011-07-06 10:21:18 +00:00
|
|
|
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.
|
2010-12-12 17:08:36 +00:00
|
|
|
|
2011-07-06 10:21:18 +00:00
|
|
|
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
|
2012-01-23 06:36:15 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2011-07-06 10:21:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __LUASCRIPT_H__
|
|
|
|
#define __LUASCRIPT_H__
|
2010-12-12 17:08:36 +00:00
|
|
|
|
|
|
|
#include "lua.hpp"
|
|
|
|
|
|
|
|
class LuaScript
|
|
|
|
{
|
|
|
|
public:
|
2011-07-06 10:21:18 +00:00
|
|
|
LuaScript(lua_State* state, const char* file);
|
|
|
|
~LuaScript();
|
2010-12-12 17:08:36 +00:00
|
|
|
|
2011-07-06 10:21:18 +00:00
|
|
|
bool IsInitialized() { return m_Initialized; }
|
2010-12-12 17:08:36 +00:00
|
|
|
|
2011-07-06 10:21:18 +00:00
|
|
|
lua_State* GetState() { return m_State; }
|
|
|
|
void PushTable() { lua_rawgeti(m_State, LUA_GLOBALSINDEX, m_iRef); }
|
2010-12-12 17:08:36 +00:00
|
|
|
|
2011-07-06 10:21:18 +00:00
|
|
|
bool IsFunction(const char* funcName);
|
|
|
|
void RunFunction(const char* funcName);
|
2011-08-01 09:08:11 +00:00
|
|
|
int RunFunctionWithReturn(const char* funcName, double& numValue, std::wstring& strValue);
|
2011-07-09 09:23:28 +00:00
|
|
|
void RunString(const char* str);
|
2010-12-12 17:08:36 +00:00
|
|
|
|
|
|
|
protected:
|
2011-07-06 10:21:18 +00:00
|
|
|
lua_State* m_State;
|
2010-12-12 17:08:36 +00:00
|
|
|
|
2011-02-10 08:48:04 +00:00
|
|
|
int m_iRef;
|
2011-07-06 10:21:18 +00:00
|
|
|
bool m_Initialized;
|
2010-12-12 17:08:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|