Cephei

The official unoffical "help a fellow plugin developer" thread

Recommended Posts

 

Hello, I know this is not that much plugin related, but when I was making engine today, I wasn't sure from the wiki and other sources how do the curves. I know how to do them, but I found many post that describes them differently. The engine have to have velCurve or VelocityCurve and AtmCurve or AtmosphereCurve, also does it need to have     

atmChangeFlow = True
    useVelCurveIsp = False
    useVelCurve = True
    useAtmCurveIsp = False
    useAtmCurve = True

these ones that aren't described anywhere?

Because when I set up the engine like this 

EDIT1: Eh and now when I tried the engine, I instantly get into space and game crashes...

 

   atmosphereCurve
    {
       key = 1 9000
       key = 0.5 8000
       key = 0.3 2000
       key = 0 0
    }
    atmChangeFlow = True
    useVelCurveIsp = False
    useVelCurve = True
    useAtmCurveIsp = False
    useAtmCurve = True
    VelCurve
        {
            key = 0 1 0 0
            key = 0.174927 0.9 0 0
            key = 0.204082 0.75 0 0
            key = 0.233236 0.55 0 0
            key = 0.262391 0.25 0 0
            key = 0.276968 0 0 0
        }
    }

 So does the VelCurve have the first number in Mach or in m/s because wiki says m/s and other forum topics Mach number.... I'm simply confused so can someone please describe it for me?

Thanks!

Toonu

Edited by Toonu

Share this post


Link to post
Share on other sites

@Toonu the crash is because it's case sensitive, you want velCurve not VelCurve.  I will attempt to give an explanation of what is what in your other thread.

Share this post


Link to post
Share on other sites
11 hours ago, blowfish said:

@Toonu the crash is because it's case sensitive, you want velCurve not VelCurve.  I will attempt to give an explanation of what is what in your other thread.

Thanks, sorry for the tread but I thought it will be more visible than just post there. Thank you for any help from you. :) 

Share this post


Link to post
Share on other sites

Does anyone know if it is possible to  ADD a UI_FloatRange to an existing KSPField?  What I am trying to do is have a "advanced" mode that has a slider for a value that is normally just a Read only field for normal users. For Development I would like a slider

I found this post describing a situation close to what I am trying to accomplish but am running into a problem with a Cast exception. 

I tried the following

        [KSPField(isPersistant = true, guiActive = true, guiActiveEditor = false, guiName = "TNT mass equivalent"),
        UI_Label(affectSymCounterparts = UI_Scene.All, controlEnabled = true, scene = UI_Scene.All)]
		public float tntMass = 1;

....
public override void OnStart (StartState state)
		{
                
            if (BDArmorySettings.ADVANCED_EDIT)
            {
              ((UI_FloatRange)Fields["tntMass"].uiControlEditor).minValue = 0f;
              ((UI_FloatRange)Fields["tntMass"].uiControlEditor).maxValue = 3000f;
              ((UI_FloatRange)Fields["tntMass"].uiControlEditor).stepIncrement = 5f;
....

It errors out with a  "System.InvalidCastException: Cannot cast from source type to destination type."

Thanks

Share this post


Link to post
Share on other sites
22 minutes ago, Benjamin Kerman said:

@gomker, I belive that you can put a tag in the KSPField

[KSPField(advancedTweakables = false, …)]
float myField;

https://kerbalspaceprogram.com/api/class_k_s_p_field.html

That can work, I would just need two fields though, I need it "seen" / readonly for regular float slider for Advanced so they developer can quickly change the field for testing.

I suppose it has to start with the UI_FloatRange

Share this post


Link to post
Share on other sites
1 hour ago, gomker said:

Does anyone know if it is possible to  ADD a UI_FloatRange to an existing KSPField?  What I am trying to do is have a "advanced" mode that has a slider for a value that is normally just a Read only field for normal users. For Development I would like a slider

I found this post describing a situation close to what I am trying to accomplish but am running into a problem with a Cast exception. 

I tried the following

        [KSPField(isPersistant = true, guiActive = true, guiActiveEditor = false, guiName = "TNT mass equivalent"),
        UI_Label(affectSymCounterparts = UI_Scene.All, controlEnabled = true, scene = UI_Scene.All)]
		public float tntMass = 1;

....
public override void OnStart (StartState state)
		{
                
            if (BDArmorySettings.ADVANCED_EDIT)
            {
              ((UI_FloatRange)Fields["tntMass"].uiControlEditor).minValue = 0f;
              ((UI_FloatRange)Fields["tntMass"].uiControlEditor).maxValue = 3000f;
              ((UI_FloatRange)Fields["tntMass"].uiControlEditor).stepIncrement = 5f;
....

It errors out with a  "System.InvalidCastException: Cannot cast from source type to destination type."

Thanks

You don't actually have a UI_FloatRange property on that field.  uiControlEditor will return the UI_Label you have defined.

Share this post


Link to post
Share on other sites

How can I play sounds from a sound file? Im trying to play a sound file but it does not work.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

namespace NodeAlert
{
    public class SoundPlayer : MonoBehaviour
    {
        FXGroup audioSource = null;
        
        public void PlaySound()
        {
            if (!audioSource.audio.isPlaying)
            {

                if (audioSource != null)
                { 
                    
                    audioSource.audio.Play();
                    if (audioSource.audio.isPlaying)
                    {
                        Debug.Log("audio playing");
                    }
                }
            }
        }

        public void LoadSound(string FXGroupName)
        {

                audioSource = new FXGroup("alert");
                audioSource.audio = Camera.main.gameObject.AddComponent<AudioSource>();
                audioSource.audio.clip = GameDatabase.Instance.GetAudioClip("NodeAlert/files/alarm.ogg");
               
                audioSource.audio.volume = GameSettings.SHIP_VOLUME;
                Debug.Log("Loaded");
                

        }
    }
}

The LoadSound function is called by Start and the PlaySound function is called by update.

Share this post


Link to post
Share on other sites

And where do you add your MonoBehaviour to an object ?

  • Like 1

Share this post


Link to post
Share on other sites
16 hours ago, sarbian said:

And where do you add your MonoBehaviour to an object ?

Thank you that was the problem it works now:)

Share this post


Link to post
Share on other sites

Hey guys

I'm searching for a way to access PartModule data from ships in construction (which exist as .craft file but has never been launched so not in persistent.sfs), is there something in the API that can help me ?

I guess I can manually parse each .craft file but I was wondering if those info were already stored somewhere in the game.

Share this post


Link to post
Share on other sites

Hello all

I'm trying to make an engine that runs on enriched uranium from NFE but i can't get thrust. It says EN depleted as reason for flameout but the craft has plenty. What have I missed? Is it because it's not really a fuel just a resource?

Share this post


Link to post
Share on other sites
On 1/31/2018 at 9:59 PM, Maxx said:

I'm trying to make an engine that runs on enriched uranium from NFE but i can't get thrust. It says EN depleted as reason for flameout but the craft has plenty. What have I missed? Is it because it's not really a fuel just a resource?

I'm seeing that EnrichedUranium has flowMode = NO_FLOW which means unless your engine part itself has EnrichedUranium in it, you'll get the EN depleted message because the engine can't draw any.

Edited by Booots

Share this post


Link to post
Share on other sites

Sweet thank you I'll see if I get it to fire later today!

Edit - It worked but I can't refuel it... Is there a way to Change the "FlowMode" within the engine or would I have to change the resource itself? I want to be able to mine and refuel the craft with said engine...

 

2nd edit - nevermind I missed the module to transfer fuel right above the tank part...sigh.

Edited by Maxx
Half blind.... it's funny cause I realy have one eye!

Share this post


Link to post
Share on other sites

Everything works with the engine. But I've got a weird thing on reentry the overheat meter on the engine panel (left) is tiny and just a letter C. When I mouse over it says text missing or some such (on phone can't see exact spelling) its by no means critical, the hovering part temp meter works still. Thoughts?

Share this post


Link to post
Share on other sites

Does anyone know how to access a parts "friendly name" - ie for instance "LV-909 "Terrier" Liquid Fuel Engine" rather than just "liquidEngine3"?

part.name returns the model name (liquidEngine3) - part.partName just returns "Part" and part.InternalModelName doesn't return anything at all.

Share this post


Link to post
Share on other sites
2 hours ago, severedsolo said:

Does anyone know how to access a parts "friendly name" - ie for instance "LV-909 "Terrier" Liquid Fuel Engine" rather than just "liquidEngine3"?

part.name returns the model name (liquidEngine3) - part.partName just returns "Part" and part.InternalModelName doesn't return anything at all.

It should be part.partInfo.title

  • Like 1

Share this post


Link to post
Share on other sites

Hey guys, I'm updating the KerbalX mod for 1.4.0, it uses UnityWebRequest and in KSP 1.3.1 I could call .isError on an instance of UnityWebRequest, but in 1.4.0 that method doesn't exist, but instead I can use .isNetworkError or .isHttpError.  

I could just make that change but then the latest version of the mod won't be backwards compatible with 1.3.1 and as it's just this one change I'd prefer to maintain a single version that supports 1.3.1 and 1.4.0.  Is there anyway to say something like;

bool request_error = false;
try{
    request_error = request.isNetworkError;
}catch{
    request_error = request.isError;
}

That won't compile against either version, but is there some cunning C# way of checking if a method exists before trying to call it and if not falling back to another method?

Share this post


Link to post
Share on other sites

Another question: It seems that textures used for this like the icon in the toolbar are now affected by the texture quality setting.  In 1.3.1 with the texture quality set to half res or full res the toolbar icons looked the same. In 1.4.0 with texture quality at half res the toolbar icons are, well, at half res. 
Is this intentional? is there a way to disregard the texture quality setting for a specific texture?

Share this post


Link to post
Share on other sites
9 hours ago, katateochi said:

I'd prefer to maintain a single version that supports 1.3.1 and 1.4.0.

Both versions uses a different Unity engine and it s not just a minor upgrade. Have different versions for 1.3 and 1.4. 

Some Unity calls changed their signature and while they compile without changes they will not work on both version.

Share this post


Link to post
Share on other sites
3 hours ago, sarbian said:

Both versions uses a different Unity engine and it s not just a minor upgrade. Have different versions for 1.3 and 1.4. 

Some Unity calls changed their signature and while they compile without changes they will not work on both version.

I did find a (rather messy) way using reflection to see if a method exists and then call accordingly, but that just raised further problems and resulted in clunky code pasta, so yes, I'll take your advice and have different versions. Thanks!

Share this post


Link to post
Share on other sites
Posted (edited)

I have looked through so much of the modding tutorials and API on doxygen. I have a few questions as I am really interesting in creating a mod that will hopefully add some very interesting features to the game.

1. I get the feeling that I need some .dll file in the actual KSP game folder somewhere to create a plugin. Where do I find it?
2. If (1) is true, will monodeveloper in Unity3D see the namespaces, classes, and variables allowing me to create my plugin directly in Unity3d? By this I mean when I type "KSPclass." Mono will give me all the options in that specific class.
3. Which Unity version is the current build for KSP after 1.4.1 (Unity3d 2017 1.3f1)?

Background: I have created a game in Unity and released it back in 2014ish. I am a beginner to intermediate level self taught C# and C++ programmer (with some knowledge of JavaScript). I will not be asking anyone to do anything for me which includes writing scripts for me since I am perfectly capable and excited about doing it myself. I may have some questions about how to access KSP classes and variables appropriately. If anyone is willing to work with a KSP modding noob on a PM basis for silly basic questions I would appreciate it. Also, I am tracking all the current EULA issues.

Edited by nightstalker101s
Grammatical Error, Found an Answer

Share this post


Link to post
Share on other sites
Posted (edited)
4 hours ago, nightstalker101s said:

I have looked through so much of the modding tutorials and API on doxygen. I have a few questions as I am really interesting in creating a mod that will hopefully add some very interesting features to the game.

1. I get the feeling that I need some .dll file in the actual KSP game folder somewhere to create a plugin. Where do I find it?
2. If (1) is true, will monodeveloper in Unity3D see the namespaces, classes, and variables allowing me to create my plugin directly in Unity3d? By this I mean when I type "KSPclass." Mono will give me all the options in that specific class.
3. Which Unity version is the current build for KSP after 1.4.1 (Unity3d 2017 1.3f1)?

Background: I have created a game in Unity and released it back in 2014ish. I am a beginner to intermediate level self taught C# and C++ programmer (with some knowledge of JavaScript). I will not be asking anyone to do anything for me which includes writing scripts for me since I am perfectly capable and excited about doing it myself. I may have some questions about how to access KSP classes and variables appropriately. If anyone is willing to work with a KSP modding noob on a PM basis for silly basic questions I would appreciate it. Also, I am tracking all the current EULA issues.

1. KSP_x64_Data folder

2. no

3.yes

Edited by Next_Star_Industries
  • Like 1

Share this post


Link to post
Share on other sites

@nightstalker101s If you are asking if you can add a reference to a KSP dll to a Unity project (for use in the Unity Editor) then the answer is no. Unity just won't load anything with a reference to KSP's Assembly-CSharp.dll (I think maybe this is because of some kind of circular referencing, or it just doesn't accept a reference to a dll that was made in Unity). For a regular C# project you can do that, but for anything to be used in the Unity Editor it won't work.

You can create a new project with custom scripts imported into Unity, but for it to work I think you have to create it outside of Unity (ie don't add scripts directly through your Unity project, instead make an assembly, compile it, and import the .dll into your Unity project), then you can use it for anything you make in Unity (like a UI). But that assembly can't contain any references to any KSP assemblies, which makes everything a pain to work with.

There is a tutorial for how to work-around this for a UI, it's not that hard, mostly just tedious:

 

  • Like 1

Share this post


Link to post
Share on other sites
Posted (edited)

I'm just getting started with a project that will use a mobile device to interact with KSP via a socket connection and kRPC. I'm using the socket interface because I can't use the provided client framework (at least not easily) on all the different platforms I'm targeting (iOS, Android, macOS, and Windows).

I already have working code (in Delphi on Windows, Mac, Android and iOS) that makes the connection to kRPC and processes the protocol buffer data, but am having problems figuring out the next steps, namely how to figure out the names of the other available services and procedures that can be accessed using the socket interface in kRPC. I've tried using the KRPC.GetServices procedure, but it returns over 300KB of data -- is there a way to just enumerate the available services first, and then query them individually to get more info?

Any info, advice, or comments are welcome. Thanks!

 

Edited by ByteArts

Share this post


Link to post
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