Epic Achievements/Online Services SDK/API for LÖVE/Lua?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
ruairidx
Prole
Posts: 5
Joined: Sun Nov 28, 2021 6:49 am
Contact:

Epic Achievements/Online Services SDK/API for LÖVE/Lua?

Post by ruairidx »

I have a game already on Steam with achievements using luasteam. In order to release the game on the Epic Games Store, the game apparently also needs (more-or-less) the same achievements using Epic Online Services (Epic has already blocked the game's release because of this). However, as far as I can tell, there's no equivalent port of the Epic Online Services SDK to Lua (which is understandable since it's a smaller market), and the Web API doesn't support anything involving achievements so I can't just make HTTP requests from the game (API docs). Is there a port that I've missed or a methodology that I'm overlooking to use EOS? Or any known LÖVE games on EGS with achievements that I can take a look at?

Failing this, does anyone have experience with contacting any sort of official support for Epic's Dev Portal? All I've found so far is links to their dev forum, which isn't really what I need. I can tell that Epic doesn't enforce this achievements-parity requirement on all games as I've found at least one LÖVE game which has achievements on Steam but not on the Epic Games Store. Not sure if this is an oversight on Epic's part (and I really don't want to grass in that case and get their game taken down), or if this is something they allow exceptions for in specific cases (if I have to wrap/port the SDK myself, I'll probably just pull the EGS release entirely since it's financially not worth the effort).

Thank you!

EDIT: Reddit x-post
User avatar
dusoft
Party member
Posts: 654
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: Epic Achievements/Online Services SDK/API for LÖVE/Lua?

Post by dusoft »

Unfortunately no. I checked their API, but as you said, there is no achievements functionality in the web API.

Would it be possible to link their SDK somehow?
https://dev.epicgames.com/docs/epic-onl ... references
They mention: "the EOS SDK in C", but I couldn't find C SDK, only their C# SDK.

Otehrwise Lua allows C language calls:
https://www.lua.org/pil/26.html
User avatar
SiENcE
Party member
Posts: 806
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: Epic Achievements/Online Services SDK/API for LÖVE/Lua?

Post by SiENcE »

You can use FFI. FFI is enabled in Löve2D.

https://luajit.org/ext_ffi.html

Here you can see how it works with Steam:
https://github.com/CapsAdmin/ffibuild/b ... mworks.lua
MrFariator
Party member
Posts: 559
Joined: Wed Oct 05, 2016 11:53 am

Re: Epic Achievements/Online Services SDK/API for LÖVE/Lua?

Post by MrFariator »

I implemented Epic's C SDK directly into löve's source code, and using the resulting executable for distribution via EGS. However, I only implemented the ownership verification (the bare minimum), so I didn't look into achievements or online services. This was acceptable to them in 2023, so if they have since then made achievement implementation a requirement, that's news to me.

If you're curious, the code you need to insert into löve is something like:

Code: Select all

//love.cpp
int initializeEOS()
{	

	EOS_InitializeOptions initOptions = {
		EOS_INITIALIZE_API_LATEST,
		NULL,
		NULL,
		NULL,
		"your game name",
		"version number",
		NULL,
		NULL,
		NULL,
	};	
	
	EOS_EResult res = EOS_Initialize (
		&initOptions
	);
	if (res == EOS_EResult::EOS_Success) {
		return 0;
	}
	else {
		return 1;
	}
}

EOS_HPlatform startEOSPlatform()
{	
	EOS_Platform_ClientCredentials credentials = {
		"asdasd", // client id
		"asdasdas", // client secret
	};
	EOS_Platform_Options platformOptions = {
		EOS_INITIALIZE_API_LATEST, // api
		NULL, // reserved
		"asdasd", // product id
		"asdasd", // sandbox id
		credentials, // credentials
		EOS_FALSE, // bIsServer
		NULL, // encryption key
		NULL, // override country code
		"en", // override locale
		"asdasd", // deployment id
		EOS_PF_WINDOWS_ENABLE_OVERLAY_OPENGL, // flags
		NULL, // cache
		3, // tick budget in ms
		NULL, // voices on/off
		NULL, // integratedplatformoptionshandle
	};
	EOS_HPlatform platform = EOS_Platform_Create(
		&platformOptions
	);
	return platform;
}

int main(int argc, char **argv)
{
	if (strcmp(LOVE_VERSION_STRING, love_version()) != 0)
	{
		printf("Version mismatch detected!\nLOVE binary is version %s\n"
			   "LOVE library is version %s\n", LOVE_VERSION_STRING, love_version());
		return 1;
	}

	int initVal = initializeEOS();
	if (initVal != 0) {
		MessageBox(
			NULL,
			"EOS failed to initialize. Please check that EOSSDK-Win64-Shipping.dll is included.",
			"EOS Launch error",
			0x00000000L
		);
		return 1;
	}
	else {
		// EOS initialized
	}

	EOS_HPlatform platform = startEOSPlatform();

	EOS_EResult res = EOS_Platform_CheckForLauncherAndRestart(platform);

	//Test stuff
	
	if (res == EOS_EResult::EOS_Success) {
		// relaunching with EGS launcher
		return 0;
	}
	else if (res == EOS_EResult::EOS_NoChange) {
		// no change, no need to do anything
	}
	else if (res == EOS_EResult::EOS_UnexpectedError) {
		// error occured, exiting!
		printf("Unknown EOS error!");
		return 1;
	}
	else if (res == EOS_EResult::EOS_InvalidParameters) {
		// error occured, exiting!
		return 1;
	}
	else {
		// Display error that EGS needs to be running.
		char str[1000];
		sprintf(str, "EOS could not launch properly. Please ensure that Epic Games Store is running. Status code: %d", res);
		MessageBox(
			NULL,
			str,
			"EOS status",
			0x00000000L
		);
		return 1;
	}

	int retval = 0;
	DoneAction done = DONE_QUIT;

	do
	{
		EOS_Platform_Tick(platform);
		done = runlove(argc, argv, retval);

	} while (done != DONE_QUIT);

	EOS_Platform_Release(platform);
	EOS_Shutdown();

	return retval;
}
You'll need to acquire things like product id, sandbox id, client id, etc from Epic.
User avatar
dusoft
Party member
Posts: 654
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: Epic Achievements/Online Services SDK/API for LÖVE/Lua?

Post by dusoft »

MrFariator wrote: Tue Oct 15, 2024 10:12 pm I implemented Epic's C SDK directly into löve's source code, and using the resulting executable for distribution via EGS. However, I only implemented the ownership verification (the bare minimum), so I didn't look into achievements or online services. This was acceptable to them in 2023, so if they have since then made achievement implementation a requirement, that's news to me.
Per their documentation it's only required, if you are already using it in other systems such as Steam. They want to be on par.
RNavega
Party member
Posts: 385
Joined: Sun Aug 16, 2020 1:28 pm

Re: Epic Achievements/Online Services SDK/API for LÖVE/Lua?

Post by RNavega »

Major edit:
----
After asking around, you can use EOS by interfacing with the provided "shipping" DLLs using LuaJIT FFI.
MrFariator's example of statically linking to it is probably the proper way of using EOS, though loading the DLL through LuaJIT FFI and calling functions from it should work as well.

The challenge is then creating the cdef definitions for all functions, structures etc. from the DLL.

Edit 2: there's some reference in this Ren'py extension, they interface with the DLLs alone: https://github.com/Ayowel/renpy-epicgam ... s/epic_eos
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Bing [Bot] and 24 guests