Jump to content

Nameless Meals


l33tmaan

Recommended Posts

This seems different enough from my old problems to have a new thread. I've got my new meal about where I want it to be, so now I just need to name it... but I'm not sure how? This is what it says below, which is different from the 'item-modid-foodwhatever' style I usually see when debugging. I tried /expclang, but when I did I get a completely blank collectablelang.json.

2021-01-11_10-30-47.png.eea26b8b7f3b4f0d666846811e9955d4.png

I'm kind of at a loss here, where does the pot draw the list of meal names from? I'd like it to say "Pot of redmeat au gratin" and '1 serving of cheddar au gratin with redmeat' or something like that. Any help?

ExpandedFoods.zip

EDIT: Is this the place? I'm still not very literate when it comes to .cs files. I noticed there's a 'recipe.GetOutputName' on line 399. Uh... is that related?
https://github.com/anegostudios/vssurvivalmod/blob/master/BlockEntity/BEMeal.cs

Edited by l33tmaan
Link to comment
Share on other sites

It probably is that GetBlockInfo function that's building the description - I've overridden that function to display info in the hud before...but you should be able to do something (although maybe not exactly how you might want it) via en.json.

With en.json, every slot in the pot can get its code converted to a word.  More or less - some of the slot descriptions are combined on the fly - i.e. if you put two redmeats in the first two slots it will say redmeat stew, not readmeat and readmeat stew.

It's this sorta stuff that's handling the translation...

    "recipeingredient-item-meatnugget-bushmeat-raw": "bushmeat nuggets",
    "recipeingredient-item-meatnugget-bushmeat-raw-insturmentalcase": "bushmeat nuggets",
    "game:meal-ingredient-stew-primary-meatnugget-bushmeat-raw": "Bushmeat nugget",
    "game:meal-ingredient-stew-secondary-meatnugget-bushmeat-raw": "Bushmeat nugget",


So if you look at...\AppData\Roaming\Vintagestory\assets\game\lang\en.json and search for the word "ingredient", you'll find many examples of how this works.  I don't know all of the specifics, so it might take a bit of trial and error.

By not exactly how you want it, I mean you might end up with "with milk and cheese" instead of "au gratin".
 

Edited by Spear and Fang
Link to comment
Share on other sites

I don't think I did that?  I didn't do it on purpose, at least. Looking at en.json, the only mention of that is  "block-claypot-cooked": "Pot of cooked food".

I also see this:

  "meal-normal-porridge": "{0} porridge {1}",
  "meal-normal-stew": "{0} stew {1}",
  "meal-normal-soup": "{0} soup {1}",

  "meal-hearty-porridge": "Hearty {0} porridge {1}",
  "meal-hearty-stew": "Hearty {0} stew {1}",
  "meal-hearty-soup": "Hearty {0} soup {1}",

  "meal-hefty-porridge": "Hefty {0} porridge {1}",
  "meal-hefty-stew": "Hefty {0} stew {1}",
  "meal-hefty-soup": "Hefty {0} soup {1}",

I'd like to just throw in "meal-normal-augratin" or something, but I don't remember defining this anywhere in my code.

Link to comment
Share on other sites

Yeah I saw that "Pot of cooked food" in there after I posted that.  I'm assuming that's the failover if it doesn't know what to display for the pot.

You could very well leverage that stuff in green above to get to your "au gratin" if you can figure out where those codes are coming from.  The {0} and {1} are just string substitutions depending on what's in the slots, so for example, that meal-hefty-stew could translate to "Hefty redmeat stew with turnips and honey".  {0} = "redmeat"  {1} = "with turnips and honey"

I'd have to do a deep dive to really figure out how that was actually implemented.

Edited by Spear and Fang
Link to comment
Share on other sites

Well, trying "meal-normal-augratin" and the larger variants didn't change anything. Given that the recipe code for stew is "meatystew" and not just "stew", this 'meal-*' must be defined in a place I haven't seen yet, and I've looked around in a lot of the various foods and meals. 

Link to comment
Share on other sites

Yeah...not a lot of luck here.  If I patch the existing advanced recipes (i.e. meaty stew) I can get at least something to show, but I couldn't get to "au gratin".

Untitled.png.747f64a5ee9cd8b2b37dae7d9504c02e.png

I feel like it would take quite a time investment and c# to get to where you really want to be, either via a Harmony patch (which I have no experience with) or rewriting the pot related c# code and patching the pot with it.  Sorry!

These were the lang.en entries I used to complement the meaty stew patch fyi, if you decide to try walking that road.

    "recipeingredient-item-cottagecheeseportion": "Cheese",
    "recipeingredient-item-cottagecheeseportion-insturmentalcase": "Cheese",
    "recipeingredient-item-milkportion": "Milk",
    "recipeingredient-item-milkportion-insturmentalcase": "Milk",

I had hoped that another lang.en entry like this:  "with boiled milk and cheese": "au gratin" 
would be enough to tidy things up, but sadly that did not work.
 

Edited by Spear and Fang
Link to comment
Share on other sites

Giving it a little more thought, if you want to keep things entirely json, you *could* create a grid recipe to combine cheese and milk to create a single ingredient (i.e. "milky cheese"  that's terrible I know), and then you could use THAT in the pot with the technique I used above to give you "au gratin".  Maybe.  Probably.  Patch the stew and soup recipes to give you some variety.

One benefit to patching the existing recipes is that you could basically just refer people to "Advanced Cooking Recipes", and tell them that you can use this optional milk/cheese mixture just like you would use all the other optional ingredients.  Basically.

https://wiki.vintagestory.at/index.php?title=Cooking

Food for thought.  (pun intended)

Edited by Spear and Fang
Link to comment
Share on other sites

Yeah, but that would mean just letting you add dairy to stew and soup, which wouldn't result in that nice and creamy look. It's really frustrating to get this far and have THE NAME be the final roadblock... but people need to know what's in their crocks! 
This sucks, because I don't even know where to start when it comes to patching c# code. I could maybe potentially cobble something together if I knew where to look for it. It's just a name! They're already in the game, how hard can this be? 😅

Link to comment
Share on other sites

Well not terribly hard.  You look at all of the classes on the block, so "BlockCookingContainer", "BlockCookedContainer", and "CookedContainer", and then follow the trail.  That ingredient list certainly seems to lead to the GetBlockInfo function in BECookedContainer.  

The first line of that function appears to be getting all of the items/blocks that are in the pot and storing them in contentStacks.
 

ItemStack[] contentStacks = GetNonEmptyContentStacks();


Then a little further down, this:
 

if (servings == 1)
            {
                dsc.Append(Lang.Get("{0} serving of {1}\nTemperature: {2}{3}{4}"Math.Round(servings1), recipe.GetOutputName(forPlayer.Entity.WorldcontentStacks), tempprettynutriFacts != null ? "\n" : ""nutriFacts));
            }
            else
            {
                dsc.Append(Lang.Get("{0} servings of {1}\nTemperature: {2}{3}{4}"Math.Round(servings1), recipe.GetOutputName(forPlayer.Entity.WorldcontentStacks), tempprettynutriFacts != null ? "\n" : ""nutriFacts));
            }


In particular, the recipe.GetOutputName function appears to take all of those contentStacks and convert them into the final description.  So one could fairly easily loop through contentStacks and look for cheese and milk and go from there.  But as always seems to be the case, what seems easy on the surface tends to be WAY harder in reality.

There's many ways to skin that cat, but one way would be to look for cheese and milk contentStacks, and if they're there remove them from contentStacks and set a new string to "au gratin".  Then throw the rest of the contentStacks at recipe.GetOutputName, and finally append your new string to the end of whatever recipe.GetOutputName returns.

Finally, take your newly modified class (lets call it BECookedContainterAuGratin), register it, and patch pot.json to replace the reference to BECookedContainer with BECookedContainerAuGratin.

Whew, just saying that out loud sounds like work.

 

Edited by Spear and Fang
Link to comment
Share on other sites

The way I see it, there's another better way to solve this, but there's two problems with this other "better way".  The fact that the ingredients are dairy, which I suspect are not properly registered recipe ingredients, and the fact that you want to combine two ingredients into one description.  But I digress.

Link to comment
Share on other sites

Wait, BECookedContainer? Where is that? 😖 I know where BEMeal and BEGenericContainer are, but I've never seen BECookedContainer!
About the description though - the only thing that should actually change in the description is the cheese type. For example, the 3 variants would be 'Cheddar au gratin', 'Blue cheese au gratin', and 'Cottage cheese au gratin', plus whatever extras you added in. The milk doesn't actually factor into the name of the meal, nor can you add it as an extra ingredient. Would that make things a bit easier?

Edited by l33tmaan
Link to comment
Share on other sites

It's in Systems\Cooking in the VSSurvivalMod folder structure.  If you're curious why I don't just tackle this myself, it's because I've been down these rabbit holes before.  It "seems" like an easy fix, but inevitably leads to a week or more of work (for me anyways).  Not knocking Tyron at all, it's a real juggling act for him to deliver new content, while at the same time making things mod friendly.  A lot of things are mod friendly, but I'd say that cooking is not one of those things.

Again if it was me, I'd try to work within the confines of the existing advanced cooking systems, and then tackle any outstanding issues after the fact. The other thing you're saying above does make things a little easier (the milk would become the 'au gratin'), but the way those meals works it also adds some words between the ingredients i.e. "with", "with boiled", "and", so I suspect you'd still need to override that class when all's said and done.  :(

Edited by Spear and Fang
Link to comment
Share on other sites

Yeah, when I say 'seems easy', I mean for coding. Which is objectively still really hard.
At the end of the day, I still like the new meals and I'd hate to not include them... at least if the crocks say 'unknown' you know there's dairy inside, at least? 😖
I can try crawling through some more .cs files, but I doubt I'll find anything super helpful. I guess I'll have to hope cooking gets a little mod-friendlier eventually. Or something. I dunno.
Of all the things to get stuck on, eh?

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.