mirror of
https://github.com/ApfelTeeSaft/gameBase.git
synced 2026-08-26 19:23:30 +00:00
generating sol views from one static lua state
This commit is contained in:
+1
-1
@@ -7,7 +7,7 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
set(states abstractAppState.cpp)
|
||||
set(core inputManager.cpp mapping.h stateManager.cpp)
|
||||
set(util util.cpp)
|
||||
set(util solUtil.cpp util.cpp)
|
||||
|
||||
set(LIB_NAME gameBase)
|
||||
add_library(${LIB_NAME} STATIC ${states} ${core} ${util})
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <sol/sol.hpp>
|
||||
|
||||
#include "abstractAppState.h"
|
||||
#include "util.h"
|
||||
#include "solUtil.h"
|
||||
#include "mapping.h"
|
||||
|
||||
namespace gameBase {
|
||||
@@ -16,6 +17,7 @@ namespace gameBase {
|
||||
void AbstractAppState::onAttached(){
|
||||
attached = true;
|
||||
|
||||
sol::state_view SOL_LUA_STATE = generateView();
|
||||
SOL_LUA_STATE.script_file(optionsFile);
|
||||
string table = "mappings";
|
||||
|
||||
|
||||
@@ -2,10 +2,15 @@
|
||||
#define ABSTRACT_APP_STATE_H
|
||||
|
||||
#include "mapping.h"
|
||||
#include "solUtil.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace sol{
|
||||
class state;
|
||||
}
|
||||
|
||||
namespace gameBase {
|
||||
class AbstractAppState{
|
||||
public:
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#include "solUtil.h"
|
||||
|
||||
namespace gameBase{
|
||||
static lua_State *state = nullptr;
|
||||
|
||||
sol::state_view generateView(){
|
||||
if(!state){
|
||||
state = luaL_newstate();
|
||||
luaL_openlibs(state);
|
||||
}
|
||||
|
||||
sol::state_view view(state);
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user