Skip to main content

Craftingmenu Ingredients

Based on game build 714014 | Last updated: 2026-03-08

Overview

CraftingMenuIngredients is a UI widget responsible for visually rendering ingredient requirements of a crafting recipe. It dynamically constructs a row of IngredientUI child widgets based on the recipe’s ingredients, character_ingredients, tech_ingredients, and optional amulet discount display. It interacts with the player's builder and inventory replicated components to determine ingredient availability and uses game mode properties to control visual effects like ui_cc shaders.

Usage example

local owner = ThePlayer
local recipe = GetRecipe("stone_patina")
local ingredients_widget = CreateWidget(CraftingMenuIngredients, owner, 6, recipe, nil)
ingredients_widget:SetPosition(0, 0)

Dependencies & tags

Components used: builder, inventory (accessed via owner.replica) Tags: Checks greenamulet on equipped body item to conditionally show amulet discount; checks health_as_oldage to substitute health ingredient.

Properties

PropertyTypeDefault ValueDescription
ownerEntitynilThe entity (typically player) whose builder/inventory are used for checks.
max_ingredients_widenumbernilMaximum horizontal space (in UI units) available for ingredient rendering, used for scaling.
extra_quantity_scalenumber?nilOptional multiplier to scale quantity text size.
recipeRecipeData?nilThe currently active recipe being displayed (set via SetRecipe).
ingredient_widgetstable{}Array of IngredientUI widgets created and displayed for each ingredient.
num_itemsnumber0Total count of ingredients rendered (including character, tech, and optional amulet).
hint_tech_ingredientstring?nilUppercase name of the first missing tech ingredient (if any), used for hint display.

Main functions

SetRecipe(recipe)

  • Description: Rebuilds the ingredient display UI for the given recipe. Clears all existing children, calculates layout and scaling, and creates IngredientUI widgets for each ingredient type. Handles tech, material, character, and amulet-based ingredients. Sets hint_tech_ingredient for use in downstream UI logic.
  • Parameters:
    • recipe (RecipeData) — the recipe to display ingredients for.
  • Returns: Nothing.
  • Error states: If recipe.ingredients is missing, #recipe.ingredients evaluates to 0. If equippedBody.prefab ~= "greenamulet" or no discount is applicable, showamulet remains false.

Events & listeners

None identified.