Comments (8)
with mlua, I can vouch that loading shared libraries works. I made a dll (.so on linux) with rust (using C abi) and successfully require
d it with a mlua script. https://github.com/khvzak/mlua#module-mode to create native libraries.
the lua environment technically can't be sandboxed anyway :D https://github.com/amethyst/rlua#sandboxing-and-untrusted-scripts there's a lot of unsafe things happening behind the scenes between luajit + rust + lua combo. it is sort of possible with luau backend (roblox version of lua) of mlua as that is explicitly designed for sandboxing.
maybe with a wasm based lua vm or https://github.com/danii/hematita we can get proper safe sandboxing in future.
you can use (and also create) luarocks packages, but you need to manage them externally and add the path + cpath of luarocks install target location to the mlua vm.
goes without saying, but you need to match the compiled dll lua versions and the embedded vm versions. I only checked lua54 and luajit.
from bevy_mod_scripting.
I am planning on swapping to mlua anyway, or rather tealr for documentation generation features, so if rlua does not allow for external modules this won't be a problem for too long. I'll investigate this once i am done working on the bevy script facing API!
from bevy_mod_scripting.
May I suggest another name for that feature? Considering that enabling it presumably also enables the debug module. It is probably also good if the feature name itself makes it clear that ub can happen if it is enabled.
unsafe_lua_instance
at least makes the fact that it uses unsafe clear but stays a bit vague. Though that might be a good thing to hopefully get people to read the docs so they know why it is unsafe?
from bevy_mod_scripting.
Hi,
I remember trying to import some other lua files from the scripts folder, and if i remember correctly that might work, but i am not sure about luarocks packages,
I would post an issue directly on rlua's repo since I basically just host the scripts directly with their library, so if it's possible there it's possible here!
from bevy_mod_scripting.
both mlua and rlua don't allow loading C libraries by default. They also don't allow loading the debug module by default.
You can enable both of them to allow this, but this requires unsafe
functions to create the lua instance as both C libraries and the debug module can result in UB due to circumventing Rust's borrow rules and/or messing with state that mlua and rlua depend on.
So, in both cases it is less about sandboxing, but more as an attempt to make sure that no UB happens through their safe api. I believe there is an issue on rlua about it, questioning if this design is not more harmful than useful.
from bevy_mod_scripting.
Hmm in this case I might put that functionality behind a feature to make it opt-in. Thanks for the info @lenscas!
from bevy_mod_scripting.
It's now possible to enable the unsafe mlua contexts with the lua_modules
feature
from bevy_mod_scripting.
That's probably a good idea, i will name it unsafe_lua_modules
though to imply clearly what functionality is enabled with the feature
from bevy_mod_scripting.
Related Issues (20)
- How to turn a ReflectedValue into a specfic type? HOT 6
- Crash when trying to loop through empty Vec HOT 3
- Bevy 0.12 HOT 2
- Can't compile with mlua anymore HOT 4
- Rune - Proxy macros HOT 2
- Luajit feature does not build. Other build issues as well. HOT 2
- lua globals are not registered until callback function. HOT 16
- tealr macro does not play nice with re-exported bevy_mod_scripting_lua crate
- Request: More exaustive tealr docgen example would be nice HOT 1
- REQUEST: Add instructions to readme on how to use bevy api gen HOT 2
- Registering a Bundle for Lua HOT 5
- Improved trait system
- Unified documentation Frontend + Backend
- Support for pre-processing HOT 1
- Feature for shared context
- Panic when mutating world from proxied raw method HOT 4
- Support for bevy 0.13.2 HOT 2
- Consider adding a WebAssembly interpreter as a host HOT 1
- Indexing the `Children` component always yields `nil` HOT 3
- Expose the proxy types for Bevy builtins HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bevy_mod_scripting.