Use gint.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
unnamed-platformer/levels.lua

37 lines
1.1 KiB

to_write = ""
current = 0
for i = 0, 9999, 1 do
file = io.open("../up-editor/screens/"..i..".scr")
if file then
file_content = file:read()
formated_file = ""
for j = 1, #file_content, 1 do
if j == 1 then
formated_file = formated_file.."-----------------------------"
end
formated_file = formated_file..file_content:sub(j, j)
if j % 26 == 0 then formated_file = formated_file.."--" end
if j == 390 then
formated_file = formated_file.."---------------------------"
end
end
file:close()
to_write = to_write.." case "..i..":\n memcpy(level, \""..
formated_file.."\", "..#formated_file..");\n"
if string.find(file_content, 'c') then
to_write = to_write.." *coin_id = "..current..";\n"
end
to_write = to_write.." break;\n"
current = current + 1
end
end
--finish and write
to_write = [[#include "levels.h"
#include <gint/std/string.h>
void set_level(int level_id, char level[], unsigned int *coin_id) {
switch (level_id)
{
]]..to_write.." }\n}\n"
io.write(to_write)