Steamworks FFI

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Steamworks FFI

Post by ivan »

This is a cross-platform LuaJIT/FFI wrapper for Steamworks. The library provides easy and simple Steamworks integration, using the original redistributable binaries provided by Valve.

https://github.com/2dengine/sworks-ffi


This project has been retired as of August 3, 2022
Last edited by ivan on Wed Aug 03, 2022 8:13 pm, edited 5 times in total.
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: Steamworks FFI

Post by grump »

Code: Select all

ffi.C.strtoull("0xffffffffffffffff", nil, 16)
LuaJIT accepts a ULL suffix for this.

Code: Select all

0xffffffffffffffffULL
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Steamworks FFI

Post by raidho36 »

Yeah, I mean, it's LuaJIT-exclusive anyway, you can't make this work in regular Lua.
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Steamworks FFI

Post by ivan »

Thanks grump, I will add that change although I have tested it and it works fine with either:

Code: Select all

a = ffi.C.strtoull("0xffffffffffffffff", nil, 16)
b = ffi.C.strtoull("0xffffffffffffffffULL", nil, 16)

assert(a == b)
In general, pure Lua can't handle such large numbers:

Code: Select all

n = 0xffffffffffffffff
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: Steamworks FFI

Post by grump »

ivan wrote: Tue Dec 17, 2019 2:35 pm In general, pure Lua can't handle such large numbers:

Code: Select all

n = 0xffffffffffffffff
The point is that you can use the ULL suffix to write 64 bit integer literals directly in LuaJIT, there's no need to call strtoull.

Code: Select all

assert(0xffffffffffffffffULL == ffi.C.strtoull("0xffffffffffffffff", nil, 16))
http://luajit.org/ext_ffi_api.html (see "Extensions to the Lua parser" at the bottom of the page)
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Steamworks FFI

Post by ivan »

I see, that's even better. I will have to see how this change would affect the rest of the code.
Thanks grump!
User avatar
ReFreezed
Party member
Posts: 612
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: Steamworks FFI

Post by ReFreezed »

Nice, this is very useful!
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Steamworks FFI

Post by ivan »

Just pushed an update upgrading the library to Steamworks v1.5.
This version includes supports for HTTP and HTTPS requests similarly to luasocket:

Code: Select all

valid = steam.request(url[, body, callback])
That's right, we've got working SSL support too!
artless
Prole
Posts: 6
Joined: Sat Jan 25, 2020 3:36 pm

Re: Steamworks FFI

Post by artless »

I know this might be a silly question:
Where should I put libsteam_api.dylib in a Mac build?


I tried to put libsteam_api.dylib in the folder, inside .love file or in love.exe's folder.
None of them worked.


Error

dlopen(libsteam_api.dylib, 5): image not found


Traceback

[builtin#202]: at 0x010c345e00
[C]: in function 'require'
sworks/api.lua:43: in function 'Init'
sworks/main.lua:16: in function 'init'
main.lua:73: in function 'load'
[C]: in function 'xpcall'
[C]: in function 'xpcall'
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Steamworks FFI

Post by ivan »

On Mac, I placed mine in:

Code: Select all

Contents/Frameworks/libsteam_api.dylib
Please confirm if this works for you.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 14 guests