Widget recipe selection.

I've been digging through the widget nodes. I havent been able to figure out a good method to generate a list of recipes used by a building type. The manufacturing widget does this with a stubbed function. Is there a way to call down into that function perhaps? The best I've come up with so far is to grab a list of recipes from each category, and then cycle through the recipes and filter by which are buildable by class of type self.
It might be better to write that up as a subsystem or cache it somehow... But I figure there has got to be a better method... Or perhaps not, and that may be why most widget mods don't carry recipe selection.
13 Replies
D4rk
D4rk2mo ago
If your buildable is a AFGBuildableManufacturer then call GetAvailableRecipes on it.
No description
D4rk
D4rk2mo ago
If you're doing this on some other class you can loop through all recipes and check if your builder class is listed as a producer of that recipe
No description
MrWolf
MrWolfOP2mo ago
You're the best. Quick question, becasue I did find the recipie manager, how did you learn what functions were available to that object?
D4rk
D4rk2mo ago
The headers are provided by CSS, look in your projects source folder. Also, in the games community resource folder.
MrWolf
MrWolfOP2mo ago
Ok, so looking for resourcemanager.h or similar... thanks
D4rk
D4rk2mo ago
No, in this case you're looking for FGBuildableManufacturer.h
MrWolf
MrWolfOP2mo ago
But you're calling a resource manager funciton get all available recipes?
D4rk
D4rk2mo ago
Yes, but there is another function of the same name that exists on AFGBuildableManufacturer, and if you're buildable is of that class, then thats the one you should use. either way will work though
MrWolf
MrWolfOP2mo ago
Oh shoot... I mixed up Widget_Manufacturer and FGBuildableManufacturer Uhm... becasue we are in Widget land instead of Buildable land... the buildable has our widget... how does our widget have access to our buildable? Widget.Parent.Function I'd guess so... in flow chart land uhm...
D4rk
D4rk2mo ago
AFGRecipemanager->GetAllAvailableRecipes returns ALL recipes currently unlocked, and you will have to filter through them to find the ones that can be produced by your machine, however, if your machine is a AFGBuildableManufacturer, you can call GetAvailableRecipes on it to get a prefiltered recipe list Get the mInteractObject, cast it to your buildable class, call GetAvailableRecipes on it Assuming your buildable is a AFGBuildableManufacturer, you havent said it is or not yet.
MrWolf
MrWolfOP2mo ago
Sorry, it is Super cool, I think you've given me everything needed to unblock me. I still have some questions but let me chew on it for a bit and see if I cant work things out. Thank you so much for your help
MrWolf
MrWolfOP2mo ago
Just making sure I understand. After a bit of googleing... seems like our object is an instance of our class. So if I take my instance object... which, I'm thinking of as kinda a void*, and cast it to my object type... It seems like Im just taking that void* and casting it to a FGBuildableManufacturer*, which in my case is my specific implementation of FGBuildableManufacturer* Build_Wolf_Furnace_NaturalDraft* which we can then access its methods, which we are calling functions so I'd guess reinterpret_cast<Build_Wolf_Furnace_NaturalDraft*>InteractObject->GetAvailableRecipes()... Uhm... why I'd want to grab the class of my object I'm not sure yet, I'd guess for comparison to see if two objects are of the same type... but thats a future me problem... Does my interpretation make sence or am I off base?
No description
D4rk
D4rk2mo ago
Yes, that is correct, use the object cast
Want results from more Discord servers?
Add your server