Jump to content

The official unoffical "help a fellow plugin developer" thread


Recommended Posts

I'm using OS X Maverick with KSP installed via Steam.

Am I correct that the install folder is through ~/Library/Application Support/steam/....etc.../common/Kerbal Space Program/ ?

I'm trying to add the Unity.dll and C#.dll references to MonoDevelop. The Wiki says to find them under the install directory inside /KSP_Data, however that folder, and none of the the .dlls exist for me.

Where should I look?

Link to comment
Share on other sites

Weird. Is the game running fine? Because without this folder KSP should not run. Maybe you are looking in the wrong directory. Try to open properities of KSP in Steam, then go to tab "Local Files" and click "Browse Local Files". If there is still not KSP_Data folder, then click "Verify Integrity of Game Cache" - Steam will download all missing or corrupted files. Hopefuly this will work. ;-)

Link to comment
Share on other sites

Weird. Is the game running fine? Because without this folder KSP should not run. Maybe you are looking in the wrong directory. Try to open properities of KSP in Steam, then go to tab "Local Files" and click "Browse Local Files". If there is still not KSP_Data folder, then click "Verify Integrity of Game Cache" - Steam will download all missing or corrupted files. Hopefuly this will work. ;-)

Yeah the game runs fine (although slow; MacBook air). I admit this is odd. I wasn't expecting it. Steam confirms the local files is the actual install directory, however KSP_Data/Managed/ does not exist.

I'm checking the integrity now, but nothing seems to be happening. Worst case I'll delete and re-install the game. I don't have anything worth saving on the laptop

@ydoow

They are located in KSP_Data\Managed\. You can also try to search your computer for an UnityEngine.dll, but that will find other games using unity as well.

I tried searching for UnityEngine.dll but nothing showed up. I'm not sure how much to trust Mac's search function though. I never really cared for it because it's not very explicit in it's search bounds. So I think I'm searching my entire HD, but I'm not 100% sure.

It honestly doesn't make sense for KSP to be able to run without these files. Unless, of course, the way KSP and Unity run on OSX is completely different from Windows

Link to comment
Share on other sites

A couple questions:

1) Has anyone found a way to deactivate an engine such that it can later be reactivated via staging? RealChutes got this working for parachutes, I believe with just the following code:

this.part.deactivate();
this.part.inverseStage = Staging.CurrentStage;

Unfortunately the engine module seems to prevent the same approach from working here. Deactivating the part doesn't entirely reset it, nor does issuing a "Shutdown" message.

2) Is there any way to include data in the window you get when right clicking on a part while EVA? KSPEvent has an option that places a button there, but KSPField doesn't appear to have a corresponding option.

Link to comment
Share on other sites

Hi!

I'd like to create a part that changes its texture based on its internal state. The state can change during the game or in the editor. Say, if the state is "1" it should have a "1" on the side, while if the state is 2,3,4.... it should show that number. The number of states is finite and small, so it would be feasible to create 1,2,..... textures for the part and change the textures depending on the state.

This seems to be a so useful thing I thought I'd ask in the forum to see if someone has done this before.

Thanks!

Link to comment
Share on other sites

A couple questions:

1) Has anyone found a way to deactivate an engine such that it can later be reactivated via staging? RealChutes got this working for parachutes, I believe with just the following code:

this.part.deactivate();
this.part.inverseStage = Staging.CurrentStage;

Unfortunately the engine module seems to prevent the same approach from working here. Deactivating the part doesn't entirely reset it, nor does issuing a "Shutdown" message.

2) Is there any way to include data in the window you get when right clicking on a part while EVA? KSPEvent has an option that places a button there, but KSPField doesn't appear to have a corresponding option.

1) That only works if you move the part to a new stage afterwhile, not sure why. What exactly hapopens with engines that doesn'T make it work? Anyway, I don't believe ModuleEngines uses that, instead, they just stop making the part work and make them work again after.

2) Yes you can do that with KSPField. Just add guiActive = true, and make sure that value is not tweakable.

Link to comment
Share on other sites

1) That only works if you move the part to a new stage afterwhile, not sure why. What exactly hapopens with engines that doesn'T make it work? Anyway, I don't believe ModuleEngines uses that, instead, they just stop making the part work and make them work again after.

2) Yes you can do that with KSPField. Just add guiActive = true, and make sure that value is not tweakable.

It's a little weird with engines. I'm still trying to figure it out, but it appears that deactivating a part doesn't deactivate the associated moduleengines, while shutting down the engine prevents the part from being activated again. In any case, I think I've found a solution for my needs: ignore the engine itself, and just activate/deactivate the part. Then make sure the engine can't operate while my code is inactive (temporarily set maxThrust to 0). In this deactivated state the icon still has a fuel gauge next to it in the staging, but that's not the end of the world.

I have variables with KSPField and guiActive=true. That works fine for seeing the data while piloting the craft, but it doesn't make it visible while EVA. For KSPEvent you need to set guiActiveUnfocused = true or externalToEVAOnly = true, but KSPField doesn't appear to have an equivalent.

Link to comment
Share on other sites

It's a little weird with engines. I'm still trying to figure it out, but it appears that deactivating a part doesn't deactivate the associated moduleengines, while shutting down the engine prevents the part from being activated again. In any case, I think I've found a solution for my needs: ignore the engine itself, and just activate/deactivate the part. Then make sure the engine can't operate while my code is inactive (temporarily set maxThrust to 0). In this deactivated state the icon still has a fuel gauge next to it in the staging, but that's not the end of the world.

I have variables with KSPField and guiActive=true. That works fine for seeing the data while piloting the craft, but it doesn't make it visible while EVA. For KSPEvent you need to set guiActiveUnfocused = true or externalToEVAOnly = true, but KSPField doesn't appear to have an equivalent.

Ah, no indeed, KSPField does not have a guiActiveUnfocused value, but a request has been made to add it iirc.

Link to comment
Share on other sites

I reinstalled KSP cleanly on OSX Maverick, but the folder still isn't there, nor the .dll's

Is there a place I can download the two .dlls need to start making a plugin?

On OS X, the UnityEngine.dll is bundled with the application. In the KSP folder, right click on the KSP application and select "Show Package Contents", you will then find the dlls in the Contents/Data/Managed subfolder.

Link to comment
Share on other sites

Today I started making my first mod, it will be for EVA building. I made a quick model and texture for a part that will contain parts for building. However when I try to use it, the texture is just blank white and it doesn't attach to attachment points. Any help will be a huge help. :) Thanks.

Link to comment
Share on other sites

So I'm going to try and learn unity by force of will (and many, many, many mistakes).

Now what I'd like to do is create a few planet objects. My first idea was to look at the existing code from the game for those objects and try to figure out how they work by tinkering here and there.

Sadly I cannot for the life of me figure out where in the world the file that describes the planets and other celestial bodies would be. I have used the search function to no avail. :(

Any help would be appreciated, and I'll probably be back after this question gets answered with a few dozen more.

Thanks.

EDIT 21:03 EST:

Okay, so I did some searching around the forum and apparently creating planets can get into some very gray and messy legal areas. Fortunately, I don't need to create a planet so much as I just need to make a sphere of influence. So if there is a way to do that without breaching the EULA that'd be nice.

Edited by Imperial528
Link to comment
Share on other sites

Today I started making my first mod, it will be for EVA building. I made a quick model and texture for a part that will contain parts for building. However when I try to use it, the texture is just blank white and it doesn't attach to attachment points. Any help will be a huge help. :) Thanks.

Someone answered in your alternate thread, on the node attachment part of your question, likely better than I could.

I ran in to the blank white texture issue twice in my short time (I am very new). The first time the cfg was referencing a bad file. The second time I had actually left a blank white texture with lines in Unity and exported it as the actual prepared texture.

Hope that helps.

Edited by Bizmar
I am bad at internet.
Link to comment
Share on other sites

Got a question about the part right-click menu's if anyone has some insights. Am trying to programmatically show/hide the resource bars for parts - eg. show/hide all the liquid fuel bars on screen as if you have used modifier + right-click on all the tanks. I have been through all the classes/instances I can think of - KSPEvents, KSPFields, but cant seem to find where these things are.

Anyone know if its possible to do this?

Link to comment
Share on other sites

Got a question about the part right-click menu's if anyone has some insights. Am trying to programmatically show/hide the resource bars for parts - eg. show/hide all the liquid fuel bars on screen as if you have used modifier + right-click on all the tanks. I have been through all the classes/instances I can think of - KSPEvents, KSPFields, but cant seem to find where these things are.

Anyone know if its possible to do this?

Hm, I'm not sure where Fuel GUI is hiden, perhaps in one of the resource classes. Perhaps you could instead completely remove the resource from the part, that would remove the GUI as well I believe?

Link to comment
Share on other sites

@Trigger Au :

Like what would happen if you click on an item in the ressource panel ? If yes, maybe ressourceShown in UIPartActionController (get from static Instance) is what you look for. It's how the ressource panel click is handled : On click on a ressource the ressource panel fire an event to set an id (i don't know how to figure out the id though) in the UIPartActionController. ressourceShown is just a list of int.

Let us know if that works I may be interrested too. =)

Link to comment
Share on other sites

Does anyone know a graceful way to either separate or delete a part or tree of parts from the editor?

I am building a plugin for a part that, depending upon a tweakable configuration value, may or may not permit other parts to be stacked on it. I need some sort of handling for when the tweakable value invalidates part stacking, and either detach the parts (and put them on the mouse, perhaps) or delete the parts (and make the user sad, perhaps). I've looked into preventing the tweakable from working, but I can't find a way to make that fail gracefully (I can refuse to change the value when the button is pressed, but that doesn't change the status of the tweakable while the tweakable tip is still open).

TIA!

EDIT:

It looks like setting a selected part via EditorLogic.fetch.SelectedPart = part; puts it on the mouse, fulfilling option number 1.

Edited by toadicus
Resolved?
Link to comment
Share on other sites

@Trigger Au :

Like what would happen if you click on an item in the ressource panel ? If yes, maybe ressourceShown in UIPartActionController (get from static Instance) is what you look for. It's how the ressource panel click is handled : On click on a ressource the ressource panel fire an event to set an id (i don't know how to figure out the id though) in the UIPartActionController. ressourceShown is just a list of int.

Let us know if that works I may be interrested too. =)

unfortunately I couldn't get the list out of UIPartActionController, although it could just be me. Designing my own now :(

Link to comment
Share on other sites

Does anyone know a graceful way to either separate or delete a part or tree of parts from the editor?

I am building a plugin for a part that, depending upon a tweakable configuration value, may or may not permit other parts to be stacked on it. I need some sort of handling for when the tweakable value invalidates part stacking, and either detach the parts (and put them on the mouse, perhaps) or delete the parts (and make the user sad, perhaps). I've looked into preventing the tweakable from working, but I can't find a way to make that fail gracefully (I can refuse to change the value when the button is pressed, but that doesn't change the status of the tweakable while the tweakable tip is still open).

TIA!

EDIT:

It looks like setting a selected part via EditorLogic.fetch.SelectedPart = part; puts it on the mouse, fulfilling option number 1.

As a follow up to this, it looks like sometimes when this happens, the selected part doesn't want to be dropped (i.e. clicked down not on a part or the parts pane). Anybody else run in to this?

Link to comment
Share on other sites

can someone help me create a randomizer which will give me more or less teh effect of random spread in a ejected object

i have a weapons mod, that needs this for the shells that are fired

my shell's firing code is as follows, basically once spawned in, this force is applied to the shell using the 2 variables shellmass and shellvelocity to determine the magnitude of this force:

newshell.rigidbody.AddForce(part.transform.up * shellvelocity * shellmass, ForceMode.Impulse);

i want to know what i can do to make this shell spawn in with a slight variation which would be random every shot (basically i need to know a method for making a variable lets just call "vectormultiplier" to change randomly as time progresses to give me a different value every shot)

this way i can give the shell a different force in either the forward/back direction or the left/right direction

also, where is information about how to implemennt resources?

i want my cannons to use a certain amount of resource per shot, and i also want to make it fo that if there is less then a certain amount of ammunition resource left, the weapon will not fire. i know this part is most likely very easy to code, i just dont know the proper terms to use in my code to make it use resources when a shell if fired, and then also not fire when the resources are empty.

Link to comment
Share on other sites

For the random part, simply add "vectormultiplier = UnityEngine.Random.Range(0.5f, 2);" and add that multiplier to your equation, that will always return a value between 0.5 and 2 randomly between each shot.

As for resources, it is probably easy, I believe it would have to do with part.requestResource();, but I'm a little tired after this evening and I'm not in the mindstate to confirm this, so perhaps someone else could come around and do so.

Link to comment
Share on other sites

Hi everyone, i'd like to create a simple warp mod which allows you to warp time as fast as you want (more than max, the only one here around is in krag's planet factory but it doesn't seem to work) and without height limits, the problem is that i have no idea about where should i start (i guess the mod is going to be a .dll plugin)

Link to comment
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.

×
×
  • Create New...