summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZly <zlyudchik@gmail.com>2020-07-29 19:10:19 +0300
committerZly <zlyudchik@gmail.com>2020-07-29 19:10:19 +0300
commitbd4a8492f843a0f613f92e1f9901657b618c4b1e (patch)
tree429d8a954eda1766d651c91356c9ba4f1dc4a7fe
parentb353904c0f80e8e5fc437621c728762de8d6fa70 (diff)
Added a path to script folder for `require` to work properly.lua_requireFix
-rw-r--r--src/SSVOpenHexagon/Core/HGScripting.cpp33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/SSVOpenHexagon/Core/HGScripting.cpp b/src/SSVOpenHexagon/Core/HGScripting.cpp
index a7fb7e32..53808e1f 100644
--- a/src/SSVOpenHexagon/Core/HGScripting.cpp
+++ b/src/SSVOpenHexagon/Core/HGScripting.cpp
@@ -6,9 +6,6 @@
#include "SSVOpenHexagon/Global/Assets.hpp"
#include "SSVOpenHexagon/Utils/Utils.hpp"
#include "SSVOpenHexagon/Core/HexagonGame.hpp"
-#include "SSVOpenHexagon/Components/CWall.hpp"
-#include "SSVOpenHexagon/Components/CCustomWallHandle.hpp"
-#include "SSVOpenHexagon/Components/CCustomWall.hpp"
using namespace sf;
using namespace ssvs;
@@ -1216,23 +1213,31 @@ void HexagonGame::initLua()
// ------------------------------------------------------------------------
// Register Lua function to get random seed for the current attempt:
addLuaFn("u_getAttemptRandomSeed", //
- [this] { return rng.seed(); })
- .doc(
- "Obtain the current random seed, automatically generated at the "
- "beginning of the level. `math.randomseed` is automatically "
- "initialized with the result of this function at the beginning of "
- "a level.");
+ [this]{ return rng.seed(); })
+ .doc(
+ "Obtain the current random seed, automatically generated at the "
+ "beginning of the level. `math.randomseed` is automatically "
+ "initialized with the result of this function at the beginning of "
+ "a level.");
+
+ // ------------------------------------------------------------------------
+ // Initialize Lua paths:
+ try{
+ lua.executeCode("package.path = package.path:sub(1, -49)..\"" + levelData->packPath + "\\Scripts\\?.lua\"");
+ }
+ catch(...){
+ ssvu::lo("HexagonGame::initLua")
+ << "Failure to initialize Lua paths\n";
+ }
// ------------------------------------------------------------------------
// Initialize Lua random seed from random generator one:
- try
- {
+ try{
lua.executeCode("math.randomseed(u_getAttemptRandomSeed())");
}
- catch(...)
- {
+ catch(...){
ssvu::lo("HexagonGame::initLua")
- << "Failure to initialize Lua random generator seed\n";
+ << "Failure to initialize Lua random generator seed\n";
}
// ------------------------------------------------------------------------