Jump to content

[1.8.x-1.12.x] Module Manager 4.2.3 (July 03th 2023) - Fireworks season


sarbian

Recommended Posts

This argument seems purely subjective to me. Don't get me wrong, but please elaborate or retract. Cause if one-liners are bad, then bigger half of I.T. world is doing bad thing many times per day (for example using shell, chaining commands with pipes in shell etc), and it is our duty to warn them, right?

Oh please. Is shell the only argument you found ? Is a endless piping of awk, grep, sed and whatever a proof that one-liner are a good idea ? I wrote such script and I loathe each time I have to edit them. The fact that one liner exist does not make them a good idea.

And I am yet to work in a company that promote a code formatting that pile instruction on the same line with ; to separate them. Have a look at the google style guide guide to see for yourself that this is the usual case.

What Murdabenne said summarize perfectly what I think.

pack_rtr : 2.6.0

Edit : Perl hater hates Perl because some Perl lover consider that writing obscure code is awesome even if they can't debug their own code 2 month later.

Edited by sarbian
Link to comment
Share on other sites

This argument seems purely subjective to me. Don't get me wrong, but please elaborate or retract. Cause if one-liners are bad, then bigger half of I.T. world is doing bad thing many times per day (for example using shell, chaining commands with pipes in shell etc), and it is our duty to warn them, right?

- - - Updated - - -

Excuse me, but (increasing line count) != (readability will increase linearly). Quite often it's quite the contrary (as screen space is limited and you need to scroll when the code is really sparse, so you can't read entire section in one glimpse, and risk distraction.

Besides, AFAIK Perl haters hate Perl because of regexps, which are dense; but You do not advocate removing regex support from MM, do You?

There is a difference between one liners and one line code.

This is a one liner (in C++) and it is perfectly fine:

if (x > 5) { x--; }

This is one line code... and it is evil.

if (x > 5) { for (int y=10; y< 100; y++) { cout << y; if(y % 2 > 0) y--; } }

That gave me a headache just typing it. I see stuff like that all the time, it's sad how many programmers do that. I think some programmers do it on purpose, which is even more sad.

Link to comment
Share on other sites

if (x > 5) { for (int y=10; y< 100; y++) { cout << y; if(y % 2 > 0) y--; } }

Now if that's only one line of this type present, then yes, it is evil.

Now imagine You have 80 cases of that, only some arg to if or for are different, and there's pattern between args. Imagine there's no better way to express Your task, only using fors and ifs like in Your example.

It can be indeed better to just form 80 one-liners like that directly below one another, and then the person who'll read this code will see something akin to table, with distinct impression on changing args (human eye is known to be good at that).

To repeat, forced impossibility to pack some code denser vertically (or horizontally, for that matter) does not immediately mean that the code will be inherently more readable.

To put it another way, readability of code is not depended on line count in said code.

I do not really know what else to say - it's kinda obvious.

As to Google guidelines, I guess that You know that they're controversial in many small places. Nothing utterly fundamental, and I agree that the general vibe is mostly right in 'em, but in almost every organization that I worked for (and I've been working with major players), coding style guidelines - even if based on Google's - were slightly different, and sometimes IMO better.. So, Your implication about that being like golden standard will not work for me, at least.

What always worked for us, though, is the process of peer code review right before it goes to repo. Unreadable code will not be reviewed, or will be rejected on the premise of its unreadability by peers. That simple.

Returning to my problem with @MODEL,* { @texture,* ^= : - I've read a few pages back that I'm not alone who stumbled upon that one...

Edited by cipherpunks
Link to comment
Share on other sites

Where did I implicate it s the golden standard ? It s one that is easy to find and while it has some "flaw" it does a great job of laying a clear style.

Here is an other one https://www.kernel.org/doc/Documentation/CodingStyle. To quote it : "Don't put multiple statements on a single line unless you have something to hide. Don't put multiple assignments on a single line either."

You love one liner ? Fine. I hate them, will not have them in my code and consider them a pain; as I expressed before. That is MY coding standard. Now go read all my code to find a one liner so you can nitpick once more.

Link to comment
Share on other sites

Now if that's only one line of this type present, then yes, it is evil.

Now imagine You have 80 cases of that, only some arg to if or for are different, and there's pattern between args. Imagine there's no better way to express Your task, only using fors and ifs like in Your example.

It can be indeed better to just form 80 one-liners like that directly below one another, and then the person who'll read this code will see something akin to table, with distinct impression on changing args (human eye is known to be good at that).

To repeat, forced impossibility to pack some code denser vertically (or horizontally, for that matter) does not immediately mean that the code will be inherently more readable.

To put it another way, readability of code is not depended on line count in said code.

I do not really know what else to say - it's kinda obvious.

As to Google guidelines, I guess that You know that they're controversial in many small places. Nothing utterly fundamental, and I agree that the general vibe is mostly right in 'em, but in almost every organization that I worked for (and I've been working with major players), coding style guidelines - even if based on Google's - were slightly different, and sometimes IMO better.. So, Your implication about that being like golden standard will not work for me, at least.

What always worked for us, though, is the process of peer code review right before it goes to repo. Unreadable code will not be reviewed, or will be rejected on the premise of its unreadability by peers. That simple.

I'm sorry, I don't mean to offend but this isn't a coherent paragraph. I have no idea what you are saying here.

Link to comment
Share on other sites

This argument seems purely subjective to me. Don't get me wrong, but please elaborate or retract. Cause if one-liners are bad, then bigger half of I.T. world is doing bad thing many times per day (for example using shell, chaining commands with pipes in shell etc), and it is our duty to warn them, right?

- - - Updated - - -

Excuse me, but (increasing line count) != (readability will increase linearly). Quite often it's quite the contrary (as screen space is limited and you need to scroll when the code is really sparse, so you can't read entire section in one glimpse, and risk distraction.

Besides, AFAIK Perl haters hate Perl because of regexps, which are dense; but You do not advocate removing regex support from MM, do You?

Oh, please dude. I write much less code that sarbian does but I've done it for years and I document even quick test scripting and code (even Perl), and I make it readable. You obviously have never had to read or deal with spaghetti legacy code (I have) and I don't want to put that on anyone I share or pass on my code or scripts to, including meself 1 month or decade later. You obvious don't care and have been brought up to assume such a stance is correct. Learn to evaluate yourself.

Link to comment
Share on other sites

Increasing line count for one liners does increase readability - please stay on your original context and topic - raising things not asked or in context does not help your case. One liners that are dense need to be cleaned up for readability if you want to have maintainability. Sufficiently spreading out the density of the symbols can ease reading for comprehension in something as potentially cryptic as heavily punctuated (symbols) code. Prime example of this is lisp and its parentheses. Or APL (a solid language for parallelism ahead of its time) whose primary issue was density and readability. Or, less computer related, mathematics proofs (especially modern algebra if you've had a course in that). Experience, and basic software engineering competency both reinforce this concept.

So, if you intend anyone other than yourself to see it, make a concession for legibility for others who may not see it the way you do. And if you believe even remotely that you might have to come back to it, cold, in 6 months or 2 years, make a concession to maintainability for yourself - or better yet, for others. Expand the one-liners out to acceptable format you see in most places for that code - common courtesy goes a long way. And with that, Im done responding to the "retract" demand. Sorry for the diversion.

Edited by Murdabenne
Link to comment
Share on other sites

I can't figure this out for the life of me. I just now updated to 1.0.4 will all up-to date mods but I'm suffering a CTD during loading when MM is installed, I tested it without MM and it loads fine though.

I'm running 64-bit on linux with 8gb of ram and KSP stays well below the limit so it's not a memory-related crash.

Like any good request for help, log provided.

I'm usually good at troubleshooting things like this but this is beyond me, the log honestly doesn't seem to have much information at the time of the crash.

Link to comment
Share on other sites

I may be wrong here, but I'm pretty sure MM isn't your issue.

At the start of your log you have KSPAPIExtensions.dll in your root GameData, try deleting that. Also, do you know why EVAManager.dll, Modulefixer.dll and PartIconFixer_1_2.dll are in the base folder as welll?

[LOG 01:23:41.440] AssemblyLoader: Loading assembly at /home/aden/.local/share/Steam/steamapps/common/Kerbal Space Program/GameData/EVAManager.dll

[LOG 01:23:41.478] Load(Assembly): /KSPAPIExtensions

[LOG 01:23:41.478] AssemblyLoader: Loading assembly at /home/aden/.local/share/Steam/steamapps/common/Kerbal Space Program/GameData/KSPAPIExtensions.dll

[LOG 01:23:41.482] AssemblyLoader: KSPAssembly 'KSPAPIExtensions' V1.7

[LOG 01:23:41.482] Load(Assembly): /ModuleManager.2.6.6

[LOG 01:23:41.482] AssemblyLoader: Loading assembly at /home/aden/.local/share/Steam/steamapps/common/Kerbal Space Program/GameData/ModuleManager.2.6.6.dll

[LOG 01:23:41.482] AssemblyLoader: KSPAssembly 'ModuleManager' V2.5

[LOG 01:23:41.482] Load(Assembly): /Modulefixer

[LOG 01:23:41.482] AssemblyLoader: Loading assembly at /home/aden/.local/share/Steam/steamapps/common/Kerbal Space Program/GameData/Modulefixer.dll

[LOG 01:23:41.483] Load(Assembly): /PartIconFixer_1_2

[LOG 01:23:41.483] AssemblyLoader: Loading assembly at /home/aden/.local/share/Steam/steamapps/common/Kerbal Space Program/GameData/PartIconFixer_1_2.dll

A little further in you have several assembly errors. I wouldn't be surprised if that is related to the KSPAPIExtensions.dll file in your gamedata folder. It appears to be v1.7 and I think the newest is v1.75.

I'd start with that and see what happens.

Link to comment
Share on other sites

"[LOG 01:35:06.402] [ModuleManager] Ran in 247.332s". MM is done loading way before you crash I am afraid you have an other problem. The fact that you do not crash without MM is mpst likely because some part does not get a module added by a MM and so that module does not start when MM is not present.

Link to comment
Share on other sites

Hi ! I'm trying to make a MM patch that looks at some globally defined value (edited by end user) to execute specific MM patch blocks.

Example from Module Manager Handbook


@PART[*]:HAS[@RESOURCE[MonoPropellant]:HAS[#maxAmount[750]]]
{
...(stuff)
}

Shows how to check for variable "maxAmount" and its value of "750" inside currently inspected PART node.

And referencing variables from this post


MYMODCONFIGS
{
rescaleMult = 2
}

@PART[fuelTank]
{
rescaleMult = #$@MYMODCONFIGS/rescaleMult$ // get a value from the MYMODCONFIGS node
...
}

Above shows how to check for a variable and its value from another node, when already inside curly braces.

I'm trying to combine the above two to check for variable value inside PART line, not when already inside curly braces for that PART node.

If this combination works, i could write two separate PART patch blocks, nicely separating two different cfgs. If not, i would have to write one PART patch block and inside make checks for each entry that needs adding/patching, intermixing everyting in big mess.

Here is my idea how it may work (still not worked out how) :


MYNODE
{
myVar = true // end user changes this as desired, this node may even be in separate cfg file
}

@PART[MI*]:HAS[@MYNODE/myVar[true]] // one set of changes/additions
{
varA = stuff
VarB = 1,2,3,4,5
}

@PART[MI*]:HAS[@MYNODE/myVar[false]] // second set of completely different changes/additions
{
RESOURCE
{
name = Ore
amount = 1
maxAmount = 1500
}
}

=====UPDATE=====

I was able to make a kind of "conditional compile switch" for MM patching :


MYNODE
{
switchFlag = DUMMY //comment out if want second set
}

@PART[X*]:HAS[@MYNODE[switchFlag]]
{
... //one set
}

@PART[X*]:HAS[!MYNODE[switchFlag]]
{
... //second set
}

To "turn off" patching of PART node, simply comment out the variable name. It is still not ideal, value of variable is still not referenced, making this one a boolean type choice.

Note that one of the sets would be used even if MYNODE does not exist at all.

If this could work for values, then multiple values could be used for multiple choices (eg. having 3 or more @PART MM variations of same part).

Edited by fatcargo
new test results
Link to comment
Share on other sites

I may be wrong here, but I'm pretty sure MM isn't your issue.

At the start of your log you have KSPAPIExtensions.dll in your root GameData, try deleting that. Also, do you know why EVAManager.dll, Modulefixer.dll and PartIconFixer_1_2.dll are in the base folder as welll?

A little further in you have several assembly errors. I wouldn't be surprised if that is related to the KSPAPIExtensions.dll file in your gamedata folder. It appears to be v1.7 and I think the newest is v1.75.

I'd start with that and see what happens.

Well, I reinstalled my mods that need KSPAPIExtensions and updated each one to the latest version and it still ctd's at the same point. All those other dlls are meant to go in the root folder. Here's another log.

- - - Updated - - -

"[LOG 01:35:06.402] [ModuleManager] Ran in 247.332s". MM is done loading way before you crash I am afraid you have an other problem. The fact that you do not crash without MM is mpst likely because some part does not get a module added by a MM and so that module does not start when MM is not present.

Is there no way to track down what module is throwing a wrench in it?

Link to comment
Share on other sites

Well, I reinstalled my mods that need KSPAPIExtensions and updated each one to the latest version and it still ctd's at the same point. All those other dlls are meant to go in the root folder. Here's another log.

- - - Updated - - -

Is there no way to track down what module is throwing a wrench in it?

Post the Player.log instead and we might see something but i doubt it.

Link to comment
Share on other sites

~/.config/unity3d/Squad/Kerbal Space Program/Player.log, where ~ is your users home directory (/home/<username>), and .config is a hidden folder therein.

- - - Updated - - -

Bah, too slow again :)

Link to comment
Share on other sites

Can I use MM to change the subcategory of a part, as listed in the VAB/SPH's "Filter by Function" tabs? Ie: If a part has "category = Utility" in the part file, can I change that? The terminology is a bit confusing to me, because in Filter by Function, the tabs are considered "subcategories", yet in the part cfg files these subcategories are listed as "category". So I'm wondering if I can use something like: @PART[Mypart] { @CATEGORY = (something) or @SUBCATEGORY = (something) to change or delete a part.cfg's category value.

Link to comment
Share on other sites

From Module Manager Handbook, with minor additions :


@PART[TargetPart]:HAS[#category[Utility]]
{
@category = Structural // change existing category from "Utility" to "Structural"

// delete variable named "myValue". Note that value "DELETE" assigned here is ignored in deletion process, it might as well say "DUMMY" or "123" etc
!myValue = DELETE
}

"#" denotes a variable in PART[] node.

- - - Updated - - -

Oh one more thing : does anyone (i mean You sarbian :) ) have time to build a small application based on MM sources to test cfg patching process, namely the PART[]:HAS[]:NEEDS[] matches ? It would diminish if not completely replace testing in KSP by DB reload or game restart. This addresses my before mentioned problem i have with trying to check for variable value from another node inside PART[]:HAS[] line. There are examples how to get value from another node, but only when already inside currently processed PART[]. And due to sheer number of possible combinations, finding one that works is extremely time consuming.

Link to comment
Share on other sites

Not much more info :(

Looking at the exception you get I would try to remove :

Hangar

FillSpotsWithTourists

KineTechAnimation (from B9 most likely ? Are you sure you have the current one ? )

KerboKatz SmallUtilities

And you have a strange dir in you NearFuturePropulsion install ( GameData/NearFuturePropulsion/.fr-6hozUs ) with duplicate models, one of which seems corrupted.

The start of your log is quite scary but you ll have to ask to those who play KSP on linux in a separate thread. It may be harmless.

Link to comment
Share on other sites

Is there a way to apply a config change but only if x resource is above y?

So say, if ElectricCharge < 200 @ElectricCharge = 200


@[COLOR=#ff0000]NODE[/COLOR]:HAS[#ElectricCharge[<200]]
{
@ElectricCharge = 200
}

should be like that

(replace the red bit with what you need)

link

Edited by Sigma88
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...