VERSIÓ 1.4.6

-[NEW] font.load()
-[NEW] font.current()
-[NEW] font.spacing()
-[NEW] font.DEFAULT
-[NEW] surf.SCREEN
This commit is contained in:
2026-03-18 20:36:14 +01:00
parent bf34c92e09
commit 779ef7acb6
8 changed files with 146 additions and 9 deletions

60
lua.cpp
View File

@@ -888,6 +888,54 @@ extern "C" {
}
// font
// ===============================================
static int cpp_font_load(lua_State *L) {
const char* str = luaL_checkstring(L, 1);
uint8_t s = loadfont(str);
if (s==255) {
luaL_error(L, "Error while loading font: Max fonts reached");
return 0;
}
lua_pushinteger(L, s);
return 1;
}
static int cpp_font_current(lua_State *L) {
const int numargs = lua_gettop(L);
switch (numargs) {
case 0: {
lua_pushinteger(L, getfont());
return 1;
}
case 1: {
uint8_t font = luaL_checkinteger(L, 1);
setfont(font);
return 0;
}
default:
return luaL_error(L, "Function 'font.current' Unexpected number of parameters.");
};
}
static int cpp_font_spacing(lua_State *L) {
const int numargs = lua_gettop(L);
switch (numargs) {
case 0: {
lua_pushinteger(L, getfontspacing());
return 1;
}
case 1: {
uint8_t spacing = luaL_checkinteger(L, 1);
setfontspacing(spacing);
return 0;
}
default:
return luaL_error(L, "Function 'font.spacing' Unexpected number of parameters.");
};
}
// mouse
// ===============================================
@@ -1061,6 +1109,8 @@ void push_lua_funcs() {
lua_pushcfunction(L,cpp_surf_source); lua_setfield(L, -2, "source");
lua_pushcfunction(L,cpp_surf_cls); lua_setfield(L, -2, "cls");
lua_pushcfunction(L,cpp_surf_pixel); lua_setfield(L, -2, "pixel");
lua_pushinteger(L, 0); lua_setfield(L, -2, "SCREEN");
lua_setglobal(L, "surf");
lua_newtable(L);
@@ -1170,6 +1220,14 @@ void push_lua_funcs() {
lua_pushcfunction(L,cpp_conf_folder); lua_setfield(L, -2, "folder");
lua_setglobal(L, "config");
lua_newtable(L);
lua_pushcfunction(L,cpp_font_load); lua_setfield(L, -2, "load");
lua_pushcfunction(L,cpp_font_current); lua_setfield(L, -2, "current");
lua_pushcfunction(L,cpp_font_spacing); lua_setfield(L, -2, "spacing");
lua_pushinteger(L, 0); lua_setfield(L, -2, "DEFAULT");
lua_setglobal(L, "font");
lua_newtable(L);
lua_pushcfunction(L,cpp_mouse_pos); lua_setfield(L, -2, "pos");
lua_pushcfunction(L,cpp_mouse_wheel); lua_setfield(L, -2, "wheel");
@@ -1335,7 +1393,7 @@ void push_lua_funcs() {
lua_setglobal(L, "pad");
lua_getglobal(L, "utf8"); // push utf8 table
lua_pushcfunction(L, cpp_utf8_sub); // push C function
lua_setfield(L, -2, "sub"); // utf8.sub = cpp_utf8_sub