From a57cb9961920b33c1b8c6683242a028a583affac Mon Sep 17 00:00:00 2001 From: minjaesong Date: Sun, 15 May 2022 15:18:03 +0900 Subject: [PATCH] simplified crafting recipe definition --- assets/mods/basegame/crafting/doc.md | 51 ++++++++++--------- assets/mods/basegame/crafting/testrecipe.json | 5 +- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/assets/mods/basegame/crafting/doc.md b/assets/mods/basegame/crafting/doc.md index 58a111118..65b94000b 100644 --- a/assets/mods/basegame/crafting/doc.md +++ b/assets/mods/basegame/crafting/doc.md @@ -1,39 +1,42 @@ Multiple JSON files can exist under this directory. -### Ingredient Querying Language +### Workbenches -An ingredient can refer one exact item or items that matches the conditions. +Some items can only be manufactured on certain workbenches. Every workbench has tags assigned and checked against +this property. -To specify single exact item: +Multiple workbenches are separated by commas, and alternative workbenches are separated by semicolons. - ID IS item@basegame:1 +### Ingredient Querying -To specify using tags: +Ingredients are defined as list of records. Multiple records denotes multiple alternative recipes, whereas +entries in a record denote multiple ingredients the recipe requires. - TAG HASALLOF a_tag,b_tag,c_tag OR TAG IS s_tag - TAG IS one_tag - TAG HASALLOF a_tag,b_tag +Example: -The query can have one or more terms. The terms are always either one of: +``` +"ingredients": [ + [2, 1, "$WOOD", 1, "$ROCK"], + [20, 1, "ITEM_PLATFORM_BUILDING_KIT"] +] +``` - TERM OPERATOR TERM - TAG_LITERAL +Each entry is interpreted as: -Since "TAG" is a valid term to operate against, said word can frequently appear for complex queries. +```[moq, count 1, ingredient 1, count 2, ingredient 2, ...]``` -#### List of Operators +- moq: this item combination creates this amount of items. -- IS : Exactly this -- HASALLOF : Has all of these -- HASSOMEOF : Has one or more of these -- HASNONEOF : Has none of these -- ISNOT : Exactly not this -- AND : Both left and right terms are truthy -- OR : One or more hands are truthy -- , : Creates an array containing two or more words separated by this operator +For example: -#### List of Predefined Operands +```[2, 1, "$WOOD", 1, "$ROCK"]``` -- TAG : Tags assigned to the blocks or items -- ID : Item ID +This line is interpreted as: this item requires 1 tagged-as-wood ingredient and 1 tagged-as-rock ingredient, +and returns 2 of manufactured items. +```[20, 1, "ITEM_PLATFORM_BUILDING_KIT"]``` + +This line is interpreted as: this item requires 1 verbatim item "ITEM_PLATFORM_BUILDING_KIT" and returns +20 of manufactured items. + +Therefore, the single record has at least three items and always has odd number of items. \ No newline at end of file diff --git a/assets/mods/basegame/crafting/testrecipe.json b/assets/mods/basegame/crafting/testrecipe.json index 207da27ab..472c51b6a 100644 --- a/assets/mods/basegame/crafting/testrecipe.json +++ b/assets/mods/basegame/crafting/testrecipe.json @@ -2,8 +2,7 @@ "basegame:176": { /* A recipe for Wooden Platform */ "workbench": "", /* Optional workbench TAGS separated by commas (e.g. smelter, saw) */ "ingredients": [ /* Multiple ingredients denotes alternative recipes */ - [1, "tag is WOOD"] /* This recipe only requires one Wooden Plank */ - ], - "moq": 2 /* Number of products per unit ingredients */ + [2, 1, "$WOOD", 1, "$ROCK"] /* This recipe only requires one Wooden Plank */ + ] } } \ No newline at end of file