MCPcopy Create free account
hub / github.com/defold/defold / TimerGetInfo

Function TimerGetInfo

engine/script/src/script_timer.cpp:754–776  ·  view source on GitHub ↗

get information about timer * * Get information about timer. * * @name timer.get_info * @param handle [type:number] the timer handle returned by timer.delay() * @return data [type:table|nil] table or `nil` if timer is cancelled/completed. table with data in the following fields: * * `time_remaining` * : [type:number] Time remaining until the next time

Source from the content-addressed store, hash-verified

752 *
753 */
754 static int TimerGetInfo(lua_State* L)
755 {
756 DM_LUA_STACK_CHECK(L, 1);
757
758 const int timer_handle = luaL_checkint(L, 1);
759 dmScript::HTimerWorld timer_world = CheckTimerWorld(L);
760
761 Timer* timer = GetTimerFromHandle(timer_world, timer_handle);
762 if (!timer)
763 {
764 lua_pushnil(L);
765 return 1;
766 }
767
768 lua_newtable(L);
769 lua_pushnumber(L,timer->m_Remaining);
770 lua_setfield(L, -2, "time_remaining");
771 lua_pushnumber(L,timer->m_Delay);
772 lua_setfield(L, -2, "delay");
773 lua_pushboolean(L,timer->m_Repeat==1);
774 lua_setfield(L, -2, "repeating");
775 return 1;
776 }
777
778 static const luaL_reg TIMER_COMP_FUNCTIONS[] = {
779 { "delay", TimerDelay },

Callers

nothing calls this directly

Calls 6

CheckTimerWorldFunction · 0.85
GetTimerFromHandleFunction · 0.85
lua_pushnilFunction · 0.85
lua_pushnumberFunction · 0.85
lua_setfieldFunction · 0.85
lua_pushbooleanFunction · 0.85

Tested by

no test coverage detected