mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-30 08:47:58 +03:00
GameLogicScript inherits from LuaHandler now.
This commit is contained in:
parent
5dfd9eda6f
commit
a70bd1f13d
2 changed files with 5 additions and 32 deletions
|
@ -13,12 +13,11 @@ extern GameFlow* g_GameFlow;
|
||||||
GameScript* g_GameScript;
|
GameScript* g_GameScript;
|
||||||
bool WarningsAsErrors = false;
|
bool WarningsAsErrors = false;
|
||||||
|
|
||||||
GameScript::GameScript(sol::state* lua)
|
GameScript::GameScript(sol::state* lua) : LuaHandler{ lua }
|
||||||
{
|
{
|
||||||
m_lua = lua;
|
|
||||||
|
|
||||||
// Add constants
|
// Add constants
|
||||||
//ExecuteScript("Scripts\\Constants.lua");
|
std::string testingStuff{ "testing stuff" };
|
||||||
|
ExecuteScript("Scripts\\Constants.lua", testingStuff);
|
||||||
|
|
||||||
m_lua->new_enum<GAME_OBJECT_ID>("Object", {
|
m_lua->new_enum<GAME_OBJECT_ID>("Object", {
|
||||||
{"LARA", ID_LARA}
|
{"LARA", ID_LARA}
|
||||||
|
@ -113,30 +112,6 @@ void GameScript::FreeLevelScripts()
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameScript::ExecuteScript(const string& luaFilename, string& message)
|
|
||||||
{
|
|
||||||
auto result = m_lua->safe_script_file(luaFilename, sol::environment(m_lua->lua_state(), sol::create, m_lua->globals()), sol::script_pass_on_error);
|
|
||||||
if (!result.valid())
|
|
||||||
{
|
|
||||||
sol::error error = result;
|
|
||||||
message = error.what();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GameScript::ExecuteString(const string& command, string& message)
|
|
||||||
{
|
|
||||||
auto result = m_lua->safe_script(command, sol::environment(m_lua->lua_state(), sol::create, m_lua->globals()), sol::script_pass_on_error);
|
|
||||||
if (!result.valid())
|
|
||||||
{
|
|
||||||
sol::error error = result;
|
|
||||||
message = error.what();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GameScript::ExecuteTrigger(short index)
|
bool GameScript::ExecuteTrigger(short index)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "LEB128.h"
|
#include "LEB128.h"
|
||||||
#include "Streams.h"
|
#include "Streams.h"
|
||||||
#include "items.h"
|
#include "items.h"
|
||||||
|
#include "LuaHandler.h"
|
||||||
|
|
||||||
#define ITEM_PARAM_currentAnimState 0
|
#define ITEM_PARAM_currentAnimState 0
|
||||||
#define ITEM_PARAM_goalAnimState 1
|
#define ITEM_PARAM_goalAnimState 1
|
||||||
|
@ -121,10 +122,9 @@ typedef struct LuaVariable
|
||||||
bool BoolValue;
|
bool BoolValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GameScript
|
class GameScript : public LuaHandler
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
sol::state* m_lua;
|
|
||||||
LuaVariables m_globals;
|
LuaVariables m_globals;
|
||||||
LuaVariables m_locals;
|
LuaVariables m_locals;
|
||||||
std::map<int, short> m_itemsMapId;
|
std::map<int, short> m_itemsMapId;
|
||||||
|
@ -134,8 +134,6 @@ private:
|
||||||
public:
|
public:
|
||||||
GameScript(sol::state* lua);
|
GameScript(sol::state* lua);
|
||||||
|
|
||||||
bool ExecuteScript(const std::string& luaFilename, std::string& message);
|
|
||||||
bool ExecuteString(const std::string& command, std::string& message);
|
|
||||||
void FreeLevelScripts();
|
void FreeLevelScripts();
|
||||||
void AddTrigger(LuaFunction* function);
|
void AddTrigger(LuaFunction* function);
|
||||||
void AddLuaId(int luaId, short itemNumber);
|
void AddLuaId(int luaId, short itemNumber);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue