diff options
| author | Alexander <alex@cogarr.net> | 2019-10-27 17:25:16 -0400 |
|---|---|---|
| committer | Alexander <alex@cogarr.net> | 2019-10-27 17:25:16 -0400 |
| commit | 0d2de2ba9c616862d7881f089382db772d034f89 (patch) | |
| tree | 5fc58b63c593e2ac17f3353b50318c299f643390 /src/shared/lua_api/load_common.cpp | |
| parent | c9db55cdc2f69c3dc7aefabe0cc828a64e377024 (diff) | |
| download | brokengine-0d2de2ba9c616862d7881f089382db772d034f89.tar.gz brokengine-0d2de2ba9c616862d7881f089382db772d034f89.tar.bz2 brokengine-0d2de2ba9c616862d7881f089382db772d034f89.zip | |
Various updates
Diffstat (limited to 'src/shared/lua_api/load_common.cpp')
| -rw-r--r-- | src/shared/lua_api/load_common.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
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 <chrono> +#include <shared/lua_api/load_common.hpp> extern "C" { #include <lua.h> #include <lauxlib.h> #include <lualib.h> } +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<std::chrono::milliseconds>(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){ + +} |
