Fix almost everything #8

Closed
pablomayobre wants to merge 11 commits from master into master
Showing only changes of commit bf5a4077bf - Show all commits

View File

@ -57,7 +57,7 @@ end
function GJ.init(id, key, args) function GJ.init(id, key, args)
GJ.gameID = id GJ.gameID = id
GJ.gameKey = key GJ.gameKey = key
if args and type(args)=="table" then if args and type(args)=="table" then
for k,v in pairs(args) do for k,v in pairs(args) do
local a = v:match("^gjapi_(.*)") local a = v:match("^gjapi_(.*)")
@ -71,23 +71,30 @@ function GJ.init(id, key, args)
end end
end end
end end
if GJ.username and GJ.userToken then if id and key then --Not sure about this huge check
return true if not args then
return true
elseif GJ.username and GJ.userToken then
return true
else
return false, "Username or token not found on args"
end
else else
return false return false, "Game Id or Game Key was nil"
end end
end end
function GJ.getCredentials() function GJ.getCredentials()
local a = love.system.getOS() == "Windows" and "\\" or "/" local a = love.system.getOS() == "Windows" and "\\" or "/"
local f = io.open(love.filesystem.getWorkingDirectory()..a.."gjapi-credentials.txt") local f = io.open(love.filesystem.getWorkingDirectory()..a.."gjapi-credentials.txt")
if f then if f then
GJ.username = f:read() GJ.username = f:read()
GJ.userToken = f:read() GJ.userToken = f:read()
return true return true, GJ.username, GJ.userToken
else else
return false return false, "Couldnt read file"
end end
end end