diff options
| -rw-r--r-- | main.c | 19 | ||||
| -rw-r--r-- | stdlib/tilemap.h | 16 | ||||
| -rw-r--r-- | stdlib/tilemap.lua | 5 |
3 files changed, 21 insertions, 19 deletions
@@ -5,8 +5,9 @@ #include "lualib.h" #include "lauxlib.h" -#include "stdlib/color.h" #include "stdlib/json.h" +#include "stdlib/color.h" +#include "stdlib/tilemap.h" #define IN_FILE "test/main.lua" #define DEBUG_LEVEL LOG_DEBUG @@ -97,6 +98,14 @@ int main(void) { lua_register(L, "draw_fps", l_draw_fps); lua_register(L, "clear_window", l_clear_window); + // Embedding JSON module. + if (luaL_loadbuffer(L, json, json_len, "json") || lua_pcall(L, 0, 1, 0)) { + fprintf(stderr, "Error loading json.lua: %s\n", lua_tostring(L, -1)); + lua_close(L); + return 1; + } + lua_setglobal(L, "json"); + // Embedding color module. if (luaL_loadbuffer(L, color, color_len, "color") || lua_pcall(L, 0, 1, 0)) { fprintf(stderr, "Error loading color.lua: %s\n", lua_tostring(L, -1)); @@ -105,13 +114,13 @@ int main(void) { } lua_setglobal(L, "color"); - // Embedding JSON module. - if (luaL_loadbuffer(L, json, json_len, "json") || lua_pcall(L, 0, 1, 0)) { - fprintf(stderr, "Error loading json.lua: %s\n", lua_tostring(L, -1)); + // Embedding tilemap module. + if (luaL_loadbuffer(L, tilemap, tilemap_len, "tilemap") || lua_pcall(L, 0, 1, 0)) { + fprintf(stderr, "Error loading tilemap.lua: %s\n", lua_tostring(L, -1)); lua_close(L); return 1; } - lua_setglobal(L, "json"); + lua_setglobal(L, "tilemap"); // Interpreting and running input file Lua script. if (luaL_loadfile(L, IN_FILE) || lua_pcall(L, 0, 0, 0)) { diff --git a/stdlib/tilemap.h b/stdlib/tilemap.h index 5795bd7..3a60c2d 100644 --- a/stdlib/tilemap.h +++ b/stdlib/tilemap.h @@ -2,18 +2,10 @@ #define tilemap_H unsigned char tilemap[] = { - 0x2d, 0x2d, 0x20, 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, - 0x20, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x68, 0x6f, 0x6c, 0x64, 0x65, 0x72, - 0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x70, 0x6f, - 0x74, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x20, 0x73, 0x74, 0x61, 0x6e, - 0x64, 0x61, 0x72, 0x64, 0x20, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, - 0x20, 0x74, 0x68, 0x61, 0x74, 0x20, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x64, - 0x73, 0x20, 0x74, 0x68, 0x65, 0x0a, 0x2d, 0x2d, 0x20, 0x66, 0x72, 0x61, - 0x6d, 0x65, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, - 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x20, 0x66, - 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x69, - 0x65, 0x73, 0x2e, 0x0a + 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x74, 0x69, 0x6c, 0x65, 0x6d, 0x61, + 0x70, 0x20, 0x3d, 0x20, 0x7b, 0x7d, 0x0a, 0x0a, 0x72, 0x65, 0x74, 0x75, + 0x72, 0x6e, 0x20, 0x74, 0x69, 0x6c, 0x65, 0x6d, 0x61, 0x70, 0x0a }; -unsigned int tilemap_len = 124; +unsigned int tilemap_len = 35; #endif // tilemap_H diff --git a/stdlib/tilemap.lua b/stdlib/tilemap.lua index e2dad67..da30c1e 100644 --- a/stdlib/tilemap.lua +++ b/stdlib/tilemap.lua @@ -1,2 +1,3 @@ --- This is a placeholder file for potential standard library that extends the --- framework with additional functionalities. +local tilemap = {} + +return tilemap |
