Created
October 2, 2022 12:36
-
-
Save Zbizu/c913a548327403dbc787fd411bacd721 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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