This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pcall(require,"socket") | |
local coroutine_scheduler = { | |
_NAME = "coroutine_scheduler.lua" | |
_VERSION = "1.0.0", | |
} | |
local Scheduler | |
do Scheduler = setmetatable({}, { | |
__call = function(class) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--======== Copyleft © 2010-2011, Team Sandbox, Some rights reserved. ========-- | |
-- | |
-- Purpose: Tests the speed of FStrEq vs "".__eq. | |
-- | |
--===========================================================================-- | |
local Count = 10000 | |
local Time = engine.Time | |
local flTimeExecution | |
local print = print |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Fluttershy(f, ...) | |
local decl = {...} | |
return function(...) | |
local arg = {...} | |
for arg_i = 1, math.ceil(#decl/2) do | |
if type(arg[arg_i]) ~= decl[arg_i*2-1] then | |
arg[arg_i] = decl[arg_i*2] | |
end | |
end | |
return f(unpack(arg)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function debug.getparams(f) | |
local co = coroutine.create(f) | |
local params = {} | |
debug.sethook(co, function(event, line) | |
local i, k, v = 1, debug.getlocal(co, 2, 1) | |
while k do | |
if k ~= "(*temporary)" then | |
table.insert(params, k) | |
end | |
i = i+1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local ffi = require"ffi" | |
jit.on() | |
ffi.cdef[[ | |
typedef int (*getval_func)(); | |
/* imagine these are C functions */ | |
typedef void (*sum_push_func)(int* total, getval_func getval); | |
typedef void (*sum_pull_func)(int* total, int val); | |
]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ deepcopy.lua | |
Deep-copy function for Lua - v0.2 | |
============================== | |
- Does not overflow the stack. | |
- Maintains cyclic-references | |
- Copies metatables | |
- Maintains common upvalues between copied functions (for Lua 5.2 only) | |
TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ socketlanes.lua | |
Multi-threaded LuaSocket with Lua Lanes example | |
=============================================== | |
Depends on the following LuaSocket 2.0.2 patch: | |
http://www.net-core.org/dl/luasocket-2.0.2-acceptfd.patch | |
(via http://www.net-core.org/39/lua/patching-luasocket-to-make-it-compatible) | |
(provided at end of file) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function contourPlot(func, lf, x, y, w, h, interval, offset, mindepth, maxdepth, dbg, depth, fvbr, fvbl, fvtl, fvtr) | |
local wh, hh = w/2, h/2 | |
local v_c = func(x+wh, y+hh)+offset | |
local v_br = fvbr or func(x+w , y+h )+offset | |
local v_bl = fvbl or func(x , y+h )+offset | |
local v_tl = fvtl or func(x , y )+offset | |
local v_tr = fvtr or func(x+w , y )+offset | |
local linelist, linecount, v = {}, 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ ]] | |
function SetLocal(func, name, value) | |
local index = 1 | |
local foundIndex = nil | |
while true do | |
local n, v = debug.getupvalue(func, index) | |
if not n then | |
break | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local networkVars = | |
{ | |
lolScale = "float", | |
} | |
local orig_Player_OnCreate = Player.OnCreate | |
function Player:OnCreate(...) | |
orig_Player_OnCreate(self, ...) | |
self.lolScale = 1 | |
end |