So I'm working on a food crafting engine that will be have an open-ended raw-ingredient-to-finished-product system. Inspired by the Cobl dinner plate system, I plan to have a set of levelled lists which contain the "raw ingredients" that one can cook with: raw meats, veggies, grains, etc. Using this system I can have a mod that's filtered into the bashed patch (similar to Cobl Filter Late MERGE ONLY.esp or the Item Interchange system) that allows me (or anyone else) to add items from other mods to these lists for players to cook with, and only the mods the player has loaded will matter. Using the raw ingredients from any number of mods is easy this way. I haven't yet figured out how to/if I can let the player make items from other mods (ie, how to craft rat-on-a-stick from Better Cities.esm). This part may not be possible...
I will allow up to 4 ingredients per cooking recipe (for simplicity more than anything), and I'm building the system to allow "specific" and "generic" ingredients. For example, to make "roast venison" you'd need to use venison as the specific (and only) ingredient. To make fruit salad, you could use any three fruits as generic ingredients. To make a fruit pie, you'd need flour (specifically) and any fruit (generically). When the player's selected their raw ingredients, the script will check the ingredients against its known recipes and ask, for example, "Are you trying to make broiled crab meat?" If it doesn't find a matching recipe it'll ask the user to name the product (or cancel, of course). I'll also have different cooking tools (ie, frying pan, pie plate, soup pot) so you could get different results using the same ingredients with a different cooking method - baked potato on the baking sheet, mashed potatoes in the pot.
I'm ruminating on a system to let the user name the cooked product, determine what type of food it is (for the Cobl food lists), and choose an icon/model for the product. It'll probably be OBSE text entry, messagebox, and a container full of icons to choose from, respectively. Oh, another thing is that I'm hoping to be able to store recipes using the names of the raw ingredients (as opposed to thier formIDs) so that if you have multiple mods that add "wolf meat" you can use anything named "wolf meat" to make your wolfburgers.
I figure the only way to create "new food" on the fly is to have a default ebible ingredient object and clone it, assigning a new name, icon/model, ingredient effects, weight, etc.
So far so good. I've got my lists, a test merge mod pulling items from alive waters and MMM, and I'm able to let the player select things to cook and determine what they've selected and whether each is specific or generic.
Now what I'm having trouble with is figuring out how to set up an array to keep track of it all. What I imagine I'll need is something like:
- product number (is this needed in an array? can I just iterate through the whole array and search by one of the keys?)
- name of the product/recipe (string)
- name of each of the 1 to 4 ingredients used, and if each is specific or generic (string? sub array? this is where I'm confoosed! This is how I'd like to match player-selected ingredients to known recipes... is this possible?)
- food type (numeric? probably easiest, since it'll need to be parsed to load into the cobl lists http://obse.silverlock.org/obse_command_doc.html#Leveled_List)
The other pertinent stuff will be part of the cloned item (weight, ingredient effects, appearance, price, etc).
What I'm hoping is that someone can take me by the hand and help me understand arrays and how best to make use of them for this project. Examples are good!
Thanks!