Skip to content

Instantly share code, notes, and snippets.

@Uradamus
Uradamus / main.lua
Created March 20, 2014 15:28
Simple example of normalized delta x and y values.
function love.load()
local start_x = 0
local start_y = 0
local end_x = 10
local end_y = 5
dx = (end_x - start_x)
dy = (end_y - start_y)
local distance = math.sqrt(dx^2 + dy^2)
@Uradamus
Uradamus / links
Created April 5, 2014 13:28
Useful game math links
@Uradamus
Uradamus / class_test.lua
Last active August 29, 2015 13:58
Simple example of a combination class definition / construction function in Lua.
function Class (arg1, arg2, arg3)
local obj = {}
obj.var1 = arg1
obj.var2 = arg2
obj.var3 = arg3
function obj:out (arg)
print(self[arg])
end
@Uradamus
Uradamus / shuffle.lua
Last active November 3, 2023 09:39
A simple array shuffle function for Lua implementing the Fisher-Yates shuffle.
function shuffle(tbl)
for i = #tbl, 2, -1 do
local j = math.random(i)
tbl[i], tbl[j] = tbl[j], tbl[i]
end
return tbl
end
@Uradamus
Uradamus / combo.lua
Created April 12, 2014 13:47
Combination key press detection function in LOVE.
function combo (key1, key2)
if love.keyboard.isDown(key1) and love.keyboard.isDown(key2) then
return true
else
return false
end
end
@Uradamus
Uradamus / ground_obj.lua
Last active August 29, 2015 14:01
Lua script that takes a file of elevation values and uses them to recreate an InWorldz / Second Life style ground mesh as an OBJ file.
--[[
Call this file with the height input file and the desired output file as arguments.
example: lua ground_obj.lua height.txt ground.obj
]]--
-- Read the input height values.
input = io.open(arg[1], "r")
heights = {}
for line in input:lines() do
table.insert(heights, tonumber(line))
@Uradamus
Uradamus / Regex
Last active August 29, 2015 14:13
Regular Expression for parsing InWorldz and Second Life teleport links.
((?:(?:inworldz|iz|secondlife)://)|(?:hop://[\w_!',@%\$\-\.\+\*\(\)]+(?:\.(?:com|net|org))(?::\d{1,5})?))/?(?:inworldz/)?(?:app/(?:teleport/)?)?(?:(?:(agent|group|parcel)/(?:((?i)[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/about))|(?:([\w\-_%]+)/))(\-?\d{1,3})?/?(\-?\d{1,3})?/?(\-?\d{1,3})?
@Uradamus
Uradamus / TML_0.1.md
Last active February 5, 2018 02:38
Terse Markup Language 0.1 Specification

TML

TML is an acronym for Terse Markup Language. It is intended as a light weight syntax alternative to XML and other similar markup languages. Development of TML was begun by Ian S on April 8, 2013. TML is an open specification that is free to use by all for any purpose.

Example TML document

[!TML, version="0.1", encoding="UTF-8"]

[example element hierarchy:

[element1: "An element with a name attribute and a value."]

@Uradamus
Uradamus / NWN Linux Install Notes.md
Last active April 12, 2022 01:55
Some notes on getting the native version of NWN installed on Linux.

This uses the version available through GOG.com. Thanks go to TheCycoONE from the Arch Linux and GOG communities who's AUR package and forums posts were instrumental in my discovering how to finally install the GOG version of Neverwinter Nights on Linux.

First step is to ensure you have the necessary dependencies and utilities installed:

  • elfutils
  • glu
  • ia-32-libs (only if you are on a 64bit distro)
  • innoextract
  • libgl
  • libstdc++5
@Uradamus
Uradamus / compress_blend.sh
Last active April 28, 2016 21:50
Batch convert .blend files to gzip compressed .blend files.
for blend in *.blend; do
if [[ $(file -ib "$blend") == application/octet-stream* ]]; then
gzip -n1 "$blend"
mv "$blend.gz" "$blend"
fi
done