Skip to content
Pablo Rodriguez

Crafting System

Create structured data system for crafting recipes and skill categories:

  • Name Text: Recipe display name
  • Ingredients Array: Data table references for required items
  • Ingredient_Quantity Array: Integer amounts for each ingredient
  • Results Array: Data table references for created items
  • Results_Quantity Array: Integer amounts for each result
  • Recipes Data Table: Collection of available recipes for this trade skill
  • Skill Categories: Cooking, blacksmithing, woodworking, potion crafting, etc.

Organize crafting data into logical database structure:

// Crafting Database Structure
Database/
├── Loot/
│ ├── DT_Loot_Carrot
│ ├── DT_Loot_Potato
│ └── DT_Loot_Soup
├── Recipe/
│ └── DT_Recipe_Soup
└── TradeSkill/
└── DT_TradeSkill_Cooking

Configure example soup recipe:

  • Ingredients: Carrot and potato data tables
  • Quantities: 1 carrot, 1 potato required
  • Results: Soup data table
  • Result Quantity: 1 soup created

Create comprehensive crafting interface:

  • Size: 800x400 for substantial crafting workspace
  • Recipe Panel: 400x400 scrollable recipe list
  • Ingredients Panel: 400x200 required materials display
  • Results Panel: 400x150 crafted item preview
  • Background Images: Color-coded panels for visual clarity
  • Scroll Boxes: Handle large recipe collections
  • Button Integration: Confirm and close buttons for user control

Enable recipe browsing and selection:

// Recipe Selection Implementation
OnRecipeButtonClick(SelectedRecipe) {
current_recipe = SelectedRecipe;
// Clear previous displays
VerticalBox_Ingredients.ClearChildren();
VerticalBox_Results.ClearChildren();
// Populate ingredient requirements
ForEach(ingredient in recipe_ingredients) {
ingredient_widget = CreateWidget(W_Inventory_Item, ingredient_data);
VerticalBox_Ingredients.AddChild(ingredient_widget);
}
// Show crafting results
ForEach(result in recipe_results) {
result_widget = CreateWidget(W_Inventory_Item, result_data);
VerticalBox_Results.AddChild(result_widget);
}
}

Create world-based crafting locations:

Based on loot actor framework:

  • Static Mesh: Crafting station appearance (anvil, cooking pot, workbench)
  • Interaction System: F key to access crafting interface
  • Trade Skill Assignment: Each station supports specific trade skill
// Crafting Station Activation
OnInteract(PlayerCharacter) {
PlayerCharacter.Interface_Load_Crafting_Station(TradeSkill_DataTable);
// Opens crafting UI with station-specific recipes
}

Create specialized crafting locations:

  • Cooking Station: Use cooking pot mesh with cooking trade skill
  • Blacksmith Station: Anvil mesh with weapon/armor recipes
  • Alchemy Station: Laboratory setup with potion recipes
  • Woodworking: Carpentry table with building material recipes

Implement complete crafting workflow:

// Crafting Execution Process
OnConfirmCraftingButtonClick() {
if (selected_recipe.IsValid()) {
// Validate player has required ingredients
if (F_Check_Inventory(recipe_ingredients, required_quantities)) {
// Remove ingredients from inventory
Interface_Inventory_Remove(recipe_ingredients, required_quantities);
// Add crafted results to inventory
ForEach(result in recipe_results) {
Interface_Inventory_Add(result, result_quantity);
}
// Provide crafting success feedback
SpawnCraftingSuccessEffects();
}
// F_Check_Inventory handles error messages for missing items
}
}
  • Inventory Validation: Use existing F_Check_Inventory function
  • Resource Consumption: Use Interface_Inventory_Remove function
  • Result Addition: Use Interface_Inventory_Add for crafted items
  • UI Updates: Inventory widget automatically updates after changes
  • Root Widget Integration: Add to main UI system
  • Anchor: Middle center positioning
  • Size to Content: Proper widget sizing
  • Default Hidden: Open only when accessing crafting stations
  • Station Interaction: F key at crafting stations opens interface
  • Recipe Browsing: Scroll through available recipes
  • Ingredient Preview: See requirements before attempting craft
  • Crafting Execution: Confirm button attempts crafting with validation
  • Error Handling: Clear feedback when ingredients insufficient

Extend loot system for building mechanics:

  • Consumable Boolean: Mark items as usable from inventory
  • Housing Items: Blocks, decorative objects, functional structures
// Housing Item Usage
OnInventoryItemConsume(LootItem) {
if (F_Check_Inventory([LootItem], [1])) {
housing_actor = SpawnActor(Actor_Housing);
housing_actor.SetAppearance(LootItem.Appearance_3D);
StartMousePlacementMode(housing_actor);
}
}
  • Mouse Position: Convert screen position to world coordinates
  • Grid Snapping: Snap placement to grid for clean building
  • Left Click: Confirm placement and remove item from inventory
  • Right Click: Cancel placement and destroy preview object

The crafting system provides deep progression mechanics while maintaining intuitive interfaces and clear feedback about resource requirements and availability.