Skip to content

Instantly share code, notes, and snippets.

View nefftd's full-sized avatar

Anthony Eadicicco nefftd

View GitHub Profile
local ASCII_PRINTABLE = {33,126}
local function genpass(len)
local amin,amax = (table.unpack or unpack)(ASCII_PRINTABLE)
local pass = {}
for i = 1,len do
pass[i] = math.random(amin,amax)
end
return string.char((table.unpack or unpack)(pass))
end
local foo,bar
function foo(x) function bar(x)
bar(x) foo(x)
end end
local foo,bar
function foo(...) -- local
end
function bar(...) -- local
mod:provider 'health' {
function(unit, event, ...)
if some_example then
return -- return nothing to not update frames
end
return UnitHealth(unit), UnitHealthMax(unit) -- returned values get sent as signal to unit frame
end,
updatefor = {'.*'}, -- invoke for all units
unitevents = {'UNIT_HEALTH','UNIT_MAXHEALTH'}, -- invoke for event's arg1 unit on these events
events = { ['.*'] = 'PLAYER_ENTERING_WORLD' }, -- also invoke on PEW for all valid units
@nefftd
nefftd / thiswerksiguess.lua
Created January 19, 2015 12:53
thiswerksiguess.lua
-- Dead
mod:provider 'dead' {
function(unit)
local isdead = UnitIsDead(unit)
local isghost = UnitIsGhost(unit)
return isdead,isghost
end,
updatefor = {'.*'},
events = {
['player'] = {'PLAYER_DEAD','PLAYER_UNGHOST','PLAYER_ALIVE'}
nametext:Listen('name',function(self,name,realm)
name = mod.abbrev_shortname(name)
if UnitCanAttack('player','targettarget') then
name = '|cff993333>|r '..name
else
name = '|cffffffff>|r '..name
end
self:SetText(name)
end)
-- Namespace
local _,mod = ...
-- Example
mod:provider 'example' {
function(unit)
local tooltip
local function create_tooltip()
local tip, fontstrings = CreateFrame("GameTooltip", "temptt"), {}
for i = 1, 8 do
local L,R = tip:CreateFontString(), tip:CreateFontString()
L:SetFontObject(GameFontNormal)
R:SetFontObject(GameFontNormal)
tip:AddFontStrings(L,R)
table.insert(fontstrings,L)
table.insert(fontstrings,R)
local tooltip
local function create_tooltip()
local tip, fontstrings = CreateFrame("GameTooltip", "temptt", nil, "GameTooltipTemplate"), {}
for i = 1, 8 do
local L,R = tip:CreateFontString(), tip:CreateFontString()
L:SetFontObject(GameFontNormal)
R:SetFontObject(GameFontNormal)
tip:AddFontStrings(L,R)
table.insert(fontstrings,L)
table.insert(fontstrings,R)
C:\Users\Neffi
λ lua
Lua 5.2.3 Copyright (C) 1994-2013 Lua.org, PUC-Rio
> local t={}; for i = 1,950000 do t[i]='a' end; local tprime = table.pack(table.unpack(t,1,#t/2)); print(#tprime)
475000
> local t={}; for i = 1,1000000 do t[i]='a' end; local tprime = table.pack(table.unpack(t,1,#t/2)); print(#tprime)
500000
> local t={}; for i = 1,1200000 do t[i]='a' end; local tprime = table.pack(table.unpack(t,1,#t/2)); print(#tprime)
600000
> local t={}; for i = 1,2200000 do t[i]='a' end; local tprime = table.pack(table.unpack(t,1,#t/2)); print(#tprime)