-- =========================================================================== -- ApiProbe.lua -- Lista las funciones y tablas globales que el ejecutable expone a Lua. -- Sirve igual en GameServer y en Main (cliente). Escribe un .txt y avisa en consola. -- Solo lee _G: no modifica nada. -- =========================================================================== -- GetMinUserIndex existe en el servidor (se usa en Functions.lua). -- GetMainScene existe en el cliente (se usa en WindowTitle.lua). local IS_SERVER = (type(GetMinUserIndex) == 'function') local function Out(msg) if IS_SERVER then if type(LogColor) == 'function' then pcall(LogColor, 3, msg) end else if type(Console) == 'function' then pcall(Console, 3, msg) end end end local function Dump() local fns, tbls, others = {}, {}, {} for k, v in pairs(_G) do local t = type(v) if t == 'function' then fns[#fns + 1] = tostring(k) elseif t == 'table' then tbls[#tbls + 1] = tostring(k) elseif t == 'number' or t == 'string' or t == 'boolean' then others[#others + 1] = tostring(k) .. ' = ' .. tostring(v) end end table.sort(fns) table.sort(tbls) table.sort(others) local text = {} text[#text + 1] = 'SIDE: ' .. (IS_SERVER and 'SERVER' or 'CLIENT') text[#text + 1] = 'LUA: ' .. tostring(_VERSION) .. (jit and (' / ' .. tostring(jit.version)) or '') text[#text + 1] = '' text[#text + 1] = 'FUNCTIONS (' .. #fns .. '):' text[#text + 1] = table.concat(fns, '\n') text[#text + 1] = '' text[#text + 1] = 'TABLES (' .. #tbls .. '):' text[#text + 1] = table.concat(tbls, '\n') text[#text + 1] = '' text[#text + 1] = 'CONSTANTS (' .. #others .. '):' text[#text + 1] = table.concat(others, '\n') local body = table.concat(text, '\n') local fileName = IS_SERVER and 'ApiProbe_server.txt' or 'ApiProbe_client.txt' if type(io) == 'table' and type(io.open) == 'function' then local ok, f = pcall(io.open, fileName, 'w') if ok and f then f:write(body) f:close() Out('[ApiProbe] ' .. (IS_SERVER and 'SERVER' or 'CLIENT') .. ': escrito ' .. fileName .. ' (' .. #fns .. ' funciones, ' .. #tbls .. ' tablas) ' .. tostring(_VERSION)) return end end -- Sin io.open: imprime por consola, nombres en tandas para no truncar. Out('[ApiProbe] io.open no disponible; imprimo por consola. ' .. tostring(_VERSION)) local chunk = {} for i = 1, #fns do chunk[#chunk + 1] = fns[i] if #chunk == 12 or i == #fns then Out('[ApiProbe] F: ' .. table.concat(chunk, ', ')) chunk = {} end end Out('[ApiProbe] T: ' .. table.concat(tbls, ', ')) end local ok, err = pcall(Dump) if not ok then Out('[ApiProbe] error: ' .. tostring(err)) end