Jump to content

Pipe Installer [Help or Mod Request]


APlayer

Recommended Posts

So, where do I start...?

Well, a while ago I tried playing with the stock setting "Resource Transfer obeys Crossfeed Rules" or something like that, as I figured this would add an interesting flavor of realism. And guess what? Stations become totally impossible! So I figured I'd need a way to add resource crossfeed to any part. But that itself would have been totally boring, as you could just add it everywhere. I decided to make this cost money and mass, just as normal pipes do. The only problem is, I know no C#, and currently do not intend to learn it. I am using Python, PHP and JavaScript until I feel like I am familiar enough with them to move on.

TL;DR: I, a person with NO knowledge in C#,  want to do a plugin that adds a button "Install/Remove Pipes" which would toggle crossfeed for some cost and mass.

I started a bit, but it does exactly nothing... Could someone point me at what to do?

 

C# code, should add a right click GUI button in the Editor to all parts:

using KSP;
using System;
using System.Collections.Generic;
using UnityEngine

namespace PipeInstaller
{
    public class PipeInstaller : PartModule
    {
        [KSPEvent(guiActive = false, guiActiveEditor = true, active = true, isPersistant = true, guiName = "Install Pipes")]
        public void InstallPipes()
        {
            this.ModuleToggleCrossfeed.isEnabled = true;
            this.mass += 0.05;
            this.cost += 1000;
            Events["InstallPipes"].active = false;
            Events["RemovePipes"].active = true;
        }

        [KSPEvent(guiActive = false, guiActiveEditor = true, active = false, isPersistant = true, guiName = "Remove Pipes")]
        public void RemovePipes()
        {
            this.ModuleToggleCrossfeed.isEnabled = false;
            this.mass -= 0.05;
            this.cost -= 1000;
            Events["InstallPipes"].active = true;
            Events["RemovePipes"].active = false;
        }
    }
}

 

MM patch to go along with it, should add a ModuleToggleCrossfeed to all parts:

@PART[*]:HAS[!MODULE[ModuleToggleCrossfeed]]
{
  MODULE[ModuleToggleCrossfeed]
  {
    crossfeedStatus = false
    toggleEditor = false
    toggleFlight = false
  }
}

 

Of course, if this code is bad beyond any hope and someone feels like it, it would be nice if they took over this idea and made a proper mod from it. I really just wanted to add myself a little feature, but I wouldn't be able to properly maintain or expand this mod, after all.

 

Thanks, any help is appreciated! Although, I ask not to go too deep into technical details or vague hints, because, as stated above, I know next to nothing in C# and even less so in KSP modding.

Link to comment
Share on other sites

18 hours ago, Jenyaza said:

Maybe you want this?


crossfeedStatus = false //  don`t know what is means, better to test it
toggleEditor = true     // looks like this must allow toggle in editor, may not work until first = true
 
 

I didn't come to test crossfeedStatus because I never came far enough for it (I wanted the GUI first). However, I suspect, or rather I hope, it is whether crossfeed is enabled. I did some quick test using craft files, and it looks like that's indeed it.

toggleEditor is a stock GUI toggle, which I have to disable because I want to implement my own. Basically what I do is hide all stock GUI related to this and use my own, which, besides controlling crossfeed, also adds mass and cost.

Thanks for the advice, though.

Link to comment
Share on other sites

Some research and luck led me to finding this: TweakableFuelPumps by Linuxgurugamer.

I see it is doing a lot of the things I need (most notably it allows me to enable crossfeed from a button). So I ask, if anyone has time, if they could explain me the relevant pieces of code. I actually PM'ed Linuxgurugamer about it, but I guess he's been too busy, so I figured I'd ask here, as someone else might explain it too.

Thanks a lot in advance.

 

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