Loading Steamworks dll from LOVE

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
Mariscal
Prole
Posts: 16
Joined: Sat Jun 25, 2016 4:51 pm
Location: London
Contact:

Loading Steamworks dll from LOVE

Post by Mariscal »

Hi all,

I've been researching lately a bit about how to integrate Valve's steam functionality within a game using Love2D. I've seen this post about it so then I learnt that Move or Die was successfully released on Steam.

So I went to steamworks, downloaded the API, played around a bit with their example in C++ and then loaded the DLL they provide from a small example using LOVE, it works, and I can see the steam overlay on my small application.

Image

My question is, there are only a few functions exported into that DLL based on the code I saw from the API, one of them being SteamAPI_Init() which is the one I'm calling to get the overlay. So, in order to use other functionality steamworks has, like achievements, leaderboards and so on, do I need to create my own DLL file exporting the functions I'll use from lua? Or is it easier/quicker to just make a custom wrap in C++ exposing what functions I can call from Lua?

What's the general approach people follow when integrating steamworks into their games? :)

Thanks!
Currently working on Breaking Fast, a competitive 2D "mario kart alike" racing game! Already passed steam greenlight, hopefully soon to be released! :D
User avatar
Linkpy
Party member
Posts: 102
Joined: Fri Aug 29, 2014 6:05 pm
Location: France
Contact:

Re: Loading Steamworks dll from LOVE

Post by Linkpy »

There are two "main" ways : the fast one, and the slow one. I speak in execution speed. The first, and easier is to use FFI to include all C functions exposed by the Steamworks API. The second one, is to create a Lua C library wrapping the API.

I never used it, so I can only speak about a generic C DLL. If you use the API just for the overlay, and other feature not used so often, FFI should be fine. But if you use an API call (let's say) 1 000 times in a second, then you should probably create a Lua C library.

For the achievements and others game features like this, the game must be on Steam. You can't create achievements, leaderboards, etc if you're game isn't published on Steam. And, how to handle achievements in the code, I think it's not the same library (maybe it's a bigger steam_api.dll, I don't know).

By the way, using the Steamworks API with a game you don't plan to publish on Steam is useless. Except for the overlay, the player's name and player's Steam ID.
Founder of NeoShadow Studio. Currently working on the project "Sirami".
github / linkpy
Mariscal
Prole
Posts: 16
Joined: Sat Jun 25, 2016 4:51 pm
Location: London
Contact:

Re: Loading Steamworks dll from LOVE

Post by Mariscal »

Thanks for the answer Linkpy!
There are two "main" ways : the fast one, and the slow one. I speak in execution speed. The first, and easier is to use FFI to include all C functions exposed by the Steamworks API. The second one, is to create a Lua C library wrapping the API.
Yes, I'm using FFI at the moment, my problem is, that as far as I know, I cannot call a function that hasn't been exposed in the DLL, normally in C you do this by using __declspec(dllexport) in the function's definition , so if the function I intend to call is not accessible I don't think FFi can help me here?
I never used it, so I can only speak about a generic C DLL. If you use the API just for the overlay, and other feature not used so often, FFI should be fine. But if you use an API call (let's say) 1 000 times in a second, then you should probably create a Lua C library.
It definitely won't call 1000 times a second, mainly we will use it for the networking and some other features potentially
For the achievements and others game features like this, the game must be on Steam. You can't create achievements, leaderboards, etc if you're game isn't published on Steam. And, how to handle achievements in the code, I think it's not the same library (maybe it's a bigger steam_api.dll, I don't know).
By the way, using the Steamworks API with a game you don't plan to publish on Steam is useless. Except for the overlay, the player's name and player's Steam ID.
Yes, the game needs to be on steam so you get a valid application ID, we are on greenlight at the moment so I'm starting to prepare everything.
Currently working on Breaking Fast, a competitive 2D "mario kart alike" racing game! Already passed steam greenlight, hopefully soon to be released! :D
Mariscal
Prole
Posts: 16
Joined: Sat Jun 25, 2016 4:51 pm
Location: London
Contact:

Re: Loading Steamworks dll from LOVE

Post by Mariscal »

In case someone bumps into this, I just realised the steam_api.dll file is actually exposing a ton more of funtions than I previously thought, I used http://www.nirsoft.net/utils/dll_export_viewer.html to see what the dll had, so I think it's just a matter of adding them with FFI, maybe I'll write a quick script to do this for me, thanks!
Currently working on Breaking Fast, a competitive 2D "mario kart alike" racing game! Already passed steam greenlight, hopefully soon to be released! :D
User avatar
zorg
Party member
Posts: 3444
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Loading Steamworks dll from LOVE

Post by zorg »

Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
Linkpy
Party member
Posts: 102
Joined: Fri Aug 29, 2014 6:05 pm
Location: France
Contact:

Re: Loading Steamworks dll from LOVE

Post by Linkpy »

I thought you've seen this post and the two links in, I was surprised when you said that there wasn't the functions you need. But like zorg said, https://github.com/CapsAdmin/ffibuild/t ... steamworks this one seams to be good.
Founder of NeoShadow Studio. Currently working on the project "Sirami".
github / linkpy
Mariscal
Prole
Posts: 16
Joined: Sat Jun 25, 2016 4:51 pm
Location: London
Contact:

Re: Loading Steamworks dll from LOVE

Post by Mariscal »

Thanks for the links, I did try them but the steam API has changed since these scripts last run.

I tried to manually run them, but I had some missing modules when parsing the json file. (local json = serializer.ReadFile("json", "steam_api.json"))
Eventually I installed all the requirements but the lua script dies without generating the new lua file with the FFI definitions, I checked and apparently it is the line to require(lpeg) the one killing the script, I did install lpeg as well but I kind of hit a wall with this at the moment, will try to check later but I'll appreciate if someone has more info about this problem :)

Thanks for the answers chaps!
Currently working on Breaking Fast, a competitive 2D "mario kart alike" racing game! Already passed steam greenlight, hopefully soon to be released! :D
Post Reply

Who is online

Users browsing this forum: No registered users and 74 guests