Jump to content

The official unoffical "help a fellow plugin developer" thread


Recommended Posts

3 hours ago, garwel said:

How can I read the persistentId of the vessel in the Editor? I tried using ShipConstruction.LoadShip().persistentId, but it causes terrible glitches (basically, the vessel on the screen is duplicated for every call of this method).

Also, will this persistentId be the same for the ship when it is launched?

Why do you need this?

Link to comment
Share on other sites

2 minutes ago, linuxgurugamer said:

Why do you need this?

I want to add a system that allows kerbals to "train" for a particular vessel before it is launched, so that they are more efficient during the mission. So I need a way to know that they have been trained for this vessel (or, as an option, for something very similar).

Link to comment
Share on other sites

6 minutes ago, garwel said:

I want to add a system that allows kerbals to "train" for a particular vessel before it is launched, so that they are more efficient during the mission. So I need a way to know that they have been trained for this vessel (or, as an option, for something very similar).

Use MM to add a field to command pods to store a unique id, then reference that ID in the training center.

You could add a new module which would allow the I'd to se set and changed in the editor, but once launched it would be readonly

Edited by linuxgurugamer
Link to comment
Share on other sites

Just now, linuxgurugamer said:

Use MM to add a field to command pods to store a unique id, then reference that ID in the training center.

I'm not sure if MM applies here, but I see what you mean. If I add a field to a PartModule to initialize all crewable parts with some IDs in the Editor, I can then check if the crew is trained for these specific parts in-flight. It may not be the simplest solution, but it is actually more flexible (should work with docking etc.).

Link to comment
Share on other sites

Just now, garwel said:

I'm not sure if MM applies here, but I see what you mean. If I add a field to a PartModule to initialize all crewable parts with some IDs in the Editor, I can then check if the crew is trained for these specific parts in-flight. It may not be the simplest solution, but it is actually more flexible (should work with docking etc.).

You would use MM to add the part module to the parts

Link to comment
Share on other sites

1 hour ago, garwel said:

Thanks, but it is bad news. I need to somehow associate the vessel in the Editor with its launched version.

Couldn't you do this by using the vessel name?

Attach a module to a kerbal ... put in the values you need to have into the part module, make them persistant and force activate the module OnStart

You can check the data in the part module through protocrewmember and pull any values you need out of it which would be specific to that kerbal only

As for MM, you dont need it really .... here's a slice of code to bypass any need for MM :wink:
(just replace the 'ModuleOrX' with whatever you want to call the part module you are adding to a Kerbal)

Spoiler

    [KSPAddon(KSPAddon.Startup.SpaceCentre, true)]
    class OrXAddModules : MonoBehaviour
    {
        public static OrXAddModules instance;

        public void Awake()
        {
            
            if (instance) Destroy(instance);
            instance = this;

            Debug.Log("[ORX] === ADDING OrX MODULE ===");
            ConfigNode EVA = new ConfigNode("MODULE");
            EVA.AddValue("name", "ModuleOrX");

            try
            {
                PartLoader.getPartInfoByName("kerbalEVA").partPrefab.AddModule(EVA);
                Debug.Log("[ORX] === ADDED OrX MODULE to kerbalEVA ===");
            }
            catch
            {
                //Debug.Log("[ORX] === ADDED OrX MODULE to kerbalEVA ===");
            }

            try
            {
                PartLoader.getPartInfoByName("kerbalEVAfemale").partPrefab.AddModule(EVA);
                Debug.Log("[ORX] === ADDED OrX MODULE to kerbalEVAfemale ===");

            }
            catch
            {
               // Debug.Log("[ORX] === ADDED OrX MODULE to kerbalEVAfemale ===");
            }
        }
    }

 

 

Edited by DoctorDavinci
Link to comment
Share on other sites

2 hours ago, DoctorDavinci said:

As for MM, you dont need it really .... here's a slice of code to bypass any need for MM :wink:

Why have an extra 20-40 lines of code when it's a single line in MM?  The fact that you can do something doesn't mean you should.  Besides, there are advantages to having a module in the vessel when it's instantiated and not afterwards.

2 hours ago, DoctorDavinci said:

Couldn't you do this by using the vessel name?

Vessels can be renamed, defeating the purpose of the mod

Link to comment
Share on other sites

  • 2 weeks later...

UI_ScaleEdit is defective on KSP 1.8.

This affects every single Add'On that uses it. Yes, all the 4 of us. :D You can see the evidences on the TweakScale thread.

@Shadowmage, Textures Unlimited and SSTUTools handle it but doesn't use it apparently. But I think you should be aware, as Add'On authors using Texture Unlimited and UI_ScaleEdit and knowing the source code can eventually ask you for help.

@allista, Ground Construction uses this on the Widgets for "Bulkhead" and "Length" on the DeployableKitContainer class. I'm pretty sure this is affecting you.

Cheers. (well, not exactly - I'm somewhat "liquided" with this. :sticktongue:)

11 hours ago, peteletroll said:

Anybody else having problems with UI_FloatEdit PAW entries in KSP 1.8? I'm getting white misaligned rectangles...

 

Ouch! I should had been here sooner! TweakScale has it, and I confirmed the behavirour testing with other Add'Ons on KSP 1.7 and trying them on KSP 1.8.

Edited by Lisias
tyop! Surprised?
Link to comment
Share on other sites

UI_FloatRange is defective on KSP 1.8. Too

This affects half the World. I can't even enumerate the victims here. Details on the TweakScale thread.

I made that in a rush (work time), I can be wrong - but the images I got appears to corroborate my thesis.

Guys, this is a way more serious and broad than I though.

Edited by Lisias
I typed that in a rush. :P
Link to comment
Share on other sites

3 hours ago, zer0Kerbal said:

both good news and bad. Good news, glass half full, silver pod lining - 1.8.1 might arrive all that much quicker! :P

We survived 1.4.0. We will survive 1.8.0.

But, boy, we will have some burning ears. :) 

I'm cooking dinner on mine! :sticktongue:

(The grumpyness factor is strong on this one!)

Edited by Lisias
EARS, YOU KRAKEN DAMNED AUTO-COMPLETE FROM HELL!!
Link to comment
Share on other sites

40 minutes ago, Lisias said:

We survived 1.4.0. We will survive 1.8.0.

But, boy, we will have some burning years. :)

KSP release history:

2018 Mar  6    1.4
2018 Mar 13    1.4.1
2018 Mar 28    1.4.2
2018 Apr 27    1.4.3
2018 Jun 21    1.4.4
2018 Jul 26    1.4.5
2018 Oct 15    1.5

 

Link to comment
Share on other sites

19 hours ago, peteletroll said:

So @Lisias, maybe we can try filing a bug, or even summon @TriggerAu! A hotfix is probably coming soon, so there's hope I guess.

Now I'm 90% confident to file a bug. But I would try some stunts on Windows first. It's not impossible that we are facing a glitch on cross-compiling.

The stunts I already tried are on TweakScale's Thread, and I did them on MacOS.

Link to comment
Share on other sites

2 hours ago, peteletroll said:

@Lisias, do you plan to file a bug soon? Probably UI_FloatRange, UI_ScaleEdit and UI_FloatEdit have the same root bug. I can file it for you too, maybe someone from @SQUAD can suggest the best way to get this fixed soon.

Please, do it. I neglected some Real Life duties, I will lack the time to do it properly - no keyboards on bathrooms. =D

Link to comment
Share on other sites

I'm trying to start learning to mod, and I've gotten kind of stuck on a simple 'Hello World'. The examples I've been following are old, so it may have something to do with that, but I've downloaded the latest unity, and am building with the .NET 4.7.2 framework. The KSP.log says it's loaded and reports no errors, but the mods do nothing. I added a second mod which adds a partmodule, and later on when it tries to load that into a part I modified, it tells me it can't find that module. So it's almost like KSP is loading the DLL, but then can't find anything in it. Here's the code:

using System;
using System.Diagnostics;
using UnityEngine;

namespace HelloWorld
{
    //[KSPAddon(KSPAddon.Startup.MainMenu, false)]
    public class Hello : MonoBehaviour
    {
        public void Update()
        {
            Debug.Log("Hello world! " + Time.realtimeSinceStartup);
        }
    }
}

namespace HelloWorld2
{
    /// <summary>
    /// My first part!
    /// </summary>
    public class HelloKerbinMod : PartModule
    {
        /// <summary>
        /// Called when the part is started by Unity.
        /// </summary>
        public override void OnStart(StartState state)
        {
            // Add stuff to the log
            print("Hello, Kerbin!");
        }
    }
}

It's real simple at this point, so I'm assuming there's something simple I'm doing wrong.

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.

 Share

×
×
  • Create New...