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
| 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 }, |
nothing calls this directly
no test coverage detected