- Jun 17, 2017
- 5,913
- 30,067
Lets goooooOK, slowly easing my way into the SJx code again. I felt the need to combine two screens...
View attachment 4331086
Lots more to do mod wise, but it's a start!
Yes I am! Slowly making progress!Lets gooooo
Glad your working on this
Good luck
next game you 2 should collab you both seem to work together quite wellBoring code talk time. yv0751 and maybe a couple others here might be interested in such things, otherwise, nothing to see here, move along!
Python is definitely NOT my jam, so I'm sure a few of you will find my migraines that manifest when trying to figure out such things amusing...
So, something was annoying me about the bot parts sorting...
Essentially, the parts grades (subpar, basic, advanced, military grade, elite) weren't sorting in order within each generation of a given part, So I probably spent waaaaay too much time today researching Python stuff, and was finally able to get things to sort within each Gen (1,2,3) by grade in ascending order. There was a 'nuance' that was preventing me to do this, until I figured out that a unique number was being attached at the end of each part ID, which was influencing the sorting...
Here's the code string I came up with:
$ GAME.lab.parts.sort(key = lambda x : (x.ID.split('-')[0], prefsort.index(x.pref), x.kind, x.price))
The prefsort.index thing references this list variable that I've added elsewhere, to determine the desired sort order:
default prefsort = ["subpar", "basic", "advanced", "military grade", "elite"]
and x.ID.split('-')[0] is the thing that splits the part ID string at the point that the unique index number is added (i.e. ignores everything at/after the dash in the x.ID string).
The end result is this:
View attachment 4349537
Hopefully this saves everyone a tiny bit of time when reviewing the parts list. This sort routine code thingie is also being added to the 'add part to bot' parts list, so that you don't have to keep scrolling up and down to find say the Gen 2 Mil Grade parts while keeping the other grades in the 'sorted list'... Yes, you could just 'uncheck everything but the 'Mil Grade' sort options, the point here is that I personally would prefer to have the full list presorted by grade within each gen to begin with...
Back to it!
List is definitely more informative...Boring code talk time. yv0751 and maybe a couple others here might be interested in such things, otherwise, nothing to see here, move along!
Python is definitely NOT my jam, so I'm sure a few of you will find my migraines that manifest when trying to figure out such things amusing...
So, something was annoying me about the bot parts sorting...
Essentially, the parts grades (subpar, basic, advanced, military grade, elite) weren't sorting in order within each generation of a given part, So I probably spent waaaaay too much time today researching Python stuff, and was finally able to get things to sort within each Gen (1,2,3) by grade in ascending order. There was a 'nuance' that was preventing me to do this, until I figured out that a unique number was being attached at the end of each part ID, which was influencing the sorting...
Here's the code string I came up with:
$ GAME.lab.parts.sort(key = lambda x : (x.ID.split('-')[0], prefsort.index(x.pref), x.kind, x.price))
The prefsort.index thing references this list variable that I've added elsewhere, to determine the desired sort order:
default prefsort = ["subpar", "basic", "advanced", "military grade", "elite"]
and x.ID.split('-')[0] is the thing that splits the part ID string at the point that the unique index number is added (i.e. ignores everything at/after the dash in the x.ID string).
The end result is this:
View attachment 4349537
Hopefully this saves everyone a tiny bit of time when reviewing the parts list. This sort routine code thingie is also being added to the 'add part to bot' parts list, so that you don't have to keep scrolling up and down to find say the Gen 2 Mil Grade parts while keeping the other grades in the 'sorted list'... Yes, you could just 'uncheck everything but the 'Mil Grade' sort options, the point here is that I personally would prefer to have the full list presorted by grade within each gen to begin with...
Back to it!
The other thing that is kind of frustrating for me atm is the fact that sorting the IDs alphabetically, well I'd rather sort per the order that I have the added sort options (Anal, Bondage, Oral, Special, Vaginal, Perversion, IQ, Immobilizer). My reasoning here is that the first five are 'alphabetically ordered' and affect only one attribute, Perversion Amps affect all five attributes. IQ is less useful IMHO, and is the last module type that I consider currently. Immobilizers last, to round out the sort routine/list/easy to spot in the sort options buttons if at the endList is definitely more informative...
My syntax OCD kicks in here: Using a tuple is the certainly the right way for a hierarchical sorting. Would have used x.attr['BaseID'] instead of the splitting orgy though...
And I am still cursing that when I devised the whole unique instances scheme I didn't add a baseID attribute to the Parts Object...
Let me solve the mystery: a neutron cannon, an area of effect moduleThe other thing that is kind of frustrating for me atm is the fact that sorting the IDs alphabetically, well I'd rather sort per the order that I have the added sort options (Anal, Bondage, Oral, Special, Vaginal, Perversion, IQ, Immobilizer). My reasoning here is that the first five are 'alphabetically ordered' and affect only one attribute, Perversion Amps affect all five attributes. IQ is less useful IMHO, and is the last module type that I consider currently. Immobilizers last, to round out the sort routine/list/easy to spot in the sort options buttons if at the end
I also did the 'alphabetical ordered' thing for the QC button in my mod, and in a couple of other places. As for adding a 'Base ID' attribute, I suppose that could be appended to the parts declaration, with a 'if BaseID not present, append'. I did something similar to earlier versions of my mod, I'd have to go back and dig to see what syntax I used. My goal is always save compatibility, which now seems to be part of your mission statement as well (finally...).
It might be more useful to 'force' a sort order' using one of the existing fields. Something I don't quite understand is what the 'A' is for...
["SBPAddOnPER3", "Perversion Amp", "A", "sexbot addons", "addon", 3 , "A module, which improves all of a bot's talents", 10000, [],{"LVL": 8}], # CR-0543
It looks like all parts have the "A" regardless of type, so I'm not understanding it's purpose. If it otherwise has none, it'd be easy enough to write a check routine that replaces it with some sort of heirarchal descriptor instead that lends itself to an alphabetical sort if used, say:
A Cortex
AP Precursor Cortex #(maybe, just sorting by cortex grade is enough for me, as precursor is already included in the description text listing if present)
B Head
C Torso
D Arms
E Legs
F Shell
G Anal Module
H Bondage Module
I Special Module
J Vaginal Module
K Perversion Module
L IQ Module
M Immobilizer Module
N Cube Attitude
O Cube Personality
P Cube Traits
If you wanted to get more fancy, you could do this (and eliminate the need for a separate .cat sort)
A1 Cortex Gen 1
A2 Cortex Gen 2
A3 Cortex Gen 3
B1 Head Gen 1
and so on and so on. The main idea here is to repurpose the 'A' slot to set up a heirarchal sort order that spits out the desired sort order with a simple sort.
My reasoning for the above listing including the name descriptor, is mainly so that you know what each letter is assigned to without having to reference a separate list somewhere else to figure out say what L1 references, and also so that you can do a:
if "A" and i.ID contains Cortex1, replace "A" with "A1 Cortex
check when a specific pre-existing part is referenced, with the proper syntax of course! 'Cuz existing save compatability and all that...
This COULD be accomplished via a label after_load, so that the GAME.lab.parts find/replace if needed check is just done once - i.e when a save is loaded. New games would already reference the new and improved partsdata[] with the new sort field data already included.
I don't think I'd put grade in this (A3 Cortex Gen 3), as there's another way to sort by grade (as I detailed in my last post, the prefsort.index thing), and the grade sort should be secondary to the main heirarchal sort in any case.
Anyways, yeah just a random thought, I have no idea what the 'A' is for so it seems like an interesting opportunity...
Or, as I noted, you could just append a new value to the SexbotPart() Class using a length check of some sort, that references a new list... as I noted I was adding a new attribute to the sexbot parts in a previous version of my mod, so I know that this is possible... it's better to do this at the start of course, but there are a LOT of saves out there with the current parts list, and it'd be better to just add a new attribute at the end.
I remember now, it was how I was adding the sixth slot for shells. You've since made the 'shell' slot part of vanilla SJx, but yeah that'd be a way to go about it. I think having a 'replace A with new value' check would be cleaner though.
Just thinking out loud here...
If that is the case, it might not make a lot of sense for say an Attitude cube to have a Neutron Cannon...Let me solve the mystery: a neutron cannon, an area of effect module
Yes, tags that can be used as easy sorting keys would make sense assuming sort order should not be flexible.If that is the case, it might not make a lot of sense for say an Attitude cube to have a Neutron Cannon...
And, since said devices haven't been introduced yet, incorporating these into my idea is rather easy:
WN1 Neutron Cannon Gen 1
XM1 Area Affect Module Gen 1
if whatever variable that references the "A" position (i'm guessing art(?) based on the partdata order) contains "W" then it's a weapon... Otherwise just append a new value as I noted...
The tuples are definitely useful and said fields are also being used in other contexts say if cat 3 then higher IQ boost value. I'm just looking at ways that don't require a rewrite of a bunch of partsdata, say IDs, in order to accomodate an alphabetical sort in a more 'make sense' order. The "A" field seems like an opportunity... or as I said, a new field could be appended...Yes, tags that can be used as easy sorting keys would make sense assuming sort order should not be flexible.
for use in sorting lambda tuples I added stuff like "kind" "cat", "pref", ...
So its a matter of philosophy. The latter can be mapped to the former though its a bit more effort.
default basesort = [
"SBPCortex1", "SBPCortex2", "SBPCortex3", "SBPCortexPre",
"SBPHead1", "SBPHead2", "SBPHead3",
"SBPTorso1","SBPTorso2", "SBPTorso3",
"SBPArms1", "SBPArms2", "SBPArms3",
"SBPLegs1", "SBPLegs2", "SBPLegs3",
"SBPShell1TypeC", "SBPShell2TypeC", "SBPShell3TypeC",
"SBPShell1TypeG", "SBPShell2TypeG", "SBPShell3TypeG",
"SBPShell1TypeI", "SBPShell2TypeI", "SBPShell3TypeI",
"SBPShell1TypeJ", "SBPShell2TypeJ", "SBPShell3TypeJ",
"SBPShell1TypeK", "SBPShell2TypeK", "SBPShell3TypeK",
"SBPShell1TypeL", "SBPShell2TypeL", "SBPShell3TypeL",
"SBPShell1TypeN", "SBPShell2TypeN", "SBPShell3TypeN",
"SBPShell1TypeP", "SBPShell2TypeP", "SBPShell3TypeP",
"SBPShell1TypeV", "SBPShell2TypeV", "SBPShell3TypeV",
"SBPCubeAttitude", "SBPCubePersonality", "SBPCubeTraits",
"SBPAddOnSkillANA", "SBPAddOnSkillANA2", "SBPAddOnSkillANA3",
"SBPAddOnSkillBON", "SBPAddOnSkillBON2", "SBPAddOnSkillBON3",
"SBPAddOnSkillORA", "SBPAddOnSkillORA2", "SBPAddOnSkillORA3",
"SBPAddOnSkillSPE", "SBPAddOnSkillSPE2", "SBPAddOnSkillSPE3",
"SBPAddOnSkillVAG", "SBPAddOnSkillVAG2", "SBPAddOnSkillVAG3",
"SBPAddOnPER", "SBPAddOnPER2", "SBPAddOnPER3",
"SBPAddOnIQ", "SBPAddOnIQ2", "SBPAddOnIQ3",
"SBPAddOnImmo", "SBPAddOnImmo2", "SBPAddOnImmo3"
]
default prefsort = ["subpar", "basic", "advanced", "military grade", "elite"]