Created
June 1, 2016 09:39
-
-
Save winny-/8d0289c3293ae777bf21a82a15b6f0b9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Sandbox = {} | |
Sandbox.Frame = CreateFrame('Frame', 'Sandbox') | |
Sandbox.Evals = {} | |
function prn(s) | |
DEFAULT_CHAT_FRAME:AddMessage(s) | |
end | |
function len(tbl) | |
local n = 0 | |
while tbl[n+1] ~= nil do | |
n = n + 1 | |
end | |
return n | |
end | |
SLASH_SANDBOX1 = '/sandbox' | |
SlashCmdList['SANDBOX'] = function() prn('Sandbox loaded! :)') end | |
SLASH_EVAL1 = '/eval' | |
SlashCmdList['EVAL'] = function(s) | |
if s == nil or s == '' then | |
prn('|cffff6060Need lua expression') | |
return | |
end | |
local tmpl = [[ | |
local res = %s | |
if res == nil then | |
return 'nil' | |
else | |
return tostring(res) | |
end | |
]] | |
local fn = loadstring(string.format(tmpl, s)) | |
if fn == nil then | |
prn('|cffff6060Bad lua expression "' .. s .. '"') | |
else | |
local res = fn() | |
table.insert(Sandbox.Evals, {input = s, output = res}) | |
prn('[' .. len(Sandbox.Evals) .. '] ' .. s .. ' => ' .. | |
(res ~= 'nil' and res or '|cffbbbbbbnil')) | |
end | |
end | |
function lsAddons() | |
local n = GetNumAddOns() | |
if n == 0 then | |
prn("(No addons)") | |
return | |
end | |
for idx = 1, n do | |
prn(tostring(idx) .. ' "' .. GetAddOnInfo(idx) .. '" ' .. (IsAddOnLoaded(idx) and 'loaded' or '*not* loaded')) | |
end | |
end | |
SLASH_LSADDONS1 = '/lsaddons' | |
SlashCmdList['LSADDONS'] = lsAddons | |
prn('Sandbox successfully executed.') |
This file contains hidden or 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
## Interface: 30300 | |
## Title: Sandbox | |
## Notes: AddOn for playing around. | |
Sandbox.lua |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment