In a python plugin it's possible to do something like this;
However in C# the type which is defined in the other plugin is not available... Is there some way to include the other plugins types? ...asCode:# reference the other plugin self.HumanNPC = plugins.Find("HumanNPC") # call the other plugins method, and return its type humanPlayer=self.HumanNPC.CreateNPC(pos,quat,key) # use its type in my plugin.... humanPlayer.info.invulnerability=False humanPlayer.info.hostile=True
doesn't seem to workCode:using Oxide.Plugins.HumanNPC;
Using objects from other plugins?
Discussion in 'Rust Development' started by Tolland, Jul 5, 2016.
-
Wulf Community Admin
See Oxide API for Rust.
-
So if I was writing the other plugin myself, then I could expose those values using Dictionary values.. as per the Oxide API. But in this case the plugin is 3rd party. I guess I can modify the plugin to expose a bunch of attributes as a Dict and pass it back and forth, but it seems odd you can do it in python, but not in C#
-
Wulf Community Admin
You'd need to call the other plugin's methods, not a dictionary or variable in it. You can see examples of this in my Slack, Babel, or other API-type plugins. In C#, you should be using [PluginReference], you can't just add it as a using statement. -
I have a reference to HumanNPC using [PluginReference] like so;
However if I try to use the type from that, like this;Code:[PluginReference] Plugin HumanNPC;
I get an error;Code:HumanNPC.HumanPlayer humanPlayer=HumanNPC.Call("CreateNPC", player.transform.position, player.transform.rotation);
which kind of makes sense.Code:[07/05/2016 23:21:31] [Oxide] 23:21 [Error] MightyDeathmatch.cs(905,4): error CS0118: `Oxide.Plugins.MightyDeathmatch.HumanNPC' is a `field' but a `type' was expected
The original plugin doesn't contain any method to set for example the invulnerability of the NPC as a method.. -
Wulf Community Admin
You wouldn't be able to get a callback as far as I know unless the other plugin's method returned something. -
The other plugins method returns an object;
However trying to use that object is impossible if my plugin doesn't import the type somehowCode:public HumanPlayer CreateNPC(Vector3 position, Quaternion currentRot, string name = "NPC", ulong clone = 0)
Anyway... so I'll customise the HumanNPC plugin to expose a method which accesses that variable..Code:humanPlayer.info.invulnerability=False; [07/05/2016 23:50:41] [Oxide] 23:50 [Error] MightyDeathmatch.cs(914,16): error CS1061: Type `object' does not contain a definition for `info' and no extension method `info' of type `object' could be found. Are you missing an assembly reference?
