Comments (4)
My understanding of your question is that it's about executing Lua scripts that are generated at runtime, for example written by users. I'll answer based on that assumption, please let me know if it's not about that.
So the short answer is yes, absolutely! If you want to execute arbitrary scripts and don't want to create your own scripting language/runtime, Lua is the first tool that comes to mind.
If using Lua PluginScript, you have a full LuaJIT runtime embedded in Godot, so you can use the customary functions load
and loadfile
to load arbitrary code, then pcall
the functions to run them (or just call directly, but protecting the calls is advised).
If you look up the keywords "Lua" and "sandbox", you'll find a lot of content on how to protect code execution from accessing unsafe stuff. It's hard to do it 100%, but depending on your needs, it may be easy enough to make a decent sandbox that won't break the game's code. Maybe it will be vulnerable to inifinite loops and freeze the app in the user's machine or allocate too much memory and crash, these are some hard ones to sandbox. But if it can't mess with the game code/functions/variables, might be good enough.
from godot-lua-pluginscript.
No problem!
If you manage to make a project using some kind of runtime generated (either by users or not) script loading, I'm interested in knowing the results ^^
Just as a side note, Lua PluginScript itself uses loadstring
/load
for loading and running Lua scripts in Godot.
It doesn't do any sandboxing because this would limit what devs can do while implementing games/apps. The only changes to the environment are additional globals (like the GD
table and types like Vector2
and PoolStringArray
) and an __index
metamethod for the global _G
table so that it can find Godot classes and singletons.
from godot-lua-pluginscript.
Yap, that is exactly what I wanted to know. Thank you.
from godot-lua-pluginscript.
I could suggest spelling this out in the first paragraph, so it becomes 1000% obvious.
from godot-lua-pluginscript.
Related Issues (20)
- Passing data between GD.yield() and resume() HOT 1
- Array:sort_custom Usage HOT 4
- Scripts Inherited By Scenes All Share Variables HOT 2
- Does this work with Godot 4 alpha / nightly? HOT 9
- key press or simulating keyboard HOT 5
- Scripts not reloading in editor HOT 3
- WebAssembly / HTML5 target HOT 3
- Reasoning behind not supporting multithreading in lua? HOT 3
- Do you know what the problem could be loading a multithreading library called effil? HOT 3
- cannot load this plugin due to "attempt to call a nil value" HOT 8
- load plugin first time has some errors. HOT 2
- "undefined symbol: lua_gettop" when attempting to load luasocket HOT 9
- `remote` keyword? HOT 1
- Get Lua script instances while unboxing Object Variants
- Plugin not working in Godot 4.0 HOT 2
- Unable to execute text from textEdit's text property with loadstring() HOT 1
- Mono: Core API Hash Mismatch Error. HOT 4
- Can't use the extension HOT 3
- cant use the plugin HOT 1
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 godot-lua-pluginscript.