Hey everyone!
I’ve been building Asobi, an open source multiplayer game backend written in Erlang/OTP, and I wanted to share it with the Defold community since we have a Defold SDK and a playable demo.
What is Asobi?
Asobi is a server-authoritative game backend that handles the boring parts of multiplayer so you can focus on your game:
- Authentication - registration, login, session tokens
- Matchmaking - queue-based with pluggable strategies (fill, skill-based, custom)
- Real-time WebSocket - 10Hz game state broadcast, input at 60fps
- Leaderboards, chat, presence, economy, inventory
- Voting system - let players vote on game events between rounds
- Bot AI - automatic queue filling with Lua-scripted bots
- Lua scripting - write your game logic in Lua, no Erlang needed
The backend runs on the BEAM VM (Erlang), which gives you massive concurrency, fault tolerance out of the box.
Lua Scripting - No Erlang Required
This is the part I’m most excited about for Defold developers. You can write your entire server-side game logic in Lua:
function init(config)
return { players = {}, projectiles = {} }
end
function join(player_id, state)
state.players[player_id] = {
x = math.random(800), y = math.random(600),
hp = 100, speed = 4
}
return state
end
function handle_input(player_id, input, state)
local p = state.players[player_id]
if input.right then p.x = p.x + p.speed end
if input.left then p.x = p.x - p.speed end
if input.shoot then
-- create projectile...
end
return state
end
function tick(state)
-- physics, collisions, win conditions
return state
end
You implement a few callbacks (init, join, leave, handle_input, tick, get_state) and Asobi handles everything else - matchmaking, WebSocket transport, bot spawning, authentication.
Arena Demo
To prove it works, we built a top-down arena shooter:
- Server: Pure Lua scripts, zero Erlang code - asobi_arena_lua
- Client: Defold - asobi-defold-demo
- SDK: Defold Lua module - asobi-defold
The game features:
- 4-10 players per match (bots fill empty slots)
- WASD movement, mouse aim, click to shoot
- 90-second rounds with projectile combat
- Between-round upgrades (boons) for top players
- Player voting on round modifiers (Double Damage, Tight Quarters, etc.)
- Ship sprites and cannonball projectiles
Running it locally
# Clone the game server (just Lua scripts + docker-compose)
git clone https://github.com/widgrensit/asobi_arena_lua
cd asobi_arena_lua
docker compose up -d
# Clone and build the Defold client
git clone https://github.com/widgrensit/asobi-defold-demo
cd asobi-defold-demo
ln -s /path/to/asobi-defold/asobi asobi
java -jar bob.jar --platform x86_64-linux resolve build
./build/x86_64-linux/dmengine
The client has a server select screen - choose LOCAL to connect to your Docker instance.
Defold SDK
The asobi-defold SDK is a pure Lua module (no native extensions) that gives you:
- HTTP client for REST APIs (auth, leaderboards, inventory, etc.)
- WebSocket client for real-time gameplay
- Matchmaker integration
- Chat and presence
Drop it into your project as a symlink or copy and you’re good to go.
A note on AI
Full transparency - I used AI (Claude) to help write the Lua game scripts. The backend platform (Asobi) is more hand-written Erlang but also some AI, but for the arena demo’s Lua code, AI was a great pair programmer.
Links
- Asobi backend: GitHub - widgrensit/asobi: Game backend platform built on Nova/OTP · GitHub
- Defold SDK: GitHub - widgrensit/asobi-defold: Defold client SDK for Asobi game backend · GitHub
- Arena game (Lua): https://github.com/widgrensit/asobi_arena_lua
- Arena client (Defold): GitHub - widgrensit/asobi-defold-demo: Defold arena demo for the Asobi game backend · GitHub
- Lua scripting guide: asobi/guides/lua-scripting.md at main · widgrensit/asobi · GitHub
Everything is open source. Would love to hear your feedback and see what you build with it!