Jump to content

Beginning addon development in Visual Studio


Recommended Posts

I've searched here (and the forum search is not helpful at all btw) and I cannot find out what to reference in a new C# project in Visual Studio 2012 express to build a plugin. Is there anywhere that shows the parts I need to build a workflow for making a plugin? And if that information isn't stickyed in this forum can it be?

Link to comment
Share on other sites

You have a nice full (a bit outdated) video tutorial

.

Taranis have made some very good example code you can have a look here.

TriggerAu have documented his remake of Alarm clock, you ca find the info here.

You best bet will also be to create a new installation of ksp, and remove all the parts/internal/props you don't need to have the loading going as fast as possible.

You can create a savefile and use this trick to autoload the game to that save file.

I personally use this code

[KSPAddon(KSPAddon.Startup.MainMenu, false)]
public class Debug_AutoLoadQuicksaveOnStartup : UnityEngine.MonoBehaviour
{
public static bool first = true;
public void Start()
{
if (first)
{
first = false;
HighLogic.SaveFolder = "SaveName";
var game = GamePersistence.LoadGame("persistent", HighLogic.SaveFolder, true, false);
if (game != null && game.flightState != null && game.compatible)
{
HighLogic.LoadScene(GameScenes.EDITOR); //Start to the VAB
CheatOptions.AllowPartClipping = true;
CheatOptions.InfiniteFuel = true;
CheatOptions.InfiniteRCS = true;
}
}
}
}

Since you cannot use the debugger/tracelog/breakpoint under VS (sadly), you will need to use a fair amount of Debug.Log() to know what are the value of the variables and where it could crash.

In the ksp config file you want to have this

VERBOSE_DEBUG_LOG = True

Link to comment
Share on other sites

I tried those links from SpannerMonkey's reply but couldn't find what to reference to get the [KSPAddon] stuff or where those DLLS are located.

The Video helped once I got to part 2. I'll do some more with that. That information needs to be sticky somewhere though.

Unrelated:

Can I attach the visual studio debugger to KSP?

Link to comment
Share on other sites

Can I attach the visual studio debugger to KSP?

Sadly no, someone made an alternative for monodevelop here.

for KSPAddon, it is declared inside Assembly-CSharp.dll

[KSPAddon(KSPAddon.Startup, bool)]

First argument is where the plugin will start

second is if it is loaded only once or everytime you go to that startup.

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...