Skip to content

Instantly share code, notes, and snippets.

View ColonelThirtyTwo's full-sized avatar

Alex Parrill ColonelThirtyTwo

View GitHub Profile
@ColonelThirtyTwo
ColonelThirtyTwo / cfunc-test.lua
Created November 5, 2012 15:50
Proof that LuaJIT cannot compile C functions
require "test"
local add = test.test_add
local x = 0
for i=1,100000 do
x = add(x,i)
end
print(x)
@ColonelThirtyTwo
ColonelThirtyTwo / timer.lua
Created October 28, 2012 14:39
Replacement timer library for gmod13
--- Improved timers module. Checks arguments more effectively, and doesn't mess up if one of the timers errors.
-- To use, just drop in lua/autorun/
--print("Improved timers loading...")
if SERVER then AddCSLuaFile() end
local timers = {}
function AddDir(dir)
local files, folders = file.Find(dir, "GAME")
for _,file in ipairs(files) do
resource.AddFile(dir.."/"..file)
end
for _,folder in ipairs(folders) do
if folder:sub(1,1) ~= "." then -- Ignore .svn/.git folders
AddDir(dir.."/"..folder)
end
end
@ColonelThirtyTwo
ColonelThirtyTwo / FakeMatrixStack.lua
Created August 11, 2012 00:03
GMod Real Matrix Stack (if VMatrix:Copy() is implemented)
local FakeMatrixStack = {}
FakeMatrixStack.m = Matrix()
function FakeMatrixStack:push()
local m = self.m
cam.PushModelMatrix(m)
self[#self+1] = m:Copy()
end
@ColonelThirtyTwo
ColonelThirtyTwo / quaternions.lua
Created February 4, 2012 05:11
Quaternions for GLua
-- faster access to some math library functions
local abs = math.abs
local Round = math.Round
local sqrt = math.sqrt
local exp = math.exp
local log = math.log
local sin = math.sin
local cos = math.cos
local sinh = math.sinh
local cosh = math.cosh