Bladeren bron

Luajit and Liabind dependencies removed. Compiles, runtime error with luabind.

Iñigo Valentin 3 jaren geleden
bovenliggende
commit
21db808d72

+ 8 - 8
CMakeLists.txt

@@ -17,6 +17,8 @@ set(VGears_VERSION__MINOR 1)
 set(VGears_VERSION__PATCH 1)
 set(VGears_VERSION ${VGears_VERSION__MAJOR}.${VGears_VERSION__MINOR}.${VGears_VERSION__PATCH})
 
+add_definitions(-DBOOST_BIND_GLOBAL_PLACEHOLDERS)
+
 # Generate version header.
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h) 
 
@@ -184,11 +186,11 @@ set(VGears_INCLUDE_DIRS
     ${CMAKE_CURRENT_SOURCE_DIR}/src/
     ${OIS_INCLUDE_DIRS}
     ${OGRE_Overlay_INCLUDE_DIRS}
-    ${CMAKE_CURRENT_SOURCE_DIR}/lib
-    ${CMAKE_CURRENT_BINARY_DIR}/lib/luajit
-    ${CMAKE_CURRENT_SOURCE_DIR}/lib/luajit/src
-    ${CMAKE_CURRENT_SOURCE_DIR}/lib/luabind
-    ${CMAKE_CURRENT_SOURCE_DIR}/lib/luabind/luabind/detail
+    #${CMAKE_CURRENT_SOURCE_DIR}/lib
+    #${CMAKE_CURRENT_BINARY_DIR}/lib/luajit
+    #${CMAKE_CURRENT_SOURCE_DIR}/lib/luajit/src
+    #${CMAKE_CURRENT_SOURCE_DIR}/lib/luabind
+    #${CMAKE_CURRENT_SOURCE_DIR}/lib/luabind/luabind/detail
 )
 
 if (MSVC)
@@ -211,7 +213,7 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") # Position Independent Code, req
 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -rdynamic -O0")
 
 add_definitions(-DTIXML_USE_STL)
-add_subdirectory(lib)
+#add_subdirectory(lib)
 add_subdirectory(src)
 
 if(VGears_BUILD_PLUGINS)
@@ -370,7 +372,5 @@ elseif(UNIX)
     #SET(CPACK_RPM_PACKAGE_REQUIRES "ogre,ois,boost,vorbis,lua,zlib1g")
 endif()
 
-SET_PROPERTY(TARGET LuaBind PROPERTY FOLDER "3rdparty")
-
 INCLUDE(CPack)
 #End of install instructions

+ 6 - 2
data/data/scripts/save.lua

@@ -14,7 +14,10 @@ end
 -- @param force If false, exisiting game data will not be overwritten if control keys are different.
 save_game = function(slot, force)
     savemap_manager:set_control_key(ControlKey)
-    savemap_manager:set_window_colours(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) -- TODO Actual data
+    savemap_manager:set_window_colour(0, 10, 10, 50) -- TODO Actual data
+    savemap_manager:set_window_colour(1, 15, 15, 75) -- TODO Actual data
+    savemap_manager:set_window_colour(2, 20, 20, 100) -- TODO Actual data
+    savemap_manager:set_window_colour(3, 15, 15, 75) -- TODO Actual data
     savemap_manager:set_money(Inventory.money)
     savemap_manager:set_game_time(123456) -- TODO Actual data
     savemap_manager:set_countdown_time(0) -- TODO Actual data
@@ -50,7 +53,8 @@ save_game = function(slot, force)
     for i = 0, 11 do
         if Characters[i] ~= nil and Characters[i].char_id ~= nil then
             local c = Characters[i]
-            savemap_manager:set_character_info(i, c.char_id, c.name, c.enabled, c.locked, c.level, c.kills, c.back_row, c.exp, c.exp_to_next, c.limit.current, c.limit.bar, c.weapon.id, c.armor.id, c.accessory or -1)
+            savemap_manager:set_character_info_1(i, c.char_id, c.name, c.enabled, c.locked, c.level, c.kills, c.back_row)
+            savemap_manager:set_character_info_2(i, c.exp, c.exp_to_next, c.limit.current, c.limit.bar, c.weapon.id, c.armor.id, c.accessory or -1)
             savemap_manager:set_character_stat(i, 0, c.stats.str.base, c.stats.str.bonus)
             savemap_manager:set_character_stat(i, 1, c.stats.vit.base, c.stats.vit.bonus)
             savemap_manager:set_character_stat(i, 2, c.stats.mag.base, c.stats.mag.bonus)

+ 18 - 3
src/CMakeLists.txt

@@ -309,14 +309,25 @@ set(SOURCE_FILES
     FF7Common.cpp
 )
 
+# Maximum number of parameters in functions bind to Lua.
+# Some of them have quite many of them, so keep it high.
+#add_definitions(-DLUABIND_MAX_ARITY=32)
+
 # Find LibOIS. TODO: Find it.
 set(ois_lib "/usr/lib/x86_64-linux-gnu/libOIS.so")
 
+set(luabind_lib "/usr/lib/x86_64-linux-gnu/libluabind.so")
+#set(luabind_lib "/usr/lib/x86_64-linux-gnu/liblua5.1.so")
+set(luajit_lib "/usr/lib/x86_64-linux-gnu/libluajit-5.1.a")
+set(lua_lib "/usr/lib/x86_64-linux-gnu/liblua5.2.so")
+
 # TODO: Find OIS
 include_directories(
     ${VGears_INCLUDE_DIRS}
     ${CMAKE_CURRENT_SOURCE_DIR}/include
     /usr/include/OIS/
+    /usr/include/luabind/
+    /usr/include/luajit-2.1/
 )
 
 # Compiler options
@@ -388,10 +399,13 @@ endif()
 
 target_link_libraries(V-Gears 
     ${VGears_LIBRARIES}
-    LuaBind
-    liblua
+    #${lua_lib}
+    luabind
+    #lua
     tinyxml
     ${ois_lib}
+    ${luabind_lib}
+    ${luajit_lib}
 )
 
 target_link_libraries(v-gears 
@@ -399,6 +413,7 @@ target_link_libraries(v-gears
     ${Boost_LIBRARIES}
     v-gears-data
     ${ois_lib}
+    ${luabind_lib}
 )
 
 target_link_libraries(v-gears-data
@@ -410,4 +425,4 @@ if(WIN32 OR APPLE)
     install(TARGETS v-gears DESTINATION .)
 else()
     install(TARGETS v-gears RUNTIME DESTINATION ./games)
-endif()
+endif()

+ 19 - 4
src/LuaIncludes.h

@@ -30,12 +30,27 @@
 #undef check
 #endif
 
-#include <luabind/luabind.hpp>
-#include <luabind/yield_policy.hpp>
+#define LUABIND_USE_CXX11
+#define LUABIND_DYNAMIC_LINK
+
+// Max number of arguments in functions bind to Lua.
+// Some of them have quite many, so keep it high.
+//#ifndef LUABIND_MAX_ARITY
+//    #define LUABIND_MAX_ARITY 16
+//#define BOOST_PARAMETER_MAX_ARITY 24
+//#else
+//    #undef LUABIND_MAX_ARITY
+//    #define LUABIND_MAX_ARITY 32
+//#endif
 
 extern "C"{
     #include "lua.h"
-    #include <lualib.h>
-    #include <lauxlib.h>
+    #include "lualib.h"
+    #include "lauxlib.h"
 }
 
+#include <luabind/luabind.hpp>
+#include <luabind/operator.hpp>
+#include <luabind/function.hpp>
+#include <luabind/class.hpp>
+#include <luabind/yield_policy.hpp>

+ 1 - 1
src/core/AudioManager.cpp

@@ -289,7 +289,7 @@ void AudioManager::Player::Stop(){
     // Delete source
     alDeleteSources(1, &source_);
     // Cleanup
-    ov_clear(&vorbis_file_);
+    //ov_clear(&vorbis_file_);
     stream_finished_ = false;
     file_ = "";
 }

+ 21 - 40
src/core/Savemap.cpp

@@ -140,40 +140,16 @@ void Savemap::SetControlKey(const std::string control){
     empty_ = false;
 }
 
-/**
- * Sets the window colours in the current savemap.
- *
- * @param[in] t_l_r Top-left corner, red component.
- * @param[in] t_l_r Top-left corner, green component.
- * @param[in] t_l_r Top-left corner, blue component.
- * @param[in] t_r_r Top-right corner, red component.
- * @param[in] t_r_r Top-right corner, green component.
- * @param[in] t_r_r Top-right corner, blue component.
- * @param[in] b_r_r Bottom-right corner, red component.
- * @param[in] b_r_r Bottom-right corner, green component.
- * @param[in] b_r_r Bottom-right corner, blue component.
- * @param[in] b_l_r Bottom-left corner, red component.
- * @param[in] b_l_r Bottom-left corner, green component.
- * @param[in] b_l_r Bottom-left corner, blue component.
- */
-void Savemap::SetWindowColours(
-  const unsigned int t_l_r, const unsigned int t_l_g, const unsigned int t_l_b,
-  const unsigned int t_r_r, const unsigned int t_r_g, const unsigned int t_r_b,
-  const unsigned int b_r_r, const unsigned int b_r_g, const unsigned int b_r_b,
-  const unsigned int b_l_r, const unsigned int b_l_g, const unsigned int b_l_b
+
+void Savemap::SetWindowColour(
+  const unsigned int corner,
+  const unsigned int red, const unsigned int green, const unsigned int blue
 ){
-    window_colours_[0][0] = std::min(MAX_COLOUR, t_l_r);
-    window_colours_[0][1] = std::min(MAX_COLOUR, t_l_g);
-    window_colours_[0][2] = std::min(MAX_COLOUR, t_l_b);
-    window_colours_[1][0] = std::min(MAX_COLOUR, t_r_r);
-    window_colours_[1][1] = std::min(MAX_COLOUR, t_r_g);
-    window_colours_[1][2] = std::min(MAX_COLOUR, t_r_b);
-    window_colours_[2][0] = std::min(MAX_COLOUR, b_r_r);
-    window_colours_[2][1] = std::min(MAX_COLOUR, b_r_g);
-    window_colours_[2][2] = std::min(MAX_COLOUR, b_r_b);
-    window_colours_[3][0] = std::min(MAX_COLOUR, b_l_r);
-    window_colours_[3][1] = std::min(MAX_COLOUR, b_l_g);
-    window_colours_[3][2] = std::min(MAX_COLOUR, b_l_b);
+    if (corner <= 3){
+        window_colours_[corner][0] = std::min(MAX_COLOUR, red);
+        window_colours_[corner][1] = std::min(MAX_COLOUR, green);
+        window_colours_[corner][2] = std::min(MAX_COLOUR, blue);
+    }
 }
 
 std::string Savemap::GetControlKey() const {return control_;}
@@ -258,13 +234,9 @@ void Savemap::SetSetting(const unsigned int key, const unsigned int value){
     // TODO : Implements when settings are working.
 }
 
-void Savemap::SetCharacterInfo(
-  const unsigned int id, const int char_id, const std::string name,
-  const bool enabled, const bool locked,
-  const unsigned int level, const unsigned int kills,
-  const bool back_row, const unsigned int exp, const unsigned int exp_to_next,
-  const unsigned int limit_level, const unsigned int limit_bar,
-  const unsigned int weapon, const unsigned int armor, const int accessory
+void Savemap::SetCharacterInfo1(
+  const unsigned int id, const int char_id, const std::string name, const bool enabled,
+  const bool locked, const unsigned int level, const unsigned int kills, const bool back_row
 ){
     if (id < MAX_CHARACTERS){
         characters_[id].id = id;
@@ -275,6 +247,15 @@ void Savemap::SetCharacterInfo(
         characters_[id].level = level;
         characters_[id].kills = kills;
         characters_[id].back_row = back_row;
+    }
+}
+
+void Savemap::SetCharacterInfo2(
+  const unsigned int id, const unsigned int exp, const unsigned int exp_to_next,
+  const unsigned int limit_level, const unsigned int limit_bar,
+  const unsigned int weapon, const unsigned int armor, const int accessory
+){
+    if (id < MAX_CHARACTERS){
         characters_[id].exp = exp;
         characters_[id].exp_to_next = exp_to_next;
         characters_[id].limit_level = std::min(limit_level, MAX_LIMIT_LEVELS);

+ 31 - 25
src/core/Savemap.h

@@ -75,26 +75,17 @@ class Savemap{
         void SetControlKey(const std::string control);
 
         /**
-         * Sets the window colours in the current savemap.
-         *
-         * @param[in] t_l_r Top-left corner, red component.
-         * @param[in] t_l_r Top-left corner, green component.
-         * @param[in] t_l_r Top-left corner, blue component.
-         * @param[in] t_r_r Top-right corner, red component.
-         * @param[in] t_r_r Top-right corner, green component.
-         * @param[in] t_r_r Top-right corner, blue component.
-         * @param[in] b_r_r Bottom-right corner, red component.
-         * @param[in] b_r_r Bottom-right corner, green component.
-         * @param[in] b_r_r Bottom-right corner, blue component.
-         * @param[in] b_l_r Bottom-left corner, red component.
-         * @param[in] b_l_r Bottom-left corner, green component.
-         * @param[in] b_l_r Bottom-left corner, blue component.
-         */
-        void SetWindowColours(
-          const unsigned int t_l_r, const unsigned int t_l_g, const unsigned int t_l_b,
-          const unsigned int t_r_r, const unsigned int t_r_g, const unsigned int t_r_b,
-          const unsigned int b_r_r, const unsigned int b_r_g, const unsigned int b_r_b,
-          const unsigned int b_l_r, const unsigned int b_l_g, const unsigned int b_l_b
+         * Sets a window corner colour in the savemap.
+         *
+         * @param[in] corner The window corner. 0: Top left, 1: Top right, 2: Bottom right, 3:
+         * bottom left.
+         * @param[in] red Red component.
+         * @param[in] green Green component.
+         * @param[in] blue Blue component.
+         */
+        void SetWindowColour(
+          const unsigned int corner,
+          const unsigned int red, const unsigned int green, const unsigned int blue
         );
 
         /**
@@ -220,6 +211,10 @@ class Savemap{
         /**
          * Sets a character basic information in the savemap.
          *
+         * This must be called immediately before {@see SetCharacterInfo2}. In fact, the only
+         * reason they are separated functions if for the limitation of 10 parameters per function
+         * imposed by Luabind (imposed, in turn, by Boost).
+         *
          * @param[in] id Character ID.
          * @param[in] char_id Character identifier.
          * @param[in] name Character name.
@@ -228,6 +223,20 @@ class Savemap{
          * @param[in] level Character level.
          * @param[in] kills Total kills.
          * @param[in] back_row If the character is in the back row.
+         */
+        void SetCharacterInfo1(
+          const unsigned int id, const int char_id, const std::string name, const bool enabled,
+          const bool locked, const unsigned int level, const unsigned int kills, const bool back_row
+        );
+
+        /**
+         * Sets a character basic information in the savemap.
+         *
+         * This must be called immediately after {@see SetCharacterInfo1}. In fact, the only
+         * reason they are separated functions if for the limitation of 10 parameters per function
+         * imposed by Luabind (imposed, in turn, by Boost).
+         *
+         * @param[in] id Character ID.
          * @param[in] exp Total experience.
          * @param[in] exp_to_next Experience to reach next level.
          * @param[in] limit_level Currently selected limit level.
@@ -236,11 +245,8 @@ class Savemap{
          * @param[in] armor Equipped armor ID.
          * @param[in] accessory Equipped accessory ID. -1 if none equipped.
          */
-        void SetCharacterInfo(
-          const unsigned int id, const int char_id, const std::string name,
-          const bool enabled, const bool locked,
-          const unsigned int level, const unsigned int kills,
-          const bool back_row, const unsigned int exp, const unsigned int exp_to_next,
+        void SetCharacterInfo2(
+          const unsigned int id, const unsigned int exp, const unsigned int exp_to_next,
           const unsigned int limit_level, const unsigned int limit_bar,
           const unsigned int weapon, const unsigned int armor, const int accessory
         );

+ 18 - 16
src/core/SavemapManager.cpp

@@ -108,16 +108,12 @@ void SavemapManager::SetControlKey(const char* control){
     current_savemap_->SetControlKey(std::string(control));
 }
 
-void SavemapManager::SetWindowColours(
-  const unsigned int t_l_r, const unsigned int t_l_g, const unsigned int t_l_b,
-  const unsigned int t_r_r, const unsigned int t_r_g, const unsigned int t_r_b,
-  const unsigned int b_r_r, const unsigned int b_r_g, const unsigned int b_r_b,
-  const unsigned int b_l_r, const unsigned int b_l_g, const unsigned int b_l_b
+void SavemapManager::SetWindowColour(
+  const unsigned int corner,
+  const unsigned int red, const unsigned int green, const unsigned int blue
 ){
     if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
-    current_savemap_->SetWindowColours(
-      t_l_r, t_l_g, t_l_b, t_r_r, t_r_g, t_r_b, b_r_r, b_r_g, b_r_b, b_l_r, b_l_g, b_l_b
-    );
+    current_savemap_->SetWindowColour(corner, red, green, blue);
 }
 
 void SavemapManager::SetMoney(const unsigned int money){
@@ -188,18 +184,24 @@ void SavemapManager::SetSetting(const unsigned int key, const unsigned int value
     current_savemap_->SetSetting(key, value);
 }
 
-void SavemapManager::SetCharacterInfo(
-  const unsigned int id, const int char_id, const char* name,
-  const bool enabled, const bool locked,
-  const unsigned int level, const unsigned int kills,
-  const bool back_row, const unsigned int exp, const unsigned int exp_to_next,
+void SavemapManager::SetCharacterInfo1(
+  const unsigned int id, const int char_id, const char* name, const bool enabled, const bool locked,
+  const unsigned int level, const unsigned int kills, const bool back_row
+){
+    if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
+    current_savemap_->SetCharacterInfo1(
+      id, char_id, std::string(name), enabled, locked, level, kills, back_row
+    );
+}
+
+void SavemapManager::SetCharacterInfo2(
+  const unsigned int id,  const unsigned int exp, const unsigned int exp_to_next,
   const unsigned int limit_level, const unsigned int limit_bar,
   const unsigned int weapon, const unsigned int armor, const int accessory
 ){
     if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
-    current_savemap_->SetCharacterInfo(
-      id, char_id, std::string(name), enabled, locked, level, kills, back_row, exp, exp_to_next,
-      limit_level, limit_bar, weapon, armor, accessory
+    current_savemap_->SetCharacterInfo2(
+      id, exp, exp_to_next, limit_level, limit_bar, weapon, armor, accessory
     );
 }
 

+ 31 - 25
src/core/SavemapManager.h

@@ -109,26 +109,17 @@ class SavemapManager : public Ogre::Singleton<SavemapManager>{
         void SetControlKey(const char* control);
 
         /**
-         * Sets the window colours in the current savemap.
-         *
-         * @param[in] t_l_r Top-left corner, red component.
-         * @param[in] t_l_r Top-left corner, green component.
-         * @param[in] t_l_r Top-left corner, blue component.
-         * @param[in] t_r_r Top-right corner, red component.
-         * @param[in] t_r_r Top-right corner, green component.
-         * @param[in] t_r_r Top-right corner, blue component.
-         * @param[in] b_r_r Bottom-right corner, red component.
-         * @param[in] b_r_r Bottom-right corner, green component.
-         * @param[in] b_r_r Bottom-right corner, blue component.
-         * @param[in] b_l_r Bottom-left corner, red component.
-         * @param[in] b_l_r Bottom-left corner, green component.
-         * @param[in] b_l_r Bottom-left corner, blue component.
-         */
-        void SetWindowColours(
-          const unsigned int t_l_r, const unsigned int t_l_g, const unsigned int t_l_b,
-          const unsigned int t_r_r, const unsigned int t_r_g, const unsigned int t_r_b,
-          const unsigned int b_r_r, const unsigned int b_r_g, const unsigned int b_r_b,
-          const unsigned int b_l_r, const unsigned int b_l_g, const unsigned int b_l_b
+         * Sets a window corner colour in the current savemap.
+         *
+         * @param[in] corner The window corner. 0: Top left, 1: Top right, 2: Bottom right, 3:
+         * bottom left.
+         * @param[in] red Red component.
+         * @param[in] green Green component.
+         * @param[in] blue Blue component.
+         */
+        void SetWindowColour(
+          const unsigned int corner,
+          const unsigned int red, const unsigned int green, const unsigned int blue
         );
 
         /**
@@ -254,6 +245,10 @@ class SavemapManager : public Ogre::Singleton<SavemapManager>{
         /**
          * Sets a character basic information in the current savemap.
          *
+         * This must be called immediately before {@see SetCharacterInfo2}. In fact, the only
+         * reason they are separated functions if for the limitation of 10 parameters per function
+         * imposed by Luabind (imposed, in turn, by Boost).
+         *
          * @param[in] id Character ID.
          * @param[in] char_id Character identifier.
          * @param[in] name Character name.
@@ -262,6 +257,20 @@ class SavemapManager : public Ogre::Singleton<SavemapManager>{
          * @param[in] level Character level.
          * @param[in] kills Total kills.
          * @param[in] back_row If the character is in the back row.
+         */
+        void SetCharacterInfo1(
+          const unsigned int id, const int char_id, const char* name, const bool enabled,
+          const bool locked, const unsigned int level, const unsigned int kills, const bool back_row
+        );
+
+        /**
+         * Sets a character basic information in the current savemap.
+         *
+         * This must be called immediately after {@see SetCharacterInfo1}. In fact, the only
+         * reason they are separated functions if for the limitation of 10 parameters per function
+         * imposed by Luabind (imposed, in turn, by Boost).
+         *
+         * @param[in] id Character ID.
          * @param[in] exp Total experience.
          * @param[in] exp_to_next Experience to reach next level.
          * @param[in] limit_level Currently selected limit level.
@@ -270,11 +279,8 @@ class SavemapManager : public Ogre::Singleton<SavemapManager>{
          * @param[in] armor Equipped armor ID.
          * @param[in] accessory Equipped accessory ID. -1 if none equipped.
          */
-        void SetCharacterInfo(
-          const unsigned int id, const int char_id, const char* name,
-          const bool enabled, const bool locked,
-          const unsigned int level, const unsigned int kills,
-          const bool back_row, const unsigned int exp, const unsigned int exp_to_next,
+        void SetCharacterInfo2(
+          const unsigned int id, const unsigned int exp, const unsigned int exp_to_next,
           const unsigned int limit_level, const unsigned int limit_bar,
           const unsigned int weapon, const unsigned int armor, const int accessory
         );

+ 38 - 2
src/core/ScriptManager.cpp

@@ -23,6 +23,8 @@
 #include "core/Utilites.h"
 #include "core/XmlScriptsFile.h"
 #include "LuaIncludes.h"
+#include <boost/filesystem/operations.hpp>
+#include <boost/filesystem/path.hpp>
 
 ConfigVar cv_debug_script(
   "debug_script", "Debug script flags. 0x01 - System, 0x02 - Entity, 0x04 - Ui.", "0"
@@ -35,6 +37,26 @@ template<>ScriptManager *Ogre::Singleton<ScriptManager>::msSingleton = nullptr;
 
 Ogre::String script_entity_type[] = {"SYSTEM", "ENTITY", "UI"};
 
+void lua_custom_open(lua_State* L){
+
+    bool is_main_thread = lua_pushthread(L) == 1;
+    lua_pop(L, 1);
+
+    if (!is_main_thread)
+    {
+        std::cout << "CUSTOM NO MAIN\n";
+    }
+    std::cout << "CUSTOM MAIN\n";
+
+
+}
+
+extern "C" int lua_init(lua_State* L){
+    using namespace luabind;
+
+    open(L);
+}
+
 /**
  * Compares the priority of two scripts.
  *
@@ -48,18 +70,32 @@ bool priority_queue_compare(QueueScript a, QueueScript b){return a.priority < b.
 ScriptManager::ScriptManager():
   system_table_name_("System"), entity_table_name_("EntityContainer"), ui_table_name_("UiContainer")
 {
-    lua_state_ = lua_open();
-    luabind::open(lua_state_);
+    if (lua_state_ == nullptr) std::cout << "lua_state WAS nullptr\n";
+    else std::cout << "lua_state WAS NOT nullptr\n";
+    lua_state_ = luaL_newstate();//lua_open();
+    std::cout << "LUA THREAD " << lua_pushthread(lua_state_) << "\n";
+    std::cout << "LUA MAIN THREAD " << std::to_string(lua_pushthread(lua_state_) == 1) << "\n";
+    if (lua_state_ == nullptr) std::cout << "lua_state IS nullptr\n";
+    else std::cout << "lua_state IS NOT nullptr\n";
     luaopen_base(lua_state_);
     luaopen_string(lua_state_);
     luaopen_table(lua_state_);
     luaopen_math(lua_state_);
+    lua_custom_open(lua_state_);
+    luabind::open(lua_state_);
+    //lua_init(lua_state_);
     luaopen_io(lua_state_);
+    std::cout << "ScriptManager: 1\n";
+    std::cout << "ScriptManager: 2\n";
     InitBinds();
     InitCmd();
+    std::cout << "ScriptManager: 3\n";
     RunFile("system/system.lua");
+    std::cout << "ScriptManager: 4\n";
     XmlScriptsFile scripts("./data/scripts.xml");
+    std::cout << "ScriptManager: 5\n";
     scripts.LoadScripts();
+    std::cout << "ScriptManager: End\n";
 }
 
 ScriptManager::~ScriptManager(){lua_close(lua_state_);}

+ 15 - 12
src/core/ScriptManagerBinds.h

@@ -171,7 +171,7 @@ void ScriptManager::InitBinds(){
             (void(Entity::*)(const char*)) &Entity::ScriptSetDefaultAnimation
           )
           .def("animation_sync", (int(Entity::*)()) &Entity::ScriptAnimationSync, luabind::yield)
-          .enum_("constants")[
+          /*.enum_("constants")[
              luabind::value("NONE", AT_NONE),
              luabind::value("LINEAR", AT_LINEAR),
              luabind::value("SMOOTH", AT_SMOOTH),
@@ -182,7 +182,7 @@ void ScriptManager::InitBinds(){
              luabind::value("DOWN_TO_UP", LM_DOWN_TO_UP),
              luabind::value("LEFT_TO_RIGHT", LM_LEFT_TO_RIGHT),
              luabind::value("RIGHT_TO_LEFT", LM_RIGHT_TO_LEFT)
-           ]
+           ]*/
     ];
 
     // Field commands.
@@ -308,13 +308,11 @@ void ScriptManager::InitBinds(){
             "set_control_key", (void(SavemapManager::*)(const char*)) &SavemapManager::SetControlKey
           )
           .def(
-            "set_window_colours",
+            "set_window_colour",
             (void(SavemapManager::*)(
-              const unsigned int, const unsigned int, const unsigned int,
-              const unsigned int, const unsigned int, const unsigned int,
-              const unsigned int, const unsigned int, const unsigned int,
+              const unsigned int,
               const unsigned int, const unsigned int, const unsigned int
-            )) &SavemapManager::SetWindowColours
+            )) &SavemapManager::SetWindowColour
           )
           .def("set_money", (void(SavemapManager::*)(const unsigned int)) &SavemapManager::SetMoney)
           .def(
@@ -371,14 +369,19 @@ void ScriptManager::InitBinds(){
               &SavemapManager::SetSetting
           )
           .def(
-            "set_character_info",
+            "set_character_info_1",
             (void(SavemapManager::*)(
               const unsigned int, const int, const char*, const bool, const bool, const unsigned int,
-              const unsigned int, const bool, const unsigned int, const unsigned int,
-              const unsigned int, const unsigned int, const unsigned int, const unsigned int,
-              const int
-            )) &SavemapManager::SetCharacterInfo
+              const unsigned int, const bool
+            )) &SavemapManager::SetCharacterInfo1
           )
+          .def(
+              "set_character_info_2",
+              (void(SavemapManager::*)(
+                const unsigned int, const unsigned int, const unsigned int, const unsigned int,
+                const unsigned int, const unsigned int, const unsigned int, const int
+              )) &SavemapManager::SetCharacterInfo2
+            )
           .def(
             "set_character_stat",
             (void(SavemapManager::*)(