Update lua.c

This commit is contained in:
Fierelier 2023-05-14 22:20:37 +02:00
parent 88b6772a14
commit 5722a621d8

View File

@ -3,25 +3,17 @@
#include <lua5.3/lauxlib.h>
lua_State * engine_lua_state;
int engine_luaf_malloc(lua_State *L) {
void * invar1 = lua_touserdata(L,1);
size_t invar2 = lua_touserdata(L,2);
void * outvar = engine_malloc(invar1,invar2);
lua_pushlightuserdata(L,outvar);
return 1;
}
int engine_luaf_free(lua_State *L) {
void * invar1 = lua_touserdata(L,1);
engine_free(invar1);
void * ptr = lua_touserdata(L,1);
engine_free(ptr);
return 0;
}
int engine_luaf_window_init(lua_State *L) {
int invar1 = luaL_checkinteger(L,1);
int invar2 = luaL_checkinteger(L,2);
char * invar3 = (char *)luaL_checkstring(L,3);
engine_window_init(invar1,invar2,invar3);
int width = luaL_checkinteger(L,1);
int height = luaL_checkinteger(L,2);
char * title = (char *)luaL_checkstring(L,3);
engine_window_init(width,height,title);
return 0;
}
@ -31,18 +23,18 @@ int engine_luaf_window_present(lua_State *L) {
}
int engine_luaf_surface_color_set(lua_State *L) {
char invar1 = luaL_checkinteger(L,1);
char invar2 = luaL_checkinteger(L,2);
char invar3 = luaL_checkinteger(L,3);
char invar4 = luaL_checkinteger(L,4);
engine_surface_color_set(invar1,invar2,invar3,invar4);
char r = luaL_checkinteger(L,1);
char g = luaL_checkinteger(L,2);
char b = luaL_checkinteger(L,3);
char a = luaL_checkinteger(L,4);
engine_surface_color_set(r,g,b,a);
return 0;
}
int engine_luaf_surface_draw_pixel(lua_State *L) {
int invar1 = luaL_checkinteger(L,1);
int invar2 = luaL_checkinteger(L,2);
engine_surface_draw_pixel(invar1,invar2);
int x = luaL_checkinteger(L,1);
int y = luaL_checkinteger(L,2);
engine_surface_draw_pixel(x,y);
return 0;
}
@ -53,8 +45,8 @@ int engine_luaf_time_get(lua_State *L) {
}
int engine_luaf_time_sleep(lua_State *L) {
long long invar1 = luaL_checkinteger(L,1);
engine_time_sleep(invar1);
long long ms = luaL_checkinteger(L,1);
engine_time_sleep(ms);
return 0;
}
@ -65,48 +57,48 @@ int engine_luaf_event_get(lua_State *L) {
}
int engine_luaf_texture_create(lua_State *L) {
int invar1 = luaL_checkinteger(L,1);
int invar2 = luaL_checkinteger(L,2);
struct ENGINE_TEXTURE * outvar = engine_texture_create(invar1,invar2);
int width = luaL_checkinteger(L,1);
int height = luaL_checkinteger(L,2);
struct ENGINE_TEXTURE * outvar = engine_texture_create(width,height);
lua_pushlightuserdata(L,outvar);
return 1;
}
int engine_luaf_texture_color_set(lua_State *L) {
char invar1 = luaL_checkinteger(L,1);
char invar2 = luaL_checkinteger(L,2);
char invar3 = luaL_checkinteger(L,3);
char invar4 = luaL_checkinteger(L,4);
engine_texture_color_set(invar1,invar2,invar3,invar4);
char r = luaL_checkinteger(L,1);
char g = luaL_checkinteger(L,2);
char b = luaL_checkinteger(L,3);
char a = luaL_checkinteger(L,4);
engine_texture_color_set(r,g,b,a);
return 0;
}
int engine_luaf_texture_draw_pixel(lua_State *L) {
struct ENGINE_TEXTURE * invar1 = lua_touserdata(L,1);
int invar2 = luaL_checkinteger(L,2);
int invar3 = luaL_checkinteger(L,3);
engine_texture_draw_pixel(invar1,invar2,invar3);
struct ENGINE_TEXTURE * texture = lua_touserdata(L,1);
int x = luaL_checkinteger(L,2);
int y = luaL_checkinteger(L,3);
engine_texture_draw_pixel(texture,x,y);
return 0;
}
int engine_luaf_texture_destroy(lua_State *L) {
struct ENGINE_TEXTURE * invar1 = lua_touserdata(L,1);
engine_texture_destroy(invar1);
struct ENGINE_TEXTURE * texture = lua_touserdata(L,1);
engine_texture_destroy(texture);
return 0;
}
int engine_luaf_texture_render_2d(lua_State *L) {
struct ENGINE_TEXTURE * invar1 = lua_touserdata(L,1);
int invar2 = luaL_checkinteger(L,2);
int invar3 = luaL_checkinteger(L,3);
engine_texture_render_2d(invar1,invar2,invar3);
struct ENGINE_TEXTURE * texture = lua_touserdata(L,1);
int sx = luaL_checkinteger(L,2);
int sy = luaL_checkinteger(L,3);
engine_texture_render_2d(texture,sx,sy);
return 0;
}
int engine_luaf_texture_from_file(lua_State *L) {
struct ENGINE_TEXTURE * invar1 = lua_touserdata(L,1);
char * invar2 = (char *)luaL_checkstring(L,2);
engine_texture_from_file(invar1,invar2);
struct ENGINE_TEXTURE * texture = lua_touserdata(L,1);
char * fpath = (char *)luaL_checkstring(L,2);
engine_texture_from_file(texture,fpath);
return 0;
}
@ -114,8 +106,6 @@ void engine_luaInit() {
engine_lua_state = luaL_newstate();
luaL_openlibs(engine_lua_state);
lua_pushcfunction(engine_lua_state,engine_luaf_malloc);
lua_setglobal (engine_lua_state,"engine_malloc");
lua_pushcfunction(engine_lua_state,engine_luaf_free);
lua_setglobal (engine_lua_state,"engine_free");
lua_pushcfunction(engine_lua_state,engine_luaf_window_init);