Skip to content

Instantly share code, notes, and snippets.

@Zbizu
Created October 2, 2022 12: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 Zbizu/c913a548327403dbc787fd411bacd721 to your computer and use it in GitHub Desktop.
Save Zbizu/c913a548327403dbc787fd411bacd721 to your computer and use it in GitHub Desktop.
local files = {"door_locked.png",
"door_locked_small.png",
"door_normal.png",
"door_normal_small.png",
"door_magic.png",
"door_magic_small.png",
"door_quest.png",
"door_quest_small.png"}
function c()
for i = 1, #files do
local fileName = files[i]
local file = io.open(fileName, "rb")
if not file then
print(string.format("Unable to load %s!", fileName))
return
end
local ofn = fileName .. ".txt"
local of = io.open(ofn, "w+")
-- read the file
local buffer = ""
local tmp = file:read(1)
local count = 0
local lineCount = -1
while tmp do
count = count + 1
lineCount = lineCount + 1
if lineCount == 5 then
lineCount = 0
of:write("\n")
end
of:write(string.format("0x%.2x, ", string.byte(tmp)))
tmp = file:read(1)
end
of:write("\ncount: " .. count .. "\n")
file:close()
of:close()
end
end
c()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment