What a recipe makes, what it costs, and who can make it

Fields

Field What it does
output What gets made: { { item = "plank", quantity = 2 } }. A recipe can make several things. quantity defaults to 1. Leave out for an action.
cost What it costs: items, money, gold or rol, or a choice of those. See Prices. Leave out for a free recipe.
costLabels Names for each way of paying, shown on the Pay with slider.
jobs Who can see and make it, on top of the location's and category's jobs. See Jobs.
limit The most of the output a player can hold. For an action, how many times it can be done at once.
animation Which animation from Anims.Animations to play. Defaults to craft.
weapon true if the output is a weapon.
label The name shown in the menu. Defaults to the item's name.
image The image shown in the menu. Defaults to the item's image.
onCraft A function run on the server after each successful craft: function(source) ... end.

Prices

cost takes anything jo_libs' pricing understands.

Items:

cost = { { item = "hwood", quantity = 5 }, { item = "nails", quantity = 2 } },

Items and money together. Everything has to be paid:

cost = { money = 1000, { item = "earth_star" }, { item = "fire_rose" } },

Tools. An item with keep = true must be in the player's inventory, but isn't used up:

cost = { { item = "iron" }, { item = "hammer", keep = true } },

A choice of ways to pay. When the options are lists themselves, the player picks one with the Pay with slider in the menu (Q / E):

cost = {
    { -- option 1
        { item = "rock", quantity = 10 },
        { item = "wood", quantity = 5 },
        { item = "coal", quantity = 4 },
    },
    { -- option 2
        { item = "hwood", quantity = 5 },
        { item = "wood", quantity = 5 },
        { item = "porkfat", quantity = 5 },
    },
},
costLabels = { "Rocks & coal", "Hardwood & pork fat" },

The slider starts on the option the player can best afford, and only the chosen option is charged.

Choices of a single cost

For alternatives that are each a single cost ($10 or 1 gold), wrap each in its own list: { { { money = 10 } }, { { gold = 1 } } }. A plain list of single costs, { { item = "a" }, { item = "b" } }, means pay all of them.

Jobs

Jobs can be set on the location, a category and a recipe:

  • The location's jobs decide who gets the prompt at all.
  • A category's jobs replace the location's for that category.
  • A recipe's jobs are checked on top, for example a higher grade for one recipe. Players without one of them don't see the recipe.
["Lockpick"] = {
    jobs = { { name = "blacksmith", minGrade = 2 } },
    output = { { item = "lockpick" } },
    cost = { { item = "iron", quantity = 3 }, { item = "copper", quantity = 2 } },
},

Actions

A recipe with no output that runs an onCraft is an action: boiling a canteen, cleaning something. Give it a label, since there's no item to take its name from:

["BoilCanteen"] = {
    label = "Boil Canteen",
    cost = { { item = "canteen", keep = true } },
    limit = 1, -- once at a time
    onCraft = function(source)
        -- fill or clean the canteen here
    end,
},

The summary uses the label: "You crafted 1x Boil Canteen."

Weapons and stack limits

jo_libs doesn't provide weapon names or stack limits, so:

  • On VORP, weapon names and images come from vorp_inventory/config/weapons.lua, and stack limits from the items table. tr-crafting waits for vorp_inventory to start, and reloads them when it restarts.
  • On other frameworks, weapons show a name made from their code (WEAPON_FISHINGROD becomes "Fishingrod"), and there are no stack limits unless you set limit on the recipe.

Weapons are given with VORP's own weapon function on VORP, and as normal items (weapon_fishingrod) elsewhere.