Skip to content

Instantly share code, notes, and snippets.

@rubbertoe98
Last active July 16, 2025 17:42
Show Gist options
  • Save rubbertoe98/5b763676f367897087046354efe2ad30 to your computer and use it in GitHub Desktop.
Save rubbertoe98/5b763676f367897087046354efe2ad30 to your computer and use it in GitHub Desktop.
ExportStrMemValues
--Traverse through all files with fileTypes defined in `allowedFileTypes` in resources/, and prints & exports all files
--that have an strmem physical of over `showFilesAbovePhys` to resources/strmeme.txt"
--(Windows only)
--Usage: /checkstrmeme
local allowedFileTypes = {
".ytd",
".ydr",
}
local showFilesAbovePhys = 50.0
local function writeLog(file,text)
log = io.open("resources/"..file, "a")
if log then
log:write(text)
else
print("Log file doesnt exist")
end
log:close()
end
local function getMem(path) --credits to @github.com/blattersturm
local f = io.open(path, 'rb')
if f then
local magic, version, virtual, physical = ("<c4I4I4I4"):unpack(f:read(16))
f:close()
if magic ~= 'RSC7' then
print("not RSC7")
return
end
local function flagToSize(flag)
return ((((flag >> 17) & 0x7f) + (((flag >> 11) & 0x3f) << 1) + (((flag >> 7) & 0xf) << 2) + (((flag >> 5) & 0x3) << 3) + (((flag >> 4) & 0x1) << 4)) * (0x2000 << (flag & 0xF)))
end
local fmt = "%.2f MiB"
if (flagToSize(physical) / 1024 / 1024) > showFilesAbovePhys then
writeLog("strmeme.txt",(flagToSize(physical) / 1024 / 1024)..":"..path.."\n")
print(path)
print("Virtual Size", fmt:format(flagToSize(virtual) / 1024 / 1024))
print("Physical Size", fmt:format(flagToSize(physical) / 1024 / 1024))
end
else
print("failed to open file :(")
end
end
local function scandir(directory)
local i, t, popen = 0, {}, io.popen
local pfile = popen('dir "'..directory..'" /b /ad')
for filename in pfile:lines() do
i = i + 1
t[i] = filename
end
pfile:close()
return t
end
local function scanfiles(directory)
local i, t, popen = 0, {}, io.popen
local pfile = popen('dir "'..directory..'" /b /a')
for filename in pfile:lines() do
i = i + 1
t[i] = filename
end
pfile:close()
return t
end
local function recursiveCheckStrMeme(path)
local listOfDirectories = scandir(path)
for k,directory in pairs(listOfDirectories) do
for _,fileName in pairs(scanfiles(path.."/"..directory)) do
for _,fileType in pairs(allowedFileTypes) do
if string.match(fileName, fileType) then
getMem(path.."/"..directory.."/"..fileName)
end
end
end
recursiveCheckStrMeme(path.."/"..directory)
end
end
RegisterCommand("checkstrmeme",function(source)
if source == 0 then
local startTime = os.time()
print("Str Meme Values")
print("==============")
recursiveCheckStrMeme("resources")
print("==============")
print("Completed and exported to resources/strmeme.txt, took " .. os.time()-startTime .. " seconds.")
end
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment