using { /Fortnite.com/Devices } using { /Fortnite.com/Items } using { /Fortnite.com/Player } # This script makes a crafting button smarter. # It checks for a second ingredient (Milk) that the device can't see, # then removes both ingredients and grants the result. # Define the items we need for our recipe const Wheat_Item := "Wheat" const Milk_Item := "Milk" const Bread_Item := "Bread" # This is the main event handler. It runs when the button is pressed. OnActivated := (event:ActivatedEvent) -> result: void = { # Get the player who pressed the button player := event.Get_Owner() # Check if the player exists (safety first, like checking for a shield) if (player == none) { return } # Get the player's inventory component inventory := player.Get_Inventory() # Check if the player has Wheat (1) and Milk (1) # We assume Wheat was already checked by the Conditional Button, # but let's verify Milk here to be safe. has_wheat := inventory.Has_Item(Wheat_Item, 1) has_milk := inventory.Has_Item(Milk_Item, 1) # If we have BOTH ingredients, craft the bread! if (has_wheat && has_milk) { # Remove the ingredients inventory.Remove_Item(Wheat_Item, 1) inventory.Remove_Item(Milk_Item, 1) # Grant the crafted item inventory.Grant_Item(Bread_Item, 1) # Optional: Send a message to the player # player.Send_Server_Message("Crafted Bread!") } else { # If missing items, maybe play a sound or do nothing # We don't want to remove items if the recipe is incomplete! } }