Lua GameJolt API [Highscore tables / achievements]

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
ManInBlackSweater
Prole
Posts: 17
Joined: Sat Aug 10, 2013 6:44 pm
Contact:

Lua GameJolt API [Highscore tables / achievements]

Post by ManInBlackSweater »

Oh hey there.
I've been playing with this for a couple of hours and I guess it's ready-ready to be released.

Lua GameJolt API Github

Have fun. :awesome:
Cheers, Max.
User avatar
josefnpat
Inner party member
Posts: 955
Joined: Wed Oct 05, 2011 1:36 am
Location: your basement
Contact:

Re: Lua GameJolt API [Highscore tables / achievements]

Post by josefnpat »

About time! I keep saying the words "nice" over and over in a high voice.

I can't wait to try this out!
Missing Sentinel Software | Twitter

FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
User avatar
josefnpat
Inner party member
Posts: 955
Joined: Wed Oct 05, 2011 1:36 am
Location: your basement
Contact:

Re: Lua GameJolt API [Highscore tables / achievements]

Post by josefnpat »

About time! I keep saying the words "nice" over and over in a high voice.

I can't wait to try this out!

update:


I've had a chance to test this, and while I have a few issues, this library is perfect!

Log in with your gamejolt account, and visit this page:

http://gamejolt.com/games/arcade/teting ... ces/48003/

and run the attached love!
Attachments
gamejoltlua-test.love
(5.24 KiB) Downloaded 235 times
Missing Sentinel Software | Twitter

FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
User avatar
andmatand
Prole
Posts: 21
Joined: Wed Jan 25, 2012 8:46 pm
Location: Eugene, OR
Contact:

Re: Lua GameJolt API [Highscore tables / achievements]

Post by andmatand »

Hmm I did those steps...am I supposed to get trophies? 'cause I didn't :(
User avatar
josefnpat
Inner party member
Posts: 955
Joined: Wed Oct 05, 2011 1:36 am
Location: your basement
Contact:

Re: Lua GameJolt API [Highscore tables / achievements]

Post by josefnpat »

You will have to change the user token in main.lua of the .love, sorry to not mention that.
Missing Sentinel Software | Twitter

FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
User avatar
andmatand
Prole
Posts: 21
Joined: Wed Jan 25, 2012 8:46 pm
Location: Eugene, OR
Contact:

Re: Lua GameJolt API [Highscore tables / achievements]

Post by andmatand »

Ah, that explains it :)
User avatar
ManInBlackSweater
Prole
Posts: 17
Joined: Sat Aug 10, 2013 6:44 pm
Contact:

Re: Lua GameJolt API [Highscore tables / achievements]

Post by ManInBlackSweater »

Added bit-sized wiki to help guys get started. :nyu:
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: Lua GameJolt API [Highscore tables / achievements]

Post by Davidobot »

I'm not too familiar with GameJolt. Do the games usually ask for the username and usertoken of a player for achievements, or are those somehow detected while downloading or something?
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
ManInBlackSweater
Prole
Posts: 17
Joined: Sat Aug 10, 2013 6:44 pm
Contact:

Re: Lua GameJolt API [Highscore tables / achievements]

Post by ManInBlackSweater »

Davidobot wrote:I'm not too familiar with GameJolt. Do the games usually ask for the username and usertoken of a player for achievements, or are those somehow detected while downloading or something?
GameJolt automatically passes username and token into Java, Silverlight, Flash and Unity apps.
Also there's a Quick Play that downloads your game and tries to pass user info into your game.
Let's see if we can catch this data in Lua.
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Lua GameJolt API [Highscore tables / achievements]

Post by Positive07 »

ManInBlackSweater wrote: Also there's a Quick Play that downloads your game and tries to pass user info into your game.
Let's see if we can catch this data in Lua.
I got this to work, already made an Issue in the Issue Tracker with two solutions, anyway I'm posting it here too.

Solution one:
Get them in love.load

Code: Select all

love.load = function (args) --Note the args here, this are the aguments passed through the console
	data = {}
	GJ = require "gamejoltlua"
	GJ.init("myid", "mykey")
	for k,v in pairs(args) do
		local a = v:match("^gjapi_(.*)")
		if a then
			key, value = a:match("^(.-)=(.-)$")
			data[key] = value
		end
	end
	GJ.authUser(data.username,data.token)
	GJ.openSession()
end
Solution two:
Using the gjapi_credentials.txt file

Code: Select all

data = {}
GJ = require "gamejoltlua"
GJ.init("myid", "mykey")
local a = love.system.getOS() == "Windows" and "\\" or "/"
local f = io.open(love.filesystem.getWorkingDirectory()..a.."gjapi-credentials.txt")
if f then
	data.username = f:read()
	data.token = f:read()
end
GJ.authUser(data.username,data.token)
GJ.openSession()
The benefit of the second alternative is that you can call it from everywhere, while the first one needs to be in love.load

The second alternatives also let users connect to GameJolt API leaving a .txt file next to the executable (not sure if anyone wanted that feature, but it's there)
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 1 guest