Skip to content

Instantly share code, notes, and snippets.

View novabyte's full-sized avatar

Chris Molozian novabyte

View GitHub Profile
@novabyte
novabyte / recover_email_password.lua
Created February 13, 2021 14:43 — forked from nickmarty/recover_email_password.lua
Nakama Email Password Recovery
--[[
Email Password Recovery module.
Using this module, you can request a password reset link from the game using 'recover_email_password' RPC.
--]]
local nk = require("nakama")
local HTTPS_PREFIX = "https://"
local MAILGUN_API_BASE_URL = "api.mailgun.net/v3"
@novabyte
novabyte / Dockerfile
Last active April 29, 2022 14:01
A small Docker-based build setup to create and build Go code with Nakama server.
FROM heroiclabs/nakama-pluginbuilder:3.2.0 AS builder
ENV GO111MODULE on
ENV CGO_ENABLED 1
WORKDIR /backend
COPY . .
RUN go build --trimpath --mod=vendor --buildmode=plugin -o ./backend.so
@novabyte
novabyte / matchskeleton.lua
Created July 6, 2018 14:00
An example of a match handler with Nakama server which tracks presence join/leave events for users in the game state.
--[[
Copyright 2018 The Nakama Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@novabyte
novabyte / docker-compose.yml
Last active April 28, 2018 23:11
Use a prerelease image of Nakama server with Docker Compose.
version: '3'
services:
cockroachdb:
image: cockroachdb/cockroach:v2.0.1
command: start --insecure --store=attrs=ssd,path=/var/lib/cockroach/
restart: always
volumes:
- data:/var/lib/cockroach
expose:
- "8080"
@novabyte
novabyte / setup_leaderboards.lua
Created November 30, 2017 07:44
An example of a leaderboard setup with Nakama server.
local nk = require("nakama")
-- use any string as an ID
local id = "8c79b85e-d5a1-11e7-87cc-7bd5871ea4a4"
local reset = nil -- no reset
local metadata = {
}
nk.leaderboard_create(id, "desc", reset, metadata, false)
@novabyte
novabyte / StoragePusher.cs
Created October 29, 2017 16:22
Push storage write changes as events to connected users with Nakama server.
/**
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@novabyte
novabyte / FacebookManager.cs
Created October 18, 2017 16:55
A simple example on how to register/login a user via Facebook with Unity and Nakama server.
/**
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@novabyte
novabyte / UUID.cs
Created October 16, 2017 11:45
A helper class to convert UUIDv4 strings into bytes and back again with C#.
using System;
public class UUID
{
public static byte[] FromString(string uuid)
{
var guid = new Guid(uuid).ToByteArray();
Array.Reverse(guid, 6, 2);
Array.Reverse(guid, 4, 2);
Array.Reverse(guid, 0, 4);
@novabyte
novabyte / static.json
Created October 6, 2017 04:31
An example on different ways to manage static game state with Nakama server.
{
"skills": [
{
"context": {"bucket": "b", "collection": "skills", "record": "fireball"},
"value": {
"name": "Fireball",
"element": 0,
"base_damage": 20
}
},
@novabyte
novabyte / matchrooms.lua
Last active September 21, 2017 15:25
Implement custom asynchronous match "rooms" on Nakama server.
--[[
Copyright 2017 The Nakama Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software