### Manual installation folder structure Source: https://github.com/aurieframework/yytoolkit/wiki/Next:-Getting-Started Folder structure to create in the game directory for manual installation. Place AurieCore.dll in the Native folder and YYToolkit.dll in the Aurie folder. ```text ├─── GameExecutable.exe └─── mods ├─── Aurie └─── Native ``` -------------------------------- ### AuriePatcher install command and output Source: https://github.com/aurieframework/yytoolkit/wiki/Next:-Getting-Started Command to patch the game with AuriePatcher, followed by its expected output. The command installs AurieCore.dll into the game executable; the output shows the patching process and success message. ```text > AuriePatcher.exe "C:\path\to\game\executable.exe" "C:\path\to\game\mods\Native\AurieCore.dll" install Using executable: "C:\path\to\game\executable.exe" Using native DLL path: "C:\path\to\game\mods\Native\AurieCore.dll" File mapped to 0x000002805FC20040 => size 0x27B0A00 .aurie section at 000002805FC20380 g_OldOEP stored at 00000280623CA5D8, contains value 0x1A83F84. Filed saved successfully. Done. ``` -------------------------------- ### Hook Source: https://github.com/aurieframework/yytoolkit/wiki/Guide:-Hooking-game-functions Documentation for the Hook function signature, parameters, return value, and usage example. ```APIDOC ## Hook ### Description Hooks a script function in the GameMaker engine, allowing interception and modification of the function's behavior. ### Syntax ```cpp RValue& Hook( [in, optional] CInstance* Self, [in, optional] CInstance* Other, [out] RValue& ReturnValue, [in] int ArgumentCount [in, optional] RValue** Arguments ); ``` ### Parameters - **Self** (CInstance*) - Optional - Pointer to the instance referred to via the `self` keyword. May be `nullptr` if called by another YYToolkit module. - **Other** (CInstance*) - Optional - Pointer to the instance referred to via the `other` keyword. May be `nullptr` if called by another YYToolkit module. If no other instance, points to the same instance as `Self`. - **ReturnValue** (RValue&) - Required - Reference to an engine-allocated buffer where the return value of the script is written. Always valid. - **ArgumentCount** (int) - Required - Number of arguments passed to the function. - **Arguments** (RValue**) - Optional - Pointer to the first element in an array of `RValue*` representing the arguments. May be `nullptr` if `ArgumentCount` is 0. ### Return Value Returns the reference passed into the `ReturnValue` parameter. Returning anything else is undefined behavior. ### Example ```cpp CScript* script_data = nullptr; int script_index = 0; // Get the script data g_YYTKInterface->GetNamedRoutinePointer( "Target script name", reinterpret_cast(&script_data) ); // Create the hook MmCreateHook( g_ArSelfModule, "My Hook", script_data->m_Functions->m_ScriptFunction, Hook, reinterpret_cast(&original_function) ); ``` ``` -------------------------------- ### Built-in Function Hooking with MmCreateHook Source: https://github.com/aurieframework/yytoolkit/wiki/Guide:-Hooking-game-functions Creates a hook for a built-in function. Uses GetNamedRoutinePointer to obtain the function pointer, then MmCreateHook to install the hook and store the original function pointer. Error handling is omitted. ```cpp TRoutine game_function = nullptr; TRoutine original_function = nullptr; // Get a pointer to the target function using YYToolkit's interface g_YYTKInterface->GetNamedRoutinePointer( "Target Function", reinterpret_cast(&game_function) ); // Create the hook MmCreateHook( g_ArSelfModule, "My Hook", game_function, Hook, reinterpret_cast(&original_function) ); ``` -------------------------------- ### Creating a hook on a script function Source: https://github.com/aurieframework/yytoolkit/wiki/Guide:-Hooking-game-functions C++ example showing how to obtain a script's function pointer via GetNamedRoutinePointer and then create a hook with MmCreateHook. The hook function is named "My Hook" and the original function pointer is stored in original_function. ```cpp CScript* script_data = nullptr; int script_index = 0; // Get the script data g_YYTKInterface->GetNamedRoutinePointer( "Target script name", reinterpret_cast(&script_data) ); // Create the hook MmCreateHook( g_ArSelfModule, "My Hook", script_data->m_Functions->m_ScriptFunction, Hook, reinterpret_cast(&original_function) ); ``` -------------------------------- ### CInstance::FromInstanceID: get CInstance pointer from instance ID Source: https://github.com/aurieframework/yytoolkit/wiki/API-changes-in-v4 Demonstrates the new static method CInstance::FromInstanceID, which returns a pointer to a CInstance from a GameMaker instance ID. The ID is assumed to be found at runtime. ```cpp int32_t instance_id = 103'545; // Assume this is an ID found at runtime CInstance* object = CInstance::FromInstanceID(instance_id); ``` -------------------------------- ### GetMethodParameterCount Source: https://github.com/aurieframework/yytoolkit/wiki/Next:-GetMethodParameterCount Gets the number of arguments needed for a built-in function call. The function takes a method name and an output reference for the count, returning an AurieStatus indicating success or failure. ```APIDOC ## GetMethodParameterCount ### Description Gets the number of arguments needed for a built-in function call. ### Syntax ```cpp AurieStatus GetMethodParameterCount( [in] std::string_view MethodName, [out] int32_t& Count ); ``` ### Parameters - **MethodName** (std::string_view) - Required - A pointer to the buffer containing the name of the function to look up. This parameter can only refer to a GameMaker built-in function. - **Count** (int32_t&) - Required - A reference to a 32-bit buffer into which the number of parameters will be written. **This count may not always be accurate**. Functions taking optional arguments may return `-1`. Some functions, eg. `surface_create` may also return `-1`, as they take a variable amount of arguments, despite YoYoGames' documentation suggesting otherwise. ### Return Value | **Value** | **Description** | | --- | --- | | `AURIE_SUCCESS` | The named routine was found, and the parameter count was written into the buffer. | | `AURIE_MODULE_INTERNAL_ERROR` | The internal function needed is unavailable. | | `AURIE_ACCESS_DENIED` | `MethodName` refers to a script or an extension function. | | `AURIE_OBJECT_NOT_FOUND` | The named routine does not exist. | ### Requirements | **Criterium** | **Value** | | --- | --- | | **Minimum YYTK Version** | 5.0.0 | | **Context** | Any | ``` -------------------------------- ### GetInstanceMemberCount Source: https://github.com/aurieframework/yytoolkit/wiki/Next:-GetInstanceMemberCount Gets the number of variables in a struct or instance. The function takes an RValue object and a reference to an int32_t to store the count. It returns an AurieStatus indicating success or failure. ```APIDOC ## GetInstanceMemberCount ### Description Gets the number of variables in a struct or instance. ### Syntax ```cpp AurieStatus GetInstanceMemberCount( [in] RValue Object, [out] int32_t& Count ); ``` ### Parameters #### Object - **Type**: RValue - **Required**: Yes - **Description**: An RValue containing the pointer to the instance object whose variables are to be counted. This variable must be of type ``VALUE_OBJECT``. #### Count - **Type**: int32_t& (reference) - **Required**: Yes - **Description**: A reference to a 32-bit integer, which receives the number of variables stored in the struct / instance. Please note that built-in variables (such as ``x``, ``image_index``, etc.) **are not counted**. The value stored in this variable prior to calling this function is guaranteed to remain unchanged if the function fails. ### Return Value | **Value** | **Description** | | --- | --- | | `AURIE_SUCCESS` | The method succeeded, and the member count was written into the buffer. | | `AURIE_UNAVAILABLE` | The internal function needed is unavailable. | | `AURIE_INVALID_PARAMETER` | `Object` does not refer to an instance or struct. | ### Requirements | **Criterium** | **Value** | | --- | --- | | **Minimum YYTK Version** | 4.0.0 | | **Context** | Engine-synchronous | ``` -------------------------------- ### GetBuiltin Source: https://github.com/aurieframework/yytoolkit/wiki/Next:-GetBuiltin Documentation for the GetBuiltin function, which retrieves the value of a local or global built-in variable. ```APIDOC ## GetBuiltin ### Description Retrieves the value of a local built-in or a global built-in variable. ### Syntax ```cpp AurieStatus GetBuiltin( [in] std::string_view Name, [in, optional] CInstance* TargetInstance [in, optional] int ArrayIndex [out] RValue& Value ); ``` ### Parameters #### Name - **Type**: `std::string_view` - **Required**: Yes - **Description**: The case-sensitive name of the built-in variable to access. Can be a local built-in (such as `id`, `image_index`) or a global built-in (such as `room`, `instance_count`). Note: a global built-in is not the same as a regular global variable; use `variable_global_get` or `GetInstanceMember` with the global instance for global variables. #### TargetInstance - **Type**: `CInstance*` - **Required**: Optional - **Description**: The instance whose built-in variables are being accessed. Unused for most global built-ins, but local built-ins (like `object_index`) require a valid instance and may crash the game if invalid. #### ArrayIndex - **Type**: `int` - **Required**: Optional - **Description**: An optional array index for accessing built-in arrays (like `argument`). For non-array accesses, specify `NULL_INDEX` (defined in YYTK's `Shared.hpp`). #### Value - **Type**: `RValue&` - **Required**: Output - **Description**: A buffer into which the value of the built-in variable will be written. The contents remain unchanged if the function fails. ### Return Value | **Value** | **Description** | | --- | --- | | `AURIE_SUCCESS` | The value of the built-in variable was written into the buffer. | | `AURIE_MODULE_INTERNAL_ERROR` | The internal function needed is unavailable. | | `AURIE_ACCESS_DENIED` | The `Name` variable does not have a getter. | | `AURIE_OBJECT_NOT_FOUND` | The variable does not exist. | ### Requirements | **Criterium** | **Value** | | --- | --- | | **Minimum YYTK Version** | 3.0.3 | | **Context** | Any if accessing a global, otherwise engine-synchronous | ``` -------------------------------- ### CallBuiltinEx Source: https://github.com/aurieframework/yytoolkit/wiki/Next:-CallBuiltinEx Documentation for the CallBuiltinEx function, which calls a GameMaker built-in function with user-specified arguments. ```APIDOC ## CallBuiltinEx ### Description Calls a GameMaker built-in function with user-specified arguments. The result is written to a provided buffer, and the function is called in the context of the specified Self and Other instances. ### Syntax ```cpp AurieStatus CallBuiltinEx( [out] RValue& Result, [in] const char* FunctionName, [in, optional] CInstance* SelfInstance, [in, optional] CInstance* OtherInstance [in] std::vector Arguments ); ``` ### Parameters #### Result - **Type**: `RValue&` - Required - A reference to a buffer into which the result of the call is written. The buffer is guaranteed to remain unchanged if the function fails. #### FunctionName - **Type**: `const char*` - Required - The name of the function to call. Must refer to a built-in function, not a script. Function names are case-sensitive. The function is called in the context of the passed in Self and Other instances. Passing a script name may crash the game or corrupt the stack. #### SelfInstance - **Type**: `CInstance*` - Optional - The instance pointed to by the `self` keyword in GML. Recommended to use the instance used by the current engine event unless calling asynchronously from the engine thread. #### OtherInstance - **Type**: `CInstance*` - Optional - The instance pointed to by the `other` keyword in GML. Recommended to use the instance used by the current engine event unless calling asynchronously from the engine thread. #### Arguments - **Type**: `std::vector` - Required - A vector of RValues containing all arguments to pass to the built-in function. The order matches the order of arguments when calling the function from GML. ### Return Value | **Value** | **Description** | | --- | --- | | `AURIE_SUCCESS` | The function was called, and the result was written into the buffer. | | `AURIE_MODULE_INTERNAL_ERROR` | The internal function needed is unavailable. | | `AURIE_OBJECT_NOT_FOUND` | The function does not exist. | ### Requirements | **Criterium** | **Value** | | --- | --- | | **Minimum YYTK Version** | 3.0.0 | | **Context** | Any if function takes and returns only primitive types (no objects, no arrays). Otherwise engine-synchronous. | ### Remarks Unlike YYTK v2's Legacy CallBuiltin function, `CallBuiltinEx` does not implicitly use the global instance if both `SelfInstance` and `OtherInstance` are specified as `nullptr`. To use the global instance, use the `GetGlobalInstance` function, or the `CallBuiltin` wrapper over `CallBuiltinEx`. ``` -------------------------------- ### CallBuiltin Source: https://github.com/aurieframework/yytoolkit/wiki/Next:-CallBuiltin Documentation for the CallBuiltin function, which invokes a GameMaker built-in function with user-specified arguments. ```APIDOC ## CallBuiltin ### Description Calls a GameMaker built-in function with user-specified arguments. ### Syntax ```cpp RValue CallBuiltin( [in] const char* FunctionName, [in] std::vector Arguments ); ``` ### Parameters - **FunctionName** (const char*) - Required - The name of the function to call. Must refer to a built-in function, not a script. Case-sensitive. Called in a global context where both `self` and `other` point to the global namespace. - **Arguments** (std::vector) - Required - A vector of RValues containing all arguments to pass to the built-in function, in the same order as in GML. ### Return Value Returns an engine-allocated RValue on success. On error, returns an `unset` RValue. Note: The function does not offer a reliable way to identify error conditions; an `unset` RValue may also be returned by functions that return `N/A` per GameMaker documentation. For proper error handling, use CallBuiltinEx. ### Remarks - Minimum YYTK Version: 3.0.0 - Context: Any if function takes and returns only primitive types (no objects, no arrays). Otherwise engine-synchronous. ``` -------------------------------- ### SetBuiltin Source: https://github.com/aurieframework/yytoolkit/wiki/Next:-SetBuiltin Documentation for the SetBuiltin function, which sets the value of a local or global built-in variable. ```APIDOC ## SetBuiltin ### Description Sets the value of a local built-in or a global built-in variable. ### Syntax ```cpp AurieStatus SetBuiltin( [in] std::string_view Name, [in, optional] CInstance* TargetInstance, [in, optional] int ArrayIndex, [in] RValue& Value ); ``` ### Parameters #### Name - **Type**: `std::string_view` - **Required**: Yes - **Description**: The case-sensitive name of the built-in variable to access. Can be a local built-in (such as `id`, `image_index`) or a global built-in (such as `room`, `instance_count`). #### TargetInstance - **Type**: `CInstance*` - **Required**: Optional - **Description**: The instance whose built-in variables are being accessed. Unused for most global built-ins, but required for local built-ins (e.g., `object_index`). Invalid instance may crash the game. #### ArrayIndex - **Type**: `int` - **Required**: Optional - **Description**: An optional array index to use when accessing built-in arrays (like `argument`). For non-array accesses, specify `NULL_INDEX` (defined in YYTK's `Shared.hpp`). #### Value - **Type**: `RValue&` - **Required**: Yes - **Description**: A buffer whose value will be copied into the built-in variable. The contents of this buffer are guaranteed to remain unchanged. ### Return Value | **Value** | **Description** | | --- | --- | | `AURIE_SUCCESS` | The built-in variable was written to successfully. | | `AURIE_MODULE_INTERNAL_ERROR` | The internal function needed is unavailable. | | `AURIE_OBJECT_NOT_FOUND` | The target variable does not exist. | | `AURIE_ACCESS_DENIED` | The target variable has no setter. | ### Requirements | **Criterium** | **Value** | | --- | --- | | **Minimum YYTK Version** | 3.0.3 | | **Context** | Any if accessing a global, otherwise engine-synchronous | ``` -------------------------------- ### CallGameScriptEx Source: https://github.com/aurieframework/yytoolkit/wiki/Next:-CallGameScriptEx Documentation for the CallGameScriptEx function, which calls a user-defined script within a user-specified context. ```APIDOC ## CallGameScriptEx ### Description Calls a user-defined script within a user-specified context. ### Syntax ```cpp AurieStatus CallGameScriptEx( [out] RValue& Result, [in] std::string_view ScriptName, [in, optional] CInstance* SelfInstance, [in, optional] CInstance* OtherInstance, [in] const std::vector& Arguments ); ``` ### Parameters #### Result A reference to a buffer into which the result of the script is written. If the script does not return a value, the RValue will be `undefined`. If the call fails, the buffer's contents are guaranteed to be unchanged. #### ScriptName The **case sensitive** name of the script, including the `gml_Script` prefix, to be called. #### SelfInstance The instance or struct pointed to by the `self` keyword in GML. Can be set to `nullptr` if you are sure the script doesn't access the `self` object. Games usually expect a custom calling convention for scripts. If your code provides an object that doesn't adhere to the game's calling convention, unexpected behavior may occur. #### OtherInstance The instance or struct pointed to by the `other` keyword in GML. Can be set to `nullptr` if you are sure the script doesn't access the `other` object. Games usually expect a custom calling convention for scripts. If your code provides an object that doesn't adhere to the game's calling convention, unexpected behavior may occur. #### Arguments A vector of arguments, with which the script will be invoked. The arguments are passed in the same order as if calling the script from regular GameMaker code. ### Return Value | **Value** | **Description** | | --- | --- | | `AURIE_SUCCESS` | The script was called successfully. | | `AURIE_OBJECT_NOT_FOUND` | The script does not exist. | | `AURIE_INVALID_PARAMETER` | `ScriptName` refers to a built-in or an extension function instead of a script. | | `AURIE_ACCESS_DENIED` | No function is linked to the script. | ### Requirements | **Criterium** | **Value** | | --- | --- | | **Minimum YYTK Version** | 4.0.0 | | **Context** | Engine-synchronous | ``` -------------------------------- ### GetInstanceObject Source: https://github.com/aurieframework/yytoolkit/wiki/Next:-GetInstanceObject This function converts an instance ID to an instance object pointer. It takes an instance ID and returns a pointer to the corresponding instance, with status codes indicating success or failure. ```APIDOC ## GetInstanceObject ### Description Converts an instance ID to an instance object. ### Syntax ```cpp AurieStatus GetInstanceObject( [in] int32_t InstanceID, [out] CInstance*& Instance ); ``` ### Parameters - **InstanceID** (int32_t) - Required - The ID of a currently active instance. This ID can be found in either the ``instance_id`` global built-in array, and is returned from functions such as ``instance_create_depth``. - **Instance** (CInstance*&) - Required - A reference to a pointer-sized buffer, into which the pointer to the instance is written. This pointer is guaranteed to remain valid until the instance is destroyed. If the function fails, the contents of this buffer are guaranteed to remain unchanged. ### Return Value | **Value** | **Description** | | --- | --- | | `AURIE_SUCCESS` | The instance was found, and the pointer to it was written into the buffer. | | `AURIE_MODULE_INTERNAL_ERROR` | The internal function needed is unavailable. | | `AURIE_OBJECT_NOT_FOUND` | The instance does not exist. | ### Requirements | **Criterium** | **Value** | | --- | --- | | **Minimum YYTK Version** | 3.1.3 | | **Context** | Engine-synchronous | ``` -------------------------------- ### CODE chunk structure for VM bytecode (bytecode 15+) Source: https://github.com/aurieframework/yytoolkit/wiki/About-VM-and-YYC Defines the structure of the CODE chunk in data.win files for bytecode 15 and newer. It shows the layout of the chunk header, pointer list, and entry elements, which is useful for understanding how VM bytecode is stored and for modding tools that parse data.win. ```cpp struct CODEChunk { char szChunkName[4]; // RIFF-style, it's not null-terminated. uint32_t nChunkLength; // The total length of the chunk struct PointerList { int nEntryCount; uint32_t nPointers[nEntryCount]; struct Element { UndertaleString sEntryName; uint16_t nLocalsCount; uint16_t nArgumentsCount; int32_t nBytecodeOffset; uint32_t nOffset; } nEntries[nEntryCount]; } pList; }; ``` -------------------------------- ### GetRoomData Source: https://github.com/aurieframework/yytoolkit/wiki/Next:-GetRoomData Documentation for the GetRoomData function, which retrieves the deserialized contents of a GameMaker room. ```APIDOC ## GetRoomData ### Description Gets the deserialized contents of a GameMaker room. ### Syntax ```cpp AurieStatus GetRoomData( [in] int32_t RoomID, [out] CRoom*& Room ); ``` ### Parameters - **RoomID** (int32_t) - Required - The room number of the room, the data of which is retrieved. - **Room** (CRoom*&) - Required - A reference to a pointer-sized buffer into which the address of the CRoom object is written. If the function fails, the buffer referenced by this parameter is left untouched. In the name of safety, this structure is normally opaque. To remove this safeguard, see [Enabling internal structure access](https://github.com/AurieFramework/YYToolkit/wiki/Guide:-Internal-structure-access). The pointer written into this buffer is guaranteed to remain valid for the duration of the room's existence. ### Return Value The function returns `AURIE_SUCCESS` on success, otherwise returns a matching error code. If the information needed for looking up rooms isn't available, the function returns `AURIE_MODULE_INTERNAL_ERROR`. If the `RoomID` index isn't a valid room, the function returns `AURIE_OBJECT_NOT_FOUND`. ### Notes Using this function to get the active room may produce unexpected results (eg. the room having no active instances) due to how the GameMaker engine works. To get a pointer to the currently active room, use the [GetCurrentRoomData](https://github.com/AurieFramework/YYToolkit/wiki/Next:-GetCurrentRoomData) function. ``` -------------------------------- ### CallGameScript Source: https://github.com/aurieframework/yytoolkit/wiki/Next:-CallGameScript Documentation for the CallGameScript function, which invokes a user-defined script in the global context. ```APIDOC ## CallGameScript ### Description Calls a user-defined script within the global context. This method invokes the script with `self` and `other` both pointing to `global`, so it may not be suitable for scripts that expect specific object references. For instance-specific context, use CallGameScriptEx. ### Syntax ```cpp RValue CallGameScript( [in] std::string_view ScriptName, [in] const std::vector& Arguments ); ``` ### Parameters - **ScriptName** (std::string_view) - Required - The name of the script, including the `gml_Script` prefix, to call. Case sensitive. - **Arguments** (const std::vector&) - Required - A vector of arguments with which the script will be invoked. Passed in the same order as if calling from regular GameMaker code. ### Return Value Returns `AURIE_SUCCESS` on success, otherwise a matching error code. See the CallGameScriptEx page for more information. ### Requirements - **Minimum YYTK Version**: 4.0.0 - **Context**: Engine-synchronous ``` -------------------------------- ### GetGlobalInstance Source: https://github.com/aurieframework/yytoolkit/wiki/Next:-GetGlobalInstance Returns a pointer to the instance representing the GameMaker global namespace. ```APIDOC ## GetGlobalInstance ### Description Returns a pointer to the instance representing the GameMaker global namespace. ### Syntax ```cpp AurieStatus GetGlobalInstance( [out] CInstance** Instance ); ``` ### Parameters - **Instance** (CInstance**) - Output - A pointer to the buffer into which the address of the global instance is written. The contents of this buffer are guaranteed to be preserved if the function fails. ### Return Value | **Value** | **Description** | | --- | --- | | `AURIE_SUCCESS` | The global instance pointer has been written into the buffer. | | `AURIE_MODULE_INTERNAL_ERROR` | The internal function needed is unavailable. | | `AURIE_OBJECT_NOT_FOUND` | The `@@GlobalScope@@` function does not exist. | ### Requirements | **Criterium** | **Value** | | --- | --- | | **Minimum YYTK Version** | 3.0.0 | | **Context** | Engine-synchronous | ``` -------------------------------- ### CreateCallback Source: https://github.com/aurieframework/yytoolkit/wiki/Next:-CreateCallback Registers a callback function for a specific game event trigger. ```APIDOC ## [FUNCTION] CreateCallback ### Description Registers a callback function for intercepting game events. The callback is invoked when the specified event trigger occurs. ### Method FUNCTION ### Endpoint CreateCallback ### Parameters #### Module - **Module** (AurieModule*) - Required - A pointer to the module registering the callback. Use `g_ArSelfModule` unless otherwise needed. #### Trigger - **Trigger** (EventTriggers) - Required - The specific event to listen for. Must not be bitwise-ORed. Determines the callback routine signature. #### Routine - **Routine** (PVOID) - Required - A pointer to the callback function. Must be unique per registration. The function prototype depends on the trigger type. #### Priority - **Priority** (int32_t) - Required - The order in which callbacks are called. Higher priority callbacks are called first. Default is 0. ### Request Example ```cpp AurieStatus status = CreateCallback( g_ArSelfModule, EVENT_FRAME, (PVOID)MyFrameCallback, 0 ); ``` ### Response #### Success Response (AURIE_SUCCESS) - **status** (AurieStatus) - Returns `AURIE_SUCCESS` on success. #### Error Response (AURIE_OBJECT_ALREADY_EXISTS) - **status** (AurieStatus) - Returns `AURIE_OBJECT_ALREADY_EXISTS` if the routine is already registered for the given module. ### Response Example ```cpp AurieStatus status = CreateCallback(...); if (status != AURIE_SUCCESS) { // handle error } ``` ### Notes - The callback routine prototype must match the trigger type. See the table below for supported triggers and their corresponding routine types. | Trigger | Type | Target event | |:-----------------:|:---------------:|:---------------------------------:| | EVENT_OBJECT_CALL | FWCodeEvent | Object events (Create, Step, ...) | | EVENT_FRAME | FWFrame | Frame rendering (Present) | | EVENT_RESIZE | FWResize | Window resizing (ResizeBuffers) | | EVENT_SCRIPT_CALL | FWScriptEvent | Script invocations **(VM-only)** | | EVENT_WNDPROC | FWWndProc | Generic window events | ``` -------------------------------- ### GetBuiltinVariableIndex Source: https://github.com/aurieframework/yytoolkit/wiki/Next:-GetBuiltinVariableIndex Documentation for the GetBuiltinVariableIndex function, which retrieves the index for a built-in variable. ```APIDOC ## GetBuiltinVariableIndex ### Description Retrieves the index for an instance built-in or global built-in variable. ### Syntax ```cpp AurieStatus GetBuiltinVariableIndex( [in] std::string_view Name, [out] size_t& Index ); ``` ### Parameters - **Name** (std::string_view) - Required - The name of the built-in to look up. Can be a local built-in (such as `id`, `image_index`, etc.) or a global built-in (such as `room`, `instance_count`, etc.). Note: A global built-in variable is not the same as a regular global variable; use `variable_global_get` or `GetInstanceMember` with the global instance from `GetGlobalInstance` for global variables. - **Index** (size_t&) - Required - A reference to a buffer into which the index of the variable is written. This buffer is guaranteed to remain unchanged if the function fails. To access built-in variables via this index, use the `GetBuiltinVariableInformation` function. ### Return Value | **Value** | **Description** | | --- | --- | | `AURIE_SUCCESS` | The built-in was found, and its index was written into the buffer. | | `AURIE_MODULE_INTERNAL_ERROR` | The internal function needed is unavailable. | | `AURIE_OBJECT_NOT_FOUND` | The function `Name` does not exist. | ### Requirements | **Criterium** | **Value** | | --- | --- | | **Minimum YYTK Version** | 3.0.3 | | **Context** | Any | ``` -------------------------------- ### GetArraySize Source: https://github.com/aurieframework/yytoolkit/wiki/Next:-GetArraySize Documentation for the GetArraySize function, which retrieves the size of a GameMaker array. ```APIDOC ## GetArraySize ### Description Gets the size of a GameMaker array. ### Syntax ```cpp AurieStatus GetArraySize( [in] RValue& Value, [out] size_t& Size ); ``` ### Parameters - **Value** (RValue&) - Required - A non-const reference to a variable of type `VALUE_ARRAY`. You can get this reference to an existing variable by calling `GetInstanceMember` on an existing instance, or by creating a new `RValue` on the stack. - **Size** (size_t&) - Required - A reference to a buffer into which the size of the array is written. If the function fails, the contents of this value are guaranteed to remain unchanged. ### Return Value The function returns `AURIE_SUCCESS` on success, otherwise returns a matching error code. If the information needed for looking up array elements isn't available, the `AURIE_MODULE_INTERNAL_ERROR` status code is returned. The function returns `AURIE_INVALID_PARAMETER` if the `Value` parameter isn't an array. ``` -------------------------------- ### GetInstanceMember Source: https://github.com/aurieframework/yytoolkit/wiki/Next:-GetInstanceMember Documentation for the GetInstanceMember function, which retrieves a direct pointer to a member variable of a GameMaker instance or struct. ```APIDOC ## GetInstanceMember ### Description Accesses variables for a given instance / GameMaker struct. This function operates only on GameMaker structs or instance pointers, not on generic data structures. ### Syntax ```cpp AurieStatus GetInstanceMember( [in] RValue Instance, [in] const char* MemberName, [out] RValue*& Member ); ``` ### Parameters #### Instance An object-typed RValue, containing the pointer to the instance the members of which will be enumerated. Given that RValues can be implicitly constructed from a `CInstance*`, it is possible for callers to pass a `CInstance*` directly. #### MemberName A pointer to a read-only buffer containing the name of the member which will be looked up. Note this lookup is case-sensitive. #### Member A reference to a pointer to an RValue. The RValue pointer retrieved from this routine may be invalidated at any time by the engine, and it is therefore not advised to hold onto pointers longer than absolutely necessary. The pointers retrieved by this routine point to not a copy, but the real variable, which means that access asynchronous from engine execution should be kept to a minimum. If the function fails, the address pointed-to by this variable is guaranteed to be preserved. ### Return Value | **Value** | **Description** | | --- | --- | | `AURIE_SUCCESS` | The member was found, and the pointer to it was written into the buffer. | | `AURIE_INVALID_PARAMETER` | `Instance` is not an object. | | `AURIE_OBJECT_NOT_FOUND` | `Instance` does not contain the member variable. | ### Remarks At first glance, this function may seem equivalent to `variable_instance_get`, however there is a clear distinction between the two. - `GetInstanceMember` returns a **direct pointer to the variable inside the instance**. - Any modifications made through this pointer are directly reflected in the instance variable as they happen. - It is **unsafe** to hold onto pointers returned by `GetInstanceMember`, as they get invalidated when the instance is destroyed. - `variable_instance_get` returns a **copy of the variable inside the instance**. - You have to write back using `variable_instance_set` for your changes to be reflected in the game's object. - It is **safe** to hold onto values returned by `variable_instance_get`, as they don't get invalidated when the instance is destroyed. ### Requirements | **Criterium** | **Value** | | --- | --- | | **Minimum YYTK Version** | 3.0.0 | | **Context** | Engine-synchronous | ``` -------------------------------- ### GetBuiltinVariableInformation Source: https://github.com/aurieframework/yytoolkit/wiki/Next:-GetBuiltinVariableInformation This code snippet documents the GetBuiltinVariableInformation function, which retrieves the engine entry for a built-in variable. ```APIDOC ## GetBuiltinVariableInformation ### Description Retrieves the engine entry for a built-in variable. ### Syntax ```cpp AurieStatus GetBuiltinVariableInformation( [in] size_t Index, [out] RVariableRoutine*& VariableInformation ); ``` ### Parameters - **Index** (size_t) - Required - The array index of the built-in variable. This index can be obtained by calling GetBuiltinVariableIndex. - **VariableInformation** (RVariableRoutine*&) - Required - A reference to a pointer-sized buffer which receives the address of the array entry for the built-in variable. You may keep a pointer to this struct, as it should be resident in memory until the runner exits. Even though the structure fields are writable, plugins should treat this structure as read-only for increased safety. ### Return Value | **Value** | **Description** | | --- | --- | | `AURIE_SUCCESS` | The variable information was written into the buffer. | | `AURIE_MODULE_INTERNAL_ERROR` | The internal function needed is unavailable. | | `AURIE_INVALID_PARAMETER` | An out-of-bounds read was attempted. | ### Requirements | **Criterium** | **Value** | | --- | --- | | **Minimum YYTK Version** | 3.0.3 | | **Context** | Any | ``` -------------------------------- ### EnumInstanceMembers Source: https://github.com/aurieframework/yytoolkit/wiki/Next:-EnumInstanceMembers Enumerates the members of a GameMaker struct or instance pointer, invoking a callback for each member. ```APIDOC ## [FUNCTION] EnumInstanceMembers ### Description Enumerates the members of a GameMaker struct or instance pointer, invoking a callback for each member. ### Method FUNCTION ### Endpoint EnumInstanceMembers ### Parameters #### Instance - **type**: RValue (object-typed) - Required - An object-typed RValue containing the pointer to the instance whose members will be enumerated. Can be implicitly constructed from a `CInstance*`. #### EnumFunction - **type**: std::function<...> - Required - A pointer to a caller-defined callback function. The callback should have the prototype: `bool ExampleFunction(const char* MemberName, RValue* Value)`. If the callback returns true, enumeration stops and the function returns `AURIE_SUCCESS`. If it returns false, enumeration continues. The callback may modify the RValue pointed to by `Value` to change the member in the enumerated instance. ### Return Value - `AURIE_SUCCESS` - The enumeration ended successfully. - `AURIE_INVALID_PARAMETER` - `Instance` does not refer to an object. - `AURIE_OBJECT_NOT_FOUND` - The enumeration function never returned true. ### Remarks This function should be used with caution, as some instances contain thousands of members (e.g., the global instance), causing the callback to be called many times. Time complexity is O(n) at best and O(n log n) at worst. ### Requirements - **Minimum YYTK Version**: 3.0.0 - **Context**: Engine-synchronous ``` -------------------------------- ### Array access via vector and raw array Source: https://github.com/aurieframework/yytoolkit/wiki/API-changes-in-v4 Shows how to access array elements using the index operator, ToRefVector (with bounds checking), ToArray (raw pointer), and ToVector (copy). Note that ToArray is only possible on non-const RValue instances. ```cpp // Creates an array of [1, 2, 3, 4] RValue my_array = { 1, 2, 3, 4 }; // Get the reference to the first element using the index operator. RValue& first_element = my_array[0]; // Get the reference to the second element using the reference vector WITH bounds checking. RValue& second_element = *my_array.ToRefVector().at(1); // Get the reference to the third element using the raw array. RValue& third_element = my_array.ToArray()[2]; // Get a COPY of the fourth element using the non-reference vector WITHOUT bounds checking. RValue fourth_element_copy = my_array.ToVector()[3]; ``` -------------------------------- ### Implicit conversions in v4.0.0 (working) Source: https://github.com/aurieframework/yytoolkit/wiki/API-changes-in-v4 In v4.0.0, the same code compiles. Note that RValue initialization now uses VALUE_INT64 instead of VALUE_INT32. Conversions to int32_t, std::string, and all floating/integral types are supported. ```cpp // Assign integral value to the RValue. Initialized as VALUE_INT64. RValue my_rvalue = 5; // OK. RValues can be casted to int32_t. // The result is the same as when calling .ToInt32(). int32_t integer_value = my_rvalue; // OK. ToString returns an std::string. std::string string_value = my_rvalue.ToString(); // OK. All the floating-point types can be implicitely converted-to from an RValue. float float_value = my_rvalue; double double_value = my_rvalue; long double long_double_value = my_rvalue; // OK. All the integral types can be implicitely converted-to from an RValue. int int_value = my_rvalue; long long_value = my_rvalue; long long_long_value = my_rvalue; ``` -------------------------------- ### GetVariableSlot Source: https://github.com/aurieframework/yytoolkit/wiki/Next:-GetVariableSlot Documentation for the GetVariableSlot function, which computes a variable's hash slot ID. ```APIDOC ## GetVariableSlot ### Description Uses the `Code_Variable_FindAlloc_Slot_From_Name` function to allocate or find a variable's hash in an object's hashmap. ### Syntax ```cpp AurieStatus GetVariableSlot( [in] const RValue& Object, [in] const char* VariableName [out] int32_t& Hash ); ``` ### Parameters - **Object** (const RValue&) - Reserved for future use. Currently ignored. - **VariableName** (const char*) - A pointer to a buffer that contains the name of the variable whose name will be converted to a slot ID. - **Hash** (int32_t&) - A reference to a 32-bit integer, into which the hash of `VariableName` will be written. If the function fails, the value in the buffer referenced by `Hash` isn't overwritten. ### Return Value | **Value** | **Description** | | --- | --- | | `AURIE_SUCCESS` | The hash was computed successfully. | | `AURIE_MODULE_INTERNAL_ERROR` | The internal function needed is unavailable. | ### Requirements | **Criterium** | **Value** | | --- | --- | | **Minimum YYTK Version** | 3.3.0 | | **Context** | Engine-synchronous | ``` -------------------------------- ### GetArrayEntry Source: https://github.com/aurieframework/yytoolkit/wiki/Next:-GetArrayEntry Documentation for the GetArrayEntry function, which retrieves a pointer to an element from a GameMaker array. ```APIDOC ## GetArrayEntry ### Description Retrieves a pointer to an element from within a GameMaker array. ### Syntax ```cpp AurieStatus GetArrayEntry( [in] RValue& Value, [in] size_t ArrayIndex, [out] RValue*& IndexedValue ); ``` ### Parameters - **Value** (RValue&) - Required - A non-const reference to a variable of type ``VALUE_ARRAY``. You can get this reference to an existing variable by calling [GetInstanceMember](https://github.com/AurieFramework/YYToolkit/wiki/Next:-GetInstanceMember) on an existing instance, or by creating a new ``RValue`` on the stack. - **ArrayIndex** (size_t) - Required - The index of the element to retrieve within the array. Valid values range from ``0`` up to ``array_length(Value) - 1``. - **IndexedValue** (RValue*&) - Required - A reference to a pointer-sized buffer, into which the pointer to the variable at index ``ArrayIndex`` will be written. If the function fails, the value stored within this buffer is guaranteed to remain unchanged. ### Return Value The function returns ``AURIE_SUCCESS`` on success, otherwise returns a matching error code. If the information needed for looking up array elements isn't available, the ``AURIE_MODULE_INTERNAL_ERROR`` status code is returned. The function returns ``AURIE_INVALID_PARAMETER`` if the lookup failed due to ``ArrayIndex`` exceeding the size of the array, or if the ``Value`` argument isn't an array. If the function failed to determine the array size, ``AURIE_EXTERNAL_ERROR`` is returned. ``` -------------------------------- ### GetScriptData Source: https://github.com/aurieframework/yytoolkit/wiki/Next:-GetScriptData Documentation for the GetScriptData function, which retrieves a pointer to a CScript object by index. ```APIDOC ## GetScriptData ### Description Retrieves a pointer to the CScript object for a given script ID. ### Syntax ```cpp AurieStatus GetScriptData( [in] int Index, [out] CScript*& Script ); ``` ### Parameters #### Index - **Type**: int - **Required**: Yes - **Description**: The index of an element within the runner's script array, the data of which to retrieve. Script IDs returned by both GameMaker built-in functions and the GetNamedRoutineIndex function are offset by 100,000 due to how asset IDs are reserved. To convert a script ID into the array index required by this function, subtract 100,000 from it. #### Script - **Type**: CScript*& - **Required**: Yes - **Description**: A reference to a pointer-sized buffer, into which the address of the script's data will be written. The contents of this buffer are guaranteed to be left untouched if the function fails. ### Return Value | **Value** | **Description** | | --- | --- | | `AURIE_SUCCESS` | The script lookup succeeded and the result was written into the buffer. | | `AURIE_MODULE_INTERNAL_ERROR` | The internal function needed is unavailable. | | `AURIE_OBJECT_NOT_FOUND` | The script does not exist. | ### Requirements | **Criterium** | **Value** | | --- | --- | | **Minimum YYTK Version** | 3.0.1 | | **Context** | Any | ``` -------------------------------- ### Hook Function Signature Source: https://github.com/aurieframework/yytoolkit/wiki/Guide:-Hooking-game-functions Defines the signature for a hook function used with MmCreateHook. Parameters include Result for output, Self and Other instance pointers, ArgumentCount, and Arguments array. ```cpp void Hook( [out] RValue* Result, [in, optional] CInstance* Self, [in, optional] CInstance* Other, [in] int ArgumentCount, [in, optional] RValue* Arguments ); ```