-
-
Notifications
You must be signed in to change notification settings - Fork 43
lua require not loading from assets dir #69
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
Comments
I think this should achievable with a custom APIProvider As for core functionality we could potentially include scripts directly in the assets folder or something akin to that within the |
I think a custom provider can probably be made which inserts a searcher over loaded LuaFile assets which would be idea. I've a bit of experience with custom searchers before so I'll give it a shot. The biggest question mark for loading from assets is in hot reloading change detection. I think for the standard luahost that searcher would need to update a map of all the script contexts that |
Ok, I've got this close to how I want it. I've ended up doing a bit of an end-run around searchers and loaders. Instead of all that, in my custom host's This has a few wrinkles left. One is hook functions, the current handle events only looks for singular global hooks, so multiple scripts loaded into global space this way can stomp on each other which sucks. I expect I'll need to make a central hook dispatch in lua that modules can register with in an on-load hook-like function. To that end it'd be nice to keep scripts from touching gobals during load(outside that on-load function) to avoid stepping on those dispatch functions, I'm not sure how to do that in lua 5.4 in a way that meshes well with what I'm already doing. The other wrinkle is load order. As is now I'm just running the load function, effectively requiring the script, as part of the I don't think this needs any further upstream changes. As a potential future crate inclusion, this all feels like it'd need to be a new host along with the shared global enviroment changes, or some pretty deep configuration switches on the current lua host. Since it kind of puts different demand on game world architecture in how you set up script collections, it feels like a separate host might be appropriate. If I were to try to implement this for the isolated lua instances of the main hosts, I think I might do it as an APIProvider. That could load chunks from a resource and insert wrapped versions into each context's Either approach seems like it could allow for a safe version of I hope none of this comes off as either me commiting to implement all this for the crate or demanding that you do either :) I'm just prone to going off on speculative tangents about how things could work. |
Your tangents are much appreciated! And I am sure these will provide a fantastic foundation for future PR's! And of course I do not expect that you in particular implement these. Thanks for all the help! |
I've accomplished all my goals in this and put my implementation up in issue #73 |
In testing, using
require "common"
with the require feature gets me the outputcommon.lua
is in this case sitting in my project'sassets\scripts
directory right next to my other lua files, it's actually being loaded by bevy's asset server even. To get it to load I must userequire "assets/scripts/common"
(running via cargo from the project root dir)Ultimately, for my ends I think I want require to load from bevy's asset server somehow as part of a sandboxing effort. That feels potentially out of scope as a core feature, but it seems like this crate should probably at the least add the assets directory to the searcher paths.
The text was updated successfully, but these errors were encountered: