Passer au contenu principal
Version: bleeding-edge 🩸

Écran de chargement

Dans nanos world il est possible d'ajouter un chargement d'écran personnalisé et dynamique a votre serveur en utilisant WebUI.

Création d'un écran de chargement

For that, you will need to create a new Package of type loading-screen, and add your HTML/CSS/JS files into the Package's root folder. Your primary HTML file should be called index.html. Votre dossier devrait ressembler à cela :

Packages/
└── my-loading-screen/
├── Package.toml
├── index.html
├── style.css
└── ...

Accéder à la progression de chargement/téléchargement

To be able to display dynamic information in the screen, you can listen to the Event UpdateScreen (which will trigger every few ms):

Event UpdateScreen

ParamètreDescription
messageAffiche l'état actuel (chargement, validation, téléchargement...)
message_secondaryAffiche le fichier/asset actuel en cours de chargement/téléchargement
progress_smallProgression du fichier en cours de chargement/téléchargement
progress_small_totalTaille du fichier en cours de chargement/téléchargement
progressProgression actuelle
progress_totalProgression totale
current_stageThe number value representing the current stage of the load (0 = None, 1 = Connecting, 2 = Fetching, 3 = Validating, 4 = Downloading, 5 = LoadingAssets, 6 = LoadingLevel, 7 = LoadingEntities, 8 = CompilingShaders, 9 = Finishing)
Packages/my-loading-screen/index.js
Events.Subscribe("UpdateScreen", function(message, message_secondary, progress_small, progress_small_total, progress, progress_total, current_stage) {
// Mettre à jour l'HTML ici
});
tip

You can use progress and progress_total for filling up the main loading bar, and progress_small for a small/sub loading bar.

info

Always use progress / progress_total for getting the current % percentage, as progress_total can represent the total amount of files being downloaded for example.

Informations sur le joueur

Also, it is possible to fetch Player’s information by accessing a global variable called LoadingScreen:

var LoadingScreen = {
server: {
ip,
port,
name,
description,
},
player: {
nanos_id,
nanos_username,
steam_id,
}
}
tip

The LoadingScreen var is only available a few frames after the Loading Screen browser is created.

Arrêter la musique du menu

Il est possible de désactiver la musique du menu intégré en appelant un événement à partir du JS de l'écran de chargement:

Packages/my-loading-screen/index.js
Events.Call("StopMenuMusic")

Configurer votre serveur pour utiliser l'écran de chargement

Note

Currently Loading Screens only work in Dedicated Servers.
Make sure you configure your server's Config.toml as dedicated_server = true.

After creating your loading-screen package, you will need to configure your server to load it in your Config.toml. Just set the setting loading_screen to your Package's folder name.

Server/Config.toml
# le package loading-screen à charger (l'écran de chargement sera affiché quand les joueurs rejoindront votre serveur)
loading_screen = "my-loading-screen"

Or start it with --loading_screen "my-loading-screen".