I’m trying do use Nakama with Love2D game engine.
I read the Lua Client docs but I’m kind of stuck.
I use the last Nakama Server but I got a Unable to login and no new device is visible on my Nakama Console.
local function device_login(client)
local body = nakama.create_api_account_device(love2d.uuid())
local result = nakama.authenticate_device(client, body, true)
if result then
if result.token then
nakama.set_bearer_token(client, result.token)
return true
end
end
print("Unable to login")
return false
end
--CORE FUNCTION
function love.load()
--load nakama
local config = {
host = "127.0.0.1",
port = 7350,
use_ssl = false,
username = "defaultkey",
password = "",
engine = love2d,
timeout = 10,
}
local client = nakama.create_client(config)
nakama.sync(function()
device_login(client)
end)
EDIT! The current output of the authenticate_device is equal to nil and I still don’t get where to correct this
Here is another output
As I continue the debugging, seems like I got a little issue with coroutine.
Without coroutine
init()
authenticate_device() with callback
HTTP POST http://127.0.0.1:7350/v2/account/authenticate/device?create=true&username=shioridotdev
DATA {"id":"dd5cb811-8c7c-4f83-cfbc-04ed336b0dff"}
Unable to login
With coroutine
init()
authenticate_device() with coroutine
HTTP POST http://127.0.0.1:7350/v2/account/authenticate/device?create=true
DATA {"id":"b417483f-bad6-44e9-c413-04ed336b0dff"}
EDIT:
My program doesn’t go inside the fn function in async.lua arround line 12
fn(function(...)
results = { ... }
if state == "YIELDED" then
local ok, err = coroutine.resume(co)
if not ok then print(err) end
else
state = "DONE"
end
end, ...)
if state == "RUNNING" then
state = "YIELDED"
coroutine.yield()
state = "DONE" -- not really needed
end
EDIT 2 : I set up a github repo to checkout the whole code if necessary nakama-love2d repository
Thanks for your answer, I’m sorry for being late in the respond and sorry if my first post was not too clear, I will try to translate better my issue in English, feel free to ask me again if I didn’t write it properly again.
What I’m trying to do:
Setting up a client base on Love2D game engine (LUA language) and make it workable with Nakama Server.
What is currently working:
Client start properly and the log are those next few lines
init()
authenticate_device() with coroutine
HTTP POST http://127.0.0.1:7350/v2/account/authenticate/device?create=true
DATA {"id":"b417483f-bad6-44e9-c413-04ed336b0dff"}
What is not working:
No new user/device are register in the Nakama Server
How to reproduce it
I set up a GIT repository that you can use to see the whole code. nakama-love2d repository
Sorry I got issue and couldn’t continue to look up it.
I got the following error while doing an http request :
authenticate_email() with coroutine
HTTP POST http://localhost:7350/v2/account/authenticate/email?username=britzl&create=true
DATA {"email":"bjorn@defold.se","password":"foobar123"}
{"code":3, "message":"invalid character 'P' looking for beginning of value"} 400 table: 0x010de8ac28 HTTP/1.1 400 Bad Request