Can't access custom resources after exporting game

Hi all! New to this forum but only a little new to Godot, hope im posting properly :grin:

I am working on trying to export my game, and everything seems to be working fine except for custom resources. They do not load at all! I did some digging and it looks like when the game is exported out, resources are not treated like other files and are loaded in a different way. I am getting conflicting messages on exactly how/where this is done, and trying all the different suggestions always leads to it not working. So I am really not sure what to do here (And no idea why this isn’t a more prominent piece of info)

Simple example, I want to create a Dictionary for all my items when the game loads. Super simple, here is the code before accounting for exporting:

func load_all_items():
var dir = DirAccess.open(“res://Resources/Items”)
if dir:
dir.list_dir_begin()
var file_name = dir.get_next()
while file_name != “”:
file_name = file_name.replace(“.tres”,“”)
all_items[str(file_name)] = load(“res://Resources/Items/” + file_name + “.tres”)
file_name = dir.get_next()

Simple code and it works like a charm! No notes.
From what I am reading, it sounds like the files essentially get a “.remap” on the end of the file path after export. So I tried adding “.remap” to the code above in various combinations to get it to work, and nothing. Still can’t locate any of the items.

I also found some info that the path itself is different when dealing with custom resources. so the “res/Resources/Items/” would no longer be the correct path, it would actually be something like “res://.godot/imported” But even when I try updating the above code to account for this, I still get nothing!

I’ve even tried combining these two suggested fixes in different combinations, and nothing. It would probably be easier if there was a way to see debug commands like print(), but oh well. Does anyone have any information on how this works? How do I get my custom resources to actually function with an exported game?

1 Like

I think this channel and link below must save all you work with resources! The answer is in the penultimate chapter, but for a complete understanding I would watch the video in full!

This is perfect! Its exactly the fix I needed! Thabks so much!!!

1 Like