MCPcopy Index your code
hub / github.com/NetHack/NetHack / l_obj_timer_stop

Function l_obj_timer_stop

src/nhlobj.c:546–572  ·  view source on GitHub ↗

stop object timer(s). return the turn when timer triggers. returns 0 if no such timer attached to the object. without a timer type parameter, stops all timers for the object. */ local timeout = o:stop_timer("rot-organic"); */ o:stop_timer(); */

Source from the content-addressed store, hash-verified

544/* local timeout = o:stop_timer("rot-organic"); */
545/* o:stop_timer(); */
546staticfn int
547l_obj_timer_stop(lua_State *L)
548{
549 int argc = lua_gettop(L);
550
551 if (argc == 1) {
552 struct _lua_obj *lo = l_obj_check(L, 1);
553
554 if (lo && lo->obj)
555 obj_stop_timers(lo->obj);
556 return 0;
557
558 } else if (argc == 2) {
559 struct _lua_obj *lo = l_obj_check(L, 1);
560 short timertype = nhl_get_timertype(L, 2);
561
562 if (timer_is_obj(timertype) && lo && lo->obj) {
563 lua_pushinteger(L, stop_timer(timertype, obj_to_any(lo->obj)));
564 return 1;
565 } else {
566 lua_pushinteger(L, 0);
567 return 1;
568 }
569 } else
570 nhl_error(L, "l_obj_timer_stop: Wrong args");
571 return 0;
572}
573
574RESTORE_WARNING_UNREACHABLE_CODE
575

Callers

nothing calls this directly

Calls 6

l_obj_checkFunction · 0.85
obj_stop_timersFunction · 0.85
nhl_get_timertypeFunction · 0.85
stop_timerFunction · 0.85
obj_to_anyFunction · 0.85
nhl_errorFunction · 0.85

Tested by

no test coverage detected