Skip to content

lua require not loading from assets dir #69

Closed
@LaserWitch

Description

@LaserWitch

In testing, using require "common" with the require feature gets me the output

2023-08-27T22:50:30.267464Z  WARN bevy_mod_scripting_core::hosts: Error in loading script AssetPath {
    path: "scripts/1.lua",
    label: None,
}:
Failed to load script asset for `AssetPath {
    path: "scripts/1.lua",
    label: None,
}` runtime error: [string "AssetPath {..."]:1: module 'common' not found:
        no field package.preload['common']
        no file 'D:\Code\luademo\target\debug\lua\common.lua'
        no file 'D:\Code\luademo\target\debug\lua\common\init.lua'
        no file 'D:\Code\luademo\target\debug\common.lua'
        no file 'D:\Code\luademo\target\debug\common\init.lua'
        no file 'D:\Code\luademo\target\debug\..\share\lua\5.4\common.lua'
        no file 'D:\Code\luademo\target\debug\..\share\lua\5.4\common\init.lua'
        no file '.\common.lua'
        no file '.\common\init.lua'
        no file 'D:\Code\luademo\target\debug\common.dll'
        no file 'D:\Code\luademo\target\debug\..\lib\lua\5.4\common.dll'
        no file 'D:\Code\luademo\target\debug\loadall.dll'
        no file '.\common.dll'
stack traceback:
        [C]: in ?
        [C]: in function 'require'
        [string "AssetPath {..."]:1: in main chunk

common.lua is in this case sitting in my project's assets\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 use require "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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions