Compare commits

...

2 Commits

Author SHA1 Message Date
KikooDX f5596360de (level.lua) Smaller output 2020-03-03 11:32:53 +01:00
KikooDX 5a4870e333 (level.lua) RAM usage improvement
(write directly to file)
2020-03-03 11:27:41 +01:00
1 changed files with 10 additions and 16 deletions

View File

@ -1,5 +1,8 @@
to_write = ""
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")
@ -18,22 +21,13 @@ for i = 0, 9999, 1 do
end
end
file:close()
to_write = to_write.." case "..i..":\n memcpy(level, \""..
formated_file.."\", "..#formated_file..");\n"
io.write("case "..i..":memcpy(level,\""..
formated_file.."\","..#formated_file..");")
if file_content and string.find(file_content, 'c') then
to_write = to_write.." *coin_id = "..current..";\n"
io.write("*coin_id = "..current..";")
current = current + 1
end
to_write = to_write.." break;\n"
io.write("break;")
end
end
to_write = to_write.." }\n}\n"
--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
io.write(to_write)
io.write("}}")