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:
31
lua.cpp
31
lua.cpp
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user