trigger a callback * * Manual triggering a callback for a timer. * * @name timer.trigger * @param handle [type:number] the timer handle returned by timer.delay() * @return true [type:boolean] if the timer was active, false if the timer is already cancelled / complete * @examples * * ```lua * self.handle = timer.delay(1, true, function() print("prin
| 693 | * ``` |
| 694 | */ |
| 695 | static int TimerTrigger(lua_State* L) |
| 696 | { |
| 697 | DM_LUA_STACK_CHECK(L, 1); |
| 698 | |
| 699 | const int timer_handle = luaL_checkint(L, 1); |
| 700 | dmScript::HTimerWorld timer_world = CheckTimerWorld(L); |
| 701 | |
| 702 | Timer* timer = GetTimerFromHandle(timer_world, timer_handle); |
| 703 | if (!timer) |
| 704 | { |
| 705 | lua_pushboolean(L, 0); |
| 706 | return 1; |
| 707 | } |
| 708 | |
| 709 | LuaCallbackInfo* callback = (LuaCallbackInfo*)timer->m_UserData; |
| 710 | if (!IsCallbackValid(callback)) |
| 711 | { |
| 712 | lua_pushboolean(L, 0); |
| 713 | return 1; |
| 714 | } |
| 715 | |
| 716 | LuaTimerCallbackArgs args = { timer->m_Handle, timer->m_Delay - timer->m_Remaining }; |
| 717 | InvokeCallback(callback, LuaTimerCallbackArgsCB, &args); |
| 718 | |
| 719 | lua_pushboolean(L, 1); |
| 720 | return 1; |
| 721 | } |
| 722 | |
| 723 | /*# get information about timer |
| 724 | * |
nothing calls this directly
no test coverage detected