I am trying to make a plugin that adds highly extendable Health, Status, and Hit/Hurt Box systems. One feature I want is comparability with the Yet Another Resource Database plugin, and I would like to know if its possible to have certain code only run or be available when another plugin is installed. The idea I had is to allow the user to have a registry of status effects and other things to be loaded by ID into components which would be very useful.
Would this prevent errors in code when the plugin is missing? I am looking to have one build support the plugin and have extended functionality when the addons present so.ill likely have to make it so that some parts do not compile or are not going to cause any errors when the addons not present.
As long as you prevent the code that depends on the additional plugins from running if tje plugins are not installed, there shouldn’t be any issues except for if there are errors in the code and you get notifications while in the inspector. You could bake almost any kind of bug into a function that never gets called without it affecting anything, as long as the code doesn’t have obvious surface level issues.
If it would cause compile-time errors then you are going to have a problem, you cannot directly reference any Globals or class_name types from the plugin, instead trying to detect or use what ever you may need by string names like with get() and set().
Maybe a specific example would help, or you should just try it out and see what kind of errors you run into- it’s possible in certain scenarios, we don’t know what scenario you are in though.
That’s the problem with “Is this possible?” questions, the answer is almost always yes, and the real question is how to do this? and the answer to that requires more information such as your starting point.
Yes, you cannot use static typing if the type doesn’t exist. If you wanted to use static typing, you could create a dummy add-on with the same folder structure and a dummy file that would be overwritten that just defines the type.