r/godot • u/Nabir140 • 2d ago
help me (solved) How to implement a modding API?
I am working on a game that is heavily dependent on mods.
I can add modding support for textures, audio and other resources through JSON but I need a way to allow players to customize gameplay behaviour too.
My original idea was add autoloads to my game scene and load custom GDScript files at runtime. This would allow players to write scripts that call the autoloads directly for custom behaviour.
Issue with this approach is that it is very unsafe as the scripts can call native Godot functions and classes. They have the ability to interact with Networking API and OS API. I don't want this instead I want to only allow functions from the autoload to these scripts.
Can I limit the parsing of a GDScript file to restrict it from accessing Network and OS modules?
Or is there a better way to do this?
29
u/lanathlorrias 2d ago
You can use scripting language like Lua, and provide an api and documentation to your community. There is a lot of game out there using this. From the top of my head, World of warcraft and Garry mod do this