2018-02-17 17:18:08 +00:00
|
|
|
#include "api.h"
|
2019-05-20 09:47:33 +00:00
|
|
|
#include "util.h"
|
2019-05-21 03:44:39 +00:00
|
|
|
#include "platform.h"
|
2018-11-14 02:18:59 +00:00
|
|
|
#include "lib/lua-cjson/lua_cjson.h"
|
|
|
|
#include "lib/lua-enet/enet.h"
|
|
|
|
|
|
|
|
const luaL_Reg lovrModules[] = {
|
|
|
|
{ "lovr", luaopen_lovr },
|
|
|
|
#ifdef LOVR_ENABLE_AUDIO
|
|
|
|
{ "lovr.audio", luaopen_lovr_audio },
|
|
|
|
#endif
|
|
|
|
#ifdef LOVR_ENABLE_DATA
|
|
|
|
{ "lovr.data", luaopen_lovr_data },
|
|
|
|
#endif
|
|
|
|
#ifdef LOVR_ENABLE_EVENT
|
|
|
|
{ "lovr.event", luaopen_lovr_event },
|
|
|
|
#endif
|
|
|
|
#ifdef LOVR_ENABLE_FILESYSTEM
|
|
|
|
{ "lovr.filesystem", luaopen_lovr_filesystem },
|
|
|
|
#endif
|
|
|
|
#ifdef LOVR_ENABLE_GRAPHICS
|
|
|
|
{ "lovr.graphics", luaopen_lovr_graphics },
|
|
|
|
#endif
|
|
|
|
#ifdef LOVR_ENABLE_HEADSET
|
|
|
|
{ "lovr.headset", luaopen_lovr_headset },
|
|
|
|
#endif
|
|
|
|
#ifdef LOVR_ENABLE_MATH
|
|
|
|
{ "lovr.math", luaopen_lovr_math },
|
|
|
|
#endif
|
|
|
|
#ifdef LOVR_ENABLE_PHYSICS
|
|
|
|
{ "lovr.physics", luaopen_lovr_physics },
|
|
|
|
#endif
|
|
|
|
#ifdef LOVR_ENABLE_THREAD
|
|
|
|
{ "lovr.thread", luaopen_lovr_thread },
|
|
|
|
#endif
|
|
|
|
#ifdef LOVR_ENABLE_TIMER
|
|
|
|
{ "lovr.timer", luaopen_lovr_timer },
|
|
|
|
#endif
|
|
|
|
#ifdef LOVR_ENABLE_JSON
|
|
|
|
{ "cjson", luaopen_cjson },
|
|
|
|
#endif
|
|
|
|
#ifdef LOVR_ENABLE_ENET
|
|
|
|
{ "enet", luaopen_enet },
|
|
|
|
#endif
|
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
2018-02-17 17:18:08 +00:00
|
|
|
|
2018-09-27 01:27:38 +00:00
|
|
|
static int l_lovrGetOS(lua_State* L) {
|
2019-05-21 03:44:39 +00:00
|
|
|
lua_pushstring(L, lovrPlatformGetName());
|
2018-09-27 01:27:38 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int l_lovrGetVersion(lua_State* L) {
|
2018-09-27 04:45:45 +00:00
|
|
|
lua_pushinteger(L, LOVR_VERSION_MAJOR);
|
|
|
|
lua_pushinteger(L, LOVR_VERSION_MINOR);
|
|
|
|
lua_pushinteger(L, LOVR_VERSION_PATCH);
|
2018-09-27 01:27:38 +00:00
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const luaL_Reg lovr[] = {
|
|
|
|
{ "_setConf", luax_setconf },
|
|
|
|
{ "getOS", l_lovrGetOS },
|
|
|
|
{ "getVersion", l_lovrGetVersion },
|
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
|
2019-08-21 22:27:26 +00:00
|
|
|
LOVR_EXPORT int luaopen_lovr(lua_State* L) {
|
2018-02-17 17:18:08 +00:00
|
|
|
lua_newtable(L);
|
|
|
|
luaL_register(L, NULL, lovr);
|
|
|
|
return 1;
|
|
|
|
}
|