FYI: I have googled for several hours prior to posting to try and find a solution but was unable to. Perhaps I could not because i'm not familiar with the correct terminology to search for? I've a programming background however this is my first time dabling with C#.
Problem: I have created several Rust plugins for myself to use all of which obviously use a very similar structure and some of them even use similar methods. To eliminate code repitition I decided it would be a good idea to make a SDK plugin for myself to put my common helper methods into it that I could use from my various plugins. However, when trying to call the functions from my SDK plugin (using Method 2 from below) in my other plugins i get "Unable to load Test. Test.cs(21,24): error CS0246: The type or namespace name `LethalsSDK' could not be found. Are you missing an assembly reference?".
Now from what i've searched and come up with is there are two ways to call another class:
Method 1)
[PluginReference]
Plugin LethalsSDK;
void SomeMethodInMainPlugin() {
LethalsSDK.Call<object>("SomeSDKMethod", arg1);
}- This method also needs the called SDK methods to be private.
Method 2)
// Requires: OtherClassnamespace Oxide.Plugins
namespace Oxide.Plugins
{
class Test : RustPlugin
{
private static LethalsSDK lSDK;
void SomeMethod(){
lSDK.SomeSDKMethod(arg1);
}
}
}- This method needs the called SDK methods to be public.
I've tried Method 1 and it works, however, I don't like it. I'd prefer to be able to have my autocomplete feature with my method calls instead of having to manually enter them as an argument to the Call function.
I've read that Method 2 allows for calling the methods directly as I would like to be able to do so but I cannot figure out the proper semantics obviously. What am I doing wrong and how can I fix it?
Structure of my SDK plugin:
namespace Oxide.Plugins
{
[Info("Lethals SDK", "LethalBunny", "0.0.1")]
[Description("Development Tool Required by most of Lethals Mods")]
public class LethalsSDK : RustPlugin
{
public static void SomeSDKMethod(string arg1)
{
Puts("Just testing " + arg1);
}
}
}