Okay, before I say anything else, I'm trying to brainstorm the best way to tackle a Trial-and-Error Crafting system (where the player punches in items to mix, instead of selecting a recipe from a menu).
I know it's a pretty tedious type of system to set up, but regular crafting and synthesis systems don't achieve what I want--- which is multiple combinations resulting in the same outcome. For simplicity's sake I am crafting Items only with Item ingredients, so no weapons or armor to account for.
So far I've tried a few things, mostly focusing on writing stuff into item noteboxes. I was thinking of having recipe ingredients defined by notetags arrays instead of Item ID numbers.
All cookable/craftable items have a recipe tag (like for a veggie omelet, <recipe:vegetable,egg>), and the game extracts the meta.recipe key by splitting it into an array and sorting it (so you'd get ["egg","vegetable"]).
When you are selecting ingredients for a recipe, it pushes their <kind> key into an array.
So you may select a spinach/pepper/etc with the tag <kind:vegetable> and an egg with the tag... well, <kind:egg>
And when you confirm your selection, the array sorts (to ["egg","vegetable"]) and then checks to see if it matches any valid recipe. Which it should, and the result is veggie omelet.
So far, I can get this much to work, at least by tinkering around in the console window... but it's pretty simple, and not without flaws.
Problem time:
What would have to be done if a recipe needed more specific item values? Like a strawberry shortcake that MUST have a strawberry to make, but the strawberry item is tagged as <kind:fruit>... in that instance, it would be better to use the item's ID instead of a notetag, or at least allow the tag to have multiple values, like <kind:fruit,strawberry,...>
So at this point, I have to rethink how the <recipe> tag is set up (or the <kind> tag?? dunno what I should be looking at), and then figure out how to get the right kind of info from the ingredients and recipe requirements to line up.
What are the best (or at least better) ways to go about doing this?
edit: I found this http://snook.ca/archives/javascript/testing_for_a_v (using "in") which looks like it's sort of in the direction I want, but I'm not really sure how to use it effectively, or if it really is what I want to do or not.
It still wouldn't fix the problem of me not knowing how to organize notetags properly, in any case.
edit edit: one possible solution to the strawberry cake problem might be done through the <recipe> tag... I figured out how to convert an array of strings to a mixed array of strings and integers. When the script tries to match ingredients to a recipe, there could be a special case when the recipe calls for an integer and it searches the ingredient item's ID instead of the notetag. It's still not a totally satisfying solution, but it's better than before. I just have to figure out the correct sequence of events.
I know it's a pretty tedious type of system to set up, but regular crafting and synthesis systems don't achieve what I want--- which is multiple combinations resulting in the same outcome. For simplicity's sake I am crafting Items only with Item ingredients, so no weapons or armor to account for.
So far I've tried a few things, mostly focusing on writing stuff into item noteboxes. I was thinking of having recipe ingredients defined by notetags arrays instead of Item ID numbers.
All cookable/craftable items have a recipe tag (like for a veggie omelet, <recipe:vegetable,egg>), and the game extracts the meta.recipe key by splitting it into an array and sorting it (so you'd get ["egg","vegetable"]).
When you are selecting ingredients for a recipe, it pushes their <kind> key into an array.
So you may select a spinach/pepper/etc with the tag <kind:vegetable> and an egg with the tag... well, <kind:egg>
And when you confirm your selection, the array sorts (to ["egg","vegetable"]) and then checks to see if it matches any valid recipe. Which it should, and the result is veggie omelet.
So far, I can get this much to work, at least by tinkering around in the console window... but it's pretty simple, and not without flaws.
Problem time:
What would have to be done if a recipe needed more specific item values? Like a strawberry shortcake that MUST have a strawberry to make, but the strawberry item is tagged as <kind:fruit>... in that instance, it would be better to use the item's ID instead of a notetag, or at least allow the tag to have multiple values, like <kind:fruit,strawberry,...>
So at this point, I have to rethink how the <recipe> tag is set up (or the <kind> tag?? dunno what I should be looking at), and then figure out how to get the right kind of info from the ingredients and recipe requirements to line up.
What are the best (or at least better) ways to go about doing this?
edit: I found this http://snook.ca/archives/javascript/testing_for_a_v (using "in") which looks like it's sort of in the direction I want, but I'm not really sure how to use it effectively, or if it really is what I want to do or not.
It still wouldn't fix the problem of me not knowing how to organize notetags properly, in any case.
edit edit: one possible solution to the strawberry cake problem might be done through the <recipe> tag... I figured out how to convert an array of strings to a mixed array of strings and integers. When the script tries to match ingredients to a recipe, there could be a special case when the recipe calls for an integer and it searches the ingredient item's ID instead of the notetag. It's still not a totally satisfying solution, but it's better than before. I just have to figure out the correct sequence of events.