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

33 lines
1.0 KiB

io.write([[#include "levels.h"
#include <gint/std/string.h>
]])
io.write("void set_level(int level_id, char level[], unsigned int *coin_id){")
io.write("switch (level_id){")
current = 0
for i = 0, 9999, 1 do
file = io.open("../up-editor/screens/"..i..".scr")
file_content = nil
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()
io.write("case "..i..":memcpy(level,\""..
formated_file.."\","..#formated_file..");")
if file_content and string.find(file_content, 'c') then
io.write("*coin_id = "..current..";")
current = current + 1
end
io.write("break;")
end
end
io.write("}}")