Jump to content

[Updated] Some help with my first plugin


Recommended Posts

I'm currently making my first plugin, and I'm trying to get something to trigger on "OnDestroy" but it doesn't seem to be working. I think it may be because I'm not overriding OnDestroy, but every time I try to build with the override in, I get a error saying there isn't anything to override.

My next issue is that I'm trying to get a force added to all nearby objects when my object is destroyed, and the only way I've found to do that uses rigidbody.addexplosiveforce but it doesn't seem to do anything. Does anyone know what units the power and radius are in? (m/s, m, etc.)

Thanks for the help,

Matrixmage

Edited by Matrixmage
Link to comment
Share on other sites

If your extending PartModule then there is no OnDestroy, but Part has onPartDestroy so you would need to create a class that extends Part to perform those actions. Btw, it's Rigidbody.AddExplosionForce not explosive, and if you don't like that you could try making the part.explosionPotential really high then doing part.explode().

Link to comment
Share on other sites

Thanks a lot for the help, and sorry for the late reply, I was away from my computer for awhile.

I got some more questions, if someone wouldn't mind dealing with their stupidity.

First: My understanding is that when your build the library, the dll is named after the solution, and when you want to use a class that extends partmodule, the name you put in the .cfg is the class's name, right?

Second: what do you do a class that extends part? How do you make it do anything meaningful?

Third: is their any usefulness (beyond organizational) to having multiple .cs's versus all the class's in one .cs file?

Forth: is their someplace people find info about this stuff, or is it asking / trial and error?

Thanks for any help!

P.S. I'm pretty sure a lot of this stuff I could know if I used library's more, so please don't just say "code more" or something obnoxious like that.

Link to comment
Share on other sites

1. By default, the assembly (DLL) is named after the project, not the solution. It can be changed under "Assembly name" in the project's properties. Yes, the name you put in the .cfg is the class's name.

2. That depends on what you want the class to do. You have access to different properties depending on what class you extend. The user-made XML documentation is handy for this, as it tells you what things do (as long as the community has figured them out).

3. There has been much discussion of this over the years. Have a read through and see for yourself. If all the things in a file are there because they're related, it makes it much easier to find what you're looking for.

4. For individual programming questions like the above, Stack Overflow is pretty good. For KSP-specific things, here in the Add-on Development section is where you need to be. Make sure and read all the sticky posts; most of your questions about getting started will be answered there. If you have small questions that don't warrant a thread of their own, this thread is the place to go.

Link to comment
Share on other sites

Thanks for the help, just a quick clarification about what a class extending part does (your thing wasn't really what I was looking for). Is extending a part supposed to be used to do logic involving the current part, rather then a actually changing the part in the game, and if so, how to I get it to do this logic on the part I want?

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...