#pragma once #define SOL_EXCEPTIONS_SAFE_PROPAGATION 1 #define SOL_ALL_SAFETIES_ON 1 //#include "SOL/sol.hpp" #include "F:/Programmieren/Lua/sol2/single/single/include/sol/sol.hpp" #include #include #include #include //#include "C:/SDK_GEN/BL3/SDK/BL3_Basic.hpp" //#include "C:/SDK_GEN/BL3/SDK/BL3_CoreUObject_classes.hpp" #include "C:/SDK_GEN/BL3-2021-4-9/SDK.hpp" #include #include "LuaComponent.h" class BL3Lua { public: BL3Lua(); ~BL3Lua(); bool ExecuteScriptFile(const char* filePath, bool printInGame = false); bool ExecuteScriptString(const char* scriptCode, bool printInGame = false); void RunCallbacks(const char* callbackName, sol::object data); void TDump(sol::object tableToDump); void ClearCallbacks(); void AddHook(sol::this_state s, sol::this_environment e, const std::string& hookName, sol::function func, bool preHook); void RemoveHook(sol::this_state s, sol::this_environment e, const std::string& hookName, sol::function func); void RemoveAllHooks(); void AddConsoleCommand(sol::this_state s, sol::this_environment e, const std::string& command, sol::function func); void RemoveConsoleCommand(sol::this_state s, sol::this_environment e, const std::string& command, sol::function func); void RemoveAllConsoleCommands(); uint32_t RegisterHotkey(sol::this_state s, sol::this_environment e, sol::variadic_args va); void RemoveHotkey(sol::this_state s, sol::this_environment e, uint32_t, sol::function func); void RemoveAllHotkeys(); void ValidateHotkeys(); //std::vector GetHooks(const char* hookName); //void RegisterUtility(); private: void registerBase(); void loadlibs(); void adjustRequirePath(); void removeAbusableFuncs(); public: sol::state* lua; CRITICAL_SECTION luaCritSec; std::unordered_map>> procEventHooks; std::unordered_map> consoleCommands; std::vector> registeredHotkeys; std::vector loadedComponents; private: sol::table callbacks; sol::environment consoleEnvironment; };