- VERSIÓ 1.1

- [NEW] map.surf() per a obtindre i fixar la surface que usa el tilemap
- [NEW] Llevats map.new, map.load i map.save. Es fa des de les surfaces.
This commit is contained in:
2025-06-17 13:53:45 +02:00
parent 2a4195c839
commit 16be589a72
4 changed files with 20 additions and 22 deletions

22
lua.cpp
View File

@@ -125,6 +125,7 @@ extern "C" {
// map
// ===============================================
/*
static int cpp_map_new(lua_State *L) {
int w = luaL_checknumber(L, 1);
int h = luaL_checknumber(L, 2);
@@ -148,10 +149,17 @@ extern "C" {
savesurf(surface, str, nullptr);
return 0;
}
*/
static int cpp_map_surf(lua_State *L) {
if (lua_gettop(L)==1) {
uint8_t surface = luaL_checkinteger(L, 1);
setmap(surface);
} else {
lua_pushinteger(L, getmap());
return 1;
}
static int cpp_map_set(lua_State *L) {
uint8_t surface = luaL_checkinteger(L, 1);
setmap(surface);
return 0;
}
@@ -826,10 +834,10 @@ void push_lua_funcs() {
lua_setglobal(L, "surf");
lua_newtable(L);
lua_pushcfunction(L,cpp_map_new); lua_setfield(L, -2, "new");
lua_pushcfunction(L,cpp_map_load); lua_setfield(L, -2, "load");
lua_pushcfunction(L,cpp_map_save); lua_setfield(L, -2, "save");
lua_pushcfunction(L,cpp_map_set); lua_setfield(L, -2, "set");
//lua_pushcfunction(L,cpp_map_new); lua_setfield(L, -2, "new");
//lua_pushcfunction(L,cpp_map_load); lua_setfield(L, -2, "load");
//lua_pushcfunction(L,cpp_map_save); lua_setfield(L, -2, "save");
lua_pushcfunction(L,cpp_map_surf); lua_setfield(L, -2, "surf");
lua_pushcfunction(L,cpp_map_draw); lua_setfield(L, -2, "draw");
lua_pushcfunction(L,cpp_map_tile); lua_setfield(L, -2, "tile");
lua_setglobal(L, "map");