3
3
#include < spdlog/spdlog.h>
4
4
#include < UI/DebugTools.h>
5
5
#include < imgui.h>
6
- #include < sol_imgui/sol_imgui.h>
6
+ // #include <sol_imgui/sol_imgui.h>
7
7
#include < lfs.h>
8
8
#include " lstate.h"
9
9
@@ -111,6 +111,11 @@ LuaAsyncQueue g_luaAsyncQueue;
111
111
112
112
namespace DriverNG
113
113
{
114
+ namespace Consts
115
+ {
116
+ static const std::string luaScriptsPath = " plugins/DriverNGHook/scripts/" ;
117
+ }
118
+
114
119
namespace Globals
115
120
{
116
121
extern std::unique_ptr<DebugTools> g_pDebugTools;
@@ -189,11 +194,14 @@ namespace DriverNG
189
194
Globals::g_pDebugTools->LogGameToConsole (oss.str ());
190
195
};
191
196
197
+ // set folder
198
+ sv[" DNGHookScriptPath" ] = Consts::luaScriptsPath;
199
+
192
200
if (firstTimeInit)
193
201
{
194
202
// init other lua state
195
203
m_luaState.open_libraries (sol::lib::base, sol::lib::string, sol::lib::io, sol::lib::math, sol::lib::package, sol::lib::os, sol::lib::table);
196
- sol_ImGui::InitBindings (m_luaState);
204
+ // sol_ImGui::InitBindings(m_luaState);
197
205
198
206
m_luaState[" registerForEvent" ] = [this ](const std::string& acName, sol::function aCallback)
199
207
{
@@ -205,12 +213,12 @@ namespace DriverNG
205
213
spdlog::error (" Tried to register an unknown event '{}'!" , acName);
206
214
};
207
215
208
- m_luaState[" setAllowOnlineCheats " ] = [this ](bool enable)
216
+ m_luaState[" allowCustomGameScripts " ] = [this ](bool enable)
209
217
{
210
218
if (enable)
211
- Globals::g_pDebugTools->LogGameToConsole (" WARNING: Online cheats ARE ALLOWED " );
219
+ Globals::g_pDebugTools->LogGameToConsole (" Custom game scripts are allowed " );
212
220
213
- m_allowOnlineCheats = enable;
221
+ m_allowCustomGameScripts = enable;
214
222
};
215
223
216
224
m_luaState[" setAllowDeveloperConsole" ] = [this ](bool enable)
@@ -220,21 +228,36 @@ namespace DriverNG
220
228
221
229
// Driver NG hook internals
222
230
{
223
- m_luaState.script_file (" plugins/DriverNGHook/scripts/ autoexec.lua" );
231
+ m_luaState.script_file (Consts::luaScriptsPath + " autoexec.lua" );
224
232
TryLuaFunction (m_onInit);
225
233
226
234
InitializeGameDevelopmentLib ();
227
235
}
228
236
}
229
237
230
- bool isOnline = IsOnlineGame ();
238
+ // little game hooks to allow console stuff
239
+ if (m_allowDeveloperConsole)
240
+ {
241
+ try
242
+ {
243
+ sv.do_file (Consts::luaScriptsPath + " driverNGConsole.lua" );
244
+ }
245
+ catch (sol::error& err)
246
+ {
247
+ spdlog::warn (" driverNGConsole.lua failed to load" );
248
+ }
249
+ }
231
250
232
251
// init game Lua hooks
233
- // if (!isOnline || isOnline && m_allowOnlineCheats )
252
+ if (m_allowCustomGameScripts && m_callLuaFunc )
234
253
{
235
- if (m_callLuaFunc)
254
+ try
255
+ {
256
+ sv.do_file (Consts::luaScriptsPath + " game_autoexec.lua" );
257
+ }
258
+ catch (sol::error& err)
236
259
{
237
- sv. do_file ( " plugins/DriverNGHook/scripts/ game_autoexec.lua" );
260
+ spdlog::warn ( " game_autoexec.lua failed to load " );
238
261
}
239
262
}
240
263
}
@@ -369,7 +392,7 @@ namespace DriverNG
369
392
if (!IsValidLuaState ())
370
393
return ;
371
394
372
- if (IsOnlineGame () && !m_allowOnlineCheats )
395
+ if (IsOnlineGame () && !m_allowCustomGameScripts )
373
396
{
374
397
g_luaAsyncQueue.Clear ();
375
398
return ;
@@ -416,7 +439,7 @@ namespace DriverNG
416
439
if (!IsValidLuaState ())
417
440
return sol::protected_function_result ();
418
441
419
- if (IsOnlineGame () && !m_allowOnlineCheats )
442
+ if (IsOnlineGame () && !m_allowCustomGameScripts )
420
443
return sol::protected_function_result ();
421
444
422
445
sol::state_view state (m_gameState);
@@ -428,7 +451,7 @@ namespace DriverNG
428
451
if (!IsValidLuaState ())
429
452
return sol::protected_function_result ();
430
453
431
- if (IsOnlineGame () && !m_allowOnlineCheats )
454
+ if (IsOnlineGame () && !m_allowCustomGameScripts )
432
455
return sol::protected_function_result ();
433
456
434
457
sol::state_view state (m_gameState);
0 commit comments