Jump to content

[Solved] Nothing printed to the logs


Recommended Posts

I'm finally making a serious attempt at plugin development.

Right now I'm not seeing any of my incredibly basic methods logging to the debug field. I'm too new to really see what's wrong.

Most tutorials on the web seem out of date, which I suspect might be my problem.

I've tried looking at active plugins source code for enlightenment...but many of those projects are so well developed - so complicated - that they can't really help me.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using KSP.IO;
namespace KSP_Konsole
{
public class Konsole : MonoBehaviour{

public Konsole(){
Debug.Log("KSP_Konsole [" + this.GetInstanceID().ToString("X") + "][" + Time.time.ToString("0.0000") + "]: Constructor");
}

void Awake(){
Debug.Log("KSP_Konsole [" + this.GetInstanceID().ToString("X") + "][" + Time.time.ToString("0.0000") + "]: Awake");
}
}
}

I have the same code for "void Start()", "void OnDestroy()", and "void Update()"

But I don't see the output in the Debug Console (Alt+F12), nor in the Player.log file (I'm on Ubuntu, so output.log doesn't exist).

The Player.log shows the game loading my .dll, but that's the only sign of it. None of these debug messages above are found.

I can post more code if wanted, but seriously it all looks like that above.

Edited by Ydoow
Link to comment
Share on other sites

The issue is that you are not telling KSP when to load your code so KSP never loads that code.

You need to make your code into a partModule at attach it to a part with ModuleManager or tag it as a KSPAddon so KSP loads it in a scene.

PartModule:

Change

public class Konsole : MonoBehaviour

to

public class Konsole : PartModule

and make a moduleManger patch assigned the Konsole partModule to the parts you want.

KSPAddon:

Add the KSPAddon attribute like so:

[KSPAddon(KSPAddon.Startup.Flight, false)]
public class Konsole : MonoBehaviour

and with the Start.Flight as noted, this class will be loaded at the start of every flight scene.

Hope that gets you going,

D.

Link to comment
Share on other sites

Thanks! Few questions though.

My desire is to use this plugin without any parts. From what I remember (years ago), extending the class as PartModule meant you had to have a specific part loaded for the plugin to work too.

To explain a bit, my goal is to have a GUI Window loaded that doesn't require a part on any vessel (similar to Kerbal Alarm Clock). Do your corrections force me to use a part, or can it be partless?

Attributes are a completely new feature to me. I can research what they are myself, but could someone briefly explain their significance within the context of KSP?

Edit: Rereading your post several times, I think I understand.

I have the option to attach it to a part by Extending it as PartModule OR if I use the attribute AddOn it will load the code without any parts at the next scene. Is that a correct interpretation?

Edit #2: It would appear so. I added the AddOn Attribute to my code as you suggested and things are working now. Thank you very much for the assist.

Edited by Ydoow
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...