How can you load current and next scene easily?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Dragon11705

Okay so I am making a level based game with each level being its own scene, and since I have use a different script for the player in each level(because I have it change levels when the player gets all of the coins and the amount varies from level to level) I just hard code the scenes to load instead of putting something like load next scene. What I want to know is if there is a simple way to get the current scene and reload it and also to load the next scene. In Unity I would just use the build index to do this but a feature like this doesn’t seem to exist in Godot.

:bust_in_silhouette: Reply From: Magso

You could save all your levels in the same directory and load the scenes using an int like this

var levelInt = 1
var levelString = "res://Levels/Level " + str(levelInt) + ".tscn"
var theLevel = load(levelString)