How do you export games correctly without having to add scenes yourself?

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

Hi there, I have a bit of a problem when exporting my game in godot. When I exported it first it gave me an error saying that it could not open the main scene. After a some time tinkering I tried putting the scenes folder inside the exported game folder, which made the game work. But that left me befuddled because I had another game that I had exported a while ago which worked perfectly just with the executable (.exe) and package (.pck), without needing the scenes folder too.

Any insight or help would be very apreciated.
Thanks in advance

You should not need to add scenes next to the executable like this.
Clearly there is something wrong in the loading of your main scene.

How is your main scene loaded? Is it just a tscn file that you have set as main scene?
Is there any file you are loading from a file path with preload? Because when a scene can’t load, it can also mean a resource inside it failed to load.

Zylann | 2019-09-04 18:27

It is a tscn scene that I set as the main scene in project settings, and I am not preloading any scene. Here is the error that the game outputs when ran without adding the scenes folder:

ERROR: load_interactive: Condition ' err != OK ' is true. returned: Ref<ResourceInteractiveLoader>()
   At: scene/resources/resource_format_text.cpp:1226
ERROR: Failed loading resource: res://Scenes/Main.tscn
   At: core/io/resource_loader.cpp:285
ERROR: Failed loading scene: res://Scenes/Main.tscn
   At: main/main.cpp:1739
WARNING: cleanup: ObjectDB Instances still exist!
     At: core/object.cpp:2095
ERROR: clear: Resources Still in use at Exit!
   At: core/resource.cpp:425

And this is the main scene (Main.tscn) script:

extends Node


var Mob = load("res://scenes/Mob.tscn")

var score

func _ready():
	$HUD.connect("start_game", self, "new_game")
	$Player.connect("hit", self, "game_over")
	$MobTimer.connect("timeout", self, "_on_MobTimer_timeout")
	$ScoreTimer.connect("timeout", self, "_on_ScoreTimer_timeout")
	$StartTimer.connect("timeout", self, "_on_StartTimer_timeout")

func _on_ScoreTimer_timeout():
	score += 1
	$HUD.update_score(score)

func _on_StartTimer_timeout():
	$MobTimer.start()
	$ScoreTimer.start()

func _on_MobTimer_timeout():
	$MobPath/MobSpawnLocation.set_offset(randi())
	
	var mob = Mob.instance()
	add_child(mob)
	
	var direction = $MobPath/MobSpawnLocation.rotation + PI / 2
	
	mob.position = $MobPath/MobSpawnLocation.position
	
	direction += rand_range(-PI / 4, PI / 4)
	mob.rotation = direction
	
	mob.linear_velocity = Vector2(rand_range(mob.min_speed, mob.max_speed), 0)
	mob.linear_velocity = mob.linear_velocity.rotated(direction)

func game_over():
	$ScoreTimer.stop()
	$MobTimer.stop()
	yield(get_tree().create_timer(1), "timeout")
	$HUD.show_game_over()

func new_game():
	score = 0
	$HUD.update_score(score)
	$HUD.show_message("Get Ready", $StartTimer.wait_time)
	$Player.start($StartPosition.position)
	$StartTimer.start()

I should also add that the game works perfectly in the editor and when the scenes folder is added manually to the export folder which makes me think that in the export process the scenes are not being added to the .pck

Gerboroso | 2019-09-04 21:00

The error is happening when loading the main scene it seems, because it could not open the file it seems… that’s really strange.
Does the character case match for the folder and the file in res://Scenes/Main.tscn?

Zylann | 2019-09-04 21:11