# Hud content

#### 1. Firstly, make sure you have already created hud (Tutorial [here](https://apigames.gitbook.io/betterhud/tutorials/creating-a-new-hud))

#### 2. Now, create a new section for your existing hud:

```yaml
configuration:

  hud-refresh:
    period: 1
    
  huds:
    example-hud: #This is the hud, we created in our previous tutorial
      display: ACTIONBAR
      permission: "hud.example"
      toggle-command: "/examplehud"
  
  hud-content:
    example-hud: #There's the new section, I've just created
     
```

{% hint style="warning" %}
The name of the section must be equal to the hud's name!
{% endhint %}

#### 3. Create a new "Hud part" inside the section we've just created:

```yaml
configuration:

  hud-refresh:
    period: 1
    
  huds:
    example-hud: 
      display: ACTIONBAR
      permission: "hud.example"
      toggle-command: "/examplehud"
  
  hud-content:
    example-hud: 
      new-part: #This is the new hud part
```

#### &#x20;4. We have to configure this hud part, firstly choose what you want to display:

{% tabs %}
{% tab title="Icon" %}
First of all you have to define a type of the part, in this case it's **ICON**\
Every type of part must have position-x, position-y and scale\
Because we want to display an icon, we have to define a **path to the texture**, I've used a default BetterHud icon "**hp.png**"

{% hint style="info" %}
Every icon you want to display must be located inside this folder:`ItemsAdder/data/resource_packs/assets/betterhud/textures/font/icons/`
{% endhint %}

```yaml
configuration:

  hud-refresh:
    period: 1
    
  huds:
    example-hud: 
      display: ACTIONBAR
      permission: "hud.example"
      toggle-command: "/examplehud"
  
  hud-content:
    example-hud: 
      new-part: #This is the new part, we are configuring
        type: ICON
        position-x: 10
        position-y: 5
        scale: 10
        texture-path: "hp.png"
```

{% hint style="danger" %}
position-y can't be greather than scale!
{% endhint %}
{% endtab %}

{% tab title="Text" %}
First of all you have to define a type of the part, in this case it's **TEXT**\
Every type of part must have position-x, position-y and scale\
Because we want to display a text, we have to define an **input** for this part\
To avoid an overflow of the output, we have to specify a **max-length.**

{% hint style="info" %}
You can use placeholders from PAPI instead of static text
{% endhint %}

```yaml
configuration:

  hud-refresh:
    period: 1
    
  huds:
    example-hud: 
      display: ACTIONBAR
      permission: "hud.example"
      toggle-command: "/examplehud"
  
  hud-content:
    example-hud: 
      new-part: #This is the new part, we are configuring
        type: TEXT
        position-x: 10
        position-y: 5
        scale: 10
        max-length: 32 #The maximum length of the displayed text is 32 characters
        input: "YOU ARE THE BEST"
```

{% hint style="danger" %}
position-y can't be greather than scale!
{% endhint %}
{% endtab %}

{% tab title="Integer" %}
First of all you have to define a type of the part, in this case it's **INTEGER**\
Every type of part must have position-x, position-y and scale\
Because we want to display an integer, we have to define an **input** for this part\
To avoid an overflow of the output, we have to specify a **max-length.**

{% hint style="danger" %}
This type can show only numbers, so the input must be a number!
{% endhint %}

```yaml
configuration:

  hud-refresh:
    period: 1
    
  huds:
    example-hud: 
      display: ACTIONBAR
      permission: "hud.example"
      toggle-command: "/examplehud"
  
  hud-content:
    example-hud: 
      new-part: #This is the new part, we are configuring
        type: INTEGER
        position-x: 10
        position-y: 5
        scale: 10
        max-length: 5 #The maximum length of displayed number is 5 digits
        input: "%player_money%"
```

{% hint style="danger" %}
position-y can't be greather than scale!
{% endhint %}
{% endtab %}
{% endtabs %}

#### 5. Fixed position (optional)

This option sticks the part to the certain position *(It's higly recommended to enable this, when placeholders are used)*

```yaml
configuration:

  hud-refresh:
    period: 1
    
  huds:
    example-hud: 
      display: ACTIONBAR
      permission: "hud.example"
      toggle-command: "/examplehud"
  
  hud-content:
    example-hud: 
      new-part: #This is the new part, we are configuring
        type: INTEGER
        position-x: 10
        position-y: 5
        scale: 10
        max-length: 4
        input: "{health}"
        fixed-position: true #We have fixed-position enabled, because input is dynamic
```

Example:

![](https://2148596203-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MU5NaEZQ9MVzcQWRT61%2F-MVi5RPODq4kxPE8UMGV%2F-MVi9IPW9UOr2TpdtiLp%2Fexample2.png?alt=media\&token=138e2f35-cff7-402d-a13c-c941a1cc38c0)

![](https://2148596203-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MU5NaEZQ9MVzcQWRT61%2F-MVi5RPODq4kxPE8UMGV%2F-MVi9IPVz-ifI-yKOJiV%2Fexample.png?alt=media\&token=41e1c1e0-6267-49f3-8260-cb5cd065c968)

## Frequently asked questions

> Q: *Whats the difference between text and integer?*
>
> A: *Text can show every character from the alphabet, some special characters and numbers, beside Integer can show only numbers.* \
> \
> I've chosen this solution, because text type creates a lot of font-characters and its a waste of characters, when you want for example display only player's health level.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://apigames.gitbook.io/betterhud/tutorials/hud-content.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
