Can't load custom resources

I feel like I’m doing something wrong, I can’t seem to read a custom resource from lua code using sys.load_resource(). I’ve managed to reproduce this in a minimal test case.

Method

Using the latest editor on Linux:
image

  1. Created a new blank project
  2. Added a folder in the project root named assets
  3. Create a file named words in the folder with some text content
  4. Add assets/words to custom_resources in the game.project file
  5. Create a new script
  6. Add a game object and the script to the collection
  7. Add the following lines to the init function of the script and build the project
local test, error = sys.load_resource("/assets/words")
print(test)
print(error)

What I expected

When run the contents of the file should be output, followed by nil

What happened

The content is nil, and the error reads:

Failed to load resource: /assets/words (-3)

I’ve attached a zip with the project: Resource.zip (3.0 KB)

What am I doing wrong here? Or have I found a bug?

Looks like it can’t load the custom resource without the file extension. For example, rename the file to words.txt and it will work.

And yeap, looks like a bug.

Yup, i can confirm adding an extension fixes it for me.

What’s more, it works if you bundle the app, and run that (tested Linux and HTML5).

Thanks for reporting!
Please create a ticket here with the info/project you gave here.

Created #5040

3 Likes