Jump to content

[WIP] Part sorting mod


Atanvaryar

Recommended Posts

Im running 19.111.44 ( I cant remerber all the numbers in it but im rnning the latest anyway ) on windows 7 64

Yes i usually do backups , i thought thr restore button was for that hehe =)

And i didnt ran it as an admin so i think thats why i got those missmatches.

Sorry for the spellning last post haha.. What i meant was, besides those empty cfg files this plugin helped me a great deal in building in vab and keeping track of my own modparts so thanks for that ^^

Edited by ahappydude
Link to comment
Share on other sites

Damn! Maybe that is the cause? I've been running it on 19.1 and I thought that was the latest game version O_o

Well, yeah, the restore button is exactly for that and so far it worked flawlessly for my, except a couple of situations with special symbols in the parts name. You know, like the apostorophe (") or brackets [}.

But I thought I fixed that in version 0.2 since I rewrote the way the program saves the stock folder and part names.

I'm curious, could any one of you use skype screen sharing maybe? To show me what happens when you run the sorter? It will be a lot more visual for me to understand what exactly happens.

Edited by Atanvaryar
Link to comment
Share on other sites

Nooope, I'm running 19.1. In my head, 5 comes after 0 :)

Edit: I downloaded the dropbox version, if that matters :P

Edit 2: Everything is broken now. I will re-install everything tomorrow.

Edited by Hocki
Link to comment
Share on other sites

Thanks for the response dude ^^ In the log it seemed to load the part correct at first, but then it made an double or something like that ant that one was "empty" But i havnt tried running as admin i will report back later on =)

Link to comment
Share on other sites

@Amaroq

1. It doesnt fix sfs files yet, nor does it fix craft files, but I am working on it. I realise, that many of you people out there might have a long persistence file behind you, so this is important.

2. I might mold this into a full fledged editor, but as for the sorting parts by diameter, I'm afraid it's not quite possible for me at this moment. Not everyone points out the diameter if the parts in the CFG, and those that do - often make it in a little bit different way than the next guy. I'm currently working on a more or less consistent accuracy of getting the real part diameter.

3. This is a standalone version for PC. I have no plans to develop for the mac at this moment, since I am not that familiar with the Mac OS scripting language, even less so with Cocoa. I might get into it when I get the PC version more stable.

4. The older parts that use the "Category=2" and others are still correctly placed in the gui, at least that is what I found out playing with the numbers. The categories go from 0 to 6 and stand for:

0 - Propulsion

1 - Control

2 - Structural

3 - Aero

4 - Utility

5 - Science

6 - Pods

Link to comment
Share on other sites

@Atanvaryar, thanks for the response - please take my suggestions as just that, observations which you may accept or reject at your preference! Your responses on #1 and #3 are pretty much what I expected; you'll find a lot more user-adoption, I think, once you have #1 sorted.

Re: #2, yeah, I couldn't see a quick way of figuring out diameter from .cfg, myself, which is why you've gotten an earlier break on this than I would have. What I was imagining was a two-step process, e.g., the application makes a "best guess" and generates some simple format (tab delimited? comma delimited?) which maps "from" and "to", probably sorted by the resulting "to" name, and then allowing the user to edit as they see fit before applying. More "hands on", I guess, aimed at letting the user really get their hands dirty to create the sort order they would prefer. So, if I wanted to sort by diameter, that'd be up to me to accomplish in my edit of the resulting names.

Re: #4, I think ISA MapSat should be Science but wound up with 2 or 3, there's a couple others like that. I know they get into a tab correctly, just not necessarily the right tab. Since your goal is supporting people with a lot of mods, "correcting" a few of the "better known" mods might or might not fit in scope.

Link to comment
Share on other sites

What are you doing that breaks craft files? I thought I remember someone saying you can rename the part folders without affecting craft files and yet that still changes the order they are loaded and hence displayed in the Parts list.

Link to comment
Share on other sites

@grom - as of right now, craft files are linking directly to a part name. so if you change the part name ingame, but do not change the link to the part in the craft file, the craft file tries to find a non-existent part as far as the craft mechanics go.

Right now I am working on some parser code to change the part links in the craft/sfs files. The craft files are staying broken only until you restore the original part names though, so it should be pretty safe to start a new game and play around, and then restore part names to enable craft files again.

@amaroq - I am working on a craft/sfs file update method right now, although things aren't coming along very smoothly. But I'll figure it out. As of right now, I can add a simple hack for people to use their own sorting order as they wish.

Thing is, I create the reverserename.ini file when you actually click the [sort] button to guarantee that it will have a reverse rename order if anything fails (although it seems access rights to the folder can still screw that up).

I can create a rename file beforehand, when you scan for parts, but then you will have to manually plow through a file with this kind of syntaxis to sort things out:

Part ingame name|Part category|Part CFG name|Part folder name|Part renamed to

Advanced Canard|Aero|AdvancedCanard|advancedCanard|Aero_advancedCanard_Advanced_Canard

Advanced S.A.S Module|Control|advSasModule|advSasModule|Control_advSasModule_Advanced_S.A.S_Module

Standard Control Surface|Aero|StandardCtrlSrf|Ailerons|Aero_Ailerons_Standard_Control_Surface

Tail Connector|Aero|airplaneTail|airplaneTail|Aero_airplaneTail_Tail_Connector

XM-G50 Radial Air Intake|Aero|airScoop|airScoop|Aero_airScoop_XM-G50_Radial_Air_Intake

Only thing that bugs me in this approach, is that I strive to make a more or less fully automated tool for people, who often add/remove parts to their installation, like I do.

And manually plowing through the list every time is really a downside, especially if you have anything above 10 parts :)

But I'll think it through, I might come up with an idea of how to enable the user to intervene with the name generation process maybe...

All in all, thanks to all of you for the comments and reports. I'll do some more testing with your outlines situations for the next release.

Edit: @Grom: I have previously tried renaming just the folder, but it was no good. Maybe it was an old version of the game or something. I have tried it now and it actually worked O_o

Thanks for the tip. I think this will make things a lot more easier for me. Next release will include this, and it will definitely make thing more stable and less buggy for you people!

Edited by Atanvaryar
Link to comment
Share on other sites

For part diameters, you might also include a parser to look at the part's current folder and partnames. I know that NovaPunch and a few other packs list the diameter in the folder/part names.

Any idea when .craft file support might become reality?

Link to comment
Share on other sites

Here is some really simple php code for reading the config files:

function readCfg($filename) {
$stack = array();
$node = array();
$fp = fopen($filename, 'r');
$lineNo = 0;
while (($line = fgets($fp)) !== false) {
$lineNo++;
$line = trim($line);
if ($line === '') {
continue;
}
if (preg_match('|^//|', $line)) {
continue;
}
if (preg_match('/^\s*{/', $line)) {
$stack[] = $node;
$node = array('_section_' => $misc);
} elseif (preg_match('/^\s*}/', $line)) {
$type = $node['_section_'];
unset($node['_section_']);
$name = $node['name'];
$parent = array_pop($stack);
if (array_key_exists($type, $parent)) {
if (array_key_exists(0, $parent[$type])) {
$parent[$type][] = $node;
} else {
$existingNode = $parent[$type];
$parent[$type] = array($existingNode, $node);
}
} else {
$parent[$type] = $node;
}
$node = $parent;
} elseif (preg_match('/=/', $line)) {
$pos = strpos($line, '=');
$key = trim(substr($line, 0, $pos));
$value = trim(substr($line, $pos + 1));
if (array_key_exists($key, $node)) {
if (is_array($node[$key])) {
$node[$key][] = $value;
} else {
$existingValue = $node[$key];
$node[$key] = array($existingValue, $value);
}
} else {
$node[$key] = $value;
}
} else {
if (preg_match('/{$/', $line)) {
$misc = rtrim($line, '{');
$stack[] = $node;
$node = array('_section_' => $misc);
} else {
$misc = $line;
}
}
}
fclose($fp);
for ($i = 0, $n = count($stack); $i < $n; $i++) {
$type = $node['_section_'];
unset($node['_section_']);
$name = $node['name'];
$parent = array_pop($stack);
if (array_key_exists($type, $parent)) {
if (array_key_exists(0, $parent[$type])) {
$parent[$type][] = $node;
} else {
$existingNode = $parent[$type];
$parent[$type] = array($existingNode, $node);
}
} else {
$parent[$type] = $node;
}
$node = $parent;
}
return $node;
}

Link to comment
Share on other sites

Hi Atanvaryar. Looks like you and I got on the same kick at about the same time. I also became interested in reordering the parts lists and decided to create a utility to help. I really like your strategy of automatically determining categorization, this is something my app does not do. I will download your utility tonight if I have time and try to put it through its paces.

Check out my part order utility here:

http://forum.kerbalspaceprogram.com/showthread.php/27541-Part-Order-Utility-Kerbal-Orderly-Parts

Link to comment
Share on other sites

  • 1 month later...

I am running this within Windows 8.

The program starts correctly but when I try to make an .INI file an error is thrown.

Line 1985: Error: Subscript used with non-Array variable.

It may be helpful to know that I am running this program inside of a Virtual Machine that has access to the host file system. The program is physically located in the game folder on the host, but executed within the VM. (You wrote this with a language that requires I run it within Windows... so... this is the only way I can get this application running) Theoretically the file structure is the same, and being as the application seems to be designed to run within the current directory, the actual location of the game should not matter as long as the directory structure is the same.

See the attached screenshot:

Screen%20Shot%202013-06-22%20at%201.42.31%20AM.png

This is the only program that I have been able to find that will auto sort parts with some level of proficiency. I'd like to be able to make use of it. :)

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