#Patch Manager

1 messages · Page 4 of 1

upbeat hare
#

Families are string fields

stiff crater
#

Oh so if I'm guessing right they are displayed directly with the order coming from the xxxx part of xxxx-family? (away from computer can't look into the code rn)

upbeat hare
#

Likely

maiden wraith
#

It needs like 7 patches

#

Pretty much the same that i did for LOABE patching of the labels

#

I have a working version already for it

north mist
maiden wraith
#

Yeah, havent had the time yet

north mist
#

just wanted to let you know

maiden wraith
#

Am out of home rn 😔

north mist
#

I think it's the only mod not fixed for 0.1.4 afaik

maiden wraith
#

Should i maintain that title? klueless

north mist
#

lmao

upbeat hare
#

@maiden wraith

public static void Patch(AssemblyDefinition assembly)
{
    GetCategoryDefinitions();
    var type = assembly.Modules.SelectMany(x => x.Types).First(x => x.FullName == "PartsCategories");
    var start = type.Fields.Count(field => field.IsStatic);
    foreach (var definition in CategoryDefinitions)
    {
        var categoryField = new FieldDefinition(definition.Key,
            FieldAttributes.Static | FieldAttributes.Literal | FieldAttributes.Public | FieldAttributes.HasDefault,
            type) { Constant = start };
        start += 1;
    }
}

Is something like this how you added the fields to the enum?

maiden wraith
#

Nop

#

It has like 8 diffrent references

#

Where it discards if not in the default range

upbeat hare
#

Oh gods

maiden wraith
#

Also has limitations for icons

#

Thus me saying 8 patches

upbeat hare
#

Alright, I'll let you work on it then

#

This really shouldn't be necessary

maiden wraith
#

If they didnt use enums

north mist
#

yeah, it makes absolutely 0 sense

#

when they load most other stuff from textassets

maiden wraith
#

Btw, both the category and the family arw enums on their unity editor

#

Can you make a list with all the families and categories pls cheese?

north mist
#

it's on the wiki

maiden wraith
#

All the 90 families?

north mist
#

but the family isn't an enum afaik

#

you can input any text

maiden wraith
#

It is on their unity editor i think, its a custom script

north mist
#

well then we have no idea to know all of them

upbeat hare
#

Idk how to write this forum suggestion

maiden wraith
#

I dont see them actually inputing by text ngl

north mist
#

I gathered all the ones that are currently used in the game

maiden wraith
north mist
#

yeah but that probably isn't even close to all of them

maiden wraith
#

Oh i see what u mean

#

Can u link the wiki l?

north mist
#

I have a script that goes through all part jsons and gets all the unique values

upbeat hare
#

... part families are a private list...

north mist
#

gathered the category, family, size category, stage type and staging icon asset address data

#

from the part jsons

upbeat hare
#

But it does generate on an unknown familky

#

Wow munix is currently the only one to have edits to the wiki in the past 30 days

#

Hopefully linking the wiki in the modslist for 1.5 will help witht hat

north mist
#

who knows

#

the current trend is that everyone makes their own separate docs/notes

upbeat hare
#

Which is ... pain

north mist
#

yeah

upbeat hare
#

Anyways ... back on topic, is there much more we should do for a prerelease
Documentation and examples ... yeah fair, but I can work on those still after prerelease, and help people with stuff which will help me with documentation

north mist
#

one thing I think would be nice would be an adapter for galaxy definitions and celestial bodies

#

even if it won't work 100%

upbeat hare
#

I don't know if thats yet necessary for a prerelease

north mist
#

the reason I'm saying it is that there was recently someone asking for basically the same thing: #1091980188096675911 message

#

though I guess they could always just use the json one

north mist
#

oh I am dumb lmao

#

welp nevermind

#

I need more sleep

upbeat hare
#

Its based off of a markdown file though so I can use something like that for an online documentation

upbeat hare
#

Yeah, I'm likely going to put it somewhere on the web in markdown

upbeat hare
#

Would it be worth moving Antlr to its own separate library?

north mist
#

I honestly don't know

north mist
#

looks awesome

maiden wraith
#

these are all patches for the labels btw

#

half of those have a "if not on the enum, return error"

frail star
#

panic not implemented

maiden wraith
#

munix

#

can you check psl

#

if this class still exists?

#

i might be going crazyt

#

actually

#

i think i just had re-exported the 1.3.2 source code

north mist
#

nope it doesn't

maiden wraith
#

renamed to KSP.UI.PartInfoOverlay

#

makes more sense

desert stirrup
# upbeat hare This is my WIP documentation so far

Now that we'll have patch manager soon and there are mods in the works with custom resources, I was thinking of creating Community Resources that mods could use to have a common ground for new resource definitions.
Reading through the docs...
So new resource would be defined like so:

@new("Stormlight")
:resources {
displayNameKey: "Resource/DisplayName/Stormlight";
abbreviationKey: "Resource/Abbreviation/SL";
isTweakable: true;
isVisible: true;
massPerUnit: 0;
volumePerUnit: 0;
specificHeatCapacityPerUnit: 2010;
FlowMode: 4;
transferMode: 1;
costPerUnit: 0.8;
NonStageable: false;
resourceIconAssetAddress: "";
vfxFuelType: "Pressurized";
}

And then mods could hook up to community resources to get definitions like so:

@use '_community_resources.patch';

Is this correct?

upbeat hare
#

A mod wouldnt even have to include the library

#

Just depend on the community resources mod

#

Because the resources get added to the games corpus of resources

desert stirrup
#

And new resources would be added to GameManager/(snip)/ResourceManager and ResourceDefinitionDatabase?

upbeat hare
#

They should be yes, those are populated by the resource definition assets

maiden wraith
#

yeah they will

desert stirrup
upbeat hare
desert stirrup
#

Alright, even better

upbeat hare
#

Also about libraries ... outside of the current mod you are in
They are namespaced like mod_id:libraryfile

#

But to answer your original q, yes that would be how to define a resource

upbeat hare
#

Made a PR for when you get the chance MunixApproved

upbeat hare
stiff crater
#

🤩
Will look at it tomorrow, I need to go to sleep rn x)

upbeat hare
#

Anyways time to test falkis patches

#

@desert stirrup I know you are sleeping but your patches seem to have worked
Food

{
  "version": 0.1,
  "useExternal": false,
  "data": {
    "name": "Food",
    "displayNameKey": "Resource/DisplayName/Food",
    "abbreviationKey": "Resource/Abbreviation/FD",
    "isTweakable": true,
    "isVisible": true,
    "massPerUnit": 1,
    "volumePerUnit": 5,
    "specificHeatCapacityPerUnit": 10,
    "flowMode": 0,
    "transferMode": 1,
    "costPerUnit": 0.8,
    "NonStageable": false,
    "resourceIconAssetAddress": "",
    "vfxFuelType": "NoFuel",
    "FlowMode": 4
  }
}

Water

{
  "version": 0.1,
  "useExternal": false,
  "data": {
    "name": "Water",
    "displayNameKey": "Resource/DisplayName/Water",
    "abbreviationKey": "Resource/Abbreviation/H20",
    "isTweakable": true,
    "isVisible": true,
    "massPerUnit": 1,
    "volumePerUnit": 1,
    "specificHeatCapacityPerUnit": 1000,
    "flowMode": 0,
    "transferMode": 1,
    "costPerUnit": 0.8,
    "NonStageable": false,
    "resourceIconAssetAddress": "",
    "vfxFuelType": "NoFuel",
    "FlowMode": 4
  }
}

Oxygen

{
  "version": 0.1,
  "useExternal": false,
  "data": {
    "name": "Oxygen",
    "displayNameKey": "Resource/DisplayName/Oxygen",
    "abbreviationKey": "Resource/Abbreviation/O2",
    "isTweakable": true,
    "isVisible": true,
    "massPerUnit": 1,
    "volumePerUnit": 1,
    "specificHeatCapacityPerUnit": 1000,
    "flowMode": 0,
    "transferMode": 1,
    "costPerUnit": 0.8,
    "NonStageable": false,
    "resourceIconAssetAddress": "",
    "vfxFuelType": "Pressurized",
    "FlowMode": 4
  }
}

Waste

{
  "version": 0.1,
  "useExternal": false,
  "data": {
    "name": "Waste",
    "displayNameKey": "Resource/DisplayName/Waste",
    "abbreviationKey": "Resource/Abbreviation/WST",
    "isTweakable": true,
    "isVisible": true,
    "massPerUnit": 1,
    "volumePerUnit": 1,
    "specificHeatCapacityPerUnit": 10,
    "flowMode": 0,
    "transferMode": 1,
    "costPerUnit": 0.8,
    "NonStageable": false,
    "resourceIconAssetAddress": "",
    "vfxFuelType": "Pressurized",
    "FlowMode": 4
  }
}
upbeat hare
#

I also put a PR into your mod to structure it better and give it a swinfo

desert stirrup
#

Worked right from the start? No way, that's a first 😛

upbeat hare
stiff crater
#

I was wondering: how is the order the patches are applied decided? (and does it matter, like if I have a patch that adds a resource from Community Resources to all command pods wouldn't CR's patches need to be applied before mine?)

upbeat hare
upbeat hare
#

That make sense Safarte?

stiff crater
#

Yes, so by default if no stages are defined it's based on definition dependencies if I understood correctly?

#

And a Community Patch Stages library would indeed be pretty useful

stiff crater
upbeat hare
upbeat hare
#

Its also likely good practice to give stages granular priorities ... like instead of 1 use 100

#

Because this means that once I add before and after stuff ... that it can actually insert stuff between those stages

north mist
#

I feel like specifically the patch ordering, stages and before/after stuff is what we could use feedback on from KSP1 modders the most

#

I know they had some pretty strong opinions on how MM does it (wrong)

#

And it might be the most complex issue of the whole system

upbeat hare
#

A complex dependency/soft dependency system :p

stiff crater
#

huh (trying to launch with PM 0.1.0)

upbeat hare
#

Ohh thats my fault

#

I broke something in a patch I made just before the prerelease ... give me one millisecond

#

@north mist can you disable oauth access restriction on KSP2community

north mist
#

Done

upbeat hare
#

It fixes the error I made

stiff crater
#

Still borked with the same error :/

upbeat hare
#

Huh, that makes no sense now

#

Let me ty

north mist
#

I made you an admin so you should just be able to do anything with the organization now

stiff crater
upbeat hare
#

It should've been, I did press build but somehow it didn't for me

#

Okay, I deleted the old artifacts and rebuilt

upbeat hare
stiff crater
north mist
#

Oh by the way, @upbeat hare if you have the md for the docs, we can make them a PM wiki page and you can keep editing it there

upbeat hare
upbeat hare
#

I put a PR out for adding @require functionality

#

Its going to immediately need to be updated once SW 1.5 is a thing

north mist
#

i see

desert stirrup
#

Newly added resources are assigned IDs before the stock resources (ID1, ID2, ID3...). I hope that doesn't cause issues down the road...?

north mist
#

hopefully

upbeat hare
#

Should be fine

#

I dont see them hardcoding any ids

#

Yeah anywhere that has resource IDs, has them being generated from the name

#

which makes sense, as idk if you can control addressables ordering to that sort of granularity

maiden wraith
#

wait

#

no it shouldnt

#

they dont get acessed by ID number

#

but by ResourceName

#

tho, it would be good practice to add the after

upbeat hare
#

it doesn't matter

maiden wraith
#

i mean it doesnt

#

but still

upbeat hare
#

as I said you can't control addressables order with that granularity

#

And its actually a lot harder to add them after, because I add the addressables to the cache in an async way and I need the new things to be created before I run any patches

maiden wraith
#

fair

#

but yeah it shouldnt make a diffrence in game since every id is gotten via the resource name

north mist
#

alright so time to start getting the nuget package ready

#

this will be annoying af

#

UitkForKsp2 nuget packages are already annoying enough as it is

#

the issue is that we read the version from the swinfo, but when the nuget package is being built by MSBuild, it isn't set for some reason

#

so the packages get always built as version 1.0.0

#

and you just have to hardcode the version in a <Version> property somewhere

#

and I have no clue how to solve that

upbeat hare
#

Thats annoying

#

Also, my reason for putting resource units out of pm is 2 fold
Its not a base game config
And it shows how to make PM addons

north mist
#

oh yeah I definitely agree

#

it's out of the scope

upbeat hare
#

Anyways, once you get the nuget package set up, ping me

stiff crater
#

Quick question: what would be the syntax to add a new object to an array field, for example adding a new PAMModuleVisualsOverride here?

upbeat hare
#

Ahh ... I was gonna need to add a thing for that field, lemme check code rq for how to do it rn

#

Alright so @stiff crater in the current version its kinda janky because I need to add some checks for arrays to be able to use +syntax by default

@use 'builtin:list';
:parts ... {
  PAMModuleVisualsOverride: $value:append(
    {
      PartComponentModuleName: "...",
      ModuleDisplayName: "...",
      ShowHeader: true,
      ShowFooter: false
    }
  );
}
#

and to append multiple, there is an list.append-all function used like $value:append-all([...])

#

That will work for now, in the future it should be something like the following for generic arrays

+ignored {
  //...
}
north mist
#

I feel like that might be more confusing than the current syntax

upbeat hare
#

Hmm, I don't know how to make a generic addition, unless I allow + without anything afterwards as a valid thing

#

like

#
+ {
}
north mist
#

couldn't it work like a "+=" operator, like it does for numeric values?

#

you can do value: +10; right?

upbeat hare
#

so something like

value: +{
  ...
}

Yeah that could work

#

I mean actually @north mist @stiff crater you can alredy do the following

value: +[
{
}
]
#

List concatenation is a thing like that

north mist
#

ahh well that's pretty much what I meant

#

awesome

upbeat hare
#

I forgot I implemented that with the plus operator lol

#
case DataValue.DataType.List when rightHandSide.IsList:
{
    // If every value is immutable a shallow copy should be fine
    var newList = new List<DataValue>(leftHandSide.List);
    newList.AddRange(rightHandSide.List);
    return newList;
}

Yeah lmao, you can just do that

#

No need for builtin:list library for that either

stiff crater
#

I think I did an oopsie

#
:parts {
    @if $$crewCapacity > 0 {
        +Module_LifeSupportRecycler {
            +Data_LifeSupportRecycler {}
        }
        PAMModuleSortOverride: +[
            {
                PartComponentModuleName: ""PartComponentModule_LifeSupportRecycler",
                sortIndex: 40
            }
        ];
        PAMModuleVisualsOverride: +[
            {
                PartComponentModuleName: "PartComponentModule_LifeSupportRecycler",
                ModuleDisplayName: "KLSS/LSR/DisplayName",
                ShowHeader: true,
                ShowFooter: false
            }
        ];
    }
}
upbeat hare
#

Accidentally put 2 quotes

stiff crater
north mist
#

seeing the patch, I love how this is all coming together though

#

I feel like with PM we could see a surge of new mods and new types of mods

stiff crater
#

I might try to do a syntax highlighting extension for VS Code for PM, is the grammar definition of the language centralized somewhere?

upbeat hare
north mist
#

Sinon already started working on a language server afaik

#

@frail star

stiff crater
frail star
#

yeah im almost done with syntax errors

#

im in class rn

#

i need to finish it

upbeat hare
#

For reference before I add them into the pdf here is every single builtin library with their functions so far
builtin:debug

debug-log(value) - logs value to console
serialize(value) - serializes a value

builtin:dictionary

dictionary.set(dict,key,value) - copies a dictionary and sets dictionary[key] to value

builtin:functional

get-function(name) - gets a function from the global environment with that name and returns it as a closure
closure.invoke(closure,...) - Invokes a closure with the `...` arguments
closure.bind(closure,...) - Binds the arguments `...` to the left side of the closure and returns a new closure
closure.right-bind(closure,...) - Binds the arguments `...` to the right side of the closure and returns a new closure

builtin:list

list.append(list,value) - copies a list and appends the value to it
list.append-all(list, values) - copies a list and concatenates it with values
list.create(...) - creates a new list with the arguments as its members
list.sort(list,[comparator]) - sorts a loist with an optional comparator function, follows the C# convention
list.map(list,function) - map a function onto a list
list.reduce(list,initial,function) - reduce a list using a function
list.length(list) - get the length of a list

builtin:reflection

typeof(value) - returns the type of value as a string

builtin:type-conversion

to-bool(value) - returns whether or not value is truthy
to-real(value) - converts a value to a real number
to-integer(value) - converts a value to an int
to-string(value) - converts a value to a string

Difference between
function($value,...) and $value:function(...)
-> $value:function(...) calls either function($value,...) or typeof($value).function(...)
So if $x is a list, $x:sort() would call list.sort($x)

frail star
#

syntax highlighting has nothing to do with parsing syntax

frail star
#

my thing adds errors when syntax isnt correct

upbeat hare
#

I should try creating an automatic documentation generator for the builtin functions lmao

north mist
#

it will probably make more sense to split the document into separate pages by the top level headings, but for now it's on one page

upbeat hare
#

I need to add how to define closures to the function section lol

#
$closure: @function(...) {}

Is literally how it is done though

north mist
#

so if you want, you can just keep editing the wiki

#

and you'll get VCS with it at least

upbeat hare
#

I'll likely move to that, no need to gen pdfs anymore, or I can just copy and paste

#

And now closures are documented

north mist
#

should I try to add the Nuget generating stuff to the 0.1.1 branch and then release the package along with the hotfix?

upbeat hare
#

Can't wait till SW 1.5 for when I can link patch manager documentation in the modlist

north mist
#

and list all the modules and extensions

#

groundbreaking

upbeat hare
#

The reason for the x.y function names is actually so I can do a minimal form of overloading

north mist
#

oh my god

#

it took almost an hour of searching and back and forth with ChatGPT

#

but I got it

#

lmao

#

Nuget version is finally generated from swinfo

#

it's so stupid, too

#

regularly I do this

stiff crater
north mist
#

and the solution was this

#

had to use Output to directly write the output into the PackageVersion property, and had to do it right before PrepareForBuild

#

it is beyond me why with BeforeTargets="Pack" it just doesn't work

#

but this does

#

now I just need to test if the package really works, and I can release it

north mist
stiff crater
north mist
#

ah good to know

stiff crater
#

It allows for more correct syntax highlighting like this accroding to the docs

north mist
#

makes sense

upbeat hare
stiff crater
upbeat hare
#

A language server or syntax highlighter would be great though

#

If I were any good at it, id make my own
Btw @stiff crater or @frail star put the source under the KSP2 community repo for that

north mist
#

just sent Sinon an invite

#

so he can make a repo

upbeat hare
#

Hows the nuget package going?

frail star
north mist
upbeat hare
#

Gonna be a pain making the SW 1.5 package

north mist
#

the task generates this nuspec file:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
  <metadata>
    <id>PatchManager</id>
    <version>0.1.0</version>
    <authors>munix</authors>
    <licenseUrl>https://raw.githubusercontent.com/jan-bures/PatchManager/main/LICENSE</licenseUrl>
    <icon>icon.png</icon>
    <readme>README.md</readme>
    <description>Package Description</description>
    <tags>ksp2 mod library</tags>
    <repository type="git" url="https://github.com/jan-bures/PatchManager" />
    <dependencies>
      <group targetFramework=".NETStandard2.0">
        <dependency id="PatchManager.Core" version="1.0.0" exclude="Build,Analyzers" />
        <dependency id="PatchManager.Generic" version="1.0.0" exclude="Build,Analyzers" />
        <dependency id="PatchManager.Parts" version="1.0.0" exclude="Build,Analyzers" />
        <dependency id="PatchManager.Resources" version="1.0.0" exclude="Build,Analyzers" />
        <dependency id="PatchManager.SassyPatching" version="1.0.0" exclude="Build,Analyzers" />
        <dependency id="PatchManager.Shared" version="1.0.0" exclude="Build,Analyzers" />
        <dependency id="BepInEx.PluginInfoProps" version="2.1.0" exclude="Build,Analyzers" />
      </group>
    </dependencies>
  </metadata>
</package>
#

but the version of all the DLLs is 0.1.0

#

so it can't find a match

upbeat hare
#

Thats kinda dumb

north mist
#

it's probably also caused by the auto-generation of Version from swinfo

#

that seems to be the root of all KSP2 modding evil

upbeat hare
#

loll

north mist
#

no luck so far

#

the easiest solution would be to just build separate nuget packages for every DLL

#

but I kinda hate that

#

but that might actually still not get rid of the issue

#

I'll try it

#

yeah of course it didn't

#

now I just have 8 packages which have wrong dependencies

#

jesus christ

upbeat hare
#

Oh gods

#

Maybe autogeneration isn't the best

north mist
#

it worked well enough the other way around, generating the swinfo from the .csproj file

#

but that's also less than ideal

upbeat hare
#

I'm stating in the specific case of a library with multiple modules, autogeneration doesn't seem to be the best idea

north mist
#

so do I just give this up and hardcode the version?

upbeat hare
#

If it stops a headache inducing amount of issues, yes, and we can always look at it later

north mist
#

I mean considering there was a solution for the version of the generated package, I'm assuming there also has to be one for the dependencies' version

#

but I can't figure it out

upbeat hare
#

As I said, hardcoding it for now, and looking at it later if you want to, might be better for now

north mist
#

sure

#

the only reason why I'm doing it anyway is to make sure we can't forget to update the version in one place but not the other

#

not the end of the world

#

we just have to mind that

upbeat hare
#

I've done that a lot with space warp
I think I've learned not to

#

Not 100% ideal, but it not broken at least

north mist
#

I'm just disappointed that I figured out like 50% but not the other 50% lmao

upbeat hare
#

Thats fair

north mist
#

I feel like to completely understand MSBuild I'd have to study it for 20 years under the guidance of an ancient warlock or something

upbeat hare
#

Legit

upbeat hare
#

Did you get it to work w/o the autogen?

north mist
#

still working on that, even with the correct versions, there's still an issue of the multiple assemblies in one package

#

so now I'm rewriting it to be generated from a .nuspec file instead of using the .csproj files

#

I know that works because I use it to build the game assemblies' nupkg

upbeat hare
#

Might need to do that for spacewarp soon

north mist
#

sob is right

#

this whole thing is a major PITA

upbeat hare
#

^ nuget

#

at least this will be the only time we have to do it for this

north mist
#

holy fucking shit

upbeat hare
#

did munix level up his class in msbuild warlock?

north mist
#

I've been trying for the past hour or so to figure out why specified files one by one like "my/build/folder/PatchManager.dll" in the nuspec file worked, as well as "my/build/folder/**/*.dll", but not "my/build/folder/*.dll"

#

it just wasn't copying anything

#

and you know what the fix was

#

"my\build\folder*.dll"

#

it needed fucking backslashes to work

upbeat hare
#

MICROSOFT!!!

#

I curse thy name

#

what fucking arcanum is this

north mist
#

at least I would understand if the other two things also didn't work without backslashes

#

but they do

#

it's only if you use the single non-recursive wildcard

upbeat hare
#

Now imagine if it needs forward slashes to build on linux

north mist
#

I don't even want to imagine

#

lmao

#

we don't support linux nuget builds

#

sorry

upbeat hare
#

Based and microsoftpilled

upbeat hare
north mist
#

it's there

#

😭

#

why doesn't it work

#

both the nuspec and the actual folder structure inside the nupkg look exactly like all the other Nuget packages we use

upbeat hare
#

Is it case sensitive?

north mist
#

it isn't

#

but I have the same case as the other packages anyway

#

if I hadn't already felt old after my birthday, I sure do now, because I feel like this thing has already shortened my lifespan by at least 20 years

upbeat hare
#

targetFramework seems to be specfically for dependencies

north mist
#

stay in school, don't do Nuget, kids

frail star
#

@upbeat hare can you write some more example patches, so i can verify some stuff for the LS

upbeat hare
#

nuget will make you want to do drugs

north mist
#

oh my god

#

it's working

#

I just didn't delete the cache

#

lmao

#

thank god

north mist
#

I never want to do anything like this again

upbeat hare
north mist
#

but it's pretty universal so I can include it in the template

#

and it doesn't require duplication of version

upbeat hare
#

thats good

north mist
#

this is my magnum opus

#

now I can die happy

frail star
#

@north mist you got the nuget to work?

north mist
#

seems like it

#

let me just test accessing some classes

upbeat hare
north mist
#

and I'll upload it

upbeat hare
#

@frail star there is actually a syntax error in the test1.patch

#
@use 'builtin:list';
@use 'builtin:dictionary';
@use 'builtin:dictionary';

@new("Stormlight")
:resources {
    displayNameKey: "Resource/DisplayName/Stormlight";
    abbreviationKey: "Resource/Abbreviation/SL";
    isTweakable: true;
    isVisible: true;
    massPerUnit: 0;
    volumePerUnit: 0;
    specificHeatCapacityPerUnit: 2010;
    flowMode: 4;
    transferMode: 1;
    costPerUnit: 0.8;
    NonStageable: false;
    resourceIconAssetAddress: "";
    vfxFuelType: "Pressurized";
}

@function ReplacePropellants($modes, $from, $to) {
    @return $modes:map(
        @function($object) {
            @if ($object["propellant"]["mixtureName"] == $from) {
                @return $object:set("propellant",$object["propellant"]:set("mixtureName",$to));
            } @else {
                @return $object;
            }
        }
    );
}


:parts {
    * > resourceContainers {
        @if ($current:length() > 0) {
            +Stormlight {
                    capacityUnits: +100.0;
                    initialUnits: +100.0;
            }
        }
    }

    #engine_3v_hydrogen_swerv > Module_Engine  {
        $useless: $current:debug-log();
    engineModes: ReplacePropellants($current, $value, "Hydrogen", "Stormlight");
    }
    #engine_3v_hydrogen_swerv > resourceSummary {
        Consumes: ["Stormlight"];
    }
}

Here it is without the error

frail star
#

give me a couple years

upbeat hare
#

You are making a ls for a functional programming language lol

frail star
#

yeah lmao

#

i have a good framework setup

#

i just need to spend a couple hours adding definitions

upbeat hare
#

You also have access to the antlr grammar

north mist
#

praise be

#

it's working

frail star
upbeat hare
#

you weren't already???

frail star
#

no lol

upbeat hare
upbeat hare
frail star
#

yay

#

figured that out

#

uh, cheese, where are the grammars stored

#

or do they compile into the dll?

#

in which case ill need to download them with the extension

upbeat hare
#

The g4 files are there

frail star
#

so they dont exist in the mod folder, mkay

#

ill need to download them with the extension

#

thats fine

north mist
#

pushed the 0.1.1 prerelease out

upbeat hare
#

@north mist do I have to register it like this?

north mist
#

Yeah, but that should work for all the labels in the cache

#

Or maybe I'm misunderstanding what you're specifically doing?

upbeat hare
#

for some reason the cache has a label the game doesn't know about

north mist
#

Huh

upbeat hare
#

OHHH

#

I'm an idiot

#

I need to put a bepin requires on community resources

north mist
#

Ah

upbeat hare
#

Dependency ordering stuff

north mist
#

Always fun

frail star
#

yipee

#

(i know its the wrong error)

#

nvm

upbeat hare
#

You know, that looks like its parsing an expression

frail star
#

im really confused right now lol

#

i think its having a stroke tbh

#

yeah....

upbeat hare
#

oh no

frail star
#

9+ errors

#

💀

#

yeah....

#

something might be a little wrong

#

oh shit

#

nvm

#

i know why....

#

yeah

#

thats a lot better

#

just one error

#

idk why it exists though

upbeat hare
#

BECAUSE YOU ARE PARSING IT AS AN EXPRESSION NOT A STATEMENT

#

so its thinking its a closure

#

sorry caps

frail star
#

lol

#

im just loading in the antler bindings

#

and using them

#

im not actually doing anything 💀

upbeat hare
#

Anyways, I made a PR, now I sleep

frail star
#

yeah cheese, there is actually something you missed

#

you need an EOF

#

lol

#

i might have just been dumb

#

hm

#

ignore what i just said for a moment i am having a crisis

frail star
#

maybe im just dumb

#

tbh

#

i thought i saw a antlr example that used a EOF

#

but its giving me an error for the EOF

#

ok apperently i was having serious trip, beacuse i just reloaded vscode and its gone

frail star
#

nooooooooo syntax highlighting hitting different

north mist
#

Oh boy

frail star
#

i am loosing my grip on reality.

north mist
#

I can see munley

frail star
#

the progress is happening

#

all at the cost of my sanity

#

i could have done this in like 30 minutes, but nooooo

#

i wanted to setup a full ass framework for all of it

upbeat hare
#

$object is a parameter tho :p

frail star
#

they are treated the same rn

#

im still finishing up my script for converting g4 into highlighting json

#

im not really confident about the script

#

we'll see

#

wait

#

bru

#

i just realized, i can just get a scss highlight json

#

lol

#

and modify it a bit

stiff crater
#

Something to note: as patches are not applied to the state of parts in the savefile, they will not affect already launched vessels. Is that how MM worked also in KSP1 or were the patches also applied to already launched vessels?

stiff crater
upbeat hare
#

@north mist should I go ahead and release PM 0.2.0, and then allow you to build the nuget?

north mist
#

Alright, go ahead, I'll finish lunch and build the nuget package (though it's easy, you just have to build the solution in Release and it should pop up in solutionDir/nuget)

upbeat hare
#

Wait, I think I forgot something

#

Called updating the swinfo version

#

give me a second

north mist
#

Uploaded

upbeat hare
#

Perfection

upbeat hare
#

@north mist do you think I should add

:parts {
  %Module_Engine {
    %Data_Engine {
      ...
    }
  }

Capability?
For create or modify

north mist
#

I think it would be nice

upbeat hare
#

Then I'll add it

upbeat hare
#

@frail star hows that LSP going?

frail star
#

pretty good

#

i’m finishing up syntax highlighting

#

then i’ll do semantic highlighting

#

and then code completion

upbeat hare
#

I should add a math library to patch manager

#

Mostly so I can do stuff like

$HO_RATIO: normalize-vector(6.0,1.0);
north mist
#

oh boy

#

a whole linear algebra library

upbeat hare
#

yes!

#

and a whole chemistry library

#

need to be able to do

$HO_RATIO: stoichiometric-ratio("H2","O2");
north mist
#

ah yes

frail star
#

@upbeat hare question

#

"Test" this is obviously valid

#

but is

#
"te
st"
``` valid
#

do you have multi-line strings

#

beacuse the antlr doesnt have a rule against it

upbeat hare
#

I mean ... I technically don't

#

have a rule against it

#

but why

frail star
#

i need to know for the langauge server lol

#

if its allowed

#

this is valid 💀

upbeat hare
#

Yes, its allowed

frail star
#

💀

#

i hate this

#

but ok

upbeat hare
#

Can't wait to have this in VSCode though, it will make writing patches a lot easier

frail star
#

lol

#

yeah

#

im gonna stop working on the highlighting for now

#

i setup the framework and stuff

#

and im just too lazy to write all the regex 😭

#

im going to do code completion

upbeat hare
#

I'll work on celestial bodies this week

#

Has the sinon made any progress on the lsp?

maiden wraith
#

wtf is the lsp?

north mist
#

language server protocol

#

it's for IDE support for the patching language

upbeat hare
#

Allows us to actually have syntax highlighting/code completion/error checking inside of VSCode

upbeat hare
#

Aight, now that I am once again in the mood to write code

#

Lets look at dem celestial bodies

#
        "assetKeyScaled": "Celestial.Ike.Scaled.prefab",
        "assetKeySimulation": "Celestial.Ike.Simulation.prefab",

This stuff here is whats gonna have to be built into addressable bundles, and is why scaling celestial bodies is nigh on impossible without a patch

#

Let me look if there is any information on celestial bodies prefabs that can assist withthat

upbeat hare
#

Alright, so the scaled prefabs seem to be 1k radius spheres

#

(Checked with Kerbin, Jool, and Ike

#

This system is confusing me

maiden wraith
#

What about it?

upbeat hare
#

Like, I was getting bugs from changing the radius of a planet, but I don't understand why

maiden wraith
#

What bugs? The planet not appearing?

upbeat hare
#

Physics glitching near the surface

maiden wraith
#

Yeah thats were pqs an cbt comes

#

They kinda balance it out

#

Same isse planety and i came accross (and a lot others)

upbeat hare
#

But I don't see anything in the PQS Renderer data that mentions radius or anything

#

Hell, the radius comes straight off the celestial body data

#

Hmmm, no this is just confusing

#

The scaled asset is only used in the map 3d view

#

Which, I might want to make a patch to modify the scale of later, but aaaa

#

Also interesting, and would make for a cool mod
Galaxy definitions can be changed per save file

#

therefore you can select what type of galaxy you want

#

Why does kerbol use the scaled asset while everything else uses the sim asset

#

The prefab key there isn't used in any case

#

But legitimately .... I don't see duplicated radius definitions or anything

north mist
#

I was helping Hyperion with that

upbeat hare
#

Makes sense

#

I'm at a loss, I don't understand this kind of black magic

upbeat hare
#

Hmmm, its not the pqs renderer thats the issue is it, its the collider?

maiden wraith
#

They are generated via the pqs iirc

upbeat hare
#

Then where the fuck is the issue

#

Everything points to it just working

upbeat hare
#

I'll give up on this for the moment and work on a math library

frail star
#

i’m still working on the core completion but i can give you a basic extension that just has syntax errors and like extremely basic highlighting

upbeat hare
#
@use 'builtin:math';
$value: normalize(1,2,3,4,5,6,7,8,9,10,11,12,13,14);
#

Is now possible

#

Also, just general math functions are possible

#

Like sin, cos, pow, log, etc...

upbeat hare
#

I still find it cool how I wrote an entire serialization/deserialization system for the language lol

upbeat hare
#

Welp, I'm gonna first update PM to support the in progress SW 1.5 and work on this

#

Wait ... I need an SW 1.5 prerelease package to make that easy on me aaaaa

#

I'll just do a test to see what version spacewarp is

upbeat hare
#

Umm, kerbin does not have a circumference measured in the AU amount

upbeat hare
#

Gods, what the fuck do I do to fix this

#

Actually, I think I'm starting to understand

upbeat hare
#

I'm ... getting it

#

I didn't fix it but I narrowed down the issue

#

Also gosh, I need that unity explorer that doesn't mess with time warp

north mist
#

Falki just made one recently

#

#🔴mod-dev message

#

actually let me put that into #🔴tools-and-resources, seems like something that shouldn't get lost in modding chat

upbeat hare
#

Like (this is from non testing install) I need it to look like this somehow and I don't understand the magic for that

upbeat hare
#

If I remove the inner atmosphere component it looks like this

#

Then if I scale up all the clouds

#

Oh gosh, this entire cloud rendering system is something

upbeat hare
#

Okay, so this field in the AtmosphereModel script, is likely whats contributing to the funkiness

#

Alright, now I got a plan

#

or I thought I did

#

You know ... i need to be able to edit the non-json data ...

#

And I can't easily do this in a patch ... unless it has to run each time

#

Which means the atmospheric scale fixing and such ... would work better as a patch manager addon as I'd have to do something like the following

@new("kerbin")
:atmosphere_replace {
  BottomRadius: 600.0 * 2.5;
  AtmosphereHeight: 60.0 * 2.5;
}

And intercept load calls, such that those values are replaced

#

As I can't just calculate this after the fact, easily

north mist
#

yeah, it makes sense

#

we kinda knew we'd have to do some Harmony patching for a lot of the stuff

upbeat hare
#

So the basic json assets are in scope for PM, but the atmosphere stuff ... likely will get pushed to a kopernicus equivalent?

upbeat hare
#

Aight, we should likely allow for @before '...' and @after '...' for patch ordering

#

And in the quotes it is before that referenced stage gets run if it exists and after that referenced stage gets run if it exists

north mist
#

and the idea is to let mods define custom stages that other mods can then refer to?

upbeat hare
#

(They already can)

north mist
#

got it

stiff crater
#

What should happen if two patches from different mods are conflicting and the modders did not provide stage order information?
I feel like the user should be notified and be able to manually define a load order but I'd love to hear what you all think about this

upbeat hare
#

Umm ... how would we detect this?

stiff crater
#

Hmm it would require keeping a list of modified json objects in RAM during patching and checking if some are modified multiple times and by whom at the end I guess

digital cloud
#

OK, Resources made. Now to figure out PM.

#

@upbeat hare is there any sort of example I should look at? This is probably easy, but I'm not sure where to start. Suppose I'd just like to take a simple Xenon tank and make an Argon one. Like fueltank_0v_inline_xenon. What would I need to do to make a copy of that and have it hold Argon?

upbeat hare
#

You ... can't copy it unfortunately

#

Not yet at least
I can see the utility in it, but it would likely have to be a PM addon

digital cloud
#

OK, then for just testing purposes (to make sure I've got the resources added correctly), how can I modify an existing tank like the fueltank_0v_radial_xenon?

#

I'd want to pick a tank I'm not currently using on a test craft - so that one would work

upbeat hare
#
:parts #fueltank_0v_inline_xenon > resourceContainers > Xenon {
  name: "Argon";
}
#

should work

digital cloud
#

Ok, but where I do put that?

upbeat hare
#

In any patch file, you can even just make a new one

digital cloud
#

Oh, so I could just drop a patch file into any mod, and if I've got Patch Manager it will run it?

upbeat hare
#

Yep

digital cloud
#

So I can put this in SPARK and not polute other mods!

#

I'm starting to get it!

#

Cool!

#

One more question then. I can whip up a tank fairly easily I think - it's one of the simplest parts to make. Do I make it hold whatever and then use PM to convert it to Argon, or with the resource defiend am I able to make it use Argon or Lithium or whatever directly?

upbeat hare
#

You can make it use whatever directly

digital cloud
#

Cool!

upbeat hare
#

I think I have an idea of how to do part copying

#

It will be in base PM out of necessity

#

But it will be a bit complex

#

Because to copy a part, there are a few other things you need to copy, or replace, the model for one

digital cloud
# upbeat hare *should* work

It didn't work... Or I'm not doing it right - probably the latter. I double checked the part name in the game's json, so AFAIK that's right, but when I look in the parts picker it still say's is holding Xenon

digital cloud
upbeat hare
#

Hmm...

#

Can you send logs

digital cloud
upbeat hare
#
[Error  :Patch Manager] Failed to generate an asset due to: PatchManager.SassyPatching.Exceptions.InterpreterException: C:\Kerbal Space Program 2 Debug\BepInEx\plugins\CommunityResources\patches\recipes.patch:24:4: System.ArgumentException: Could not determine JSON object type for type <>f__AnonymousType0`2[System.String,System.Double].
  at Newtonsoft.Json.Linq.JValue.GetValueType (System.Nullable`1[T] current, System.Object value) [0x000f2] in <394015232cf841bc8e43c6c98d8e6545>:0 
  at Newtonsoft.Json.Linq.JValue..ctor (System.Object value) [0x00000] in <394015232cf841bc8e43c6c98d8e6545>:0 
  at Newtonsoft.Json.Linq.JContainer.CreateFromContent (System.Object content) [0x0000c] in <394015232cf841bc8e43c6c98d8e6545>:0 
  at Newtonsoft.Json.Linq.JContainer.AddInternal (System.Int32 index, System.Object content, System.Boolean skipParentCheck) [0x00048] in <394015232cf841bc8e43c6c98d8e6545>:0 
  at Newtonsoft.Json.Linq.JContainer.Add (System.Object content) [0x0000c] in <394015232cf841bc8e43c6c98d8e6545>:0 
  at Newtonsoft.Json.Linq.JObject..ctor (System.Object content) [0x00011] in <394015232cf841bc8e43c6c98d8e6545>:0 
  at PatchManager.Resources.Selectables.RecipeSelectable.AddElement (System.String elementType) [0x00001] in C:\Users\arall\PatchManager\src\PatchManager.Resources\Selectables\RecipeSelectable.cs:76 
  at PatchManager.SassyPatching.Nodes.Selectors.ElementAdditionSelector.<SelectAll>b__2_0 (PatchManager.SassyPatching.Interfaces.ISelectable selectable) [0x00000] in C:\Users\arall\PatchManager\src\PatchManager.SassyPatching\Nodes\Selectors\ElementAdditionSelector.cs:25 
  at System.Linq.Enumerable+SelectListIterator`2[TSource,TResult].ToList () [0x0002a] in <351e49e2a5bf4fd6beabb458ce2255f3>:0 
  at System.Linq.Enumerable.ToList[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x0001f] in <351e49e2a5bf4fd6beabb458ce2255f3>:0 
  at PatchManager.SassyPatching.Nodes.Selectors.ElementAdditionSelector.SelectAll (System.Collections.Generic.List`1[T] selectables) [0x00002] in C:\Users\arall\PatchManager\src\PatchManager.SassyPatching\Nodes\Selectors\ElementAdditionSelector.cs:25 
  at PatchManager.SassyPatching.Nodes.Selectors.ElementAdditionSelector.SelectAll (System.Collections.Generic.List`1[T] selectables) [0x0001e] in C:\Users\arall\PatchManager\src\PatchManager.SassyPatching\Nodes\Selectors\ElementAdditionSelector.cs:29 
  at PatchManager.SassyPatching.Nodes.Statements.SelectionBlock.ExecuteOn (PatchManager.SassyPatching.Execution.Environment environment, PatchManager.SassyPatching.Interfaces.ISelectable selectable, PatchManager.SassyPatching.Interfaces.IModifiable modifiable) [0x0009c] in C:\Users\arall\PatchManager\src\PatchManager.SassyPatching\Nodes\Statements\SelectionBlock.cs:171 
  at PatchManager.SassyPatching.Nodes.Statements.SelectionBlock.ExecuteCreation (PatchManager.SassyPatching.Execution.Environment snapshot, System.Collections.Generic.List`1[T] arguments) [0x0008c] in C:\Users\arall\PatchManager\src\PatchManager.SassyPatching\Nodes\Statements\SelectionBlock.cs:99 
  at PatchManager.SassyPatching.Execution.SassyGenerator.Create (System.String& label, System.String& name) [0x00001] in C:\Users\arall\PatchManager\src\PatchManager.SassyPatching\Execution\SassyGenerator.cs:46 
  at PatchManager.Core.Assets.PatchingManager.CreateNewAssets (System.Action resolve, System.Action`1[T] reject) [0x0001c] in C:\Users\arall\PatchManager\src\PatchManager.Core\Assets\PatchingManager.cs:287 
digital cloud
#

Ahh, so I've goofed up the recipes.patch...

#

Does this part point to line 24? "recipes.patch:24:4"

upbeat hare
#

Line 24 column 4

digital cloud
#

If so, then that's this " +Hydrogen {"

#

in the Hydrolox recipie

upbeat hare
#

Can you show the full patch file again

#

I likely goofed that one up

digital cloud
#

// 6 units of hydrogen to 1 unit of oxidizer, normalized @new("Hydrolox", true) :resources { displayNameKey: "Resources/DisplayName/Hydrolox"; abbreviationKey: "Resource/Abbreviation/HO"; +Hydrogen { unitsPerRecipeUnit: 0.986394; } +Oxidizer { unitsPerRecipeUnit: 0.164399; } }

upbeat hare
#

Wait, no, I know that bug...

#

thats my fault

#

for sure

#

in PMs own source code

#

Or rather community resources I think

#

No, PM

#

Goddamnit

#

I'm dumb

digital cloud
#

You're not - this is just wickedly complex and you're juggling a lot.

#

On the plus side you've got eager early adopters like me who will help us surface these things!

upbeat hare
#
var obj = new JObject(new
        {
            name = "Unknown",
            unitsPerRecipeUnit = 0.00
        });

Of course this is the fucking issue
Newtonsoft.Json hates anonymous objects

digital cloud
#

See how smart you are? I'd have never guessed that in a million years.

upbeat hare
#
var obj = new JObject
{
    ["name"] = "Unknown",
    ["unitsPerRecipeUnit"] = 0.00
};
#

There, thats the fix for that line, but its quite a lot uglier

digital cloud
#

If it works, then it's beautiful!

upbeat hare
#

Alright, pushed to dev branch of PM

#

Made a PR for someone to look at

#

Also, can you zip up the cache folder from your latest run for me to look at?

#

Like the cache folder under patch manager

#

There might be another bug

digital cloud
upbeat hare
#

As I thought, it didn't even patch the fuel tank

#

Schloshrat, where did you put the file for the patch, and can you send the full patch file

digital cloud
upbeat hare
#

I'm thinking it honestly might be the name selector that causes an issue...

#

If you remove the #... it will change every ion tank to xenon hopefully

#

Could you try that for me

digital cloud
#

Like this?
:parts fueltank_0v_radial_xenon > resourceContainers > Xenon { name: "Argon"; }

upbeat hare
#

No, just remove that entire name there

#

So its
:parts > resourceContainers

#

Itll change every xenon tank, but I need to know if its a name selection issue

digital cloud
#

OK, but I've failed so far in my attempts to fork the dev branch and compile with the fix

#

I mean, I've forked it, but my local copy is only the main branch...

upbeat hare
#

Hmm, whats wrong?

digital cloud
#

I did a fork of all branches, and can see all of them on GitHib, but in vs I've only got main.

upbeat hare
#

Is there an update button?

digital cloud
#

Not that I see. It's like I can pick that branch, but then don't see any files.

upbeat hare
#

Ss?

digital cloud
#

Nvm, it was vs being stupiod I think

#

I closed it and reopened and Isee m to see them now.

upbeat hare
#

Thats correct

digital cloud
#

I think I did a build. Which file has your change so I can make sure that's in here

upbeat hare
#

Resources/selectables/recipeselectable

digital cloud
#

like this?

    internal ResourceSelectable(string data)
    {
        _originalData = data;
        JObject = JObject.Parse(data);
        Classes = new() { "resource" };
        Children = new();
        var resourceData = JObject["data"];
        Name = (string)resourceData["name"];
        ElementType = "resource";
    }```
upbeat hare
#

Its in RecipeSelectable.cs
And the add element function

digital cloud
#

Ahhh! This!

    public override ISelectable AddElement(string elementType)
    {
        var obj = new JObject
        {
            ["name"] = "Unknown",
            ["unitsPerRecipeUnit"] = 0.00
        };
        var child = new JTokenSelectable(SetModified, obj, tok => tok["name"].Value<string>(), "ingredient");
        Children.Add(child);
        Ingredients.Add(obj);
        return child;
    }```
#

If so, then I'll put that in and see what the patch does

upbeat hare
#

I'm not sure that will fix the patch tbh, itll fix the recipes patch, but im not sure about your patch

digital cloud
#

Hang on, there's nothing from PM in that log!

upbeat hare
#

you forgot to clear pm cache

#

Wait, hmm

#

no something si wrong

digital cloud
#

Should I clear it and try again?

upbeat hare
#

please do

digital cloud
#

No effect on tanks. Sending log.

#

I must have broken it somehow

#

I don't think it's running at all

upbeat hare
#

Yeah, something is wrong there

digital cloud
#

There's nothing in the cache folder

upbeat hare
#

Wait, patch manager isn't even being loaded by bepinex

#

no it is

#

I'm blind

#

Can you send KSP2.log

digital cloud
#

[ERR 12:17:22.769] AssetProvider unable to find assets with label 'resource_units'.
UnityEngine.Debug:LogError (object)
PatchManager.Core.Patches.Preload.AssetProviderPatch/<>c__DisplayClass0_01<UnityEngine.TextAsset>:<LoadByLabel>b__0 (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle1<System.Collections.Generic.IList1<UnityEngine.TextAsset>>) (at C:/KSP2Mods/PatchManager/src/PatchManager.Core/Patches/Preload/AssetProviderPatch.cs:35) DelegateList1<UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle1<System.Collections.Generic.IList1<UnityEngine.TextAsset>>>:Invoke (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle1<System.Collections.Generic.IList1<UnityEngine.TextAsset>>)
UnityEngine.ResourceManagement.ResourceManager:Update (single)
MonoBehaviourCallbackHooks:Update ()

upbeat hare
#

That is completely wrong

digital cloud
#

What about the resource_units error?

upbeat hare
#

Thats a side effect from community resources due to PM not running

#

I'm sorry, but I can't continue to help on this for a bit, I have some chores to do, and a movie to watch with a friend after that...

digital cloud
#

No worries. I appreciate what you've been able to do. I'll work on other things!

digital cloud
#

FYI - rolling back to the previous PM and taking out the recipes.patch (I don't think I need it for this), I saw that of course the resources are getting defined, but this still didn't address the part patching. I'll take a shot at making a super simple tank as a new part and defining it to use Argon or Lithium.

digital cloud
#

Yep, I can make an Argon tank!

#

Maybe not perfectly though...

#

Leaves a little bit to be desired, huh?

#

Like actually having some usable argon in it?

#

Huh, I thought I fixed the size thing?

#

At least the localization is working now

#

Still no actual resource inside it either - thought I had that fixed too.

#

We have resource!

#

And we have size!

#

I'm sure the numbers are all whack - and the model is weaksause, but it does seem I'm able to get these in the game.

#

Once we sort out the recipe patch business I may be able to turn out some nifty engine variants that use these new fuels!

#

Maybe this will help tone down the ludicrously OP MPD-1?

digital cloud
#

Not much surprise here, Lithium works too - though I really ought to make it's own mesh for this. I think a lithium "tank" should be very different as it actually holds ingots of metallic lithium that are slowly vaporized to deliver a gaseous form of the fuel. That's actually one of the technical hurdles preventing lithium powered ion thrusters from being used today. It's hard enough to handle that junk safely here let alone in space.

upbeat hare
digital cloud
#

No worries! I've made lots of progress and have some more part modelling ahead of me. When PM is working with recipies again then I'll be ready to give those a shot and see if I can make engines that use these new fuels. Enjoy your movie and your time with your friend(s)!

digital cloud
#

Hey Cheese, if we can sort out the PM business with reciepies and resources, then I'm ready to test with a bunch of Lithium tanks and a Lithium engine. I think all I need here is for LithiumEC to be a working recipe and then I can get that working.

upbeat hare
#

Gotcha

#

I need to figure out why PM won't run at all on the current version

digital cloud
#

Is there anything I could do to help?

upbeat hare
#

Sorry ... I've been having a week where its hard to focus on stuff
No luck

digital cloud
#

Well that doesn't sound like much fun. I hope your week improves!

digital cloud
# upbeat hare Sorry ... I've been having a week where its hard to focus on stuff No luck

Hey, sounds like there's not been a lot of progress on this one lately - more frustration than actual progress at least. I'm getting ready to push out an update to SPARK, so I'll make this next update not require PM or CR, since I think CR depends on PM, and neither are fully released yet. If there's anything I can do to help move this along please let me know as I'd very much like to see PM and CR released!

upbeat hare
#

Aight, not much you can do to help rn, though I should be able to look into it later today or tomorrow

upbeat hare
#

Alright ... yeah I kind of realize I forgot to, or got completely sidetracked
Not to worry I will look into it today

upbeat hare
#

@digital cloud try the dev build of PM with SW 1.5?

digital cloud
# upbeat hare <@402620630585049088> try the dev build of PM with SW 1.5?

Not sure if I'm doing it right, but I got this result.
[Error :Patch Manager] Failed to generate an asset due to: System.NotImplementedException: The method or operation is not implemented. at PatchManager.Resources.Selectables.RecipeSelectable.Serialize () [0x00000] in C:\KSP2Mods\PatchManager\src\PatchManager.Resources\Selectables\RecipeSelectable.cs:88 at PatchManager.SassyPatching.NewAssets.NewGenericAsset.get_Text () [0x00000] in C:\KSP2Mods\PatchManager\src\PatchManager.SassyPatching\NewAssets\NewGenericAsset.cs:30 at PatchManager.SassyPatching.Execution.SassyGenerator.Create (System.String& label, System.String& name) [0x00029] in C:\KSP2Mods\PatchManager\src\PatchManager.SassyPatching\Execution\SassyGenerator.cs:49 at PatchManager.Core.Assets.PatchingManager.CreateNewAssets (System.Action resolve, System.Action1[T] reject) [0x0001c] in C:\KSP2Mods\PatchManager\src\PatchManager.Core\Assets\PatchingManager.cs:302
[Error :Patch Manager] Failed to generate an asset due to: System.NotImplementedException: The method or operation is not implemented.
at PatchManager.Resources.Selectables.RecipeSelectable.Serialize () [0x00000] in C:\KSP2Mods\PatchManager\src\PatchManager.Resources\Selectables\RecipeSelectable.cs:88
at PatchManager.SassyPatching.NewAssets.NewGenericAsset.get_Text () [0x00000] in C:\KSP2Mods\PatchManager\src\PatchManager.SassyPatching\NewAssets\NewGenericAsset.cs:30
at PatchManager.SassyPatching.Execution.SassyGenerator.Create (System.String& label, System.String& name) [0x00029] in C:\KSP2Mods\PatchManager\src\PatchManager.SassyPatching\Execution\SassyGenerator.cs:49
at PatchManager.Core.Assets.PatchingManager.CreateNewAssets (System.Action resolve, System.Action1[T] reject) [0x0001c] in C:\KSP2Mods\PatchManager\src\PatchManager.Core\Assets\PatchingManager.cs:302

#

[Error :Patch Manager] Failed to generate an asset due to: System.NotImplementedException: The method or operation is not implemented. at PatchManager.Resources.Selectables.RecipeSelectable.Serialize () [0x00000] in C:\KSP2Mods\PatchManager\src\PatchManager.Resources\Selectables\RecipeSelectable.cs:88 at PatchManager.SassyPatching.NewAssets.NewGenericAsset.get_Text () [0x00000] in C:\KSP2Mods\PatchManager\src\PatchManager.SassyPatching\NewAssets\NewGenericAsset.cs:30 at PatchManager.SassyPatching.Execution.SassyGenerator.Create (System.String& label, System.String& name) [0x00029] in C:\KSP2Mods\PatchManager\src\PatchManager.SassyPatching\Execution\SassyGenerator.cs:49 at PatchManager.Core.Assets.PatchingManager.CreateNewAssets (System.Action resolve, System.Action1[T] reject) [0x0001c] in C:\KSP2Mods\PatchManager\src\PatchManager.Core\Assets\PatchingManager.cs:302 `

#

Why is there crap like "System.Action`1[T] reject) [0x0001c]" in the log?

#

Why does an automated log include something with a ` in the name?

#

That's just stupid.

#

Way to fuck up MD

#

Anyway, all the materials seem to come in, but there are three recipies, and none of those come in.

#

I tried to make sure I was on the dev branch, but I'm not 100% sure I did that right.

upbeat hare
#

Aight lemme look at it

#

Ah, I was just being in the common parlance, an idiot

upbeat hare
#

Thats how generic type names just get outputted

#

anyways, try with the newest commit?

#

@digital cloud if you didn't see

digital cloud
#

Doing it now

#

Not sure what I've done wrong but now I'm not getting the new resources or any recipies.

upbeat hare
#

Forgot to clear out the cache

#

There should be a cache folder under the patch manager, just delete that

digital cloud
#

done. launching now

#

Wheeeee!

#

[Info :Patch Manager] Generated an asset with the label resources, and name LithiumEC: { "version": 0.1, "useExternal": false, "isRecipe": true, "data": { "name": "LithiumEC", "displayNameKey": "Resources/DisplayName/LithiumEC", "abbreviationKey": "Resource/Abbreviation/LE", "resourceIconAssetAddress": "", "vfxFuelType": "NoFuel", "ingredients": [ { "name": "Unknown", "unitsPerRecipeUnit": 1 }, { "name": "Unknown", "unitsPerRecipeUnit": 1 } ] } }

#

I can now play with Lithium fueld engines!

#

I think

upbeat hare
#

Well

#

"name": "Unknown"

digital cloud
#

Hmmm....

upbeat hare
#

Ahh, thats my fault again

digital cloud
#

That's not supposed to be like that....

upbeat hare
#

I know

#

I just fixed it

digital cloud
#

Yeah, Hydrolox is the same way as is ArgonEC..

upbeat hare
#

So if you want to try rebuilding, then deleting the cache and launching again, it should likely work

digital cloud
#

Doing that rn!

#

launching...

#

[Info :Patch Manager] Generated an asset with the label resources, and name Hydrolox: { "version": 0.1, "useExternal": false, "isRecipe": true, "data": { "name": "Hydrolox", "displayNameKey": "Resources/DisplayName/Hydrolox", "abbreviationKey": "Resource/Abbreviation/HO", "resourceIconAssetAddress": "", "vfxFuelType": "NoFuel", "ingredients": [ { "name": "Hydrogen", "unitsPerRecipeUnit": 0.986394 }, { "name": "Oxidizer", "unitsPerRecipeUnit": 0.164399 } ] } }

#

and

upbeat hare
#

That looks right!

digital cloud
#

`

#

[Info :Patch Manager] Generated an asset with the label resources, and name LithiumEC: { "version": 0.1, "useExternal": false, "isRecipe": true, "data": { "name": "LithiumEC", "displayNameKey": "Resources/DisplayName/LithiumEC", "abbreviationKey": "Resource/Abbreviation/LE", "resourceIconAssetAddress": "", "vfxFuelType": "NoFuel", "ingredients": [ { "name": "Lithium", "unitsPerRecipeUnit": 1 }, { "name": "ElectricCharge", "unitsPerRecipeUnit": 1 } ] } }

#

Looks good for me!

#

ArgonEC looks good too. I'll take these for a spin and see if they really do work!

digital cloud
# upbeat hare That looks right!

OK, the problem may be at my end - I don't know yet, but I'm getting Engine does not have a valid Mixture defined spamming in my log if I select anything that uses LithiumEC, and in the parts picker I'm getting this

#

For one of my other engins burning Xenon it looks like this

upbeat hare
#

Hmm, how is it defined in text and can I see the logs?

digital cloud
upbeat hare
#

Hmmm

digital cloud
#

This is XenonEC

#

{ "_comment": "flowMode is integer: 0 - NULL, 1 - NO_FLOW, 2 - ALL_VESSEL, 3 - STAGE_PRIORITY_FLOW, 4 - STACK_PRIORITY_SEARCH, 5 - STAGE_STACK_FLOW_BALANCE", "_Comment2": "transferMode is integer: 0 - NONE, 1 = PUMP", "_commentDescription": "Compound resource for most basic jet engines", "version": 0.1, "useExternal": false, "isRecipe": true, "recipeData": { "name": "XenonEC", "displayNameKey": "Resource/DisplayName/Xenon", "abbreviationKey": "Resource/Abbreviation/Xe", "resourceIconAssetAddress": "", "ingredients": [ { "name": "Xenon", "unitsPerRecipeUnit": 1 }, { "name": "ElectricCharge", "unitsPerRecipeUnit": 1 } ], "vfxFuelType": "Pressurized" } }

upbeat hare
#

Can you zip up your cache for me and send it rq?

#

OHHH

#

I seee

#

data vs recipeData

digital cloud
#

That may be it!

upbeat hare
#

Pushed a commit that changes that

digital cloud
#

OK, grabbing now.

upbeat hare
#

Remember to nuke the cache (it doesn't do that cuz no actual patch files or versions have changed)

digital cloud
#

Ahhh... That's why it didn't work... On sec, nuking and re-testing

upbeat hare
#

I should really add a config option to always rebuild cache

digital cloud
#

So far so good!

#

So far, so very good!

upbeat hare
#

Awesome!

digital cloud
#

Holy Shit! My plume is RED!

#

I do NOT no why... I kinda like it though...

#

Not the right color, but that tank definitely holds Lithium (and not water), and the engine is "burning" lithium!

#

That thing is soooooo OP.

#

I swear I've got the same mass, Isp, and thrust as what Nertea has in NFP...

#

Granted, it needs some real thermal management, but even with that it would have thrust out the ying yang

#

Most players seem to like their thrust that way, but this is OP!

upbeat hare
#

Lol
But yeah, fucking awesome

digital cloud
#

Is this pushable?

#

How close to a release?

#

I think this may be a watershed moment for KSP2 modding.

upbeat hare
#

I honestly wanted to really finish up planet stuff before a release, but I'm not sure how soon could do that

stiff crater
upbeat hare
#

Also a few other things insofar as needing to have the SW 1.5.1 nuget package up so I can set it as a dependency

digital cloud
#

How about a PM roadmap? In a first release perhaps it allows for new resources and recipies and what not, then in a future planned release it's doing planets?

#

I'm not really sure what the roadmap would be, but something where we can stake a claim for this is what it does now, and this is what we've got planned.

#

I can see where the planets part may really impact the game when science gets here.

upbeat hare
upbeat hare
#

The other thing I was waiting for tbqh was a mod to release alongside PM to show what it can be used for, which either KLSS or SPARK can fulfill

stiff crater
digital cloud
#

So, some more testing to be certain it's ready. No need to be overly hasty here

#

I'll have a version of SPARK ready to drop with dependencies for PM and CR.

#

Oooo! I need to work on Argon fueld VASIMR engines!

#

More toys....

#

One can never have to many of those amiright?

upbeat hare
#

Lol true

stiff crater
#

Are the fixes to recipe patching merged in main / in a pre-release? (trying to fix the Community Resources non-stageable resources UI fix thingy and the mod is erroring out a bunch because of broken recipes)
If not I can just build PM locally real quick no problem

upbeat hare
#

They are currently in dev

stiff crater
#

Ok so I'm trying to wrap my head around the "module patches not applied to vessels that are not directly launched from VAB" bug and it seems to happen because the PartBehaviourModules' Data is null when Init() calls ModuleDataList.TryAddUnique.
Was this also the previous assessment? Also, do we know where the PartBehaviourModules are instanciated / where their Data is usually initialized?

upbeat hare
#

It happens normally when the json merging magic happens, I could see if I can get a better location than that

stiff crater
#

Btw in PM this magic happens in PatchManager.Parts.Patchers.PartModuleLoadPatcher or is there other places related to that?

upbeat hare
#

Thats where I was tryna fix it

stiff crater
upbeat hare
#

I think so

stiff crater
#

Oy what the hell were they on when they wrote that

#

I'm gonna need a few hours trying to wrap my head around this stuff

stiff crater
#

Is there a way to inspect a JSON generated by Patch Manager?

upbeat hare
#

Just look in the cache that PM makes

stiff crater
#

Roger that, thanks!

#

Uh a bunch of things do not seem to be initialized properly in the generated json

#

I'll try initializing all of this in my patch to see if it fixes the bug

#

But that can't be just it, I had issues with a Data_ResourceCapacities too even though there's nearly nothing in the DataObject for this one...

stiff crater
stiff crater
upbeat hare
stiff crater
#

I'll need to check again when I get back home but iirc if you launch a new craft with custom modules, then save, then reload that save, the craft loads with the usual null data issue

upbeat hare
#

That feels like a very odd bug

stiff crater
upbeat hare
#

Hmmm ... specifically stock?

stiff crater
#

Ah no for all I think, I just added a null check to AddModuleData in my custom module

#

(a very dirty fix would be to add such null check & initialization to stock modules maybe)

stiff crater
upbeat hare
#

i dont understand how stock craft arent nulled??

stiff crater
#

The data for those are, right? Pretty sure I had issues with those

#

I mean the data for added modules

#

I'll check when I'm home in ~45min

#

Btw I need to look at how eva_kerbal is loaded because it is nulled too. I had assumed it'd work like a launched vessel but no

stiff crater
#

Fun? fact: the data is nulled on save game load after restarting the game, but if it's during the same session as when the vessel was launched it works perfectly??

upbeat hare
#

h-huh

stiff crater
#

Ah and launching a stock craft from the VAB is okay (expected)
But when launching directly from a launchpad from the KSC screen it's "partially" broken

#

Like no errors but the converter is broken

north mist
#

oh god this will be insane to deal with

upbeat hare
#

what do saves look like

stiff crater
#

The pod of the partially broken craft doesn't have its ResourceConverter

#

My mod should add a Module_LifeSupportConsumer and a Module_ResourceConverter to all crewable parts

#

So for the situations that definitely generate null data we have:

  • starting an EVA
  • loading a save game with vessels launched before the last game reboot
    do I forget any?

And when launching stock crafts directly from a launchpad menu, PM doesn't seem to properly add the module (half-broken-ish)

upbeat hare
#

#🔴mod-dev message
Well if we need more reason for planet support :p

north mist
#

we better help Tim go to the Moon before he actually goes to the Moon

upbeat hare
#

But yeah, after we fix this bug, planets are my top priority

#

Also @stiff crater that file does have your full name in it

stiff crater
#

Ah indeed, let me re-send it rq

#

(my name is not a big secret, pretty easy to find, but let's be safe)

upbeat hare
#

Yeah

#

Just was letting ya know

stiff crater
#

There are other crafts in the save that were launched from VAB so should have the more correct data

#

(except a bunch of null stuff from not correctly initialized fields)

upbeat hare
#

So did this part have a converter before restart?

stiff crater
#

The converter is kinda here but missing some stuff

#

Like the mode dropdown

upbeat hare
#

Let me ask, what was the process to make this buggy craft?

#

Did you launch a craft from the VAB, save game, reboot game, and load save?
And were the mods changed at any point there

stiff crater
upbeat hare
#

Ahh, then I think I understand

stiff crater
upbeat hare
#

Crafts have to go through the VAB for the default json merging to occur, when loading a saved craft from a craft save file, that json never gets merged as its assumed to already be in there

upbeat hare
stiff crater
#

Well the module is here, but when loading the save AddModuleData fails because the data field of the Module is null

upbeat hare
#

And was that with or without KLSS being installed on the first launch?

stiff crater
#

With it installed

upbeat hare
#

I'm sorry to ask more of you, but can you grab a save file from before and after that as well?

stiff crater
#

Before and after what precisely? (just to be sure)

upbeat hare
#

Launch it and save, then reboot and load the game and I suppose save if you can

stiff crater
#

Roger

upbeat hare
#

Looks fine on the first one

stiff crater
#

No diffs in the files expect for some float values here and there

upbeat hare
#

Yeah, no there isn't

#

This a loading bug?

stiff crater
upbeat hare
#

So it gets nulled out...

stiff crater
#

The weird part is that it works well if the game is not rebooted, for the loading part

upbeat hare
#

Hmmm, does the game cache part prefabs with added modules?

stiff crater
#

🤷‍♂️ No idea

#

The big question is: when is this protected field normally initialized and why is it not for added modules after rebooting / when going on EVA

#

It being null at the moment of AddDataModules (called on PartBehaviourModule.Init, which is called at PartBehaviour.Start) is what is breaking the Module

upbeat hare
#

Looking at this ... this is called on the cached object, so yeah it does cache the prefabs

#

But me adding the modules to the prefab shouldn't be an issue

upbeat hare
#

Hence the [FormallySerializedAs] and the [SerializeField]

#

Thats meant for someone to set up the default data within the unity editor

stiff crater
#

Ohh so the C# class is instanciated in the part prefab kind of? (I'm still very new to Unity stuff 🙇 )

upbeat hare
#

Yep

#

Which means ... hmm maybe we have to hijack that

#

But hmm, thats quite a bit of reflection

stiff crater
#

When PM adds modules to prefabs does it initialize those serialized fields?

upbeat hare
#

No.

#

It should, shouldn't it?

#

That would solve the issue, but how would we do that?

#

Well actually, I do know how ... as I said, a bit of reflection magic

#

Aaaaa, I only got 20 mins before I told someone I'd speak to them in VRChat

#

But the fix is on my mind

stiff crater
#

Nice!

upbeat hare
#

I could just do a simple fix looping over fields and looking for one that extends from PartData and then initialize that with the data value from the json

stiff crater
#

(it extends from ModuleData to be precise but yeah that sounds good)

upbeat hare
#

Yeah, I was just saying stuff likely incorrect

#

So that would hopefully fix the first bug

stiff crater
#

The "partially incorrect modules when not launching from VAB for a vessel pre-dating a mod install" one feels a bit more difficult to deal with

#

Unless it is possible to highjack the launching process to force a json merge somewhere?

#

Well anyways, it's already past 1am I'm going to sleep. If you need more saves / logs, I'll be able to send those tomorrow

upbeat hare
#

For the SerializedField not being loaded fix?

stiff crater
upbeat hare
#

Want me to build the dev branch or are you able to pull and build it?

stiff crater
#

I have PM locally dw

upbeat hare
#

Gotcha

#

Thanks for hunting down where the issue comes from for me, its much easier to fix when I know exactly what the issue is

stiff crater
#

Still broken :/ Let me check Unity Explorer rq to see if data is still null

upbeat hare
# stiff crater :/

Thats completely odd to me, what I did shoulda worked :/
I'll work on it more tomorrow

#

Hmm, likely will have to do some print debugging
Meaning I shall also need to make a custom patch for testing purposes, but what?

#

Anyways yeah, goodnight safarte, I need to go now as well

stiff crater
#

'night!

upbeat hare
#

Itll be a bit till I can work on it today

#

Hmm, would you mind sending me a version of KLSS to test this with though, so I can do the testing myself?

#

If not, I can figure out someway to make something to test with

upbeat hare
upbeat hare
#

Testing now

#

@stiff crater how does the error manifest itself in game? as I'm not seeing anything obviously wrong?

#

In fact I see these logs which seems correct

#

(That was after a restart of the game)

#

In fact I do see some stuff happening to EVA_kerbal as well

stiff crater
upbeat hare
stiff crater
#

Maybe I have some cache shenanigans with BepInEx

upbeat hare
stiff crater
#

Yeah that looks perfect

upbeat hare
#

And I see all the resources on Valentina Kerman as well

stiff crater
#

Does the time count down on the UI ?

#

for Val

upbeat hare
#

No...

#

Hmm

#

But it does in the pod

stiff crater
#

That may be an issue on my side, I need to check my patches