From 05af10873ed487e3fdf81784d8a0df4eccfd83f6 Mon Sep 17 00:00:00 2001 From: Pablo Mayobre Date: Sun, 8 Feb 2015 20:07:29 -0300 Subject: [PATCH] Added getCredetials function A function to parse the gjapi_credentials.txt file generated by Quick Play, some other minor changes --- gamejolt/init.lua | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/gamejolt/init.lua b/gamejolt/init.lua index 127c635..e9d8d07 100644 --- a/gamejolt/init.lua +++ b/gamejolt/init.lua @@ -1,4 +1,4 @@ -local folder = (...):gsub('%.init$', '') +local folder = {...}[1]:gsub('%.init$', '') local md5 = require(folder .. ".md5" ) local http = require("socket.http") @@ -71,12 +71,30 @@ function GJ.init(id, key, args) end end end + + if GJ.username and GJ.userToken then + return true + else + return false + end +end + +function GJ.getCredentials() + local a = love.system.getOS() == "Windows" and "\\" or "/" + local f = io.open(love.filesystem.getWorkingDirectory()..a.."gjapi-credentials.txt") + if f then + GJ.username = f:read() + GJ.userToken = f:read() + return true + else + return false + end end -- users function GJ.authUser(name, token) - GJ.username = name or GJ.username - GJ.userToken = token or GJ.userToken + GJ.username = name or GJ.username or "" --Here we could put LÖVE default ones + GJ.userToken = token or GJ.userToken or "" local s = string.find(req("users/auth/?", "dump", true, true), "SUCCESS") ~= nil GJ.isLoggedIn = s