Skip to main content

Ingredientui

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

Overview

IngredientUI is a custom widget that visually represents a single ingredient in the crafting menu UI. It extends ImageButton and displays the ingredient's icon, quantity (if applicable), and state (e.g., sufficient amount, insufficient amount, prototype, locked). It also handles user interaction, including click behavior and focus-based sub-ingredient previews. It integrates with the AllRecipes, STRINGS.UI.CRAFTING, and TheInput systems to provide localized, context-aware UI.

Usage example

local IngredientUI = require "widgets/ingredientui"

local ingredient_widget = IngredientUI(
resolvefilepath("images/hud.xml"), -- atlas
"wood.tex", -- image
5, -- quantity needed
10, -- on_hand
true, -- has_enough
"Wood", -- name
player, -- owner
"workbench", -- recipe_type
1.0, -- quant_text_scale
ingredient_recipe -- ingredient_recipe (optional)
)

Dependencies & tags

Components used: None identified
Tags: Uses player's replica.builder component (via owner.replica.builder) to compute ingredient modifiers.

Properties

PropertyTypeDefault ValueDescription
ingImageChild image widget displaying the ingredient icon.
quantText (optional)nilChild text widget displaying quantity (e.g., 10/5), only present if quantity is non-nil.
fgImage (optional)nilForeground overlay (e.g., lock or craft icon), set when ingredient_recipe.meta is defined.
recipe_typestring (optional)nilRecipe category (e.g., "workbench"), used to check if recipe is valid.
has_enoughbooleanfalseWhether the owner has sufficient quantity of this ingredient.
ownerentity (optional)nilOwner entity (e.g., player) whose builder component is used for modifiers.
ingredient_recipetable (optional)nilReference to the full recipe object containing meta and action info.

Main functions

No publicly exposed methods beyond constructor initialization.

Events & listeners

  • Pushes: onclick, ongainfocus, onlosefocus — internally handled callbacks for user interaction; no events fired to the game event system.