1
0
Fork 0
mirror of https://github.com/ctruLua/ctruLua.git synced 2025-10-28 00:39:30 +00:00
ctruLua/source/ctr.c
Reuh 9ab25f7518 TABS. TABS EVERYWHERE. Please.
Also, gfx.set3D now accept any value (not only boolean), like on Lua. Because why not (Also changed the ctrulib gfxSet3D function to the sf2dlib one).
2015-08-20 10:45:18 +02:00

48 lines
923 B
C

#include <3ds/types.h>
#include <3ds/os.h>
#include <lua.h>
#include <lauxlib.h>
int load_os_lib(lua_State *L);
int load_gfx_lib(lua_State *L);
int load_news_lib(lua_State *L);
int load_ptm_lib(lua_State *L);
int load_hid_lib(lua_State *L);
static int ctr_time(lua_State *L) {
lua_pushinteger(L, osGetTime());
return 1;
}
// Functions
static const struct luaL_Reg ctr_lib[] = {
{ "time", ctr_time},
{ NULL, NULL }
};
// Subtables
struct { char *name; int (*load)(lua_State *L); } ctr_libs[] = {
{ "gfx", load_gfx_lib },
{ "news", load_news_lib },
{ "ptm", load_ptm_lib },
{ "hid", load_hid_lib },
{ NULL, NULL }
};
int luaopen_ctr_lib(lua_State *L) {
luaL_newlib(L, ctr_lib);
for (int i = 0; ctr_libs[i].name; i++) {
ctr_libs[i].load(L);
lua_setfield(L, -2, ctr_libs[i].name);
}
return 1;
}
void load_ctr_lib(lua_State *L) {
load_os_lib(L);
luaL_requiref(L, "ctr", luaopen_ctr_lib, 0);
}