Skip to content

Instantly share code, notes, and snippets.

@winny-
Created June 1, 2016 08:01
Show Gist options
  • Save winny-/da9b300188564aa0d93c490df9a3e14e to your computer and use it in GitHub Desktop.
Save winny-/da9b300188564aa0d93c490df9a3e14e to your computer and use it in GitHub Desktop.
function prn(s)
DEFAULT_CHAT_FRAME:AddMessage(s)
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('Need 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('Bad lua expression "' .. s .. '"')
else
local res = fn()
prn(res ~= nil and res or 'nil')
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
prn('Sandbox successfully executed.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment