unnamed-platformer/levels.lua

34 lines
1.0 KiB
Lua
Raw Normal View History

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