Skip to content

Instantly share code, notes, and snippets.

@gabrielmoreira
Created November 18, 2011 00:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabrielmoreira/1375114 to your computer and use it in GitHub Desktop.
Save gabrielmoreira/1375114 to your computer and use it in GitHub Desktop.
Codea GLOBAL dump
DUMP_IGNORE = {os = 1, io = 1, table = 1, _VERSION = 1, math = 1, love = 1, string = 1, package = 1, _G = 1, DUMP_IGNORE = 1, ndump = 1, xpcall = 1, unpack = 1, type = 1, require = 1, setmetatable = 1, next = 1, pairs = 1, ipairs = 1, dofile = 1, collectgarbage = 1, load = 1, loadfile = 1, loadstring = 1, module = 1, pcall = 1, gcinfo = 1, getmetatable = 1, error = 1, debug = 1, coroutine = 1, assert = 1, tonumber = 1, tostring = 1, setfenv = 1, arg = 1, argv = 1, dumpAll = 1, dumpUserData = 1, getfenv = 1, newproxy = 1, select = 1}
function ndump(object, map, visited, prefix, ignoredMap)
map = map or {}
ignoredMap = ignoredMap or {}
visited = visited or {}
if object ~= nil and visited[object] == nil then
visited[object] = true
for k, v in pairs(object) do
local useMap = not prefix and DUMP_IGNORE[tostring(k)] ~= nil and ignoredMap or map
local child = nil
local vtype = type(v)
k = tostring(k)
if vtype == "table" then
child = v
v = "{}"
elseif vtype == "string" then
v = "\"" .. string.gsub(string.gsub(v, "\\", "\\\\"),"\n", "\\n") .. "\""
elseif vtype == "function" then
v = (prefix and (prefix .. "[\"" .. k .. "\"]") or k) .. " or function() end"
elseif vtype == "userdata" then
v = "{} --[[ " .. tostring(v) .. "]]--"
end
table.insert(useMap, (prefix and (prefix .. "[\"" .. k .. "\"]") or k) .. " = " .. tostring(v))
if child then
ndump(child, useMap, visited, (prefix and (prefix .. "[\"" .. k .. "\"]") or k))
end
end
end
if not prefix then
local sf = function(a, b)
return string.lower(a) < string.lower(b)
end
table.sort(map, sf)
table.sort(ignoredMap, sf)
return table.concat(map, "\n"), "-- " .. table.concat(ignoredMap, "\n-- ")
end
end
function dumpAll()
local r, i = ndump(_G)
print("--------------------------------------------------")
print("--[[ CODEA Constants, Variables and Functions ]]--")
print("--------------------------------------------------")
print(r)
print("")
print("")
print("-----------------------")
print("--[[ CODEA IGNORED ]]--")
print("-----------------------")
print(i)
end
function dumpUserData()
print("CurrentTouch.x = " .. tostring(CurrentTouch.x))
print("CurrentTouch.y = " .. tostring(CurrentTouch.y))
print("CurrentTouch.prevX = " .. tostring(CurrentTouch.prevX))
print("CurrentTouch.prevY = " .. tostring(CurrentTouch.prevY))
print("CurrentTouch.deltaX = " .. tostring(CurrentTouch.deltaX))
print("CurrentTouch.deltaY = " .. tostring(CurrentTouch.deltaY))
print("CurrentTouch.id = " .. tostring(CurrentTouch.id))
print("CurrentTouch.tapCount = " .. tostring(CurrentTouch.tapCount))
print("CurrentTouch.state = " .. tostring(CurrentTouch.tapCount))
end
function setup()
dumpAll()
end
function draw()
end
--------------------------------------------------
--[[ CODEA Constants, Variables and Functions ]]--
--------------------------------------------------
background = background or function() end
BEGAN = 1
CENTER = 2
class = class or function() end
color = color or function() end
CORNER = 0
CORNERS = 1
CurrentTouch = {} --[[ Touch
x:0.000000, y:0.000000
prevX:0.000000, prevY:0.000000
id:0
state:0
tapCount:0]]--
DeltaTime = 0
draw = draw or function() end
ElapsedTime = 0
ellipse = ellipse or function() end
ellipseMode = ellipseMode or function() end
ENDED = 4
fill = fill or function() end
Gravity = {} --[[ (0.000000, 0.000000, 0.000000)]]--
HEIGHT = 748
iparameter = iparameter or function() end
iwatch = iwatch or function() end
line = line or function() end
lineCapMode = lineCapMode or function() end
MOVING = 2
noFill = noFill or function() end
noise = noise or function() end
noSmooth = noSmooth or function() end
noStroke = noStroke or function() end
noTint = noTint or function() end
parameter = parameter or function() end
point = point or function() end
pointSize = pointSize or function() end
popMatrix = popMatrix or function() end
popStyle = popStyle or function() end
print = print or function() end
PROJECT = 2
pushMatrix = pushMatrix or function() end
pushStyle = pushStyle or function() end
RADIUS = 3
rect = rect or function() end
rectMode = rectMode or function() end
resetMatrix = resetMatrix or function() end
resetStyle = resetStyle or function() end
rotate = rotate or function() end
ROUND = 0
rsqrt = rsqrt or function() end
scale = scale or function() end
setInstructionLimit = setInstructionLimit or function() end
setup = setup or function() end
smooth = smooth or function() end
sound = sound or function() end
SOUND_BLIT = "blit"
SOUND_EXPLODE = "explode"
SOUND_HIT = "hit"
SOUND_JUMP = "jump"
SOUND_PICKUP = "pickup"
SOUND_RANDOM = "random"
SOUND_SHOOT = "shoot"
sprite = sprite or function() end
SQUARE = 1
STATIONARY = 3
stroke = stroke or function() end
strokeWidth = strokeWidth or function() end
tint = tint or function() end
translate = translate or function() end
UserAcceleration = {} --[[ (0.000000, 0.000000, 0.000000)]]--
vec2 = vec2 or function() end
vec3 = vec3 or function() end
watch = watch or function() end
WIDTH = 748
zLevel = zLevel or function() end
-----------------------
--[[ CODEA IGNORED ]]--
-----------------------
-- _G = {}
-- _VERSION = "Lua 5.1"
-- assert = assert or function() end
-- collectgarbage = collectgarbage or function() end
-- coroutine = {}
-- coroutine["create"] = coroutine["create"] or function() end
-- coroutine["resume"] = coroutine["resume"] or function() end
-- coroutine["running"] = coroutine["running"] or function() end
-- coroutine["status"] = coroutine["status"] or function() end
-- coroutine["wrap"] = coroutine["wrap"] or function() end
-- coroutine["yield"] = coroutine["yield"] or function() end
-- DUMP_IGNORE = {}
-- DUMP_IGNORE["_G"] = 1
-- DUMP_IGNORE["_VERSION"] = 1
-- DUMP_IGNORE["arg"] = 1
-- DUMP_IGNORE["argv"] = 1
-- DUMP_IGNORE["assert"] = 1
-- DUMP_IGNORE["collectgarbage"] = 1
-- DUMP_IGNORE["coroutine"] = 1
-- DUMP_IGNORE["debug"] = 1
-- DUMP_IGNORE["dofile"] = 1
-- DUMP_IGNORE["DUMP_IGNORE"] = 1
-- DUMP_IGNORE["dumpAll"] = 1
-- DUMP_IGNORE["dumpUserData"] = 1
-- DUMP_IGNORE["error"] = 1
-- DUMP_IGNORE["gcinfo"] = 1
-- DUMP_IGNORE["getfenv"] = 1
-- DUMP_IGNORE["getmetatable"] = 1
-- DUMP_IGNORE["io"] = 1
-- DUMP_IGNORE["ipairs"] = 1
-- DUMP_IGNORE["load"] = 1
-- DUMP_IGNORE["loadfile"] = 1
-- DUMP_IGNORE["loadstring"] = 1
-- DUMP_IGNORE["love"] = 1
-- DUMP_IGNORE["math"] = 1
-- DUMP_IGNORE["module"] = 1
-- DUMP_IGNORE["ndump"] = 1
-- DUMP_IGNORE["newproxy"] = 1
-- DUMP_IGNORE["next"] = 1
-- DUMP_IGNORE["os"] = 1
-- DUMP_IGNORE["package"] = 1
-- DUMP_IGNORE["pairs"] = 1
-- DUMP_IGNORE["pcall"] = 1
-- DUMP_IGNORE["require"] = 1
-- DUMP_IGNORE["select"] = 1
-- DUMP_IGNORE["setfenv"] = 1
-- DUMP_IGNORE["setmetatable"] = 1
-- DUMP_IGNORE["string"] = 1
-- DUMP_IGNORE["table"] = 1
-- DUMP_IGNORE["tonumber"] = 1
-- DUMP_IGNORE["tostring"] = 1
-- DUMP_IGNORE["type"] = 1
-- DUMP_IGNORE["unpack"] = 1
-- DUMP_IGNORE["xpcall"] = 1
-- dumpAll = dumpAll or function() end
-- dumpUserData = dumpUserData or function() end
-- error = error or function() end
-- gcinfo = gcinfo or function() end
-- getmetatable = getmetatable or function() end
-- io = {}
-- io["write"] = io["write"] or function() end
-- ipairs = ipairs or function() end
-- math = {}
-- math["abs"] = math["abs"] or function() end
-- math["acos"] = math["acos"] or function() end
-- math["asin"] = math["asin"] or function() end
-- math["atan"] = math["atan"] or function() end
-- math["atan2"] = math["atan2"] or function() end
-- math["ceil"] = math["ceil"] or function() end
-- math["cos"] = math["cos"] or function() end
-- math["cosh"] = math["cosh"] or function() end
-- math["deg"] = math["deg"] or function() end
-- math["exp"] = math["exp"] or function() end
-- math["floor"] = math["floor"] or function() end
-- math["fmod"] = math["fmod"] or function() end
-- math["frexp"] = math["frexp"] or function() end
-- math["huge"] = inf
-- math["ldexp"] = math["ldexp"] or function() end
-- math["log"] = math["log"] or function() end
-- math["log10"] = math["log10"] or function() end
-- math["max"] = math["max"] or function() end
-- math["min"] = math["min"] or function() end
-- math["mod"] = math["mod"] or function() end
-- math["modf"] = math["modf"] or function() end
-- math["pi"] = 3.14159
-- math["pow"] = math["pow"] or function() end
-- math["rad"] = math["rad"] or function() end
-- math["random"] = math["random"] or function() end
-- math["randomseed"] = math["randomseed"] or function() end
-- math["sin"] = math["sin"] or function() end
-- math["sinh"] = math["sinh"] or function() end
-- math["sqrt"] = math["sqrt"] or function() end
-- math["tan"] = math["tan"] or function() end
-- math["tanh"] = math["tanh"] or function() end
-- module = module or function() end
-- ndump = ndump or function() end
-- newproxy = newproxy or function() end
-- next = next or function() end
-- pairs = pairs or function() end
-- pcall = pcall or function() end
-- select = select or function() end
-- setmetatable = setmetatable or function() end
-- string = {}
-- string["byte"] = string["byte"] or function() end
-- string["char"] = string["char"] or function() end
-- string["find"] = string["find"] or function() end
-- string["format"] = string["format"] or function() end
-- string["gfind"] = string["gfind"] or function() end
-- string["gmatch"] = string["gmatch"] or function() end
-- string["gsub"] = string["gsub"] or function() end
-- string["len"] = string["len"] or function() end
-- string["lower"] = string["lower"] or function() end
-- string["match"] = string["match"] or function() end
-- string["rep"] = string["rep"] or function() end
-- string["reverse"] = string["reverse"] or function() end
-- string["sub"] = string["sub"] or function() end
-- string["upper"] = string["upper"] or function() end
-- table = {}
-- table["concat"] = table["concat"] or function() end
-- table["foreach"] = table["foreach"] or function() end
-- table["foreachi"] = table["foreachi"] or function() end
-- table["getn"] = table["getn"] or function() end
-- table["insert"] = table["insert"] or function() end
-- table["maxn"] = table["maxn"] or function() end
-- table["remove"] = table["remove"] or function() end
-- table["setn"] = table["setn"] or function() end
-- table["sort"] = table["sort"] or function() end
-- tonumber = tonumber or function() end
-- tostring = tostring or function() end
-- type = type or function() end
-- unpack = unpack or function() end
-- xpcall = xpcall or function() end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment