Skip to content

Instantly share code, notes, and snippets.

@balaam
balaam / pick_sketch.lua
Last active March 20, 2016 10:29
Quick code sketch for picking from six cards
function shuffle(t)
local n = #t
while n > 2 do
local k = math.random(n)
t[n], t[k] = t[k], t[n]
n = n - 1
end
return t
end
@balaam
balaam / stats.lua
Last active September 2, 2015 04:09
Stats
mBase =
{
body = 4,
mind = 5,
vitality = function(stats)
local bodyWeighting = 0.5
local mindWeight = 0.1
return stats:Get("body") * bodyWeighting + stats:Get("mind") * mindWeight
end,
hp_max = function(stats)
@balaam
balaam / gist:2850821296a924d81af4
Created July 30, 2015 03:54
Lua code for a fractional function.
function frac(v)
return v - math.floor(v)
end
print(1.6, frac(1.6))
print(2.0, frac(2.0))
print(1356.9999, frac(1356.9999))
http://audiorpc.weblogs.com/RPC2
http://bing.com/webmaster/ping.aspx
http://blo.gs/ping.php
http://blog.goo.ne.jp/XMLRPC
http://blog.with2.net/ping.php
http://blogping.unidatum.com/RPC2
http://blogpingr.de/ping/rpc2
http://blogsearch.google.com/ping/RPC2
http://feedsky.com/api/RPC2
http://geourl.org/ping
#!/opt/local/bin/lua
local addFigs = true
-- print("Markdown -> TeX")
-- print("...")
-- os.execute('pandoc -s ./test.md -o ./middle.tex --latex-engine="xelatex" -V --highlight-style espresso documentclass="report"')
-- print("Done.")
-- print(" ")
-- print("TeX -> PDF")
@balaam
balaam / Pandoc hackery
Last active August 29, 2015 14:21
Hackery for pandoc
s = "![Encounter tileset.](./collision_tileset.png)\\"
s = string.gsub(s, "!%[(.-)]%s*%((.-)%)%s*\\",
function(comment, path)
local ret = "![%s](%s)\\\n\\begin{center} \\emph{%s} \\end{center}\n\n"
return string.format(ret, comment, path, comment)
end)
print(s)
list =
{
{ y = 2 },
{ y = 3 },
{ y = 1 },
{ y = 1 },
{ y = 8 },
}
table.sort(list, function(a, b) return a.y > b.y end)
@balaam
balaam / gist:ae6378ca4f149de36c6c
Created November 14, 2014 09:22
Unity Serialiser Helpers
[System.Serializable]
public struct SaveDataVector3
{
float x, y, z;
public SaveDataVector3(Vector3 v)
{
x = v.x;
y = v.y;
z = v.z;
}
#!/opt/local/bin/lua
dofile("./printtable.lua")
dofile("./blacklist.lua")
local BACKUP_PATH = "./backup/"
function dofile (filename)
local f = assert(loadfile(filename))
return f()
list =
{
{n="old", p=1}
}
function add(effect)
for i = 1, #list do
local priority = list[i].p