AngryBeaver / beavers-crafting

Crafting module for Foundry
MIT License
8 stars 4 forks source link
foundry-vtt foundry-vtt-module foundryvtt

Beaver's Crafting Module

Foundry Core Compatible Version Foundry System Download Count

This module is for:

by:

in possibly all Systems: (List of adaption layers)

Features

Crafting

potionCrafting.png

full Length Video

Character advancement

img.png

DownTimeActivities

downtime.png

TOC

HowTo

Create Recipes

img.png

For this to work you must go to your settings and enter the name of the create Item Dialog. Default is "Create New Item" obviously you need to adapt if you have a different language.

Configure Recipe

configure.png

requires:

you may add required items to your recipe via drag and drop. Required items are not consumed and could be anything from classes to backgrounds.

costs:

You may add costs to your recipe named ingredients. This can either be currency or items You may add items via drag and drop.

tests:

you may add steps or tests that are needed in the process. When adding tests you can define that your progress can fail on certain amount of failed tests. You can configure that costs are consumed or returned when you fail your progress.

Tests consisting of one or more TestSections.

TestSection

In ech TestSection you need to hit a given amount of successes specified by "hits" in the TestSection default is 1.

Each TestSection consist of one or more TestOption you can add as choice . There are up to 4 types of TestOptions.

You can add multiple times the same type of TestOption for example to choose from diffrent skills. Your Recipe can fail if you reach the specified "fails" default is 1. If you set the fails to 0 your recipe can never fail. You can also specify if your costs will get consumed when your recipe fails. e.g. img.png

meaning:

results:

You may add Items or RollTable via drag and drop as result of your process. You will receive the result at the end of the progress, if your progress was successfully. If you add a RollTable you will get quantity amount of rolls on that table not one roll quantity of times.

instruction:

description.png

You may add flavour text to your "recipe". Make sure to hit the save button.

folder:

You may add a folder structure to group your progresses on your actor tab.

macro:

Advanced user may use the optional recipe macro that gets executed during the crafting process. see RecipeMacro

Executing Recipes

On your actor-sheet you will find a new tab.

add

Initially your sheet will be blank except for the add button. you can add a new crafting process by clicking on +Add, which will open the Recipe Compendium.

Recipe Compendium

img.png

or Condition

img.png Some recipe can have "or conditions" for required, cost and result items. You can choose one of those or conditions in the RecipeCompendium.

list

img.png

It lists all your progress with the various recipes you are currently interacting with.

You can show details to each progress by clicking on the progress-name.

advancement

if your recipe has a test/progress involved you can advance it on this tab.

Your process will start by locking the resources needed. you can advance or test your progress by clicking on the progress column:

advance.png

when your progress ends by reaching 100% success you will be rewarded with the results of the recipe. or nothing when you fail.

result

img.png

You will see a chat message with your result

Items updated or created in a successfull crafting process are flagged:

flags.beavers-crafting.isCrafted = true

AnyOf

AnyOf is an Item that is intended to be used as ingredient to create recipes that do not need a specific ingredient but any ingredient of... e.g. specific type.

Therefor AnyOf Item has an input field to write a macro code that gets executed when a recipe is checked for its ingredients. The macro has "item" as input and should return boolean as output. The macro will test if the given item meets the conditions of the AnyOf Ingredient.

Example

To understand the intension of this feature you can use this as examples:

return item.name.startsWith("Test") any item that has a name that starts with "Test"

return item.type === "weapon" any item of type weapon (if weapon is a type in your system) The attributes of item depend on your system. To find out what attributes your item has you can test with console.log(item); return false. When you hit f12 the item document structure should be copied to your logs when ever you test this anyOf.

ItemTags

For people with 0 code experience to better filter the item AnyOf we point out the ItemTags a simple and easy module to use and integrates perfectly with this feature all you have to do is insert the following macro: return ItemTags.Check(item, ['tag1','tag2']) and modify the tag array as you want ['metal','sword'] or ['metal','bow'] etc., major details about this module are on this API this allows you to "draconianly" filter your components with little and definitely more dynamic effort.

test

You can test your AnyOf Conditions by dropping an item in the dropArea and hit the "test item" button.

customize Recipes

When you use a recipe with AnyOf you can customize it and by doing so define what specific ingredients you finally want to use for this recipe.

Drag And Drop

img.png img.png

drag and drop an ingredient (e.g. from your inventar) to "anyOf" ingredient within your recipeCompendium.

Select available

selection.png clicking the AnyOf will popup a multiple choice dialog of available matching items you can choose from.

It will automatically check if that new ingredient is available in that quantity.

none customized AnyOf ingredients will popup a multiple choice dialog of available matching items before starting

reset

when you reselect the recipe it will remove your customization and start over with unconfigured anyOf Items again.

Hooks

beavers-crafting.start

This is fired for all crafting processes directly after all components are selected and before anything is actually processed.

Hooks.on("beavers-crafting.start", (recipe) => {
  console.log(recipe);  
});

Parameters

Examples

The easiest way to get started with this module is with some examples.

Ingredients

This module provides an example ingredient compendium for dnd5e. that can be used with your recipes.

img.png

Recipes

You can find some example recipes for potions (dnd5e) in the companion module beavers-potions

img.png

Every Character will now have access to 50+ recipes to brew potions.

Settings

img.png

3.3.x isCrafted flag

This module now tracks a isCrafted flag on items. It will only be usefull if you want a crafting system that needs to differentiate between crafted and non crafted items. E.g. you want to create recipes that will only work with crafted daggers not bought daggers. Per default this setting is disabled. You can enable it in the settings to either full mode or partial mode.

When this feature is enabled crafted items will be marked with an icon.

img.png

Draggable chat result

With this setting the results within your chat messages are draggable. You then can copy the item over to another character.

Limitations

Notes

Currency reorder

When adding costs to your recipe your currency will get exchanged to highest values. You can however turn off currencyExchange then you need to have the exact currency values.

Items reorder

Actor Items will get merged to stacks in the crafting process. (only those that match ingredients or results)

ItemReference

The recipes do not store an item but a reference to the item. You can manipulate your items afterward the recipe always refers to the actual item.

When you create recipes be carefully from where you pull your results/costs/requires items.

Troubleshooting

Dont show "RECIPE" in item menu

Problem:

When creating new Items the drop down menu does not have Recipe or AnyOf.

Explanation:

The module need to detect the window that creates new Items. For this it uses internally the title of that window. If you have the default language the title is most likely "Create New Item".

img.png.

Solution:

Enter the title of your item creation window in the module setup.

image

As of dnd5 v3.x it seems some systems can manipulate the window title to appear different to capture the right window use:

img.png

this will add a bullseye to the header:

img.png

click it this will configure this windows as your Item creation window and will add the new subtypes whenever you reopen it.

Advanced Explanation:

It is not possible to add a new item subtype into all supported systems, even with this addition since v11. So beavers-crafting fake it by listening to an event that opens windows and when the window is the Item Creation Window it adds item types to the drop down list. Yes that is evil and has high risks to break at somepoint but as said there is no other possiblity. To filter the right window the module uses the title of the window as there is no real good identification.

Credits

Copy organizational structur from midi-qol (gulpfile,package.json,tsconcig.json)

translated to Brazilian Portuguese by Andersants