User Tools

Site Tools


Using The AshitaCore Object

What is the AshitaCore Object?

The AshitaCore object (IAshitaCore) is the main object created inside of the Ashita hook. This object is exposed to plugins, including Addons, which in turn is then exposed to Lua via custom exposure methods and the combined efforts of Luabind. This is the main object used to interact with the Ashita hook.

Inside of addons, this object is named and accessible via: AshitaCore

Using AshitaCore

Making use of AshitaCore is very simple and similar to other languages. AshitaCore is created from a class object inside of C++. This means that calls are considered __thiscall. What this means is that the calling convention used (__thiscall) makes use of an object while making the call to the desired function. For example, take this C++ code:

class Derp
    void HelloWorld();

auto x = new Derp();
delete x;

This example code shows creating a class called Derp, making an instance of it named 'x', and then invoking the 'HelloWorld' function. Because 'x' is an instance of Derp, we use the → operator to invoke the function. In Lua, → is represented by : instead.

You can learn more about the differences between . and : in Lua here:

In Lua, metatables are used to mimic a style of object-oriented coding.

Lets take for example, inside of the IAshitaCore interface, we have a function:

virtual HMODULE GetHandle(void) const = 0;

In C++, this would be invoked like this:

auto handle = coreObject->GetHandle();

In Lua, we would call it like this:

local handle = AshitaCore:GetHandle();

By using the : operator in Lua, we are automatically informing the interpreter that on the left side of the : (in this case, AshitaCore) our object to invoke the GetGameHwnd with is AshitaCore. This can also be called like this:

local handle = IAshitaCore.GetHandle(AshitaCore);

However, in this case, it is not as elegant as the first.

What's Exposed From AshitaCore? (And the ADK.)

Each interface (and its children) are broken into their own pages incase any specific information is needed to be explained with them. You can find the sub-pages for the exposed interfaces under the following namespace: adk

Below is a list of pages that are currently created for the exposed interfaces.

addons/using_ashitacore.txt · Last modified: 2017/04/23 00:16 by atom0s