-
-
Notifications
You must be signed in to change notification settings - Fork 42
fix: Sandboxing Scripts in Shared Contexts #357
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
Conversation
Regarding the "when to sandbox": before my changes, the globals of scripts were accessible by every other script when context sharing was disabled. So this causes a "breaking change" in that respect. However, @makspll mentioned in Discord that your stance was that scripts should be private by default, but you may have meant strictly for shared contexts. |
@@ -18,6 +18,7 @@ use bevy::{ | |||
reflect::TypePath, | |||
utils::HashMap, | |||
}; | |||
use mlua::Table; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙅 This is introducing lua logic into the bms_core layer. The idea is to only keep language agnostic logic in here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The crate does have mlua and rhai dependencies behind feature flags, but those are only there to implemenet Error
conversions
I will be fixing the issue of event handler collisions via a different method. I'll let someone else work on this later :) |
Summary
This PR changes the way scripts are loaded and how event handlers are called so that scripts don't collide when sharing the same context. Works to solve #339.
Load
ScriptEnvironmentStore
.Function Calls
ScriptEnvironmentStore
via ScriptId, search for the requested function in that environment and then call it.Next Steps