Git Product home page Git Product logo

Comments (4)

gilzoide avatar gilzoide commented on September 27, 2024 2

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.

gilzoide avatar gilzoide commented on September 27, 2024 2

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.

Frontrider avatar Frontrider commented on September 27, 2024 1

Yap, that is exactly what I wanted to know. Thank you.

from godot-lua-pluginscript.

Frontrider avatar Frontrider commented on September 27, 2024

I could suggest spelling this out in the first paragraph, so it becomes 1000% obvious.

from godot-lua-pluginscript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.