Skip to main content
Version: bleeding-edge 🩸

Ladebildschirm

In nanos world it is possible to add a customized and dynamic Loading Screen to your Server using WebUI.

Ladebildschirm erstellen

Dazu müssen Sie ein neues Paket vom Typ loading-screen erstellen und die HTML/CSS/JS-Dateien in das Package Wurzelverzeichnis (Root-Ordner) einfügen. Ihre primäre HTML-Datei sollte index.html heißen. Beispielsweise könnte dies wie folgt aussehen:

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

Abrufen des Lade- und Herunterlade-Fortschritts

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

Ereignis-Codes des UpdateScreen

ParameterBeschreibung
messageDisplay the current state (loading, validating, downloading...)
message_secondaryZeigt das aktuelle Asset oder die aktuelle Datei, welche geladen oder heruntergeladen wird
progress_smallAktueller kleiner Fortschritt
progress_small_totalMaximaler kleiner Fortschritt
progressAktueller Fortschritt
progress_totalMaximaler Fortschrittswert
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) {
// HTML-Aktualisierung hier...
});
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

Immer Fortschritt / progress_total verwenden, um den aktuellen % Prozentsatz zu erhalten, da Progress_total die Gesamtanzahl der heruntergeladenen Dateien darstellen kann.

Player Information

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.

Stop Menu Music

It is possible to turn off the built-in menu music by calling an event from Loading Screen JS:

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

Konfigurieren Ihres Servers für die Nutzung des Ladebildschirms

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. Setzen Sie einfach die Einstellung loading_screen auf den Ordnernamen Ihres Paketes.

Server/Config.toml
# Ladebildschirm-Paket (der Ladebildschirm wird angezeigt, wenn die Spieler Ihrem Server beitreten)
loading_screen = "my-loading-screen"

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