Skip to content

VTFTK

Types

SoundModel

Represents a sound within VTFTK

PropertyTypeDescription
idstringID of the sound
namestringName of the sound
srcstringURL for the sound file that can be played
volumenumberVolume the sound should be played at (0 - 1)
ordernumberOrder the sound is shown within the UI
created_atstringISO date time of when the sound was created

SoundSeq

Represents a sound in a sequence of sounds to play

PropertyTypeDescription
srcstringURL for the sound file that can be played
volumenumberVolume the sound should be played at (0 - 1)

ItemModel

Represents an item within VTFTK

PropertyTypeDescription
idstringID of the item
namestringName of the item
imageItemModelImageItem image configuration
ordernumberOrder the item is shown within the UI
created_atstringISO date time of when the sound was created
impact_sound_idsstring[]List of IDs for the sounds that can play when this item impacts

ItemModelImage

Image configuration for an item

PropertyTypeDescription
srcstringURL for the item image
weightnumberWeight of the item on impact
scalenumberScale of the image
pixelatebooleanWhether to pixelate when scaling

ItemsWithSounds

Items with their loaded impact sounds

PropertyTypeDescription
itemsItemModel[]List of items
soundsSoundModel[]List of impact sounds

BarrageConfig

Configuration for how a barrage is thrown

PropertyTypeDescription
totalAmountnumberTotal number of items to throw for the barrage
amountPerThrownumberAmount of items per throw of the barrage
frequencynumberThe time between each barrage (ms)

Functions

playSound

Function (src: string, volume?: number) => Promise<void>

Tells the overlay to play a sound by URL

ArgumentTypeExampleDescription
srcstringURL of the sound to play
volume Optionalnumber0.5Optional volume to play the sound at (0 - 1) defaults to 1
// Use "await" to wait until the sound is queued (Almost immediate)
await api.vtftk.playSound("http://example.com/example.wav");

playSoundSeq

Function (sounds: SoundSeq[]) => Promise<void>

Tells the overlay to play a sequence of sounds one after another. Waits for the previous sound to complete before the next is started

ArgumentTypeExampleDescription
soundsSoundSeq[]List of sounds to play
// Use "await" to wait until the sound sequence is queued (Almost immediate)
await api.vtftk.playSoundSeq([
{
url: "http://example.com/example.wav",
volume: 1,
},
{
url: "http://example.com/example1.wav",
volume: 1,
},
{
url: "http://example.com/example2.wav",
volume: 1,
},
]);

playSoundByName

Function (name: string, ignoreCase?: boolean, volume?: number) => Promise<void>

Tells the overlay to play a sound by name (Sound must exist in VTFTK)

ArgumentTypeExampleDescription
namestringName of the sound to play
ignoreCase OptionalbooleanWhether to ignore case when matching the name (Default: false)
volume Optionalnumber0.5Optional volume to play the sound at (0 - 1) (Default: 1)
// Use "await" to wait until the sound is queued (Almost immediate)
await api.vtftk.playSoundByName("My Sound", true, 0.5);

playSoundByID

Function (id: string, volume?: number) => Promise<void>

Tells the overlay to play a sound by ID

ArgumentTypeExampleDescription
idstringUUID of the sound to play
volume Optionalnumber0.5Optional volume to play the sound at (0 - 1) (Default: 1)
// Use "await" to wait until the sound is queued (Almost immediate)
await api.vtftk.playSoundByID(
"xxxxx-xxxxx-xxxxx-xxxxx-xxxxxxxxxxxx",
true,
0.5
);

getSoundByName

Function (name: string, ignoreCase?: boolean) => Promise<SoundModel | null>

Get a sound by name(Sound must exist in VTFTK) returns a SoundModel or null if the sound does not exist

ArgumentTypeExampleDescription
namestringName of the sound to find
ignoreCase OptionalbooleanWhether to ignore case when matching the name (Default: false)
const sound = await api.vtftk.getSoundByName("My Sound", true);
if (sound === null) {
// .. Sound doesn't exist
return;
}
// .. inspect the sound src URL
console.log(sound.src);
// .. play the sound
await api.vtftk.playSound(sound.src, sound.volume);

getSoundsByName

Function (name: string, ignoreCase?: boolean) => Promise<SoundModel[]>

Gets multiple sounds by name (Sound must exist in VTFTK) returns a SoundModel list

ArgumentTypeExampleDescription
namestringName of the sound to find
ignoreCase OptionalbooleanWhether to ignore case when matching the name (Default: false)
const sounds = await api.vtftk.getSoundByName("My Sound", true);
if (sounds.length < 1) {
// .. No sounds found
return;
}
const firstSound = sounds[0];
// .. inspect the sound src URL
console.log(firstSound.src);
// .. play the sound
await api.vtftk.playSound(firstSound.src, firstSound.volume);

getSoundsByNames

Function (names: string, ignoreCase?: boolean) => Promise<SoundModel[]>

Gets multiple sounds from a collection of sound names (Sound must exist in VTFTK) returns a SoundModel list of all matching sounds

ArgumentTypeExampleDescription
namesstringName of the sound to find
ignoreCase OptionalbooleanWhether to ignore case when matching the name (Default: false)
const sounds = await api.vtftk.getSoundsByNames(
["My Sound", "My Other Sound", "My Other Other Sound"],
true
);
if (sounds.length < 1) {
// .. No sounds found
return;
}
const firstSound = sounds[0];
// .. inspect the sound src URL
console.log(firstSound.src);
// .. play the sound
await api.vtftk.playSound(firstSound.src, firstSound.volume);

getSoundByID

Function (id: string) => Promise<SoundModel | null>

Get a sound by ID (Sound must exist in VTFTK) returns a SoundModel or null if the sound does not exist

ArgumentTypeExampleDescription
idstringID of the sound to find
const sound = await api.vtftk.getSoundByID(
"xxxxx-xxxxx-xxxxx-xxxxx-xxxxxxxxxxxx",
true
);
if (sound === null) {
// .. Sound doesn't exist
return;
}
// .. inspect the sound src URL
console.log(sound.src);
// .. play the sound
await api.vtftk.playSound(sound.src, sound.volume);

getSoundsByIDs

Function (id: string) => Promise<SoundModel[]>

Gets multiple sounds by ID (Sound must exist in VTFTK) returns a SoundModel list

ArgumentTypeExampleDescription
idstringID of the sound to find
const sounds = await api.vtftk.getSoundsByIDs(
[
"xxxxx-xxxxx-xxxxx-xxxxx-xxxxxxxxxxxx",
"xxxxx-xxxxx-xxxxx-xxxxx-xxxxxxxxxxxx",
"xxxxx-xxxxx-xxxxx-xxxxx-xxxxxxxxxxxx",
],
true
);
if (sounds.length < 1) {
// .. No sounds found
return;
}
const firstSound = sounds[0];
// .. inspect the sound src URL
console.log(firstSound.src);
// .. play the sound
await api.vtftk.playSound(firstSound.src, firstSound.volume);

getItemsWithSounds

Function (items: ItemModel[]) => Promise<ItemsWithSounds>

Loads the impact sounds for a collection of items returns a ItemsWithSounds list

This is only really intended to be used with throwBarrage, throwItems, and throwAll but using the ByNames (i.e throwAllByNames) and ByIds functions are preferred

ArgumentTypeExampleDescription
itemsItemModel[]Item models to load the sounds for
const items = [
/* ...The items here */
];
const itemsWithSounds = await api.vtftk.getItemsWithSounds(items);
// Throw the items
await api.vtftk.throwAll(itemsWithSounds, 10);

getItemByName

Function (name: string, ignoreCase?: boolean) => Promise<ItemModel | null>

Finds an ItemModel by name returning null if the model is not found

ArgumentTypeExampleDescription
namestringName of the item to find
ignoreCase OptionalbooleanWhether to ignore case when searching for the item (Default: false)
const item = await api.vtftk.getItemByName("My Item", true);
if (item === null) {
// .. Item not found
return;
}
// .. Work with the item

getItemsByName

Function (name: string, ignoreCase?: boolean) => Promise<ItemModel[]>

Finds any number of ItemModel by name

ArgumentTypeExampleDescription
namestringName of the item to find
ignoreCase OptionalbooleanWhether to ignore case when searching for the item (Default: false)
const items = await api.vtftk.getItemsByName("My Item", true);
if (item.length < 1>) {
// .. No items found
return;
}
// .. Work with the items

getItemsByNames

Function (names: string[], ignoreCase?: boolean) => Promise<ItemModel[]>

Finds any number of ItemModel from a collection of names

ArgumentTypeExampleDescription
namesstring[]List of item names to find
ignoreCase OptionalbooleanWhether to ignore case when searching for the item (Default: false)
const items = await api.vtftk.getItemsByNames(
[
"My Item",
"My Item 1",
"My Item 2"
],
true
);
if (item.length < 1>) {
// .. No items found
return;
}
// .. Work with the items

getItemById

Function (id: string) => Promise<ItemModel | null>

Finds an ItemModel by ID returning null if the model is not found

ArgumentTypeExampleDescription
idstringID of the item to find
const item = await api.vtftk.getItemById(
"xxxxx-xxxxx-xxxxx-xxxxx-xxxxxxxxxxxx"
);
if (item === null) {
// .. Item not found
return;
}
// .. Work with the item

getItemsByIds

Function (ids: string[]) => Promise<ItemModel[]>

Finds multiple ItemModels from a collection of IDs

ArgumentTypeExampleDescription
idsstring[]IDs of the items to find
const items = await api.vtftk.getItemsByIds([
"xxxxx-xxxxx-xxxxx-xxxxx-xxxxxxxxxxxx",
"xxxxx-xxxxx-xxxxx-xxxxx-xxxxxxxxxxxx",
"xxxxx-xxxxx-xxxxx-xxxxx-xxxxxxxxxxxx",
]);
if (items.length < 1) {
// .. Items not found
return;
}
// .. Work with the items

throwAllByIds

Function (ids: string[], amount?: number) => Promise<void>

Throws a bunch of items all at once from a collection of item IDs

ArgumentTypeExampleDescription
idsstring[]IDs of the items to throw
amount OptionalnumberNumber of items to throw (Default: 10)
await api.vtftk.throwAllByIds(
[
"xxxxx-xxxxx-xxxxx-xxxxx-xxxxxxxxxxxx",
"xxxxx-xxxxx-xxxxx-xxxxx-xxxxxxxxxxxx",
"xxxxx-xxxxx-xxxxx-xxxxx-xxxxxxxxxxxx",
],
10
);

throwAllByNames

Function (names: string[], ignoreCase?: number, amount?: number) => Promise<void>

Throws a bunch of items all at once from a collection of item names

ArgumentTypeExampleDescription
namesstring[]Names of the items to throw
ignoreCase OptionalnumberWhether to ignore case when finding the items by name (Default: false)
amount OptionalnumberNumber of items to throw (Default: 10)
await api.vtftk.throwAllByNames(["My Item", "My Item 1", "My Item 2"], 10);

throwAll

Function (items: ItemsWithSounds, amount?: number) => Promise<void>

Throws a bunch of items all at once from a collection of item names

ArgumentTypeExampleDescription
itemsItemsWithSoundsItems to throw
amount OptionalnumberNumber of items to throw (Default: 10)
const items = [
/* ...The items here */
];
const itemsWithSounds = await api.vtftk.getItemsWithSounds(items);
await api.vtftk.throwAll(itemsWithSounds, 10);

throwBarrage

Function (items: ItemsWithSounds, config?: BarrageConfig) => Promise<void>

Throws a barrage of items

ArgumentTypeExampleDescription
itemsItemsWithSoundsItems to throw
config OptionalBarrageConfigConfig for the barrage
const items = [
/* ...The items here */
];
const itemsWithSounds = await api.vtftk.getItemsWithSounds(items);
await api.vtftk.throwBarrage(itemsWithSounds, {
totalAmount: 15,
amountPerThrow: 5,
frequency: 100,
});

throwBarrageByIds

Function (ids: string[], config?: BarrageConfig) => Promise<void>

Throws a barrage of items by the IDs of the items to throw

ArgumentTypeExampleDescription
idsstring[]IDs of the items to throw
config OptionalBarrageConfigConfig for the barrage
await api.vtftk.throwBarrageByIds(
[
"xxxxx-xxxxx-xxxxx-xxxxx-xxxxxxxxxxxx",
"xxxxx-xxxxx-xxxxx-xxxxx-xxxxxxxxxxxx",
"xxxxx-xxxxx-xxxxx-xxxxx-xxxxxxxxxxxx",
],
{
totalAmount: 15,
amountPerThrow: 5,
frequency: 100,
}
);

throwBarrageByNames

Function (names: string[], ignoreCase?: boolean, config?: BarrageConfig) => Promise<void>

Throws a barrage of items by the names of the items to throw

ArgumentTypeExampleDescription
namesstring[]Names of the items to throw
ignoreCasestring[]Whether to ignore case when finding items (Default: false)
config OptionalBarrageConfigConfig for the barrage
await api.vtftk.throwBarrageByNames(
["My Item", "My Item 1", "My Item 2"],
true,
{
totalAmount: 15,
amountPerThrow: 5,
frequency: 100,
}
);

throwItemsByIDs

Function (ids: string[], config: ThrowItemConfig) => Promise<void>

Throws items by IDs. Low level primitive for the throwBarrageByIds and throwAllByIds functions

ArgumentTypeExampleDescription
idsstring[]IDs of the items to throw
configThrowItemConfigConfig for the throw
await api.vtftk.throwItemsByIDs(
[
"xxxxx-xxxxx-xxxxx-xxxxx-xxxxxxxxxxxx",
"xxxxx-xxxxx-xxxxx-xxxxx-xxxxxxxxxxxx",
"xxxxx-xxxxx-xxxxx-xxxxx-xxxxxxxxxxxx",
],
{
type: "Barrage",
amount: 15,
amount_per_throw: 5,
frequency: 100,
}
);

throwItemsByNames

Function (names: string[], ignoreCase: boolean, config: ThrowItemConfig) => Promise<void>

Throws items by names. Low level primitive for the throwBarrageByNames and throwAllByNames functions

ArgumentTypeExampleDescription
namesstring[]Names of the items to throw
ignoreCasebooleanWhether to ignore case when matching names
configThrowItemConfigConfig for the throw
await api.vtftk.throwItemsByNames(["My Item", "My Item 1", "My Item 2"], true, {
type: "Barrage",
amount: 15,
amount_per_throw: 5,
frequency: 100,
});

throwItems

Function (items: ItemsWithSounds, config: ThrowItemConfig) => Promise<void>

Throws items. Low level primitive for the throwBarrage and throwAll functions

ArgumentTypeExampleDescription
itemsItemsWithSoundsItems to throw
configThrowItemConfigConfig for the throw
const items = [
/* ...The items here */
];
const itemsWithSounds = await api.vtftk.getItemsWithSounds(items);
await api.vtftk.throwItems(itemsWithSounds, {
type: "Barrage",
amount: 15,
amount_per_throw: 5,
frequency: 100,
});

triggerVTHotkey

Function (hotkeyID: string) => Promise<void>

Trigger a VTube Studio hotkey by ID.

ArgumentTypeDescription
hotkeyIDstringID of the hotkey
// "await" to wait until the trigger is queued
await api.vtftk.triggerVTHotkey("HOTKEY ID");

triggerVTHotkeyByName

Function (hotkeyID: string, ignoreCase?: boolean) => Promise<void>

Trigger a VTube Studio hotkey by name.

ArgumentTypeDescription
hotkeyNamestringName of the hotkey
ignoreCase OptionalbooleanWhether to ignore case when matching the hotkey name (Default: false)
// "await" to wait until the trigger is queued
await api.vtftk.triggerVTHotkeyByName("Bonk");