How to test if the game is exported?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Zylann
:warning: Old Version Published before Godot 3 was released.

In my game, I build a list of levels from files inside the res://levels/ directory.
It works fine when testing in the editor, but once exported my code returns zero files :open_mouth:
It is caused by my code filtering out files that are not .tscn. In exported games, they are converted to .scn, so I get no files.
Also, in some places I need to append .tscn to parameters, but in the exported version it changes to .scn, then doesn’t works…

how do I know that I’m in an exported version?

:bust_in_silhouette: Reply From: duke_meister

Kind of a work-around but if you export only release you could check for debug vs release in your code.

Also you didn’t say what you export to, but if it’s to mobile then you can also check for the platform/OS name.

I’m exporting for Windows and Android, but the target doesn’t matters, I just need to know if assets got exported or not.
I can only find partial workarounds at the moment, but all they do is partially work and mess with my codebase :s

Zylann | 2016-05-30 22:28

Wouldn’t debug/release work though?

duke_meister | 2016-05-30 23:01

Ok apparently loading .tscn works thanks to resource remaps, but iterating the directory still gives no results, unless I match both .tscn and .scn. That workaround should do the trick better than debug/release :slight_smile:

Zylann | 2016-05-30 23:19

ok good. I guess you’ve come across the various issues with file/directory functions under Android.

duke_meister | 2016-05-30 23:21

So if you had an is_exported() function, that still wouldn’t have solved it for you?

duke_meister | 2016-05-30 23:28

It would had solved in a way I could know which extension to deal with. But taking it on a higher level, file encodings and extensions shouldn’t actually matter when dealing with the problem of “get this scene having this name” or “get scenes in that folder”.

Zylann | 2016-05-30 23:53