Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDScript: Add support for relative paths in load() #90054

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dalexeev
Copy link
Member

@AThousandShips
Copy link
Member

I think this could be a great improvement, but some questions and things to clarify in the documentation bit:

  • Is this determined on a script by script basis, i.e. not by the scene the script is used in, if it is, or the location of a resource using the script, i.e. if you have res://a/foo.gd and save a resource of that resource as res://b/bar.tres, and in a method in foo.gd there's a load("baz.png"), does it load res://a/baz.png or res://b/baz.png?
  • If yes, how does it work with inheritance, I.e. if you create a script res://b/bar.gd which extends some script res://a/foo.gd, how does it handle the question above?

Just some things I think would be easy traps for people depending on how it works, so would be important to document clearly

@dalexeev
Copy link
Member Author

I think the behavior should be identical to preload(), except for load() is executed at runtime. I.e. path is relative to the directory in which the current script is located.

@lyuma
Copy link
Contributor

lyuma commented Mar 30, 2024

Does this handle edge cases in which the load or ResourceLoader.load functions are called dynamically?

For example, if I pass a reference to the ResourceLoader.load function using .bind(), or if I use .call_deferred("load", ...) vs .load.call_deferred(...), those will not work with relative paths I assume?

Also what happens if a user who does not use ResourceLoader declares their own func load(filename: String) in script?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

load doesn't work for relative paths that go back a folder without "res://"
3 participants