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
|
|
|
|
2012-03-09 10:28:25 +00:00
|
|
|
#include "LuaManager.h"
|
2010-12-12 17:08:36 +00:00
|
|
|
|
|
|
|
class LuaScript
|
|
|
|
{
|
|
|
|
public:
|
2012-10-06 18:43:07 +00:00
|
|
|
LuaScript();
|
2011-07-06 10:21:18 +00:00
|
|
|
~LuaScript();
|
2012-10-06 18:43:07 +00:00
|
|
|
|
2012-10-06 19:03:29 +00:00
|
|
|
bool Initialize(const std::wstring& scriptFile);
|
2012-10-06 18:43:07 +00:00
|
|
|
void Uninitialize();
|
|
|
|
bool IsInitialized() { return m_Ref != LUA_NOREF; }
|
2012-10-06 19:03:29 +00:00
|
|
|
|
|
|
|
const std::wstring& GetFile() { return m_File; }
|
2013-08-06 17:43:57 +00:00
|
|
|
int GetRef() { return m_Ref; }
|
|
|
|
bool IsUnicode() const { return m_Unicode; }
|
|
|
|
|
|
|
|
lua_State* GetState() { return LuaManager::GetState(m_Unicode); }
|
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);
|
2013-08-06 17:43:57 +00:00
|
|
|
void RunString(const std::wstring& str);
|
2010-12-12 17:08:36 +00:00
|
|
|
|
|
|
|
protected:
|
2012-10-06 19:03:29 +00:00
|
|
|
std::wstring m_File;
|
2013-08-06 17:43:57 +00:00
|
|
|
int m_Ref;
|
|
|
|
bool m_Unicode;
|
2010-12-12 17:08:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|