using { /Fortnite.com/Characters } using { /Fortnite.com/Playspaces } using { /Fortnite.com/Itemization } using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } using { /UnrealEngine.com/Itemization } # This is our main script. It runs when the game starts. BuildToolGiver := class(creative_device): # This runs once when the island starts. OnBegin(): void = # Get the playspace so we can find players. Playspace := GetPlayspace() # Wait until at least one player is present. Players := Playspace.GetPlayers() if (Players.Length = 0): return # Find the player who started the game. Player := Players[0] # A fort_character is needed to access inventory components. # GetFortCharacter[] is a failable expression, so we use 'if'. if (FortCharacter := Player.GetFortCharacter[]): # We need to talk to the player's build hotbar. # This gets the special "sleeve" for building tools. # GetInventoryComponent[] is failable, so we use 'if'. if (BuildHotbar := FortCharacter.GetInventoryComponent[fort_inventory_build_hotbar_component]): # Now let's add some building materials! # We use AddItem to put items in the hotbar. # Add 100 Wood # note: wood_item_definition is the asset tag for the Wood resource in UEFN's Content Browser. BuildHotbar.AddItem(WoodItemDefinition, 100) # Add 100 Stone # note: stone_item_definition is the asset tag for the Stone resource in UEFN's Content Browser. BuildHotbar.AddItem(StoneItemDefinition, 100) # Add 100 Metal # note: metal_item_definition is the asset tag for the Metal resource in UEFN's Content Browser. BuildHotbar.AddItem(MetalItemDefinition, 100) Print("Player got their build tools!") # Item definitions are wired up in the UEFN editor as device properties. # Drag the Wood, Stone, and Metal asset references into these slots. WoodItemDefinition: item_definition = item_definition{} StoneItemDefinition: item_definition = item_definition{} MetalItemDefinition: item_definition = item_definition{}