Passing by to update that the Lib now supports retrieving data that came from Javascript, it as simple as doing the the post-only requests, firstly , in your main.lua file
After that, you just need to call
Code: Select all
gUsername = ""
JS.newRequest('kongregate.services.getUsername()',
function(data)
gUsername = data
end)
That will enqueue the request, for actually completing it, you will need to update the request status, you do that by append to your
love.update the following code
Code: Select all
if(retrieveData(dt)) then
return
end
Doing so will make your code synchronous, but as I show here, it is fairly easy to make it assync
Every request has a timeout value, defaulted to 2 seconds, you can pass the timeout value in the same func, the entire func prototype is
Code: Select all
JS.newRequest(funcToCall, onDataLoaded, onError, timeout, optionalId)
There is a function in error case(timeout), this function can be nil or it can be set to a default function by calling
Code: Select all
JS.setDefaultErrorFunction(errorFunc)
It receives a function that receives the id that generated the error, the Id can either be a string or number(default and incrementable)