Fix loading old-style levels in exported versions of the game

This commit is contained in:
Sebastian Morr 2020-10-06 18:53:31 +02:00
parent 0421ec3030
commit ec841ce485

View file

@ -12,18 +12,7 @@ func load(path):
slug = parts[parts.size()-1] slug = parts[parts.size()-1]
var dir = Directory.new() var dir = Directory.new()
if dir.dir_exists(path): if dir.file_exists(path):
# This is an old-style level.
description = helpers.read_file(path+"/description", "(no description)")
congrats = helpers.read_file(path+"/congrats", "Good job, you solved the level!\n\nFeel free to try a few more things or click 'Next Level'.")
var yours = LevelRepo.new()
yours.setup_commands = helpers.read_file(path+"/start", "")
#goal_commands = helpers.read_file(path+"/goal", "")
yours.win_commands = helpers.read_file(path+"/win", "")
repos["yours"] = yours
elif dir.file_exists(path):
# This is a new-style level. # This is a new-style level.
var config = helpers.parse(path) var config = helpers.parse(path)
@ -57,6 +46,17 @@ func load(path):
else: else:
repo = "yours" repo = "yours"
repos[repo].win_commands = config[k] repos[repo].win_commands = config[k]
elif dir.file_exists(path+"/description"):
# This is an old-style level.
description = helpers.read_file(path+"/description", "(no description)")
congrats = helpers.read_file(path+"/congrats", "Good job, you solved the level!\n\nFeel free to try a few more things or click 'Next Level'.")
var yours = LevelRepo.new()
yours.setup_commands = helpers.read_file(path+"/start", "")
#goal_commands = helpers.read_file(path+"/goal", "")
yours.win_commands = helpers.read_file(path+"/win", "")
repos["yours"] = yours
else: else:
helpers.crash("Level %s does not exist." % path) helpers.crash("Level %s does not exist." % path)