Skip to content

Instantly share code, notes, and snippets.

Making Defold even better!

Björn Ritzl britzl

Making Defold even better!
View GitHub Profile
britzl / cla.txt
Created Apr 23, 2019
Trying out for the public Defold repos
View cla.txt
Thank you for your interest in Defold. In order to clarify the intellectual property license granted with Contributions from any person or entity, Defold must have a Contributor License Agreement ("CLA") on file that has been signed by each Contributor, indicating agreement to the license terms below. This license is for your protection as a Contributor as well as the protection of Defold and its users; it does not change your rights to use your own Contributions for any other purpose.
You accept and agree to the following terms and conditions for Your present and future Contributions submitted to Defold. Except for the license granted herein to Defold and recipients of software distributed by Defold, You reserve all right, title, and interest in and to Your Contributions.
1. Definitions.
"You" (or "Your") shall mean the copyright owner or legal entity authorized by the copyright owner that is making this Agreement with Defold. For legal entities, the entity making a Contribution and all other entities that
britzl / luautils.cpp
Last active Sep 1, 2019
Lua C utility functions for manipulating the stack and setting up listeners
View luautils.cpp
#include <dmsdk/sdk.h>
#include "luautils.h"
void luaL_checklistener(lua_State* L, int idx, struct lua_Listener& listener) {
int top = lua_gettop(L);
luaL_checktype(L, idx, LUA_TFUNCTION);
lua_pushvalue(L, idx);
int cb = dmScript::Ref(L, LUA_REGISTRYINDEX);
if (listener.m_Callback != LUA_NOREF) {
britzl / tinted_label.fp
Last active May 19, 2019
DEPRECATED - How to tint labels in Defold
View tinted_label.fp
varying mediump vec2 var_texcoord0;
varying lowp vec4 var_face_color;
varying lowp vec4 var_outline_color;
varying lowp vec4 var_shadow_color;
uniform lowp vec4 texture_size_recip;
uniform lowp sampler2D texture;
uniform lowp vec4 tint;
void main()
britzl /
Last active Dec 10, 2020
Script to build and bundle a Defold project for multiple platforms
title=$(less game.project | grep "^title = " | cut -d "=" -f2 | sed -e 's/^[[:space:]]*//')
title_no_space=$(echo -e "${title}" | tr -d '[[:space:]]')
echo "Project: ${title}"
if [ ! -f bob.jar ]
echo "Unable to find bob.jar. Download it from"
exit 1
britzl / timer.lua
Last active Feb 13, 2018
Timer module that can be used to get a callback when a certain amount of time has elapsed
View timer.lua
--- Module that can be used to get a callback when a certain amount of time has elapsed
-- @usage
-- local timer = require "timer"
-- function init(self)
-- self.t1 = timer.seconds(2, function()
-- print("2 seconds have elapsed")
-- end)
-- self.t2 = timer.seconds(5, function()
-- print("5 seconds have elapsed")
britzl /
Created Aug 25, 2014
Shell script to download an OS specific Lua 5.1 binary
# Downloads an OS specific Lua 5.1 binary
if [[ "$OSTYPE" == "linux-gnu" ]]; then
elif [[ "$OSTYPE" == "darwin"* ]]; then
elif [[ "$OSTYPE" == "win32" ]]; then
# from
if [[ "$OSTYPE" == "linux-gnu" ]]; then
# ...
elif [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
elif [[ "$OSTYPE" == "cygwin" ]]; then
# POSIX compatibility layer and Linux environment emulation for Windows
elif [[ "$OSTYPE" == "msys" ]]; then
# Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
elif [[ "$OSTYPE" == "win32" ]]; then
britzl / gdump.lua
Last active Aug 29, 2015
Dump contents of global table
View gdump.lua
local function gdump()
local function dump_table(t, indentation)
indentation = indentation or ""
local table_model = {}
for k,v in pairs(t) do
table_model[type(v)] = table_model[type(v)] or {}
table_model[type(v)][k] = v
for type,_ in pairs(table_model) do
print(indentation .. type .. ":")
britzl / superstrict.lua
Last active Aug 29, 2015
Lua strict mode variant with a whitelist for allowed names
View superstrict.lua
--- A module for guarding tables from new indices. Typical use is to guard the global scope.
-- Get the latest version from
-- @module superstrict
-- @usage
-- -- Defold specific example. Allow the gameobject and gui script lifecycle functions. Also allow assignment of
-- -- facebook and iap modules for dummy implementations on desktop. The whitelist handles pattern matching and in the
-- -- example all functions prefixed with '__' will also be allowed in the global scope
-- local superstrict = require("superstrict")
-- superstrict.lock(_G, { "go", "gui", "msg", "url", "sys", "render", "factory", "particlefx", "physics", "sound", "sprite", "image", "tilemap", "vmath", "matrix4", "vector3", "vector4", "quat", "hash", "hash_to_hex", "hashmd5", "pprint", "iap", "facebook", "push", "http", "json", "spine", "zlib", "init", "final", "update", "on_input", "on_message", "on_reload", "__*" })

Keybase proof

I hereby claim:

  • I am britzl on github.
  • I am britzl ( on keybase.
  • I have a public key whose fingerprint is 0550 F9F9 695B AA0E C6A3 E29E 081A 6067 688C FEA3

To claim this, I am signing this object: