global.lua 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. ---@meta
  2. ---Global objects
  3. -----------------
  4. -- `EnvRef` of the server environment and world.
  5. -- - Any function in the minetest namespace can be called using the syntax
  6. -- `minetest.env:somefunction(somearguments)` instead of
  7. -- `minetest.somefunction(somearguments)`
  8. -- - Deprecated, but support is not to be dropped soon.
  9. ---@type mt.Core
  10. minetest.env = nil
  11. ---Global callback registration functions
  12. -----------------------------------------
  13. ---Register a function that will be called every server step, usually interval of 0.1s
  14. ---@param func fun(dtime: number)
  15. function minetest.register_globalstep(func) end
  16. ---Map of registered globalsteps.
  17. ---@type fun(dtime: number)[]
  18. minetest.registered_globalsteps = {}
  19. ---Register a function that will be called after mods have finished loading and before the media is cached or the aliases handled.
  20. ---@param func fun()
  21. function minetest.register_on_mods_loaded(func) end
  22. ---Map of registered on_mods_loaded.
  23. ---@type fun()[]
  24. minetest.registered_on_mods_loaded = {}
  25. ---Register a function that will be called before server shutdown.
  26. ---
  27. ---**Warning**: If the server terminates abnormally (i.e. crashes), the registered callbacks **will likely not be run**.
  28. ---
  29. ---Data should be saved at semi-frequent intervals as well as on server shutdown.
  30. ---@param func fun()
  31. function minetest.register_on_shutdown(func) end
  32. -- Called always when a client receive a message.
  33. --
  34. -- * Return `true` to mark the message as handled,
  35. -- which means that it will not be shown to chat.
  36. ---@param func fun(message:string):boolean?
  37. function minetest.register_on_receiving_chat_message(func) end
  38. -- Called always when a client sends a message from chat
  39. --
  40. -- * Return `true` to mark the message as handled,
  41. -- which means that it will not be sent to server
  42. ---@param func fun(message:string):boolean?
  43. function minetest.register_on_sending_chat_message(func) end
  44. -- Called when the local player dies.
  45. ---@param func fun()
  46. function minetest.register_on_death(func) end
  47. -- Called when server modified player's HP.
  48. ---@param func fun(hp:number)
  49. function minetest.register_on_hp_modification(func) end
  50. -- Called when the local player take damages.
  51. ---@param func fun(hp:number)
  52. function minetest.register_on_damage_taken(func) end
  53. ---Map of registered on_shutdown.
  54. ---@type fun()[]
  55. minetest.registered_on_shutdown = {}
  56. ---Register a function that will be called when a node has been placed.
  57. ---
  58. ---If return `true` no item is taken from `itemstack`
  59. ---
  60. ---**Not recommended**: use `on_construct` or `after_place_node` in node definition then possible.
  61. ---@param func fun(pos: mt.Vector, newnode: string, placer?: mt.ObjectRef, oldnode: string, itemstack: mt.Item, pointed_thing: mt.PointedThing): boolean|nil
  62. function minetest.register_on_placenode(func) end
  63. ---Map of registered on_placenode.
  64. ---@type (fun(pos: mt.Vector, newnode: mt.Node, placer?: mt.ObjectRef, oldnode: mt.Node, itemstack: mt.Item, pointed_thing: mt.PointedThing): boolean|nil)[]
  65. minetest.registered_on_placenodes = {}
  66. ---Register a function that will be called when a node has been dug.
  67. ---
  68. ---**Not recommended**: use `on_destruct` or `after_dig_node` in node definition then possible.
  69. ---@param func fun(pos: mt.Vector, oldnode: mt.Node|string, digger: mt.ObjectRef|nil)
  70. function minetest.register_on_dignode(func) end
  71. ---Map of registered on_dignode.
  72. ---@type fun(pos: mt.Vector, oldnode: mt.Node|string, digger: mt.ObjectRef)[]
  73. minetest.registered_on_dignodes = {}
  74. ---Register a function that will be called when a node has been punched.
  75. ---@param func fun(pos: mt.Vector, node: mt.Node, puncher: mt.ObjectRef, pointed_thing: mt.PointedThing)
  76. function minetest.register_on_punchnode(func) end
  77. ---Map of registered on_punchnode.
  78. ---@type fun(pos: mt.Vector, node: mt.Node, puncher: mt.ObjectRef, pointed_thing: mt.PointedThing)[]
  79. minetest.registered_on_punchnodes = {}
  80. ---Register a function that will be called when a piece of world has been generated.
  81. ---
  82. ---Modifying nodes inside the area is a bit faster than usually.
  83. ---@param func fun(minp: integer, maxp: integer, blockseed: integer)
  84. function minetest.register_on_generated(func) end
  85. ---Map of registered on_generated.
  86. ---@type fun(minp: integer, maxp: integer, blockseed: integer)[]
  87. minetest.registered_on_generateds = {}
  88. ---Register a function that will be called when a player join for the first time.
  89. ---@param func fun(player: mt.PlayerObjectRef)
  90. function minetest.register_on_newplayer(func) end
  91. ---Map of registered on_newplayer.
  92. ---@type fun(player: mt.PlayerObjectRef)[]
  93. minetest.registered_on_newplayers = {}
  94. ---Register a function that will be called when a player is punched.
  95. ---
  96. ---Note: This callback is invoked even if the punched player is dead.
  97. ---
  98. ---Callback should return `true` to prevent the default damage mechanism.
  99. ---@param func fun(player: mt.PlayerObjectRef, hitter: mt.ObjectRef, time_from_last_punch: number, tool_capabilities: mt.ToolCaps, dir: mt.Vector, damage: number): boolean|nil
  100. function minetest.register_on_punchplayer(func) end
  101. ---Map of registered on_punchplayer.
  102. ---@type (fun(player: mt.PlayerObjectRef, hitter: mt.ObjectRef, time_from_last_punch: number, tool_capabilities: mt.ToolCaps, dir: mt.Vector, damage: number): boolean)[]
  103. minetest.registered_on_punchplayers = {}
  104. ---Register a function that will be called when a player is rightclicked (the `place/use` key was used while pointing a player).
  105. ---@param func fun(player: mt.PlayerObjectRef, clicker: mt.ObjectRef)
  106. function minetest.register_on_rightclickplayer(func) end
  107. ---Map of registered on_rightclickplayer.
  108. ---@type fun(player: mt.PlayerObjectRef, clicker: mt.ObjectRef)[]
  109. minetest.registered_on_rightclickplayers = {}
  110. ---Register a function that will be called when a player is damaged or healed.
  111. ---@param func fun(player: mt.PlayerObjectRef, hp_change: integer, reason: mt.PlayerHPChangeReason): integer?, boolean?
  112. ---@param modifier boolean|nil When true, the function should return the actual `hp_change`.
  113. ---Note: modifiers only get a temporary `hp_change` that can be modified by later modifiers.
  114. ---
  115. ---Modifiers can return true as a second argument to stop the execution of further functions.
  116. ---
  117. ---Non-modifiers receive the final HP change calculated by the modifiers.
  118. function minetest.register_on_player_hpchange(func, modifier) end
  119. ---@class mt.PlayerHPChangeReason
  120. ---@field type
  121. -- A mod or the engine called `set_hp` without giving a type -
  122. -- use this for custom damage types.
  123. ---|"set_hp"
  124. -- Was punched. `reason.object` will hold the puncher, or nil if none.
  125. ---|"punch"
  126. ---|"fall"
  127. -- `damage_per_second` from a neighboring node.
  128. ---|"node_damage"
  129. ---|"drown"
  130. ---|"respawn"
  131. ---@field object mt.ObjectRef|nil
  132. ---@field node string|nil node name
  133. ---@field from
  134. ---|"mod"
  135. ---|"engine"
  136. -- When true, the function should return the actual `hp_change`.
  137. --
  138. -- Note: modifiers only get a temporary `hp_change` that can be modified by
  139. -- later modifiers. Modifiers can return true as a second argument to stop the
  140. -- execution of further functions. Non-modifiers receive the final HP change
  141. -- calculated by the modifiers.
  142. ---@field modifier boolean
  143. ---Map of registered on_player_hpchange.
  144. ---@type {modifiers: (fun(player: mt.PlayerObjectRef, hp_change: integer, reason: mt.PlayerHPChangeReason): integer?, boolean?)[], loggers: (fun(player: mt.PlayerObjectRef, hp_change: integer, reason: mt.PlayerHPChangeReason): integer?, boolean?)[]}
  145. minetest.registered_on_player_hpchanges = { modifiers = {}, loggers = {} }
  146. ---Register a function that will be called when a player dies.
  147. ---@param func fun(player: mt.PlayerObjectRef, reason: mt.PlayerHPChangeReason)
  148. function minetest.register_on_dieplayer(func) end
  149. ---Map of registered on_dieplayers.
  150. ---@type fun(player: mt.PlayerObjectRef, reason: mt.PlayerHPChangeReason)[]
  151. minetest.registered_on_dieplayers = {}
  152. ---Register a function that will be called when a player is to be respawned.
  153. ---
  154. ---Called **before** repositioning of player occurs.
  155. ---
  156. ---Return `true` in func to disable regular player placement.
  157. ---@param func fun(player: mt.PlayerObjectRef): boolean|nil
  158. function minetest.register_on_respawnplayer(func) end
  159. ---Map of registered on_respawnplayer.
  160. ---@type (fun(player: mt.PlayerObjectRef): boolean|nil)[]
  161. minetest.registered_on_respawnplayers = {}
  162. ---Register a function that will be called when a client connects to the server, prior to authentication.
  163. ---
  164. ---If it returns a string, the client is disconnected with that string as reason.
  165. ---@param func fun(name: string, ip: string): string
  166. function minetest.register_on_prejoinplayer(func) end
  167. ---Map of registered on_prejoinplayer.
  168. ---@type (fun(name: string, ip: string): string)[]
  169. minetest.registered_on_prejoinplayers = {}
  170. ---Register a function that will be called when a player joined.
  171. ---
  172. ---`last_login`: The timestamp of the previous login, or `nil` if player is new
  173. ---@param func fun(player: mt.PlayerObjectRef, last_login?: integer)
  174. function minetest.register_on_joinplayer(func) end
  175. ---Map of registered on_joinplayer.
  176. ---@type fun(player: mt.PlayerObjectRef, last_login?: integer)[]
  177. minetest.registered_on_joinplayers = {}
  178. ---Register a function that will be called when a player leaves the game.
  179. ---
  180. ---`timed_out`: True for timeout, false for other reasons.
  181. ---@param func fun(player: mt.PlayerObjectRef, timed_out: boolean|nil)
  182. function minetest.register_on_leaveplayer(func) end
  183. ---Map of registered on_leaveplayer.
  184. ---@type fun(player: mt.PlayerObjectRef, timed_out: boolean|nil)[]
  185. minetest.registered_on_leaveplayers = {}
  186. ---Register a function that will be called when a client attempts to log into an account.
  187. ---
  188. ---* `name`: The name of the account being authenticated.
  189. ---* `ip`: The IP address of the client
  190. ---* `is_success`: Whether the client was successfully authenticated
  191. ---* For newly registered accounts, `is_success` will always be true
  192. ---@param func fun(name: string, ip: string, is_success: boolean|nil)
  193. function minetest.register_on_authplayer(func) end
  194. ---@type fun(name: string, ip: string, is_success: boolean|nil)[]
  195. minetest.registered_on_authplayers = {}
  196. ---Register a function that will be called when a client attempts to log into an account but fails.
  197. ---
  198. ---**DEPRECATED**, use `minetest.register_on_authplayer` instead.
  199. ---@deprecated
  200. ---@param func fun(name: string, ip: string)
  201. function minetest.register_on_auth_fail(func) end
  202. ---Register a function that will be called when a player is detected by builtin anticheat.
  203. ---@param func fun(player: mt.PlayerObjectRef, cheat: {type: '"moved_too_fast"'|'"interacted_too_far"'|'"interacted_with_self"'|'"interacted_while_dead"'|'"finished_unknown_dig"'|'"dug_unbreakable"'|'"dug_too_fast"'})
  204. function minetest.register_on_cheat(func) end
  205. ---Map of registered on_cheat.
  206. ---@type fun(player: mt.PlayerObjectRef, cheat: {type: '"moved_too_fast"'|'"interacted_too_far"'|'"interacted_with_self"'|'"interacted_while_dead"'|'"finished_unknown_dig"'|'"dug_unbreakable"'|'"dug_too_fast"'})[]
  207. minetest.registered_on_cheats = {}
  208. ---Register a function that will be called when a player send a chat message.
  209. ---
  210. ---Return `true` to mark the message as handled, which means that it will not be sent to other players.
  211. ---@param func fun(name: string, message: string): boolean|nil
  212. function minetest.register_on_chat_message(func) end
  213. ---Map of registered on_chat_message.
  214. ---@type (fun(name: string, message: string): boolean|nil)[]
  215. minetest.registered_on_chat_messages = {}
  216. ---Register a function that will be called when a player send a chat command.
  217. ---
  218. ---Called always when a chatcommand is triggered, before `minetest.registered_chatcommands` is checked to see if the command exists, but after the input is parsed.
  219. ---
  220. ---Return `true` to mark the command as handled, which means that the default handlers will be prevented.
  221. ---@param func fun(name: string, command: string, params: string)
  222. function minetest.register_on_chatcommand(func) end
  223. ---Map of registered on_chatcommand.
  224. ---@type fun(name: string, command: string, params: string)[]
  225. minetest.registered_on_chatcommands = {}
  226. ---Register a function that will be called when the server received input from player in a formspec.
  227. ---
  228. ---Specifically, this is called on any of the following events:
  229. ---* a button was pressed,
  230. ---* Enter was pressed while the focus was on a text field
  231. ---* a checkbox was toggled,
  232. ---* something was selected in a dropdown list,
  233. ---* a different tab was selected,
  234. ---* selection was changed in a textlist or table,
  235. ---* an entry was double-clicked in a textlist or table,
  236. ---* a scrollbar was moved, or
  237. ---* the form was actively closed by the player.
  238. ---
  239. ---Fields are sent for formspec elements which define a field. `fields` is a table containing each formspecs element value (as string), with the `name` parameter as index for each. The value depends on the formspec element type:
  240. ---* `animated_image`: Returns the index of the current frame.
  241. ---* `button` and variants: If pressed, contains the user-facing button text as value. If not pressed, is `nil`
  242. ---* `field`, `textarea` and variants: Text in the field
  243. ---* `dropdown`: Either the index or value, depending on the `index event` dropdown argument.
  244. ---* `tabheader`: Tab index, starting with `"1"` (only if tab changed)
  245. ---* `checkbox`: `"true"` if checked, `"false"` if unchecked
  246. ---* `textlist`: See `minetest.explode_textlist_event`
  247. ---* `table`: See `minetest.explode_table_event`
  248. ---* `scrollbar`: See `minetest.explode_scrollbar_event`
  249. ---* Special case: `["quit"]="true"` is sent when the user actively closed the form by mouse click, keypress or through a `button_exit[]` element.
  250. ---* Special case: `["key_enter"]="true"` is sent when the user pressed the Enter key and the focus was either nowhere (causing the formspec to be closed) or on a button. If the focus was on a text field, additionally, the index `key_enter_field` contains the name of the text field. See also: `field_close_on_enter`.
  251. ---
  252. ---Newest functions are called first.
  253. ---
  254. ---If function returns `true`, remaining functions are not called.
  255. ---@param func fun(player: mt.PlayerObjectRef, formname: string, fields: table<string, any>): boolean|nil
  256. function minetest.register_on_player_receive_fields(func) end
  257. ---Map of registered on_player_receive_fields.
  258. ---@type (fun(player: mt.PlayerObjectRef, formname: string, fields: table<string, any>): boolean|nil)[]
  259. minetest.registered_on_player_receive_fields = {}
  260. ---Register a function that will be called when a player craft something.
  261. ---* `itemstack` is the output
  262. ---* `old_craft_grid` contains the recipe (Note: the one in the inventory is cleared).
  263. ---* `craft_inv` is the inventory with the crafting grid
  264. ---* Return either an `ItemStack`, to replace the output, or `nil`, to not modify it.
  265. ---@param func fun(itemstack: mt.ItemStack, player: mt.PlayerObjectRef, old_craft_grid: table, craft_inv: mt.InvRef): mt.ItemStack?
  266. function minetest.register_on_craft(func) end
  267. ---Map of registered on_craft.
  268. ---@type (fun(itemstack: mt.Item, player: mt.PlayerObjectRef, old_craft_grid: table, craft_inv: mt.InvRef): mt.ItemStack?)[]
  269. minetest.registered_on_crafts = {}
  270. ---Register a function that will be called before a player craft something to make the crafting prediction.
  271. ---
  272. ---Similar to `minetest.register_on_craft`.
  273. ---@param func fun(itemstack: mt.Item, player: mt.PlayerObjectRef, old_craft_grid: table, craft_inv: mt.InvRef)
  274. function minetest.register_craft_predict(func) end
  275. ---Map of registered craft_predicts.
  276. ---@type fun(itemstack: mt.Item, player: mt.PlayerObjectRef, old_craft_grid: table, craft_inv: mt.InvRef)[]
  277. minetest.registered_craft_predicts = {}
  278. ---List of possible `action` (string) values and their `inventory_info` (table) contents:
  279. ---* `move`: `{from_list=string, to_list=string, from_index=number, to_index=number, count=number}`
  280. ---* `put`: `{listname=string, index=number, stack=ItemStack}`
  281. ---* `take`: Same as `put`
  282. ---@alias mt.InvInfo {from_list: string, to_list: string, from_index: integer, to_index: integer, count: integer}|{listname: string, index: integer, stack: mt.Item}
  283. ---Determines how much of a stack may be taken, put or moved to a player inventory.
  284. ---
  285. ---`player` (type `ObjectRef`) is the player who modified the inventory `inventory` (type `InvRef`).
  286. ---
  287. ---List of possible `action` (string) values and their `inventory_info` (table) contents:
  288. ---* `move`: `{from_list=string, to_list=string, from_index=number, to_index=number, count=number}`
  289. ---* `put`: `{listname=string, index=number, stack=ItemStack}`
  290. ---* `take`: Same as `put`
  291. ---
  292. ---Return a numeric value to limit the amount of items to be taken, put or moved.
  293. ---
  294. ---A value of `-1` for `take` will make the source stack infinite.
  295. ---@param func fun(player: mt.PlayerObjectRef, action: '"move"'|'"put"'|'"take"', inventory: mt.InvRef, inventory_info: mt.InvInfo): integer
  296. function minetest.register_allow_player_inventory_action(func) end
  297. ---Map of registered allow_player_inventory_action.
  298. ---@type (fun(player: mt.PlayerObjectRef, action: '"move"'|'"put"'|'"take"', inventory: mt.InvRef, inventory_info: mt.InvInfo): integer)[]
  299. minetest.registered_allow_player_inventory_action = {}
  300. ---Called after a take, put or move event from/to/in a player inventory.
  301. ---
  302. ---Function arguments: see `minetest.register_allow_player_inventory_action`
  303. ---
  304. ---Does not accept or handle any return value.
  305. ---@param func fun(player: mt.PlayerObjectRef, action: '"move"'|'"put"'|'"take"', inventory: mt.InvRef, inventory_info: {from_list: string, to_list: string, from_index: integer, to_index: integer, count: integer}|{listname: string, index: integer, stack: mt.ItemStack})
  306. function minetest.register_on_player_inventory_action(func) end
  307. ---Map of registered on_player_inventory_action.
  308. ---@type fun(player: mt.PlayerObjectRef, action: '"move"'|'"put"'|'"take"', inventory: mt.InvRef, inventory_info: mt.InvInfo)[]
  309. minetest.registered_on_player_inventory_action = {}
  310. ---Called by `builtin` and mods when a player violates protection at a position (eg, digs a node or punches a protected entity).
  311. ---
  312. ---The registered functions can be called using `minetest.record_protection_violation`.
  313. ---
  314. ---The provided function should check that the position is protected by the mod calling this function before it prints a message, if it does, to allow for multiple protection mods.
  315. ---@param func fun(pos: mt.Vector, name: string)
  316. function minetest.register_on_protection_violation(func) end
  317. ---Map of registered on_protection_violation.
  318. ---@type fun(pos: mt.Vector, name: string)[]
  319. minetest.registered_on_protection_violation = {}
  320. ---Called when an item is eaten, by `minetest.item_eat`.
  321. ---
  322. ---Return `itemstack` to cancel the default item eat response (i.e.: hp increase).
  323. ---@param func fun(hp_change: integer, replace_with_item, itemstack: mt.ItemStack, user: mt.ObjectRef, pointed_thing: mt.PointedThing): mt.ItemStack?
  324. function minetest.register_on_item_eat(func) end
  325. ---Map of registered on_item_eat.
  326. ---@type (fun(hp_change: integer, replace_with_item, itemstack: mt.ItemStack, user: mt.ObjectRef, pointed_thing: mt.PointedThing): mt.ItemStack?)[]
  327. minetest.registered_on_item_eat = {}
  328. -- Called by `minetest.item_pickup` before an item is picked up.
  329. --
  330. -- * Function is added to `minetest.registered_on_item_pickups`.
  331. -- * Oldest functions are called first.
  332. -- * Parameters are the same as in the `on_pickup` callback.
  333. -- * Return an itemstack to cancel the default item pick-up response (i.e.: adding
  334. -- the item into inventory).
  335. ---@param func fun(itemstack:mt.ItemStack, picker:mt.ObjectRef, pointed_thing:mt.PointedThing, time_from_last_punch:number, ...:any): mt.ItemStack?
  336. function minetest.register_on_item_pickup(func) end
  337. ---Map of registered on_item_pickup
  338. ---@type (fun(itemstack:mt.ItemStack, picker:mt.ObjectRef, pointed_thing:mt.PointedThing, time_from_last_punch:number, ...:any): mt.ItemStack?)[]
  339. minetest.registered_on_item_pickup = {}
  340. -- Called when the local player uses an item.
  341. --
  342. -- * Newest functions are called first.
  343. -- * If any function returns true, the item use is not sent to server.
  344. ---@param func fun(item:mt.ItemStack, pointed_thing:mt.PointedThing): boolean?
  345. function minetest.register_on_item_use(func) end
  346. ---@type (fun(item:mt.ItemStack, pointed_thing:mt.PointedThing): boolean?)[]
  347. minetest.registered_on_item_use = {}
  348. ---Called when `granter` grants the priv `priv` to `name`.
  349. ---
  350. ---Note that the callback will be called twice if it's done by a player, once with `granter` being the player name, and again with `granter` being `nil`.
  351. ---@param func fun(name: string, granter?: string, priv: string)
  352. function minetest.register_on_priv_grant(func) end
  353. ---Map of registered on_priv_grant.
  354. ---@type fun(name: string, granter?: string, priv: string)[]
  355. minetest.registered_on_priv_grant = {}
  356. ---Called when `revoker` revokes the priv `priv` from `name`.
  357. ---
  358. ---Note that the callback will be called twice if it's done by a player, once with `revoker` being the player name, and again with `revoker` being `nil`.
  359. ---@param func fun(name: string, revoker?: string, priv: string)
  360. function minetest.register_on_priv_revoke(func) end
  361. ---Map of registered on_priv_revoke.
  362. ---@type fun(name: string, revoker?: string, priv: string)[]
  363. minetest.registered_on_priv_revoke = {}
  364. ---Called when `name` user connects with `ip`.
  365. ---
  366. ---Return `true` to by pass the player limit
  367. ---@param func fun(name: string, ip: string): boolean|nil
  368. function minetest.register_can_bypass_userlimit(func) end
  369. ---Map of registered can_bypass_userlimit.
  370. ---@type fun(name: string, ip: string)[]
  371. minetest.registered_can_bypass_userlimit = {}
  372. ---Called when an incoming mod channel message is received.
  373. ---
  374. ---You should have joined some channels to receive events.
  375. ---
  376. ---If message comes from a server mod, `sender` field is an empty string.
  377. ---@param func fun(channel_name: string, sender: string, message: string)
  378. function minetest.register_on_modchannel_message(func) end
  379. -- Called when a valid incoming mod channel signal is received.
  380. --
  381. -- * Signal id permit to react to server mod channel events.
  382. -- * Possible values are:
  383. -- 0: join_ok
  384. -- 1: join_failed
  385. -- 2: leave_ok
  386. -- 3: leave_failed
  387. -- 4: event_on_not_joined_channel
  388. -- 5: state_changed
  389. ---@param func fun(channel_name: string, signal:unknown)
  390. function minetest.register_on_modchannel_signal(func) end
  391. -- Called when the local player open inventory.
  392. --
  393. -- * Newest functions are called first.
  394. -- * If any function returns true, inventory doesn't open.
  395. ---@param func fun(inventory:mt.InvRef):boolean?
  396. function minetest.register_on_inventory_open(func) end
  397. ---Map of registered on_modchannel_message.
  398. ---@type fun(channel_name: string, sender: string, message: string)[]
  399. minetest.registered_on_modchannel_message = {}
  400. ---Called after liquid nodes (`liquidtype ~= "none"`) are modified by the engine's liquid transformation process.
  401. ---* `pos_list` is an array of all modified positions.
  402. ---* `node_list` is an array of the old node that was previously at the position with the corresponding index in `pos_list`.
  403. ---@param func fun(pos_list: mt.Vector[], node_list: mt.Node[])
  404. function minetest.register_on_liquid_transformed(func) end
  405. ---Map of registered on_liquid_transformed.
  406. ---@type fun(pos_list: mt.Vector[], node_list: mt.Node[])[]
  407. minetest.registered_on_liquid_transformed = {}
  408. ---@param func function
  409. function minetest.register_on_mapgen_init(func) end
  410. -- Called soon after any nodes or node metadata have been modified. No
  411. -- modifications will be missed, but there may be false positives.
  412. --
  413. -- * Will never be called more than once per server step.
  414. -- * `modified_blocks` is the set of modified mapblock position hashes. These
  415. -- are in the same format as those produced by `minetest.hash_node_position`,
  416. -- and can be converted to positions with `minetest.get_position_from_hash`.
  417. -- The set is a table where the keys are hashes and the values are `true`.
  418. -- * `modified_block_count` is the number of entries in the set.
  419. -- * Note: callbacks must be registered at mod load time.
  420. ---@param modified_blocks integer
  421. ---@param modified_block_count integer
  422. function minetest.register_on_mapblocks_changed(
  423. modified_blocks,
  424. modified_block_count
  425. )
  426. end