-
Notifications
You must be signed in to change notification settings - Fork 0
[LooksCrafter] HandlersAndSlots
Each handler is tied to a "base texture" and handles layers of textures merged to this base texture. Each base texture can have only one handler.
local looksAPI = require("your/path/to/LooksCrafter.lua")
-- Creates a handler for the texture located at assets/Skin.png
local skinHandler = looksAPI:newHandler(textures["assets.Skin"])Restores the base texture to its unmodified state, merges the clothing textures with the base texture with sequence according to slots priority, sets the visibility of the model parts specified in the items, and loads the modified no-longer-base texture into GPU memory.
updateLook()Returns:
| Type | Description |
|---|---|
| table | Returns handler for chaining |
Example:
skinHandler:updateLook()Changes the base texture and leaving slots and items untouched. The new base texture that given as an parameter must not be bound to any existing handlers.
changeBaseTexture()Parameters:
| Name | Type | Is required | Description | Default |
|---|---|---|---|---|
| newBaseTexture | Texture | Required | New base texture | Required |
Returns:
| Type | Description |
|---|---|
| table | Returns handler for chaining |
Example:
skinHandler:changeBaseTexture(textures["assets.otherSkin"])Creates a new slot for clothing parts.
newSlot()Parameters:
| Name | Type | Is required | Description | Default |
|---|---|---|---|---|
| name | string | Required | Slot name | Required |
| priority | number | Required | A number that determines the item's texture place in the texture merging sequence when updateLook() is executed. |
Required |
| defaultItemName | string or false
|
Optional | The index key of one of the elements of the next parameter that determines which item from the list of the next parameter will be equipped if the slot name is missing from the handler configuration file. If false is passed as a parameter, nothing will be equipped in the slot. |
The first element from the list passed in the next parameter |
| items | table | Required | Table of items that can be equipped in a slot | Required |
Returns:
| Type | Description |
|---|---|
| table | Returns handler for chaining |
Example:
skinHandler:newSlot("Shirts", 1, "CyanShirt", {
CyanShirt= {
texture = textures["assets.Shirts.CyanShirt"]
},
OrangeShirt = {
texture = textures["assets.Shirts.OrangeShirt"],
chromaKeyColor = vec(0, 0, 0, 1)
}
})Equips the specified item into the slot.
setSlot()Parameters:
| Name | Type | Is required | Description | Default |
|---|---|---|---|---|
| slotName | string | Required | The slot name into which the item will be equipped. | Required |
| itemName | string or false
|
Required | The name of the item to be equipped in the slot. If false is passed instead of the name, the slot will become empty. |
Required |
| shouldNotUpdateLook | boolean | Optional | If you are changing many slots at once, you can pass true here so that when this slot is changed, instructions for updateLook() are not wasted. |
false |
Returns:
| Type | Description |
|---|---|
| table | Returns handler for chaining |
Example:
-- Setting only one slot
skinHandler:setSlot("Shirts", "RedShirt")
-- Setting many slots at once
skinHandler:setSlot("Shirts", "RedShirt", true)
:setSlot("Hats", "BrownFedora", true)
:setSlot("Boots", "WhiteSneakers")Returns the name of equipped item in the slot.
getItemInSlot()Parameters:
| Name | Type | Is required | Description | Default |
|---|---|---|---|---|
| slotName | string | Required | The slot name from which the name of the equipped item will be taken | Required |
Returns:
| Type | Description |
|---|---|
string or boolean(specifically false) |
Name of the equipped item |
local equippedShirtName = skinHandler:getItemInSlot("Shirts")Returns a table with slots and their items.
getSlots()Returns:
| Type | Description |
|---|---|
| table | A table with slot names as indexes and their items as elements |
Example:
local slots = skinHandler:getSlots()Sets the number of seconds between synchronizations of all slots for viewers that joined the game after you.
setSyncCooldown()Parameters:
| Name | Type | Is required | Description | Default |
|---|---|---|---|---|
| seconds | number | Optional | The number of seconds between synchronizations of all slots | 60 |
Returns:
| Type | Description |
|---|---|
| table | Returns handler for chaining |
Example:
skinHandler:setSyncCooldown(30)