Cephei

The official unoffical "help a fellow plugin developer" thread

Recommended Posts

You are more likely to get an answer in kRPC thread than here.

Share this post


Link to post
Share on other sites

Thanks -- I was looking for that. The link to the kRPC forum from the kRPC git page is broken.

5 hours ago, sarbian said:

You are more likely to get an answer in kRPC thread than here.

Share this post


Link to post
Share on other sites

KSP 1.4.1 doesn't like my PNG textures.  Why?  The exact same textures worked fine in KSP 1.3, 1.2, 1.1, 1.0.  I've tried re-saving them several times with different editors, no go.

ixQu96I.jpg

Share this post


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

KSP 1.4.1 doesn't like my PNG textures.  Why?  The exact same textures worked fine in KSP 1.3, 1.2, 1.1, 1.0.  I've tried re-saving them several times with different editors, no go.

ixQu96I.jpg

Do you know whether you're using OpenGL or one of the Direct-things? I think I saw this on one of them but not the others.

Share this post


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

KSP 1.4.1 doesn't like my PNG textures.  Why?  The exact same textures worked fine in KSP 1.3, 1.2, 1.1, 1.0.  I've tried re-saving them several times with different editors, no go.

ixQu96I.jpg

Are they sized to a power of two ? 

  • Like 1

Share this post


Link to post
Share on other sites
1 minute ago, sarbian said:

Are they sized to a power of two ? 

Gimp says those black boxes are 20x20.

  • Like 1

Share this post


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

Are they sized to a power of two ? 

They are not!  I was unaware of this (new?) requirement.  Thanks, I'll try with 32x32.

Share this post


Link to post
Share on other sites
6 minutes ago, hab136 said:

They are not!  I was unaware of this (new?) requirement.  Thanks, I'll try with 32x32.

 You could also load the images manually rather then using the game database. 

I had this exact same problem with part commander, and solved it with manual loading.

@hab136, here is the code I'm using, it works nicely

 Log.Info("Loading image manually");

_imagetex = new WWW(KSPUtil.ApplicationRootPath.Replace("\\", "/") +  "/GameData/" + path + ".png");
Texture2D img = _imagetex.texture;
_imagetex.Dispose();

 

Edited by linuxgurugamer
  • Like 2

Share this post


Link to post
Share on other sites

Hello.

Does anyone know how to differentiate the overview of the KSC from, say, the management building scene?

I'm trying to make my plugin appear only in the KSC overview, the trackstation and in flight...

I tried with 

[KSPAddon (KSPAddon.Startup.FlightAndKSC, true)]
coupled with a little
UnityEngine.Object.DontDestroyOnLoad (this);
and some
if (HighLogic.LoadedScene.Equals (GameScenes.SPACECENTER) || HighLogic.LoadedScene.Equals (GameScenes.TRACKSTATION) || HighLogic.LoadedSceneIsFlight)

But it keeps showing up in KSC's building other than editors.

I tried to remove the DontDestroyOnLoad(), but once it's gone, it's gone for good...

 

I'm out of ideas, please send help :P

Share this post


Link to post
Share on other sites

@Askirkela My guess is that building others than editors and the tracking station are not scene, just screen on top of the current scene (ie the KSC). You can try to listen for event fired when those screen shows/hide : "GameEvents.onGUIAdministrationFacilitySpawn" for example. And hide/show your app accordingly.

Share this post


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

Hello.

Does anyone know how to differentiate the overview of the KSC from, say, the management building scene?

I'm trying to make my plugin appear only in the KSC overview, the trackstation and in flight...

The second param of KSPAddon is true if you want a plugin to start only once. So set it to false and remove the dontdestroyonload

Share this post


Link to post
Share on other sites

does anyone know how to chance the cost typ in the tech tree from 'science' to funds or specific science experiments?

like: crew report from launchpad will unlock basic rocketry node

or: 1k funds instead of 5 science will unlock the node

thank you!

Share this post


Link to post
Share on other sites

Hey all! Got a mod engine I made using NFE uranium as fuel but I cannot get an alternator to output depleted fuel for some reason. I've got the code for the alternator pulled off another liquid engine and just replaced electric charge with depleted. (With the proper names) what have I done wrong?

It's also a fuel tank with the rules for needing an engineer to transfer fuels if that matters?

Edited by Maxx

Share this post


Link to post
Share on other sites

I have just started dipping my toes into modding, trying to make some parts. For some reason this cockpit insist on coming being upside down and backwards, or if you will rotated 180 degrees about the x axis. I have tried rotating the part in unity, but that seems to do exactly nothing, and googling the issue only turns up results for how to rotate stuff in the SPH, which is not at all useful. Any Ideas of what I am doing wrong? There are some more images in the imgur album.

https://imgur.com/a/jyHzhP9

Figured it out on my own. Apparently it does not work to have the part tools in the mesh, needs to be in the "root" empty.

Edited by neistridlar
figured it out

Share this post


Link to post
Share on other sites

Hello there! I am new to creating mods, but I have already learned the basics of changing and adding functionality to parts. My question is How do you change the name of a module without changing the functionality of the module? Should I just create a new module, and if so, how? Also, is there a way to bundle multiple modules together so that they all fire with one action? And lastly, How do I make a module that generates a specific amount of a resources relative to another resource without actually using that second resource? Thanks a lot!

Share this post


Link to post
Share on other sites

In moving from 1.3.1 to 1.4.0 I've run into a problem with scrollable sections. 
I've got a simple GUILayout window with a GUILayout.BeginScrollView....GUILayout.EndScrollView section. In 1.3.x this worked as expected, but in 1.4.0 (also tried in 1.4.3) there are several issues;
1) the mouse wheel scroll is inverted, mouse wheel down results in scrolling up
2) mouse wheel scroll is very slow compared to how it was in 1.3.x
3) Main issue: there is an offset in where mousewheel scroll is detected. with the mouse over the top of the scrollable section it doesn't respond to the mouse wheel, but by moving the mouse down to about halfway down the scrollable section it then detects and responds to the mousewheel (and continues to detect and respond after the mouse has gone off the bottom of the scrollable area (by about the same offset as was needed to start detection at the top).  I'm also noticing that buttons (or things with on hover style changes) are behaving like the mouse is over them, when in fact the mouse is much lower down, but only while using the scroll wheel.  It's like using the scrollwheel results in the position of the mouse being interpreted incorrectly.

Has anyone else run into mouse wheel scroll related issues in 1.4.x and are there any know workarounds?

Share this post


Link to post
Share on other sites
7 minutes ago, katateochi said:

Has anyone else run into mouse wheel scroll related issues in 1.4.x and are there any know workarounds?

I don't have those issue in Antenna Helper (tested on last version recompiled against KSP 1.4.3 dll). The scroll view code start here if you want to have a look.

Share this post


Link to post
Share on other sites

I've made a little test mod that is just a window with a scroll view to check that it's not dependent on something else I'm doing, so this is my test code;
This is in 1.4.3 on Linux, and aside from this bit of code, nothing else non-stock is present.
 

using System;
using UnityEngine;

namespace ScrollTest
{
    [KSPAddon(KSPAddon.Startup.AllGameScenes, false)]
    public class ScrollTest : MonoBehaviour
    {
        public Rect window_pos = new Rect(100, 100, 310, 5);
        public Vector2 scroll_pos = new Vector2();
        public int window_id = 42;

        protected void OnGUI(){
            window_pos = GUILayout.Window(
                window_id, window_pos, WindowContent, "test", GUI.skin.window               
            );
        }

        protected void WindowContent(int win_id){
            if(GUILayout.Button("test")){
                Debug.Log("test clicked");
            }
            GUILayout.Label(scroll_pos.y.ToString());

            float scroll_width = 200f;
            float scroll_height = 200f;

            scroll_pos = GUILayout.BeginScrollView(scroll_pos, GUI.skin.scrollView, GUILayout.Width(scroll_width), GUILayout.MaxWidth(scroll_width), GUILayout.Height(scroll_height));
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.EndScrollView();
        }
    }
}

And this is the result: 
mousewheel scroll is not detected where you'd expect, but is detected (roughly) in the large red shaded box. and for added oddness, if you keep rolling the mousewheel while moving the mouse further down to the small red box the on hover effect for the 'test' button is shown.  So....it's like the mouse detection is inverted and transposed 
vepP6SR.png

Edit: removing the extra arguments to BeginScrollView doesn't change anything. with `scroll_pos = GUILayout.BeginScrollView(scroll_pos);` the same issue happens. 

Edited by katateochi

Share this post


Link to post
Share on other sites

Surround each one with a GUILayout.BeginHorizontal()/GUILayout.EndHorizontal().  Works for me.

Here is a link to some working code:  

https://github.com/linuxgurugamer/ToolbarControl/blob/b23b0106570b219b84e00b002d3623585fdcd160/ToolbarControl/BlizzyOptions.cs#L121-L198

Share this post


Link to post
Share on other sites
8 minutes ago, linuxgurugamer said:

Surround each one with a GUILayout.BeginHorizontal()/GUILayout.EndHorizontal().  Works for me.

Thanks for the tip.....but I still get the same issue.
This is the code now:

using System;
using UnityEngine;

namespace ScrollTest
{
    [KSPAddon(KSPAddon.Startup.AllGameScenes, false)]
    public class ScrollTest : MonoBehaviour
    {
        public Rect window_pos = new Rect(100, 100, 310, 5);
        public Vector2 scroll_pos = new Vector2();
        public int window_id = 42;

        protected void OnGUI(){
            window_pos = GUILayout.Window(
                window_id, window_pos, WindowContent, "test", GUI.skin.window               
            );
        }

        protected void WindowContent(int win_id){
            if(GUILayout.Button("test")){
                Debug.Log("test clicked");
            }
            GUILayout.Label(scroll_pos.y.ToString());

            GUILayout.BeginHorizontal();

            scroll_pos = GUILayout.BeginScrollView(scroll_pos);
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.Label("foo");
            GUILayout.EndScrollView();

            GUILayout.EndHorizontal();
        }
    }
}

and it has the same problem of mousewheel scroll being detected some way below the scrollable area (and inverted).

BUT, I just tried this same bit out in windows and it works fine, the scroll behaves exactly as expected.

Share this post


Link to post
Share on other sites

Oh,  I missed the Linux part, sorry.

Sounds like a Unity issue, maybe?

Share this post


Link to post
Share on other sites
17 minutes ago, linuxgurugamer said:

Oh,  I missed the Linux part, sorry.

Sounds like a Unity issue, maybe?

You off all people to miss the Linux part! :P
I guess it could be a unity issue, I always assume that it's something that I've done wrong!
If you have a moment, could you throw that bit of code into a test mod and see if you get the same issue in Linux?

Share this post


Link to post
Share on other sites
3 minutes ago, katateochi said:

You off all people to miss the Linux part! :P
I guess it could be a unity issue, I always assume that it's something that I've done wrong!
If you have a moment, could you throw that bit of code into a test mod and see if you get the same issue in Linux?

Believe it or not, I don't run KSP on Linux :D

Share this post


Link to post
Share on other sites
4 minutes ago, linuxgurugamer said:

Believe it or not, I don't run KSP on Linux :D

nope, I refuse to believe that @linuxgurugamer doesn't game solely on Linux....stop challening my preconceptions!!

  • Like 1

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