server.lua 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ---@meta
  2. ---Request the server to shutdown.
  3. ---@param message? string Will display `message` to clients.
  4. ---@param reconnect? boolean Displays a reconnect button to players.
  5. ---@param delay? any Adds an optional delay (in seconds) before shutdown. Negative delay cancels the current active shutdown. Zero delay triggers an immediate shutdown.
  6. function minetest.request_shutdown(message, reconnect, delay) end
  7. ---Cancel current delayed shutdown.
  8. function minetest.cancel_shutdown_requests() end
  9. ---Returns the server status string when a player joins or when the command `/status` is called.
  10. ---
  11. ---Returns `nil` or an empty string when the message is disabled.
  12. ---
  13. ---This function may be overwritten by mods to customize the status message.
  14. ---@param name string
  15. ---@param joined any Indicates whether the function was called when a player joined.
  16. ---@return string
  17. function minetest.get_server_status(name, joined) end
  18. ---Returns the server uptime in seconds.
  19. ---@return integer
  20. function minetest.get_server_uptime() end
  21. ---Returns the current maximum lag.
  22. ---@return number
  23. function minetest.get_server_max_lag() end
  24. ---Remove player from database if he is not connected.
  25. ---
  26. ---As auth data is not removed, `minetest.player_exists` will continue to return true.
  27. ---
  28. ---Call `minetest.remove_player_auth(name)` as well if you want to remove auth data too.
  29. ---@param name string
  30. ---@return 0|1|2 (0: successful, 1: no such player, 2: player is connected).
  31. function minetest.remove_player(name) end
  32. ---Remove player authentication data.
  33. ---
  34. ---Returns boolean indicating success (false if player nonexistant).
  35. ---@param name string
  36. ---@return boolean
  37. function minetest.remove_player_auth(name) end
  38. ---@class dynamic_add_media_options
  39. local dynamic_add_media_options = {}
  40. ---Path to a media file on the filesystem.
  41. ---@type string
  42. dynamic_add_media_options.filepath = nil
  43. ---Name of the player the media should be sent to instead of all players (optional).
  44. ---@type string
  45. dynamic_add_media_options.to_player = nil
  46. ---Marks the media as ephemeral, it will not be cached on the client (optional, default: false).
  47. ---@type boolean
  48. dynamic_add_media_options.ephemeral = nil
  49. ---Pushes the specified media file to client(s).
  50. ---
  51. ---The file must be a supported image, sound or model format.
  52. ---
  53. ---Returns `false` on error, `true` if the request was accepted.
  54. ---
  55. ---The given callback will be called for every player as soon as the media is available on the client.
  56. ---Details/Notes:
  57. ---* If `ephemeral`=false and `to_player` is unset the file is added to the media sent to clients on startup, this means the media will appear even on old clients if they rejoin the server.
  58. ---* If `ephemeral`=false the file must not be modified, deleted, moved or renamed after calling this function.
  59. ---* Regardless of any use of `ephemeral`, adding media files with the same name twice is not possible/guaranteed to work. An exception to this is the use of `to_player` to send the same, already existent file to multiple chosen players.
  60. ---* Clients will attempt to fetch files added this way via remote media, this can make transfer of bigger files painless (if set up). Nevertheless it is advised not to use dynamic media for big media files.
  61. ---@param options dynamic_add_media_options
  62. ---@param callback fun(name: string)
  63. ---@return boolean
  64. function minetest.dynamic_add_media(options, callback) end