### Lua API Examples Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/SUMMARY.md Examples demonstrating the usage of the UE4SS Lua API. ```APIDOC ## Lua API Examples ### Description This section provides practical examples for using the UE4SS Lua API. ### Method Not applicable (Lua examples) ### Endpoint Not applicable ### Parameters None explicitly defined in the provided text. ### Request Example ```lua -- Example: Registering a simple console command RegisterConsoleCommandHandler('hello', function(args) print('Hello, ' .. (args[1] or 'World') .. '!') end) -- Example: Hooking into a function call RegisterCallFunctionByNameWithArgumentsPreHook('SomeGameFunction', function(args) print('About to call SomeGameFunction with arguments:', args) end) ``` ### Response None explicitly defined in the provided text. ``` -------------------------------- ### Guides Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/SUMMARY.md Guides for creating and managing mods using UE4SS. ```APIDOC ## Creating a Lua Mod ### Description This guide explains the process of creating a mod using Lua scripting with UE4SS. ### Method Not applicable (Guide) ### Endpoint Not applicable ### Parameters None explicitly defined in the provided text. ### Request Example ```lua -- Lua mod script example print('My Lua mod is loading!') -- Add your mod logic here ``` ### Response None explicitly defined in the provided text. ``` ```APIDOC ## Using Custom Lua Bindings ### Description This guide covers how to use custom Lua bindings within your UE4SS mods. ### Method Not applicable (Guide) ### Endpoint Not applicable ### Parameters None explicitly defined in the provided text. ### Request Example ```lua -- Example of using a custom Lua binding local myCustomValue = GetCustomValue('some_setting') print('Custom value:', myCustomValue) ``` ### Response None explicitly defined in the provided text. ``` ```APIDOC ## Fixing Compatibility Problems ### Description This guide provides steps to fix compatibility issues with mods, potentially related to missing AOBs. ### Method Not applicable (Guide) ### Endpoint Not applicable ### Parameters None explicitly defined in the provided text. ### Request Example ``` -- No code example available for this guide. ``` ### Response None explicitly defined in the provided text. ``` ```APIDOC ## Fixing Compatibility Problems (Advanced) ### Description An advanced guide for resolving compatibility issues, likely involving more complex solutions than the basic guide. ### Method Not applicable (Guide) ### Endpoint Not applicable ### Parameters None explicitly defined in the provided text. ### Request Example ``` -- No code example available for this guide. ``` ### Response None explicitly defined in the provided text. ``` ```APIDOC ## Generating UHT Compatible Headers ### Description This guide explains how to generate UHT-compatible headers, which is crucial for C++ modding. ### Method Not applicable (Guide) ### Endpoint Not applicable ### Parameters None explicitly defined in the provided text. ### Request Example ``` -- Command or tool usage example for generating headers would go here. ``` ### Response None explicitly defined in the provided text. ``` -------------------------------- ### Install xwin Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/README.md Installs the xwin tool, which is used to download Microsoft tools and SDKs for cross-compilation. ```bash cargo install xwin ``` -------------------------------- ### LoadAsset Example Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/global-functions/loadasset.md This example demonstrates how to use LoadAsset within a console command handler. Ensure this function is only called from the game thread. ```lua RegisterConsoleCommandHandler("summon", function(FullCommand, Parameters) if #Parameters < 1 then return false end -- Parameters[1] example: /Game/LevelElements/Refinery/Pipeline/BP_Pipeline_Start LoadAsset(Parameters[1]) return false end) ``` -------------------------------- ### Advanced Mod Management Example Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/global-functions/modmanagement.md This example demonstrates how to register multiple keybinds to restart various mods. It iterates through a list of mods and their associated keys to provide convenient restart functionality. ```lua local ModsToManage = { {Key = Key.ONE, ModName = "ActorDumperMod"}, {Key = Key.TWO, ModName = "LineTraceMod"}, {Key = Key.THREE, ModName = "ConsoleCommandsMod"}, } for _, entry in ipairs(ModsToManage) do RegisterKeyBind(entry.Key, {ModifierKey.CONTROL, ModifierKey.SHIFT}, function() print(string.format("Restarting %s...\n", entry.ModName)) RestartMod(entry.ModName) end) end ``` -------------------------------- ### Example Usage Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/classes/futf8string.md Demonstrates how to use the FUtf8String class with various methods. ```APIDOC ## Example Usage ```lua -- FUtf8String works seamlessly with UTF-8 data local utf8String = FUtf8String("Hello UTF-8! 你好") print(utf8String:ToString()) -- Output: "Hello UTF-8! 你好" utf8String:Append(" 世界") print(utf8String:ToString()) -- Output: "Hello UTF-8! 你好 世界" if utf8String:StartsWith("Hello") then print("String starts with Hello!") end local upperString = utf8String:ToUpper() print(upperString:ToString()) local index = utf8String:Find("UTF-8") if index then print("Found at index: " .. index) end ``` ``` -------------------------------- ### Install LLVM/Clang on Ubuntu/Debian Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/README.md Installs LLVM, Clang, and LLD required for building on Ubuntu/Debian systems. ```bash sudo apt install clang lld llvm ``` -------------------------------- ### Examples of Delayed Actions Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/global-functions/delayedactions.md Illustrative examples of how to use various delayed action functions. ```APIDOC ### Simple Delay Executes a function after a specified delay in milliseconds. ```lua ExecuteInGameThreadWithDelay(2000, function() print("This prints after 2 seconds\n") end) ``` ### Self-Cancelling Loop Creates a loop that executes at a specified interval and can cancel itself after a condition is met. ```lua local counter = 0 local loopHandle -- Declare first for closure capture loopHandle = LoopInGameThreadWithDelay(1000, function() counter = counter + 1 print(string.format("Tick %d\n", counter)) if counter >= 5 then CancelDelayedAction(loopHandle) print("Loop stopped\n") end end) ``` ### Debounced Action Ensures a function is only called after a certain period of inactivity, useful for preventing rapid, repeated calls. ```lua local debounceHandle = MakeActionHandle() RegisterKeyBind(Key.F, function() -- Only fires 500ms after the last key press RetriggerableExecuteInGameThreadWithDelay(debounceHandle, 500, function() print("Debounced action fired\n") end) end) ``` ### Pausable Timer Demonstrates how to pause and resume a delayed action. ```lua local timerHandle = ExecuteInGameThreadWithDelay(10000, function() print("Timer completed\n") end) -- Pause after 2 seconds ExecuteInGameThreadWithDelay(2000, function() PauseDelayedAction(timerHandle) print("Timer paused\n") end) -- Resume after 5 seconds ExecuteInGameThreadWithDelay(5000, function() UnpauseDelayedAction(timerHandle) print("Timer resumed\n") end) ``` ### UE-Style Delay (Only Create If Not Exists) Creates a delay only if one with the same handle is not already active, useful for cooldowns. ```lua local cooldownHandle = MakeActionHandle() RegisterKeyBind(Key.E, function() -- Only creates the delay if not already active ExecuteInGameThreadWithDelay(cooldownHandle, 1000, function() print("Ability ready!\n") end) print("Ability used (1s cooldown)\n") end) ``` ### Frame-Based Delay Executes a function after a specified number of frames, requires `EngineTickAvailable` to be true. ```lua if EngineTickAvailable then ExecuteInGameThreadAfterFrames(60, function() print("Fired after 60 frames\n") end) end ``` ``` -------------------------------- ### Install LLVM/Clang on Arch Linux Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/README.md Installs LLVM, Clang, and LLD required for building on Arch Linux systems. ```bash sudo pacman -S clang lld llvm ``` -------------------------------- ### Install Wine on Ubuntu/Debian Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/README.md Installs Wine, Wine64, and Winbind required for the msvc-wine toolchain on Ubuntu/Debian systems. ```bash sudo apt install wine wine64 winbind ``` -------------------------------- ### FString Example Usage Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/classes/fstring.md Demonstrates how to use FString methods in Lua. ```APIDOC ## Example Usage ```lua local myString = FString("Hello") myString:Append(" World") print(myString:ToString()) -- Output: "Hello World" if myString:StartsWith("Hello") then print("String starts with Hello!") end local upperString = myString:ToUpper() print(upperString:ToString()) -- Output: "HELLO WORLD" local index = myString:Find("World") print(index) -- Output: 7 (1-based index) ``` ``` -------------------------------- ### Mod File Structure Example Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/guides/installing-a-c++-mod.md This illustrates the expected folder structure for a mod within the game's Mods directory. ```text Mods\ MyAwesomeMod\ dlls\ main.dll ``` -------------------------------- ### FindObjects Example Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/global-functions/findobjects.md Demonstrates how to use FindObjects to retrieve a list of SceneComponents with specific properties and iterate over the results. ```lua local Object = FindObjects(4, "SceneComponent", "TransformComponent0", EObjectFlags.RF_NoFlags, EObjectObjectFlags.RF_ClassDefaultObject, true) for _, Object in pairs(Objects) do -- Do something with Object end ``` -------------------------------- ### Minimal main.lua Example Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/guides/creating-a-lua-mod.md This is the simplest form of a `main.lua` file. It prints a message to the console when the mod is loaded, indicating successful initialization. ```lua print("[MyLuaMod] Mod loaded\n") ``` -------------------------------- ### FAnsiString Example Usage Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/classes/fansistring.md Demonstrates how to use FAnsiString in Lua. ```APIDOC ## Example Usage ```lua -- FAnsiString for ANSI-encoded data local ansiString = FAnsiString("Hello ANSI") print(ansiString:ToString()) -- Output: "Hello ANSI" ansiString:Append(" World") print(ansiString:ToString()) -- Output: "Hello ANSI World" if ansiString:EndsWith("World") then print("String ends with World!") end local lowerString = ansiString:ToLower() print(lowerString:ToString()) -- Output: "hello ansi world" local index = ansiString:Find("ANSI") if index then print("Found at index: " .. index) end ``` ``` -------------------------------- ### ExecuteInGameThreadWithDelay Example Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/global-functions/executeasync.md This is the recommended alternative to ExecuteAsync. It executes on the game thread on the next frame and provides a handle for cancellation. ```lua -- Executes on the game thread on the next frame/ProcessEvent local handle = ExecuteInGameThreadWithDelay(0, function() print("Executed on game thread\n") end) -- Can now cancel with: CancelDelayedAction(handle) ``` -------------------------------- ### Migration Example: Simple Property Iteration Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/upgrade-guide.md Compares the old ForEachProperty() method with the new recommended TFieldRange for simple property iteration. ```cpp // Old (still works) for (FProperty* Prop : MyStruct->ForEachProperty()) { Output::send(STR("{}\n"), Prop->GetName()); } ``` ```cpp // New (recommended) for (FProperty* Prop : TFieldRange(MyStruct, EFieldIterationFlags::None)) { Output::send(STR("{}\n"), Prop->GetName()); } ``` -------------------------------- ### Object Dumper Example Output Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/feature-overview/dumpers.md This is an example of the output generated by the Object Dumper. It shows the memory address, type, name, and class of loaded objects and properties. ```text [000002A70F57E5C0] Function /Game/UI/Art/WidgetParts/Basic_ButtonScalable2.Basic_ButtonScalable2_C:BndEvt__Button_0_K2Node_ComponentBoundEvent_0_OnButtonClickedEvent__DelegateSignature [n: 5343AA] [c: 000002A727993A00] [or: 000002A708466980] [000002A70F57E4E0] Function /Game/UI/Art/WidgetParts/Basic_ButtonScalable2.Basic_ButtonScalable2_C:PreConstruct [n: 4057B] [c: 000002A727993A00] [or: 000002A708466980] [000002A70F876600] BoolProperty /Game/UI/Art/WidgetParts/Basic_ButtonScalable2.Basic_ButtonScalable2_C:PreConstruct:IsDesignTime [o: 0] [n: 4D63DB] [c: 00007FF683722CC0] [owr: 000002A70F57E4E0] ``` -------------------------------- ### Default mods.txt Configuration Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/guides/installing-a-c++-mod.md This is an example of the default mods.txt file. Mods are enabled by adding their name followed by a colon and '1'. ```text CheatManagerEnablerMod : 1 ActorDumperMod : 0 ConsoleCommandsMod : 1 ConsoleEnablerMod : 1 SplitScreenMod : 0 LineTraceMod : 1 BPModLoaderMod : 1 jsbLuaProfilerMod : 0 ; Built-in keybinds, do not move up! Keybinds : 1 ``` -------------------------------- ### Install Wine on Arch Linux Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/README.md Installs Wine and Samba required for the msvc-wine toolchain on Arch Linux systems. ```bash sudo pacman -S wine samba ``` -------------------------------- ### Build Project with CMake Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/UVTD/README.md Use this command in the repository's root directory to generate build files for Visual Studio. Ensure CMake is installed and in your PATH. ```bash cmake CMakeLists.txt ``` -------------------------------- ### Construct a UConsole Object Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/global-functions/staticconstructobject.md This example demonstrates how to construct a UConsole object using StaticConstructObject. Ensure that the Engine, ConsoleClass, and GameViewport are valid before attempting construction. ```lua local Engine = FindFirstOf("Engine") local ConsoleClass = Engine.ConsoleClass local GameViewport = Engine.GameViewport if not ConsoleClass:IsValid() or not GameViewport:IsValid() then print("Was unable to construct UConsole because the console class didn't exist\n") else local CreatedConsole = StaticConstructObject(ConsoleClass, GameViewport, 0, 0, 0, nil, false, false, nil) if CreatedConsole:IsValid() then print(string.format("CreatedConsole: %s\n", CreatedConsole:GetFullName())) else print("Was unable to construct UConsole\n") end end ``` -------------------------------- ### Migration Example: Property Iteration with Inheritance Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/upgrade-guide.md Demonstrates the transition from the old ForEachPropertyInChain() to the new TFieldRange with IncludeSuper flag for iterating properties including inheritance. ```cpp // Old (still works) for (FProperty* Prop : MyStruct->ForEachPropertyInChain()) { Output::send(STR("{}\n"), Prop->GetName()); } ``` ```cpp // New (recommended) for (FProperty* Prop : TFieldRange(MyStruct, EFieldIterationFlags::IncludeSuper)) { Output::send(STR("{}\n"), Prop->GetName()); } ``` -------------------------------- ### Migration Example: Parent-to-Child Iteration Order Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/upgrade-guide.md Shows how to achieve parent-to-child property iteration using the new TReverseFieldRange, replacing the old OrderedForEachPropertyInChain. ```cpp // Old (still works) for (FProperty* Prop : OrderedForEachPropertyInChain(MyStruct)) { Output::send(STR("{}\n"), Prop->GetName()); } ``` ```cpp // New (recommended) for (FProperty* Prop : TReverseFieldRange(MyStruct, EFieldIterationFlags::None)) { Output::send(STR("{}\n"), Prop->GetName()); } ``` -------------------------------- ### UI Initialization with ImGui Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/assets/Changelog.md Use the on_ui_init() function and the UE4SS_ENABLE_IMGUI macro to safely initialize UI elements with ImGui. Failing to do so will cause a crash. ```cpp void on_ui_init() { UE4SS_ENABLE_IMGUI // Your ImGui rendering code here } ``` -------------------------------- ### Get Elapsed Time for Delayed Action Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/global-functions/delayedactions.md Gets the time that has passed since a delayed action started or was reset. Returns elapsed milliseconds or frames. Returns -1 for invalid handles. ```lua local elapsedMs = GetDelayedActionTimeElapsed(handle) ``` -------------------------------- ### Reference Key Code in Lua Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/table-definitions/key.md Example of how to reference a virtual key-code string from the Key table in Lua. Ensure the Key table is populated before use. ```lua local enter_key = Key.RETURN ``` -------------------------------- ### Build with build.sh (xwin-clang-cl) Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/README.md Builds the project using the build.sh script with the xwin-clang-cl toolchain. Ensure XWIN_DIR is exported. ```bash ./tools/buildscripts/build.sh --toolchain xwin-clang-cl ``` -------------------------------- ### Set Up Interface Library and C++ Standard Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/deps/first/Profiler/CMakeLists.txt Creates an INTERFACE library for the profiler and enables C++23 support. It also makes the include directories visible in IDEs. ```cmake add_library(${TARGET} INTERFACE) # Enabling c++23 support target_compile_features(${TARGET} INTERFACE cxx_std_23) target_include_directories(${TARGET} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) # Make headers visible in the IDE # Uses make_headers_visible() from cmake/modules/IDEVisibility.cmake make_headers_visible(${TARGET} "${CMAKE_CURRENT_SOURCE_DIR}/include") ``` -------------------------------- ### Editor-Specific Lighting and GUIDs Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/guides/generating-uht-compatible-headers.md Editor-specific methods for static lighting information and GUID management. ```APIDOC ## UVoxelProceduralMeshComponent::GetStaticLightingInfo ### Description Retrieves static lighting information for the primitive. ### Method void ### Endpoint N/A (Class Method) ### Parameters - **OutPrimitiveInfo** (FStaticLightingPrimitiveInfo&) - Output structure to hold primitive lighting info. - **InRelevantLights** (const TArray&) - Array of relevant light components. - **Options** (const FLightingBuildOptions&) - Lighting build options. ### Response None ``` ```APIDOC ## UVoxelProceduralMeshComponent::AddMapBuildDataGUIDs ### Description Adds GUIDs related to map build data. ### Method void ### Endpoint N/A (Class Method) ### Parameters - **InGUIDs** (TSet&) - Set of GUIDs to add to. ### Response None ``` ```APIDOC ## UVoxelProceduralMeshComponent::PostEditUndo ### Description Handles post-edit undo operations. ### Method void ### Endpoint N/A (Class Method) ### Parameters None ### Response None ``` -------------------------------- ### Build with build.sh (xwin-clang) Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/README.md Builds the project using the build.sh script with the xwin-clang toolchain. Ensure XWIN_DIR is exported. ```bash ./tools/buildscripts/build.sh --toolchain xwin-clang ``` -------------------------------- ### Configure UE4SS CMake Project Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/deps/first/Function/CMakeLists.txt Sets the minimum CMake version, defines the target name, and initializes the project. This is a standard starting point for CMake projects. ```cmake cmake_minimum_required(VERSION 3.18) set(TARGET Function) project(${TARGET}) message("Project: ${TARGET} (HEADER-ONLY)") ``` -------------------------------- ### Get TArray Length Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/classes/tarray.md Use the length operator (#) to get the current number of elements in the array. ```Lua #TArray ``` -------------------------------- ### FString Usage Example Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/classes/fstring.md Demonstrates common FString operations like initialization, appending, checking prefixes, converting case, and finding substrings. Ensure FString is initialized correctly before use. ```lua local myString = FString("Hello") myString:Append(" World") print(myString:ToString()) -- Output: "Hello World" if myString:StartsWith("Hello") then print("String starts with Hello!") end local upperString = myString:ToUpper() print(upperString:ToString()) -- Output: "HELLO WORLD" local index = myString:Find("World") print(index) -- Output: 7 (1-based index) ``` -------------------------------- ### Build with build.sh (wine-msvc) Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/README.md Builds the project using the build.sh script with the wine-msvc toolchain. Assumes Wine and msvc-wine are set up. ```bash ./tools/buildscripts/build.sh --toolchain wine-msvc ``` -------------------------------- ### Build with build.sh (wine-clang-cl) Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/README.md Builds the project using the build.sh script with the wine-clang-cl toolchain. Assumes Wine and msvc-wine are set up. ```bash ./tools/buildscripts/build.sh --toolchain wine-clang-cl ``` -------------------------------- ### Add Map Build Data GUIDs (Editor) Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/guides/generating-uht-compatible-headers.md Adds GUIDs related to map build data. This is a placeholder and does not contain implementation details. ```cpp #if WITH_EDITOR void UVoxelProceduralMeshComponent::AddMapBuildDataGUIDs(TSet& InGUIDs) const { } #endif // WITH_EDITOR ``` -------------------------------- ### Start a looping asynchronous task Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/global-functions/loopasync.md Use LoopAsync to start a loop that sleeps for a specified duration and continues until the callback returns true. This function is deprecated. ```lua LoopAsync(1000, function() print("Hello World!") return false -- Loops forever end) ``` -------------------------------- ### Get Remaining Time for Delayed Action Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/global-functions/delayedactions.md Gets the time left until a delayed action executes. Returns remaining milliseconds or frames. Returns -1 for invalid handles. ```lua local remainingMs = GetDelayedActionTimeRemaining(handle) ``` -------------------------------- ### Download Microsoft Tools with xwin Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/README.md Downloads necessary Microsoft tools and SDKs using xwin. This command should only be run once. ```bash xwin --accept-license splat --output ~/.xwin ``` -------------------------------- ### FWeakObjectPtr Methods Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api.md Methods for FWeakObjectPtr to get the pointed-to object. ```APIDOC ## FWeakObjectPtr Methods ### Description Represents a weak pointer to an Unreal Engine object. ### Inheritance LocalObject ### Methods - **Get() -> UObjectDerivative** - Returns the pointed-to UObject or UObject derivative. Note: The returned object may be invalid, so always call `UObject:IsValid` after calling `Get`. ``` -------------------------------- ### UObjectReflection Methods Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api.md Methods for UObjectReflection to get property metadata. ```APIDOC ## UObjectReflection Methods ### Description Provides reflection capabilities for UObjects. ### Methods - **GetProperty(string PropertyName) -> Property** - Returns a property meta-data object for the specified property name. ``` -------------------------------- ### Build specific configuration with build.sh Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/README.md Builds the project with a specific configuration (e.g., Game__Debug__Win64) using the build.sh script and xwin-clang toolchain. ```bash ./tools/buildscripts/build.sh --toolchain xwin-clang --build-config Game__Debug__Win64 ``` -------------------------------- ### C++ API Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/SUMMARY.md Documentation and guides for using the C++ API with UE4SS. ```APIDOC ## C++ API Overview ### Description This section provides an overview of the C++ API available for developing mods with UE4SS. ### Method Not applicable (C++ API section) ### Endpoint Not applicable ### Parameters None explicitly defined in the provided text. ### Request Example ```cpp // C++ mod example structure #include "UnrealEngine" // Your C++ mod code here ``` ### Response None explicitly defined in the provided text. ``` ```APIDOC ## BP Macros ### Description Information regarding Blueprint Macros usable within the C++ API. ### Method Not applicable (C++ API section) ### Endpoint Not applicable ### Parameters None explicitly defined in the provided text. ### Request Example ```cpp // Example of using a BP Macro in C++ // UFUNCTION(BlueprintCallable) // void MyBlueprintMacroFunction(); ``` ### Response None explicitly defined in the provided text. ``` ```APIDOC ## C++ Examples ### Description Provides code examples for developing mods using the C++ API. ### Method Not applicable (C++ API section) ### Endpoint Not applicable ### Parameters None explicitly defined in the provided text. ### Request Example ```cpp // Example: Accessing a game property via C++ // auto PlayerController = GetWorld()->GetFirstPlayerController(); // if (PlayerController) { // float Health = PlayerController->Health; // UE_LOG(LogTemp, Warning, TEXT("Player Health: %f"), Health); // } ``` ### Response None explicitly defined in the provided text. ``` ```APIDOC ## Creating a C++ Mod ### Description A guide detailing the steps and considerations for creating a mod using C++ with UE4SS. ### Method Not applicable (Guide) ### Endpoint Not applicable ### Parameters None explicitly defined in the provided text. ### Request Example ```cpp // Basic structure for a C++ mod entry point // #include "CoreMinimal.h" // IMPLEMENT_PRIMARY_GAME_MODULE(FDefaultGameModuleImpl, MyCppMod, "MyCppMod.uplugin"); ``` ### Response None explicitly defined in the provided text. ``` ```APIDOC ## Installing a C++ Mod ### Description Instructions on how to install a C++ mod developed for UE4SS. ### Method Not applicable (Guide) ### Endpoint Not applicable ### Parameters None explicitly defined in the provided text. ### Request Example ``` -- Installation steps would be described here. ``` ### Response None explicitly defined in the provided text. ``` ```APIDOC ## Creating GUI Tabs with a C++ Mod ### Description This guide explains how to create custom GUI tabs within the UE4SS interface using C++ mods. ### Method Not applicable (Guide) ### Endpoint Not applicable ### Parameters None explicitly defined in the provided text. ### Request Example ```cpp // Example snippet for creating a GUI tab // void RegisterMyGuiTab(FModuleManager& ModuleManager) { // ModuleManager.RegisterModule("MyGuiTabModule"); // } ``` ### Response None explicitly defined in the provided text. ``` ```APIDOC ## Accessing UE Properties with a C++ Mod ### Description This guide focuses on how to access and manipulate Unreal Engine properties from your C++ mods. ### Method Not applicable (Guide) ### Endpoint Not applicable ### Parameters None explicitly defined in the provided text. ### Request Example ```cpp // Example: Accessing Actor Location // AActor* MyActor = ...; // FVector Location = MyActor->GetActorLocation(); // UE_LOG(LogTemp, Warning, TEXT("Actor Location: %s"), *Location.ToString()); ``` ### Response None explicitly defined in the provided text. ``` -------------------------------- ### Build specific configuration with build.sh (Wine) Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/README.md Builds the project with a specific configuration (e.g., Game__Debug__Win64) using the build.sh script and wine-clang-cl toolchain. ```bash ./tools/buildscripts/build.sh --toolchain wine-clang-cl --build-config Game__Debug__Win64 ``` -------------------------------- ### Get TArray Address Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/classes/tarray.md Retrieves the memory address of the TArray struct itself. ```Lua TArray:GetArrayAddress() ``` -------------------------------- ### FWeakObjectPtr Get() Method Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/classes/fweakobjectptr.md Details on how to retrieve the pointed-to UObject from an FWeakObjectPtr. ```APIDOC ## Get() / get() ### Description Retrieves the pointed-to `UObject` or `UObject` derivative from an `FWeakObjectPtr`. ### Method `Get()` or `get()` ### Endpoint N/A (Method within a class) ### Parameters None ### Request Example None ### Response #### Success Response - **Return type:** `UObjectDerivative` - The pointed-to `UObject` or `UObject` derivative. ### Response Example ```cpp UObject* obj = weakPtr.Get(); if (obj && obj->IsValid()) { // Use obj } ``` ### Notes The return value can be invalid. It is recommended to call `UObject:IsValid` after calling this function to ensure the object is still valid before dereferencing. ``` -------------------------------- ### Set Supported Platforms Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/guides/generating-uht-compatible-headers.md Sets the supported platforms for the project to Windows. This is a configuration note. ```bash Set supported platforms to windows ``` ``` -------------------------------- ### ExecuteAsync Function Example Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/global-functions/executeasync.md This function asynchronously executes a callback. It is deprecated in favor of ExecuteInGameThreadWithDelay. ```lua ExecuteAsync(function() print("Executed asynchronously\n") end) ``` -------------------------------- ### FUtf8String Example Usage Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/classes/futf8string.md Demonstrates basic FUtf8String operations including initialization, appending, checking prefixes, case conversion, and finding substrings. Note that ToUpper() only affects ASCII characters. ```lua -- FUtf8String works seamlessly with UTF-8 data local utf8String = FUtf8String("Hello UTF-8! 你好") print(utf8String:ToString()) -- Output: "Hello UTF-8! 你好" utf8String:Append(" 世界") print(utf8String:ToString()) -- Output: "Hello UTF-8! 你好 世界" if utf8String:StartsWith("Hello") then print("String starts with Hello!") end local upperString = utf8String:ToUpper() print(upperString:ToString()) local index = utf8String:Find("UTF-8") if index then print("Found at index: " .. index) end ``` -------------------------------- ### Get TArray Element Count Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/classes/tarray.md Returns the current number of elements stored in the array. ```Lua TArray:GetArrayNum() ``` -------------------------------- ### Get and Compare Unreal Engine Version Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/classes/unrealversion.md Demonstrates how to retrieve the current Unreal Engine version and perform various comparisons against a target version. Ensure the UnrealVersion class is accessible. ```lua local Major = UnrealVersion.GetMajor() local Minor = UnrealVersion.GetMinor() print(string.format("Version: %s.%s\n", Major, Minor)) if UnrealVersion.IsEqual(5, 0) then print("Version is 5.0\n") end if UnrealVersion.IsAtLeast(5, 0) then print("Version is >=5.0\n") end if UnrealVersion.IsAtMost(5, 0) then print("Version is <=5.0\n") end if UnrealVersion.IsBelow(5, 0) then print("Version is <5.0\n") end if UnrealVersion.IsAbove(5, 0) then print("Version is >5.0\n") end ``` -------------------------------- ### Accessing Modifier Key in Lua Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/table-definitions/modifierkey.md Example of how to access and use a modifier key constant in Lua. ```lua local CTRL_Key = ModifierKey.CONTROL ``` -------------------------------- ### FetchContent Configuration for fmt Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/deps/third/fmt/CMakeLists.txt Configures the 'fmt' library using FetchContent. Ensure 'FMT_HEADER_ONLY' is set appropriately for your build needs. ```cmake include(FetchContent) set(FETCHCONTENT_QUIET OFF) # Set fmt options set(FMT_HEADER_ONLY OFF CACHE BOOL "Build fmt as a compiled library, not header-only") # Use the modern FetchContent approach # The patching is now done via PATCH_COMMAND in the parent CMakeLists.txt FetchContent_MakeAvailable(fmt) # Uses suppress_third_party_warnings() from cmake/modules/ThirdPartyWarnings.cmake suppress_third_party_warnings(fmt) ``` -------------------------------- ### Get Material by Index for VoxelProceduralMeshComponent Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/guides/generating-uht-compatible-headers.md Retrieves a material by its index. The current implementation returns nullptr. ```cpp UMaterialInterface* UVoxelProceduralMeshComponent::GetMaterial(int32 MaterialIndex) const { UMaterialInterface* Material = nullptr; return Material; } ``` -------------------------------- ### Get Used Materials for VoxelProceduralMeshComponent Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/guides/generating-uht-compatible-headers.md Retrieves the materials used by the VoxelProceduralMeshComponent. The current implementation is empty. ```cpp void UVoxelProceduralMeshComponent::GetUsedMaterials(TArray& OutMaterials, bool bGetDebugMaterials) const { } ``` -------------------------------- ### Build with Ninja Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/README.md Build the project using the Ninja build system after CMake configuration. ```bash cmake --build build_cmake_Game__Shipping__Win64 ``` -------------------------------- ### Get TArray Data Address Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/classes/tarray.md Returns the memory address where the actual array data is stored. ```Lua TArray:GetArrayDataAddress() ``` -------------------------------- ### Build with CMake (Wine) Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/README.md Builds the project using CMake after configuration with a Wine-based toolchain. Assumes the build directory has been set up. ```bash cmake --build build_wine ``` -------------------------------- ### Get TArray Capacity Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/classes/tarray.md Returns the maximum number of elements the array can hold without reallocating memory. ```Lua TArray:GetArrayMax() ``` -------------------------------- ### Get Number of Materials for VoxelProceduralMeshComponent Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/guides/generating-uht-compatible-headers.md Returns the number of materials used by the VoxelProceduralMeshComponent. The current implementation returns 0. ```cpp int32 UVoxelProceduralMeshComponent::GetNumMaterials() const { return 0; } ``` -------------------------------- ### FetchContent and Corrosion Integration Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/deps/third/corrosion/CMakeLists.txt This snippet demonstrates how to use CMake's FetchContent module to download and make available the 'corrosion' module, which is then used to import a Rust crate. Ensure 'corrosion' is available or fetched by FetchContent. ```cmake include(FetchContent) set(FETCHCONTENT_QUIET OFF) FetchContent_MakeAvailable(corrosion) # Import Rust crate corrosion_import_crate(MANIFEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../first/patternsleuth_bind/Cargo.toml") # Include the patternsleuth_bind CMakeLists.txt for folder organization add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../../first/patternsleuth_bind" "${CMAKE_CURRENT_BINARY_DIR}/patternsleuth_bind") ``` -------------------------------- ### Set XWIN_DIR Environment Variable Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/README.md Sets the XWIN_DIR environment variable to the location where Microsoft tools were installed by xwin. ```bash export XWIN_DIR=~/.xwin ``` -------------------------------- ### Configure Proxy Generator Build Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/UE4SS/proxy_generator/CMakeLists.txt Sets up the build for the proxy generator executable. Links necessary libraries and defines build configurations. ```cmake cmake_minimum_required(VERSION 3.22) set(TARGET proxy_generator) project(${TARGET}) add_executable(${TARGET} "main.cpp") target_link_libraries(${TARGET} PRIVATE Constructs File imagehlp) target_compile_definitions(${TARGET} PRIVATE RC_FILE_BUILD_STATIC) # Directly set folder for proxy_generator to Programs/proxy set_target_properties(${TARGET} PROPERTIES FOLDER "Programs/proxy") add_subdirectory("proxy") ``` -------------------------------- ### Get Streaming Render Asset Info Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/guides/generating-uht-compatible-headers.md Retrieves information about streaming render assets for the VoxelProceduralMeshComponent. The current implementation is empty. ```cpp void UVoxelProceduralMeshComponent::GetStreamingRenderAssetInfo(FStreamingTextureLevelContext& LevelContext, TArray& OutStreamingRenderAssets) const { } ``` -------------------------------- ### Initialize Git Submodules Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/README.md Initialize and update git submodules recursively. Ensure your GitHub account is linked to your Epic Games account for UE source access. Do not use the --remote option. ```bash git submodule update --init --recursive ``` -------------------------------- ### Getting UObject Reflection Object Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/classes/uobject.md The Reflection() method returns a UObjectReflection object, providing access to reflection-related functionalities for the UObject. ```lua local Character = FindFirstOf("Character") local ReflectionData = Character:Reflection() -- Use ReflectionData for further reflection operations ``` -------------------------------- ### Recommended Alternative: ExecuteInGameThreadWithDelay Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/global-functions/executeasync.md Demonstrates the recommended alternative to ExecuteAsync, which is ExecuteInGameThreadWithDelay, offering more control. ```APIDOC ## Recommended Alternative: ExecuteInGameThreadWithDelay ### Description Executes a callback on the game thread on the next frame or ProcessEvent. This function provides cancellation, pause/resume, and state querying capabilities. ### Method Not applicable (function call) ### Endpoint Not applicable ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **delay** (number) - Required - The delay in seconds before execution. Use 0 for next frame. - **callback** (function) - Required - The callback function to execute. ### Request Example ```lua -- Executes on the game thread on the next frame/ProcessEvent local handle = ExecuteInGameThreadWithDelay(0, function() print("Executed on game thread\n") end) -- Can now cancel with: CancelDelayedAction(handle) ``` ### Response #### Success Response (200) Returns a handle that can be used to manage the delayed action (e.g., cancellation). #### Response Example ```lua -- handle variable would contain the return value ``` ``` -------------------------------- ### TObjectPtr Before v4.x Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/upgrade-guide.md Illustrates the simple wrapper implementation of TObjectPtr in versions prior to v4.x. ```cpp template class TObjectPtr { public: UnderlyingType* UnderlyingObjectPointer; }; ``` -------------------------------- ### Define ArrayPropertyInfo in Lua Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/table-definitions/arraypropertyinfo.md Example of how to define an ArrayPropertyInfo table in Lua, specifying the property type. Ensure PropertyTypes are correctly referenced. ```lua local ArrayPropertyInfo = { ["Type"] = PropertyTypes.IntProperty } ``` -------------------------------- ### FAnsiString Example Usage Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api/classes/fansistring.md Demonstrates basic FAnsiString operations including creation, appending, checking suffixes, converting to lowercase, and finding substrings. Use this for handling ANSI-encoded strings. ```lua local ansiString = FAnsiString("Hello ANSI") print(ansiString:ToString()) ansiString:Append(" World") print(ansiString:ToString()) if ansiString:EndsWith("World") then print("String ends with World!") end local lowerString = ansiString:ToLower() print(lowerString:ToString()) local index = ansiString:Find("ANSI") if index then print("Found at index: " .. index) end ``` -------------------------------- ### Get Light Map Resolution Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/guides/generating-uht-compatible-headers.md Retrieves the light map resolution for the component. Returns false, indicating no valid resolution is available. ```cpp bool UVoxelProceduralMeshComponent::GetLightMapResolution( int32& Width, int32& Height ) const { return false; } ``` -------------------------------- ### Build with CMake Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/README.md Builds the project using CMake after configuration. Assumes the build directory has been set up. ```bash cmake --build build_xwin ``` -------------------------------- ### Registering a GUI Tab with `UE4SSProgram::add_gui_tab` Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/guides/creating-gui-tabs-with-c++-mod.md Use `UE4SSProgram::add_gui_tab` for manual tab registration. You are responsible for cleaning up the tab in the mod's destructor to prevent crashes. The callback for this method receives a `nullptr` for the instance. ```cpp m_less_safe_tab = std::make_shared(STR("My Less Safe Tab"), [](CppUserModBase* instance) { // This callback is identical to the one used with 'register_tab' except 'instance' is always nullptr. ImGui::Text("This is the contents of the less safe tab"); }); UE4SSProgram::get_program().add_gui_tab(m_less_safe_tab); ``` -------------------------------- ### Migrating TObjectPtr Pointer-to-Integer Conversions Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/upgrade-guide.md Illustrates how to perform pointer-to-integer conversions with TObjectPtr in v4.x, using Get() or the ToRawPtr helper function. ```cpp // Old uintptr_t addr = reinterpret_cast(ObjectPtr.UnderlyingObjectPointer); // New uintptr_t addr = reinterpret_cast(ObjectPtr.Get()); // or uintptr_t addr = reinterpret_cast(ToRawPtr(ObjectPtr)); // using helper to extract a raw pointer from TObjectPtr ``` -------------------------------- ### RegisterInitGameStatePostHook Source: https://github.com/ue4ss-re/re-ue4ss/blob/main/docs/lua-api.md Registers a callback that will be invoked after AGameModeBase::InitGameState is called. ```APIDOC ## RegisterInitGameStatePostHook(function Callback) ### Description Registers a callback that will get called after AGameModeBase::InitGameState is called. ### Method N/A (Function Call) ### Endpoint N/A ### Parameters #### Callback Parameters - **Context** (AGameModeBase) - The game mode context. ### Notes - Params (except strings & bools & FOutputDevice) must be retrieved via 'Param:Get()' and set via 'Param:Set()'. ```