This is an example on how to add mod.io functionality to your OpenFL project by using mod.io SDK Haxe wrapper available on Github. The wrapper simplifies the mod.io API usage by using the mod.io SDK as intermediary. The mod.io's getting started guide is a good place to start if you are completely new to mod.io and it's API.
- Download the wrapper from the modioHaxe releases page page and extract it.
- Place the
ModioWrapper.hx
on yourSources/
directory. - Place the
.ndll
files on your project's directory - Add the following in your
project.xml
Note: You will need to install the Visual C++ Redistributable for Visual Studio in order to use the the modio.dll
library on your windows project.
<ndll name="modioWrapperLinux_x64" if="linux"/>
<ndll name="modioWrapperWindows_x86" if="windows"/>
- Import the ModioWrapper class by adding
import ModioWrapper;
in your game's source code. - Add the mod.io functionality, this are some of functions available now. For a complete list check out the modioHaxe wiki.:
Initializes the mod.io wrapper. You will need the game id and api key, you can grab them from the mod.io web.
ModioWrapper.init(ModioWrapper.MODIO_ENVIRONMENT_TEST, YOUR_GAME_ID, "YOUR API KEY");
Process the callbacks and events. Call this frequently, preferably on your update function.
ModioWrapper.process();
To authenticate a user, you will have to ask for their email and then a 5-digit security code sent to their email. To do so, first call emailRequest to send the email and then emailExchange to exchange the security code for an access token that will be handled internally by the SDK so you won't need to deal with it.
Sends an email to the user with the security code needed to login.
ModioWrapper.emailRequest(email, function (resonse_code:Int)
{
if (resonse_code == 200)
{
// The user is now successfully logged in
}
else
{
// Error while sending the authentication email
}
});
Exchanges the security code to complete the authentication.
ModioWrapper.emailExchange(security_code, function (resonse_code:Int)
{
if (resonse_code == 200)
{
// The code was exchanged successfully
}
else
{
// Error exchanging the security code
}
});
Returns true if the user is logged in.
ModioWrapper.isLoggedIn();
Logs out the user.
ModioWrapper.logout();
- Complie and run using
openfl build windows
oropenfl build linux
. Mac OS is not supported yet. - Add the corresponding library (
libmodio.so
ormodio.dll
) from the providedLib/
folder into your exportedbin/
directory, next to your binary executable. - Now, you should be able to execute the game.
In this example, you can authenticate by providing your email and then your seucurity code sent to your email. Once that is done, automatic downloads will occur on the background.
Still WIP but in this example you will be able to browse, subscribe and unsubscribe from mods in-game.