Quick start — Defold
Connect a Defold project to a running Asobi server in about five minutes. Don't have a server yet? Run the server quickstart first.
1. Add the SDK as a library dependency
Open game.project → Project → Dependencies and add:
https://github.com/widgrensit/asobi-defold/archive/refs/heads/main.zipThen Project → Fetch Libraries. The SDK shows up as asobi in your project tree.
2. Bootstrap
Add a bootstrap script (main/boot.script) and assign it to a game object in your main collection:
local asobi = require("asobi.client")
local HOST = "localhost"
local PORT = 8080
function init(self)
self.client = asobi.new(HOST, PORT, false) -- use_ssl = false
end3. Authenticate
self.client.auth.register("player1", "secret123", "Player One", function(err, result)
if err then
print("auth failed: " .. err)
return
end
print("logged in as " .. self.client.player_id)
end)Auth requests are rate-limited at 5/sec per IP. Production builds should use a platform provider — see Auth & rate limiting.
4. Open the WebSocket and queue
self.client.realtime.on_connected(function()
print("ws connected")
self.client.realtime.add_to_matchmaker("arena")
end)
self.client.realtime.on_matched(function(data)
print("matched: " .. data.match_id)
end)
self.client.realtime.on_match_state(function(state)
-- update game world from server tick
end)
self.client.realtime.connect()5. Send input
self.client.realtime.send_match_input(json.encode({
action = "move", x = 1, y = 0
}))Input is fire-and-forget. The next on_match_state callback will reflect the server's authoritative response.
What's next
- Full SDK reference
- asobi-defold-demo — a working arena demo.
- game.* Lua API
- Live-edit your game