jobs.lua 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. ---@meta
  2. ---Timing
  3. ---------
  4. -- Returned by `minetest.after`.
  5. ---@class mt.Job
  6. local job = {}
  7. -- Cancels the job function from being called.
  8. function job:cancel() end
  9. -- Call the function `func` after `time` seconds, may be fractional.
  10. ---@param time number
  11. ---@param func function
  12. ---@param ... unknown Arguments that will be passed to `func`.
  13. ---@return mt.Job
  14. function minetest.after(time, func, ...) end
  15. ---Async environment
  16. --------------------
  17. -- Queue the function `func` to be ran in an async environment.
  18. --
  19. -- Note that there are multiple persistent workers and any of them may end up
  20. -- running a given job.
  21. --
  22. -- The engine will scale the amount of worker threads automatically.
  23. --
  24. -- When `func` returns, the callback is called (in the normal environment)
  25. -- with all of the return values as arguments.
  26. --
  27. -- **List of APIs available in an async environment:**
  28. --
  29. -- Classes:
  30. --
  31. -- - `ItemStack`
  32. -- - `PerlinNoise`
  33. -- - `PerlinNoiseMap`
  34. -- - `PseudoRandom`
  35. -- - `PcgRandom`
  36. -- - `SecureRandom`
  37. -- - `VoxelArea`
  38. -- - `VoxelManip`
  39. -- - only if transferred into environment; can't read/write to map
  40. -- - `Settings`
  41. --
  42. -- Class instances that can be transferred between environments:
  43. --
  44. -- - `ItemStack`
  45. -- - `PerlinNoise`
  46. -- - `PerlinNoiseMap`
  47. -- - `VoxelManip`
  48. --
  49. -- Functions:
  50. --
  51. -- - Standalone helpers such as logging, filesystem, encoding, hashing or
  52. -- compression APIs
  53. -- - `minetest.request_insecure_environment` (same restrictions apply)
  54. --
  55. -- Variables:
  56. --
  57. -- - `minetest.settings`
  58. -- - `minetest.registered_items`, `registered_nodes`, `registered_tools`,
  59. -- `registered_craftitems` and `registered_aliases`
  60. -- - with all functions and userdata values replaced by `true`, calling any
  61. -- callbacks here is obviously not possible
  62. ---@param func function
  63. ---@param callback fun(...: any): any
  64. ---@param ... unknown Variable number of arguments that are passed to `func`.
  65. function minetest.handle_async(func, callback, ...) end
  66. -- Register a path to a Lua file to be imported
  67. -- when an async environment is initialized.
  68. --
  69. -- You can use this to preload code which you can then call later
  70. -- using `minetest.handle_async()`.
  71. ---@param path string
  72. function minetest.register_async_dofile(path) end