Page 1 of 5

Steamworks FFI

Posted: Tue Dec 17, 2019 8:47 am
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

Re: Steamworks FFI

Posted: Tue Dec 17, 2019 10:45 am
by grump

Code: Select all

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

Code: Select all

0xffffffffffffffffULL

Re: Steamworks FFI

Posted: Tue Dec 17, 2019 1:36 pm
by raidho36
Yeah, I mean, it's LuaJIT-exclusive anyway, you can't make this work in regular Lua.

Re: Steamworks FFI

Posted: Tue Dec 17, 2019 2:35 pm
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

Re: Steamworks FFI

Posted: Tue Dec 17, 2019 2:41 pm
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)

Re: Steamworks FFI

Posted: Tue Dec 17, 2019 2:55 pm
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!

Re: Steamworks FFI

Posted: Mon Jan 06, 2020 10:56 am
by ReFreezed
Nice, this is very useful!

Re: Steamworks FFI

Posted: Wed Sep 02, 2020 2:18 pm
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!

Re: Steamworks FFI

Posted: Wed Nov 18, 2020 10:40 am
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'

Re: Steamworks FFI

Posted: Wed Nov 18, 2020 2:54 pm
by ivan
On Mac, I placed mine in:

Code: Select all

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