Jump to content

[WIP] Part sorting mod


Atanvaryar

Recommended Posts

Version updated. Now 0.2 Please download new version.

Now sorts structural parts too, specifically decouplers, separators, faierings and nose cones.

I've also done some optimizations. Now it should more reliably rename parts with special symbols in their names, like the [LSI]CargoBay pack.

As an added bonus, I changed the way the parsing algorithm works, so now it should be a little bit faster. Testing on a 1000 parts folder I got about 10-15 seconds faster times compared to first version.

Please report any bugs you find, and test the hell out of this :) I can't possibly test all packs. Currently my base tests run on KW Rocketry and Nova Punch, as those seem to be the largest and most popular.

I've also added a video demo of how this works. And proof that it actually works :)

Hello fellow space travellers!

I have recently picked up KSP, and even though I've been only playing it for a couple of days now I just love it.

I do have one problem with it though, and that is the fact that all the parts in the building menu are mixed up. Especially when you are using different part mods (think of Nova Punch or KW Rocketry). When those things add a tonn of engines and fuel tanks and other stuff the task of finding something you need can be simply daunting.

Of course, in some way this can be solved by the Part Filter mod I was pointed to in the Steam forums. But then again, it only works if you know what to look for, which is not tha case for me, and maybe a lot of other new palyers.

So I figured out the way the game sorts parts and then sat down and threw together a little mod, for personal use mostly, but maybe it will be usefull to anyone else.

I bring you - "The Part Sorter". Rofl. I need to think of a cool name, but seriously though. It's just a small program I build using AutoIT. What it does is, it parses all the parts that you have installed in your parts folder. Saves their initial information and then renames the folders and part names in the part.cfg files. The process is fast and totally reversible. This is how it looks:

P5OfZFN.jpg

When you launch the program, press [Create INI]

0BMEYkF.jpg

After a very short while (well, depending on how many parts you have installed) it will create an INI file with all settings saved and new names generated for all installed parts.

This can take from as little as 1-2 seconds if you have only the stock parts, to as much as 10-15 seconds when I tested it with over 500 parts inside the game folder.

Now you just press the [sort] button.

Here is how it looks before and after:

THTRIlu.jpghyybhm3.jpg

As you can see, the parts are a lot more readable now. This also helps a lot, if you want to remove some part that you don't want, but cannot bother to search through all the folders for it if you don't know exactly where it is at.

You can now just use the in-game part name to search for its folder.

Now, this isn't all. The names you get after sorting aren't just for the lulz. My script analyzes parts for what they are and generates specific names for specific parts.

For example, on the left you can see the stock Mark1Cockpit, Mk1-2Pod, mk2LanderCabin and probeCoreOcto. If you look on the right, you will see that they are now called Pods_Cockpit_Mk1, Pods_Pod_mk1-2, Pods_Lander_Mk2 and Pods_Probe_OKTO respectively. So it also differs parts in the same category.

Currently I have more or less finished this functionality for the Pods and Propulsion categories. In propulsion it sorts ALL engines by fuel-type and then thrust, and fuel tanks by fuel-type and tank capacity. I tested this with Nova Punch and KW Roketry mods - all stuff is sorted correctly, and that is over 200 new parts in the game, easy to access and intuitive to find.

Now, when you want to add new mods, just press the [Restore] button, and everything is back to the way it was. You can now add new parts, create a new INI and sort them all again.

QiNBzhE.jpg

I will be very gratefull if someone could try this out and comment on it. I'm pretty sure it's usefull not only for me. I will be working on finetuning the Propulsion category and adding other part categories too. I might even make t able to sort parts by diameter, just need to figure some things out first.

Anyway, give it a go and let me know if you like it. It works good in tandem with the Part Filter too.

Cheers.

Download Link: DropBOX

Download Link: SpacePort

Edited by Atanvaryar
Updated download link
Link to comment
Share on other sites

Of course! Otherwise it would serve only cosmetical purposes of finding the parts in the parts folder :)

EDIT: Ok, I have found a potential issue for people that use .craft files, like complete ships or subassemblies - this mod breaks them, because the .craft files refer to old part names.

I will be working on a fix this weekend. I guess I will have to parse the craft files too if I want them to work >.<

Edited by Atanvaryar
Link to comment
Share on other sites

Interesting and very useful for sorting. However, I had a non-part file in the parts folder for some reason :confused: and it caused it to throw an error while sorting. The good thing is it did rename the parts and the part folders; but upon reopening, the parts sorter did not realize that the sorting had already been completed and gave me no option to restore to the original names. Leaving my parts stuck with the new names. Attempting to run it again left me with "Aero_Aero_deltaWing_Delta_Wing_Delta_Wing". Perhaps if it throws an error then force it to undo the sorting?

I used a backup install just in case something like this happened; so no worries. It's not a big deal as you shouldn't really have random stuff in the parts folder anyway lol. Otherwise this thing is really useful!

Link to comment
Share on other sites

Thanks for the comment! I will definitely look into the error reactions over the weekend. This is still just the first release which I threw together in two days so... it is to be expected to have some flaws :)

This weekend I'll try to finish the structural category, which is the most daunting task right now because of a TONN of stuff there that is very difficult to differentiate based on CFG files.

Also, if all goes well, maybe I will figure out a way to sort the part diameter for those parts that have it in the description in one way or another.

Link to comment
Share on other sites

Hey, Toastify, here is the link to the part you might be interested in. It's all commented to help you figure out what's going on. It's on pastebin.

source

I don't know if it will help you though, since it's written in autoit script language, not in C# (which you are more likely to be using). Let me know if you have a ny questions or if I can help you out with anything.

I'm by no means a pro-programmer, but I can figure stuff out on the way pretty quickly.

On a side note. I'm thinking of moving the part sorter codebase to C# myself. It should help with some issues when part names use INI-file unfriendly names, like using "[]" in them.

Link to comment
Share on other sites

If anyone is using this - please leave some feedback. I am improving things on the go right now, but I need comments on what kind of problems you have with this mod (and surely you must have SOME problems... there aren't andy bug-free programs. Ever. :) )

Link to comment
Share on other sites

Hey, I love this idea, and its a direction I'd been thinking of going as well. Some questions, though:

1. Will it also fix my .SFS files? I have a career operating with something like 40+ flights-in-progress that I wouldn't want to render inoperable due to renaming my parts.

2. Any provision for letting me specify the part names? By this, I mean, let's assume my preferred sort-order and your preferred sort-order are different, whatever that might look like -- you might want to sort "Propulsion" such that all the engines are first, then all the fuel tanks, where I might want to sort it so that all 0.625-m parts are top, then all 1.25m parts, etc.

3. This is a standalone application? Is there Mac support? Or is it a plugin?

4. There are a number of older mods / parts, and even some parts in the default game, which are miscategorized. They're on the wrong tab. Any provision for fixing those? For the most part, its "category=2", "category=3", etc, which just need to get pushed out to the named version.

Link to comment
Share on other sites

I dont know how much you tested it, but after restoring your program screwed up my parts folder and created alot of empty cfg files so you know :P:) Ok now im irritated, five times started the game five times i get the empy cfg error even thou i restored it and the cfg fil isnt empty.

And the loading is slower..

Edited by ahappydude
Link to comment
Share on other sites

@ahappydude, - man, I'm really sorry it screwed up for you. I dunno what's wrong... I've tested this for a few days, constantly switching out all kinds of parts from the popular mods and never had any issue with it.

What version of KSP do you use? the Steam version or the KSP Store? What version of OS do you use?

A few screenshots of the game error would be cool too. Or a video if you can record it.

I've only tested it on my PC, which is a Windows 7 64bit, KSP store version, extracted to my desktop.

The only thing that comes to mind, is that maybe the game has somehow lost the rights to access the parts folder. Don't know how that would happen though. But check it out - right click Parts folder, go to Security tab, and go through the permissions.

Give me as much information as you can and I'll do everything I can to help. I mean, seriously, 160 people downloaded it and only three complained. But none provided any specific information as to what went wrong >.<

Maybe try launching the game with admin rights, just to be sure (if you are using Windows Vista, 7 or 8)

Link to comment
Share on other sites

I didnt mean to sound angry sorry for that just got a bit irritated haha , hm i dont know first version worked better for me. Still i think this is much needed for those with many parts and so on, so keep on the good work =) cheers for the reply

Link to comment
Share on other sites

I dont know how much you tested it, but after restoring your program screwed up my parts folder and created alot of empty cfg files so you know :P:) Ok now im irritated, five times started the game five times i get the empy cfg error even thou i restored it and the cfg fil isnt empty.

And the loading is slower..

I have the exact same problem, but with the Hitchhiker Storage Container. :(

Edit: The first time I ran it I had 396 parts, the second time, I had 401, but I hadn't installed anything between those runs.

Edit 2: Every stock part stops the loading.

Edit 3: Almost every stock part stops the loading.

Edit 4: Nope, Every stock part stops the loading.

Edit 5:Nope, random parts stop the loading.

Edited by Hocki
Link to comment
Share on other sites

@ahappydude:

Well, you are welcome.. I guess... I hope the next version will be better for you. Oh, and please - this is an alpha still, so backup you game first.

As for me, I have my KSP_win on my desktop and I tested it for performance with up to 500 parts ingame (when I decided to rewrite some code to test out the performance change, if any), and up to 1000 parts for just the rename / restore process.

Damn, I even tried just now multiple rename - launch - restore launch sequences with 500 parts installed - everything works.

YOu didnt say which version of the game you were running and on which OS?

@Hocki:

Could you please be a bit more specific about the part numbers? Are you saying, that after you ran a rename - restore you have more parts than you had originally?

That is only possible if you have some issue with access rights to the game folder or to the part sorter. Specifically, the part of code that renames the folders is actually moving the folders to the same location but with a new name. Could you possibly test it out and narrow down the extra parts? They could be something with special symbols in the folder or part name. I can give you a version of my sorter with some extra debug calls which can help you narrow down the issue, if you are willing to lend me a hand here too :)

Edited by Atanvaryar
Link to comment
Share on other sites

I'm running .19.5 on Windows 8. The Windows 8 part shouldn't matter.

Edit: But it's okay :) I have all the mods I had installed still on my PC, so it won't take long to re install everything :)

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