# Ped Texture `[Client]`

A powerfull module to manage the ped texture like makeup/tatoo/...

:::warning
Textures can only be apply on **networked** ped. If you want use it in a script with ped only visible by one player, like character selector, you have to move the player in solo routing bucket and spawn the ped as networked.
:::

## JO Variables

### jo.pedTexture.categories
An object to know the on each part of the ped the layername has to be apply
#### Syntax
```lua
jo.pedTexture.categories[layername]

```
#### Parameters
`layername` : *string*
> The layer name of the texture

#### Example
```lua
local part = jo.pedTexture.categories.eyeshadow
print(part)
-- Expected output: heads

```

### jo.pedTexture.variations
A variable with the list of existing texture for peds. The key is the layername and value the list of variations
#### Syntax
```lua
jo.pedTexture.variations[layername] = variations

```
#### Parameters
`layername` : *string*
> The layername of the texture
  
`variations` : *table*
> the list of variations  
> `variations[x].label` : *string* - the label of the variations  
> `variations[x].value` : *table* - the definition of the variations
  

#### Example
```lua
local listEyeshadow = jo.pedTexture.variations.eyeshadow
for _, variation in pairs(listEyeshadow) do
    log(variation)
end

```

## JO Functions

### jo.pedTexture.apply()

A function to apply texture on a specific ped <br>

#### Syntax

```lua
jo.pedTexture.apply(ped, layerName, _data)
```

#### Parameters

`ped` : _integer_
> The entity ID
>

`layerName` : _string_
> The layername of the texture
>

`_data` : _table_

> The data of the texture
>

> `_data.id` : _integer_ - The ID of the texture <br> OR
> 
> `_data.albedo` : _string_ - The albedo of the texture
> 
> `_data.sheetGrid` : _integer_ - The sheet grid of the texture <br> default: 0 `[Optional]`
> 
> `_data.opacity` : _number_ - The opacity of the texture <br> default: 1.0 `[Optional]`
> 
> `_data.blendType` : _integer_ - The blend type of the texture <br> default: 1 `[Optional]`
> 
> `_data.palette` : _string|integer_ - The palette of the colors <br> default: "metaped_tint_makeup" `[Optional]`
> 
> `_data.tint0` : _string|integer_ - The first color `[Optional]`
> 
> `_data.tint1` : _string|integer_ - The second color `[Optional]`
> 
> `_data.tint2` : _string|integer_ - The third color `[Optional]`
> 

---

### jo.pedTexture.getAll()

Return the list of layers in all categories <br>

#### Syntax

```lua
jo.pedTexture.getAll(ped)
```

#### Parameters

`ped` : _integer_
> The entity ID
>

#### Return Value

Type : _object_

> Return the list of layer apply on the ped

---

### jo.pedTexture.getOverlayAssetFromId()

A function to get the hashname of a texture <br>

#### Syntax

```lua
jo.pedTexture.getOverlayAssetFromId(isMale, category, data)
```

#### Parameters

`isMale` : _boolean_
> `true` if the texture is for a male, `false` otherwise
>

`category` : _string_
> The layername of the texture
>

`data` : _table|integer_
> The texture data <br> ⚠️ Can be either a `number` representing the texture ID or a `table` with detailed configuration
>

#### Return Value

Type : _string_

> Return the hashname of the texture for this ID

---

### jo.pedTexture.overwriteBodyPart()

A function to overwrite all the layers of a body part <br>

#### Syntax

```lua
jo.pedTexture.overwriteBodyPart(ped, category, overlays, forceRemove)
```

#### Parameters

`ped` : _integer_
> The entity ID
>

`category` : _string_
> The category of the texture
>

`overlays` : _object_
> The list of layers
>

`forceRemove` : _boolean_ `[Optional]`
> Whether to force remove existing textures even if the category doesn't exist <br> default: false
>

---

### jo.pedTexture.refreshAll()

A function to refresh the ped texture <br>

#### Syntax

```lua
jo.pedTexture.refreshAll(ped)
```

#### Parameters

`ped` : _integer_
> The entity ID
>

---

### jo.pedTexture.refreshNow()

A function to apply now the ped texture modification <br>

#### Syntax

```lua
jo.pedTexture.refreshNow(ped)
```

---

### jo.pedTexture.remove()

A function to remove a texture <br>

#### Syntax

```lua
jo.pedTexture.remove(ped, layerName)
```

#### Parameters

`ped` : _integer_
> The entity ID
>

`layerName` : _string_
> The layer name of the texture
>
