Jump to content

Can't get a simple plugin to load?!


Recommended Posts

Hi, I followed the tutorials in the wiki to create a simple plugin:

using System;
using System.Collections.Generic;
using System.Text;
using KSP;
using UnityEngine;
namespace KSPFlightPlanner
{
public class FPComputer : PartModule
{
private bool inEditor = false;
public override void OnStart(StartState state)
{

print("FP Started instance" + state);
if (state == StartState.Editor)
{
inEditor = true;

}
}
public override void OnInitialize()
{
print("Initiated instance");
}
public override void OnUpdate()
{

if (inEditor)
{
GUI.Box(new Rect(100, 100, 100, 300), "Test");
}
}

}
}

The library does not throw any errors when loading, but I can't find any output in the log files. What's wrong here ?

Link to comment
Share on other sites

Hi, I followed the tutorials in the wiki to create a simple plugin:

using System;
using System.Collections.Generic;
using System.Text;
using KSP;
using UnityEngine;
namespace KSPFlightPlanner
{
public class FPComputer : PartModule
{
private bool inEditor = false;
public override void OnStart(StartState state)
{

print("FP Started instance" + state);
if (state == StartState.Editor)
{
inEditor = true;

}
}
public override void OnInitialize()
{
print("Initiated instance");
}
public override void OnUpdate()
{

if (inEditor)
{
GUI.Box(new Rect(100, 100, 100, 300), "Test");
}
}

}
}

The library does not throw any errors when loading, but I can't find any output in the log files. What's wrong here ?

afaik GUI only works inside of

public void OnGUI()

{

}

afaik

print should work aswell

I suggest to use FixedUpdate instead of OnUpdate for the repeated work..

And - just to be certain..

you are aware, that a part module only works if loaded with a part?

you must add it to a cfg file and it has to be loaded for those log entrys to show up..

other than that, I don't see a problem with your code..

Link to comment
Share on other sites

You should find at least one line that mentions the filename of your plugin DLL reasonably near the start of the output_log.txt/player.log file. Have you got any other mods installed in KSP and do they work? KSP can have problems loading mod plugins if KSP is installed inside "Program Files" (e.g. a standard Steam install). If your KSP is inside Program Files then create a new copy of it elsewhere on your disk (e.g. in C:\Games).

You are creating a PartModule. Have you created a part that includes the module or added it to an existing part?

If you want a part-less plugin then you need to look at using the KSPAddon attribute on your class (and deriving directly from MonoBehaviour rather than PartModule).

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