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

Apply LUA api providers before loading script. #98

Merged
merged 3 commits into from
Jan 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions languages/bevy_mod_scripting_lua/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,23 @@ impl<A: LuaArg> ScriptHost for LuaScriptHost<A> {
#[cfg(not(feature = "unsafe_lua_modules"))]
let lua = Lua::new();

lua.load(script)
// init lua api before loading script
let mut lua = Mutex::new(lua);
makspll marked this conversation as resolved.
Show resolved Hide resolved
providers.attach_all(&mut lua)?;

lua.get_mut()
.map_err(|e| ScriptError::FailedToLoad {
script: script_data.name.to_owned(),
msg: e.to_string(),
})?
.load(script)
.set_name(script_data.name)
.exec()
.map_err(|e| ScriptError::FailedToLoad {
script: script_data.name.to_owned(),
msg: e.to_string(),
})?;

let mut lua = Mutex::new(lua);

providers.attach_all(&mut lua)?;
Ok(lua)
}

Expand Down
Loading