Cephei

The official unoffical "help a fellow plugin developer" thread

Recommended Posts

1) Use 64x64, judging by the example file (size of one of the grid squares).

No insight on 2) for now, gotta try that

64x64 was my first thought for the same reason, but in game it's not right. It appears off center and too large.

Share this post


Link to post
Share on other sites

Does anyone know the name of the interior game object for the space plane hangar? I'd like to be able to make a part that does the same thing the new mumech launchpad/vab obliterator does but with the sph.

I've tried a couple names now, interior_spaceplane, interior_spaceplanehangar, but neither of those are correct.

Edited by Foran

Share this post


Link to post
Share on other sites

Looks like mumech has handled that one, Foran; it's been updated. Easy fix, I guess?

Okay. Possibly esoteric question- I've not found any discussion on the topic, so I'll toss it in, here, and see what happens.

I've been playing with decouplers and trying to determine how they work.. it looks like there are three different types (RadialDecoupler, Decoupler, and DecouplerGUI), and RadialDecoupler and the other two work differently.

The RadialDecoupler appears to "let go" of its parent, and take all of the children attached to it with it.

The Decoupler/DecouplerGUI, on the other hand, doesn't seem to let go of the parent, but instead lets go of the "top" node - at least, as far as the included default decouplers are concerned. That looks like the last (second?) element in the attachNode list, but I'm not finding anything that indicates why that's the case. I can just assume it's dropping the last attachNode and run with that, but I'm not sure that's really the correct answer; should I be looking at some other bit of data to tell me this?

(Why do I care? Playing with complex delta-V calculation from the VAB, and it rather matters which bits fall off when a decoupler triggers, since you could conceivably attach silly-large weights to the surface of the decoupler instead of just using the thing "normally"..)

Thanks for any assistance; this one currently has me stumped...

Share this post


Link to post
Share on other sites

Hey guys, quick question, I was wondering if anyone had any idea how to implement any of these:

1. Preventing the user from taking certain actions (more specifically: leaving IVA mode {including the map view}, entering IVA mode, drawing arbitrary orbits in

the map view, controlling the spacecraft, and leaving map view)

2. drawing arbitrary orbits in the map view, that change in real time, as if the person was piloting the spacecraft on said orbit

Thanks in advance to anyone who can answer this! (P.S. mad props if you can figure out what I'm trying to make, feel free to take a guess)

Share this post


Link to post
Share on other sites

Alright so supposing one wanted to allow a craft to be controlable, what would have to change in a preexisting persistance file with a preexisting craft to allow the said rocket to be controllable without a pod, but with the usually Ki Kd Kp parameters of say a mark 1 pod?

Share this post


Link to post
Share on other sites

I want to add sounds to existing parts. Mostly Kerbals themselves. How would I go about doing this?

Share this post


Link to post
Share on other sites
I want to add sounds to existing parts. Mostly Kerbals themselves. How would I go about doing this?

You should look at the source for Kethane. That does sounds pretty well, and the code is pretty clear.

Share this post


Link to post
Share on other sites

Quick (I hope) question: I want to do a check whenever a part gets attached to the ship in the VAB. How do I set up a callback hook so MyMethod(Part newPart) gets called whenever a new part is attached to the ship that's being built?

Share this post


Link to post
Share on other sites
Quick (I hope) question: I want to do a check whenever a part gets attached to the ship in the VAB. How do I set up a callback hook so MyMethod(Part newPart) gets called whenever a new part is attached to the ship that's being built?

In PartModule, it would be OnAwake or OnStart, probably. You should test both and see which one does what you need.

Share this post


Link to post
Share on other sites
In PartModule, it would be OnAwake or OnStart, probably. You should test both and see which one does what you need.

Neither, because I'm not coding a PartModule. I'm coding a UI interface, which needs to pay attention to parts as they are added to the ship.

Share this post


Link to post
Share on other sites

Ah, you should go looking for DEADB33F's subassembly loader. It's a partless plugin (meaning it doesn't need to be bound to a part to load and run), and there's also some neat stuff he does with the VAB interface, but you could repurpose it for nearly anything.

Share this post


Link to post
Share on other sites

//Is it possible to create a prefab in unity and then load it into KSP? Assuming you put the prefab into the resources folder and everything the prefab points to a folder called PluginData/PluginName/assets

//Why I'm asking this is I am planning on creating a complex gui in unity using a what you see is what you get editor and then porting it across KSP. using a prefab would just be an incredible simple solution.

The answer is Asset Bundles. Unfortunately I don't have a pro license so back to doing it all by code.

Edited by Swifty
Remembered Unity asset bundles

Share this post


Link to post
Share on other sites
Ah, you should go looking for DEADB33F's subassembly loader. It's a partless plugin (meaning it doesn't need to be bound to a part to load and run), and there's also some neat stuff he does with the VAB interface, but you could repurpose it for nearly anything.

That was helpful for about 90% of what I need. The remaining 10% might be more difficult. :)

Here's what I want to do right now:

FvzhYAe.jpg

Share this post


Link to post
Share on other sites

Update: Making good progress, but I'm discovering an annoying bug.

EditorLogic.fetch.PartSelected doesn't seem to work when you're in the Action Groups menu.

Any ideas?

Share this post


Link to post
Share on other sites

Anyone played much with KSP.File.IO, I am after grabbing the whole data for a vessel currently in flight, but not having much success.

The line if (KSP.IO.File.Exists<Vessel>(this.vessel.GetName(), this.vessel)) causes a warning: G:/Steam/steamapps/common/Kerbal Space Program/KSP_Data/../PluginData\.flights\150c3412-1c57-4bde-a0c0-1d2da7767d01

Generating a nice empty directory at that location. Any ideas?

Share this post


Link to post
Share on other sites

@ialdabaoth

I don't see why it would. In Action Groups, you're selecting a group of parts (all in the same symmetry), so it wouldn't make sense to be able to get an individual part from that.

Why do you need to have a selected part when in the Action Groups menu, anyway?

@Caswal

That might be a temporary file created during vessel loading or something. What kind of vessel data do you need? Most of your vessel info can be pulled straight from Assembly-CSharp's FlightGlobals class, from the ActiveVessel field.

Edited by ummwut

Share this post


Link to post
Share on other sites
@ialdabaoth

I don't see why it would. In Action Groups, you're selecting a group of parts (all in the same symmetry), so it wouldn't make sense to be able to get an individual part from that.

Why do you need to have a selected part when in the Action Groups menu, anyway?

You saw what I'm trying to do, right?

FvzhYAe.jpg

I need to get which part/part group is selected, so I can give the user buttons to add modules or change its fuel load.

Share this post


Link to post
Share on other sites

How do I make monodevelop build a dll? Currently it pesters me about no Main method entry point, and won't allow me to build. If I add a main method (which I shouldn't need), then it builds me an .exe

I'm not seeing any way to change this

Share this post


Link to post
Share on other sites

Does anyone know where the code is that defines the positions of celestial bodies / SOIs?

Share this post


Link to post
Share on other sites
How do I make monodevelop build a dll? Currently it pesters me about no Main method entry point, and won't allow me to build. If I add a main method (which I shouldn't need), then it builds me an .exe

I'm not seeing any way to change this

Start a new solution, make it a library, import the Unity and KSP assemblies.

Share this post


Link to post
Share on other sites
Does anyone know where the code is that defines the positions of celestial bodies / SOIs?

The code itself is hidden, since KSP is not open source. The devs have provided an API for us to use, however.

For the position of an object, you would call one of the methods (stored in the orbit class) in [object].orbit.getPositionAtUT([time]), which returns a Vector 3d pointing to an object's location at the given universal time. For examples on things you can do with that, feel free to peruse the code for my Protractor plugin here.

Share this post


Link to post
Share on other sites

Sorry if this has been asked before, but how do I remove the atmospheric 2.5 km limit on objects that are not being controlled by the player?

Share this post


Link to post
Share on other sites
Sorry if this has been asked before, but how do I remove the atmospheric 2.5 km limit on objects that are not being controlled by the player?

That's a consequence of the wider system as to which vessels simulate physics and which don't. Any vessels within 2.5km run physics simulations, any vessels beyond that are assumed to be in a fixed orbit ('on rails'). Any fixed orbits that intersect atmosphere above a certain pressure are considered to deorbit and are removed from the game.

You can extend the physics limit, I believe Lazor mod does it, but that has other side effects. I don't know if you can change the deorbit behaviour.

Share this post


Link to post
Share on other sites

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.