Skip to content

Instantly share code, notes, and snippets.

View ColonelThirtyTwo's full-sized avatar

Alex Parrill ColonelThirtyTwo

View GitHub Profile
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 / 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 = {}
@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 / winmap.lua
Created January 29, 2013 20:46
Windows file to memory mapping structure for LuaJIT, which I was going to use for my game but discovered a better solution.
local mmap = {}
mmap.__index = mmap
local new_map
local ffi = require "ffi"
ffi.cdef[[
unsigned long GetLastError();
void* CreateFileA(
const char* lpFileName,
unsigned long dwDesiredAccess,
@ColonelThirtyTwo
ColonelThirtyTwo / tables_test_entity.lua
Created March 26, 2013 13:20
Garry's Mod Alternate Entity Table Storage
AddCSLuaFile()
DEFINE_BASECLASS( "base_anim" )
ENT.PrintName = "Entity table test"
ENT.Author = "Alex 'Colonel Thirty Two' Parrill"
ENT.Information = "Proof of concept for better entity table storage"
ENT.Category = "Other"
class MyTest
{
public:
int a,b,c;
void test()
{
}
};
@ColonelThirtyTwo
ColonelThirtyTwo / e2ffi.lua
Created September 1, 2013 22:26
Library for calling E2 functions from Starfall. Hasn't been tested in awhile, and since it requires mocking the E2 entity, may not work with all functions.
-------------------------------------------------------------------------------
-- Expression 2 Foreign Functions Interface Library
-------------------------------------------------------------------------------
local functions_cache = setmetatable({},{__mode="v"})
local function identity(v) return v end
local lua2e2_converters = {
["number"] = identity,
#!/usr/bin/env python3
import json
import subprocess
import os
import cgi
import cgitb
from time import asctime as curtime
cgitb.enable(display=0, logdir="/var/log/cgitb", format="text")
@ColonelThirtyTwo
ColonelThirtyTwo / boostShoes.lua
Created October 25, 2013 00:46
"Boost Shoes" Item for Cobalt
hook.add("gameInit", function()
localize.set(localize.language, "item_boostShoes", "Boost Shoes")
ITEMS.boostShoes = {
rechargeTime = 3,
jumpPower = 30,
jetTime = 0.3,
ai = {},
local tinsert = table.insert
local tsort = table.sort
--- Recursively dumps a table's contents (sorted by the keys) to a file.
local function dumpTable(tbl, fname)
local out = assert(io.open(fname, "w"))
local visited = {}
local function sortKey(a,b)
local at, bt = type(a), type(b)