VERSIÓ 1.3.14

- [NEW] draw.pattern() sense paràmetres restableix el patró de relleno
- [FIX] Llevat el std::vector que estava donant pel cul. No, si ja sabia jo...
- [NEW] Gestió del cas en que es supere el nombre màxim de textures (en compte d'explotar, tira un error bonico)
This commit is contained in:
2025-12-04 11:35:34 +01:00
parent 3e524fd32d
commit 4858d94378
4 changed files with 50 additions and 28 deletions

31
lua.cpp
View File

@@ -16,19 +16,34 @@ extern "C" {
static int cpp_surf_new(lua_State *L) {
int w = luaL_checknumber(L, 1);
int h = luaL_checknumber(L, 2);
lua_pushinteger(L, newsurf(w, h));
uint8_t s = newsurf(w, h);
if (s==255) {
luaL_error(L, "Error while creating new surface: Max surfaces reached");
return 0;
}
lua_pushinteger(L, s);
return 1;
}
static int cpp_surf_load(lua_State *L) {
const char* str = luaL_checkstring(L, 1);
lua_pushinteger(L, loadsurf(str));
uint8_t s = loadsurf(str);
if (s==255) {
luaL_error(L, "Error while loading surface: Max surfaces reached");
return 0;
}
lua_pushinteger(L, s);
return 1;
}
static int cpp_surf_loadex(lua_State *L) {
const char* str = luaL_checkstring(L, 1);
lua_pushinteger(L, loadsurf(str, true));
uint8_t s = loadsurf(str, true);
if (s==255) {
luaL_error(L, "Error while loading surface: Max surfaces reached");
return 0;
}
lua_pushinteger(L, s);
return 1;
}
@@ -472,9 +487,13 @@ extern "C" {
}
static int cpp_draw_pattern(lua_State *L) {
uint16_t pat = luaL_checkinteger(L, 1);
bool transparent = lua_toboolean(L, 2);
fillp(pat, transparent);
if (lua_gettop(L) == 0) {
fillp(0xffff);
} else {
uint16_t pat = luaL_checkinteger(L, 1);
bool transparent = lua_toboolean(L, 2);
fillp(pat, transparent);
}
return 0;
}