nodetimer.lua 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. ---@meta
  2. ---NodeTimerRef
  3. ---------------
  4. -- Node Timers: a high resolution persistent per-node timer. Can be gotten via
  5. -- `minetest.get_node_timer(pos)`.
  6. ---@class mt.NodeTimerRef
  7. local NodeTimerRef
  8. -- - Set a timer's state.
  9. -- - Will trigger the node's `on_timer` function after `(timeout - elapsed)`
  10. -- seconds.
  11. ---@param timeout number is in seconds, and supports fractional values (0.1 etc)
  12. ---@param elapsed number is in seconds, and supports fractional values (0.1 etc)
  13. function NodeTimerRef:set(timeout, elapsed) end
  14. -- - Start a timer.
  15. -- - Equivalent to `set(timeout, 0)`.
  16. ---@param timeout number is in seconds, and supports fractional values (0.1 etc)
  17. function NodeTimerRef:start(timeout) end
  18. -- Stops the timer.
  19. function NodeTimerRef:stop() end
  20. -- Returns current timeout in seconds.
  21. --
  22. -- - If `timeout` equals `0`, timer is inactive.
  23. ---@return number
  24. function NodeTimerRef:get_timeout() end
  25. -- Returns current elapsed time in seconds.
  26. --
  27. -- - The node's `on_timer` function will be called after `(timeout - elapsed)` seconds.
  28. ---@return number
  29. function NodeTimerRef:get_elapsed() end
  30. -- Returns boolean state of timer.
  31. --
  32. -- - Returns `true` if timer is started, otherwise `false`.
  33. ---@return boolean
  34. function NodeTimerRef:is_started() end