From 0d2de2ba9c616862d7881f089382db772d034f89 Mon Sep 17 00:00:00 2001 From: Alexander Date: Sun, 27 Oct 2019 17:25:16 -0400 Subject: Various updates --- src/shared/lua_api/load_common.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'src/shared/lua_api/load_common.cpp') diff --git a/src/shared/lua_api/load_common.cpp b/src/shared/lua_api/load_common.cpp index 66afe67..dc61ef1 100644 --- a/src/shared/lua_api/load_common.cpp +++ b/src/shared/lua_api/load_common.cpp @@ -1,8 +1,30 @@ +#include +#include extern "C" { #include #include #include } +using namespace std::chrono; -void loadCommonLibs(lua_State* L); -void gameloop_common(lua_State* L); +//Gets the time +int get_time(lua_State* L){ + std::chrono::high_resolution_clock::time_point now = high_resolution_clock::now(); + std::chrono::high_resolution_clock::duration since_epoch = now.time_since_epoch(); + double dc = std::chrono::duration_cast(since_epoch).count(); + lua_pushnumber(L,dc); + return 1; +} + +void loadCommonLibs(lua_State* L){ + lua_getglobal(L,"GAME"); + lua_pushcfunction(L,make_crashy); + lua_setfield(L,-2,"crashy"); + lua_pop(L,1); + lua_pushcfunction(L,get_time); + lua_setglobal(L,"get_time"); +} + +void gameloop_common(lua_State* L){ + +} -- cgit v1.2.3-70-g09d2