diff --git a/src/modules/timer/Timer.cpp b/src/modules/timer/Timer.cpp index d98244d4a..95b511953 100644 --- a/src/modules/timer/Timer.cpp +++ b/src/modules/timer/Timer.cpp @@ -61,7 +61,7 @@ Timer::Timer() prevFpsUpdate = currTime = getTime(); } -void Timer::step() +double Timer::step() { // Frames rendered frames++; @@ -84,6 +84,8 @@ void Timer::step() prevFpsUpdate = currTime; frames = 0; } + + return dt; } void Timer::sleep(double seconds) const diff --git a/src/modules/timer/Timer.h b/src/modules/timer/Timer.h index ce05e66bd..02cfc332a 100644 --- a/src/modules/timer/Timer.h +++ b/src/modules/timer/Timer.h @@ -42,9 +42,9 @@ public: /** * Measures the time between this call and the previous call, - * and updates internal values accordinly. + * and updates internal values accordingly. **/ - void step(); + double step(); /** * Tries to sleep for the specified amount of time. The precision is diff --git a/src/modules/timer/wrap_Timer.cpp b/src/modules/timer/wrap_Timer.cpp index 71c3b6a1f..cb8cf3bef 100644 --- a/src/modules/timer/wrap_Timer.cpp +++ b/src/modules/timer/wrap_Timer.cpp @@ -30,10 +30,10 @@ namespace timer #define instance() (Module::getInstance(Module::M_TIMER)) -int w_step(lua_State *) +int w_step(lua_State *L) { - instance()->step(); - return 0; + lua_pushnumber(L, instance()->step()); + return 1; } int w_getDelta(lua_State *L) diff --git a/src/scripts/boot.lua b/src/scripts/boot.lua index ca8156b5e..c27453f0e 100644 --- a/src/scripts/boot.lua +++ b/src/scripts/boot.lua @@ -535,8 +535,7 @@ function love.run() -- Update dt, as we'll be passing it to update if love.timer then - love.timer.step() - dt = love.timer.getDelta() + dt = love.timer.step() end -- Call update and draw diff --git a/src/scripts/boot.lua.h b/src/scripts/boot.lua.h index daa9d6da3..21b960d29 100644 --- a/src/scripts/boot.lua.h +++ b/src/scripts/boot.lua.h @@ -993,10 +993,8 @@ const unsigned char boot_lua[] = 0x69, 0x74, 0x20, 0x74, 0x6f, 0x20, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x0a, 0x09, 0x09, 0x69, 0x66, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x72, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, - 0x09, 0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x65, 0x70, - 0x28, 0x29, 0x0a, 0x09, 0x09, 0x09, 0x64, 0x74, 0x20, 0x3d, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x72, - 0x2e, 0x67, 0x65, 0x74, 0x44, 0x65, 0x6c, 0x74, 0x61, 0x28, 0x29, 0x0a, + 0x2e, 0x73, 0x74, 0x65, 0x70, 0x28, 0x29, 0x0a, 0x09, 0x09, 0x65, 0x6e, 0x64, 0x0a, 0x09, 0x09, 0x2d, 0x2d, 0x20, 0x43, 0x61, 0x6c, 0x6c, 0x20, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x64, 0x72, 0x61, 0x77, 0x0a,