Skip to content
This repository was archived by the owner on Sep 18, 2023. It is now read-only.

functions

emlo40 edited this page Jan 27, 2023 · 13 revisions

Quick message: Never remove or change websocket in the functions.

List of functions:

Get token and authenticate with token

token(websocket) and authen(websocket,authtoken)
The function returns a token when called. Data the function handles page

authtoken = await token(websocket)#gets token
authen(websocket,authtoken)#uses token to authenticate session

Get tracking parameters

gettrackparam(websocket)
I have not used this parameter, so I do not have an example. Data the function handles page

Get current models information

getmd(websocket)
You can use the code below to get specific data about the model. Data the function handles page

model1 = await getmd(websocket)
model1id = model1["data"]["modelID"]#note this can also be used in the other fuctions  
print(model1id)

Get statistics of vtube studio

getstat(websocket)
You can use getstat to get statistics about your VTube Studio session, for example, uptime (how long the program has been running). The data that the function handles can be found on this page

stat = await getstat(websocket)
statistic = stat["data"]["uptime"]
print(statistic)

Get api state

getapi(websocket) This function will give you relevant information about the API. The data that the function handles can be found on this page

print(await getapi(websocket))

get vtube studio directory's

getvtsfolder(websocket)
If you use this function, the console will print out all information about the VTube Studio directory. You can also use the code below to get specific data. The data that the function handles can be found on this page

stat = await getvtsfolder(websocket)
bg = stat["data"]["backgrounds"]
items = stat["data"]["items"]
models = stat["data"]["models"]
print(bg)
print(items)
print(models)

get hotkeys

gethotkeys(websocket,mdid)
I have not used this parameter, so I do not have an example. The data that the function handles can be found on this page

Get scene lighting overlay color

getloc(websocket)
Returns scene color information Data the function handles page)<br/

print(await getloc(websocket))

Get Expression State

getexstate(websocket,expressionfile,detail)
Data the function handles page

print(await getexstate(websocket,"mycooolexp.json",true))

Get Item list

getitem(websocket,includeAvailableSpots,includeItemInstancesInScene,includeAvailableItemFiles,onlyItemsWithFileName,onlyItemsWithInstanceID)
Data the function handles page

print(await getitem(websocket,False,False,True,"",""))
or
payload1 = [itemname,item2name]
payload2 = [instanceid,instanceid]
getitem(websocket,False,False,True,payload1,payload2)

Check if face is detected

facecheck(websocket)
Data the function handles page

print(await facecheck(websocket))

list models

listvtsmodel(websocket)
If you use this function, the console will print out data about all models loaded in VTube Studio. You can also use the code below to get specific data. The data that the function handles can be found on this page

md = await listvtsmodel(websocket)
num = md['data']['numberOfModels']
for i in range(num):
    print(md['data']['availableModels'][i]['modelName'])
    print(md["data"]["availableModels"][i]["modelID"])

Set Expresion State

ExpresState(websocket,expressionFile,state)
Data the function handles page

ExpresState(websocket,"ligma.json",True)

Request execution of hotkeys

ExHotkey(websocket,hotkeyid,itemInstanceID)
Executes hotkeys. Data the function handles page

ExHotkey(websocket,5675uj643,"")

change current model

mdch(websocket,modelid) This function loads a new model when called. Note that you need to get an ID first using getmd or listvtsmodel
how to use

await mdch(websocket,"a5a3mjka3ja3jj3jjj3")

list and get data of all art meshes in model

listArtM(websocket,modeldid)
if you use this the console will print out data about all artmeshes in a loaded model you can also do the code below to get specific data
data the function handels page

md = await listArtM(websocket,"modeldid")
meshnamenumber = md["data"]["numberOfArtMeshNames"]
meshtagnumber = md["data"]["numberOfArtMeshTags"]
artMeshNames = md["data"]["artMeshNames"]
artMeshTags = md["data"]["artMeshTags"]
print(meshnamenumber)
print(meshtagnumber)
print(artMeshNames)
print(artMeshTags)

Asking user to select ArtMeshes

AskMeshSelect(websocket,textOverride,helpOverride,requestedArtMeshCount,activeArtMeshes)
The function shows pop up text. Data the function handles page

AskMeshSelect(websocket,"This text is shown over the ArtMesh selection list.","This text is shown when the user presses the ? button.",5,"artmesh")
or
payload = [artmesh,armesh2]
AskMeshSelect(websocket,"This text is shown over the ArtMesh selection list.","This text is shown when the user presses the ? button.",5,payload)

move model

mdmv(websocket,time,revelance,xp,yp,rot,size)
this function moves the currently loaded model
data the function handles page

await mdmv(websocket,0.2,False,0.1,0.1,300,-22.5)

Load Item

loaditem(websocket,fileName,X,Y,Size,Rotation,fadeTime0-2,order/layer,failIfOrderTaken,smoothing,censored,flipped,locked,unloadWhenPluginDisconnects)
Data the function handles page

await loaditem(websocket,"b_woozy (@denchisoft).png",0,0,0,0,0.5,4,0,False,False,False,False,True)

Remove Item

rmitem(websocket,unloadAllInScene,unloadAllLoadedByThisPlugin,allowUnloadingItemsLoadedByUserOrOtherPlugins,instanceIDs,fileNames)
removes items from scene, can deleat multiple at once Data the function handles page

await rmitem(websocket,False,False,True,itemid,"b_woozy (@denchisoft).png")
or for multiple

payload1 = [itemid,itemid2]
payload2 = [itemname,item2name]
await rmitem(websocket,False,False,True,payload1,payload2)

Control Item and Item Animation

conitem(websocket,itemInstanceID,FPS,frame,brightness,ALPHA,setAutoStopFrames,autoStopFrames,setAnimationPlayState,animationPlayState)
Data the function handles page

conitem(websocket,itemid,12,3,1,1,True,[0, 7, 26],True,True)

Move Item

mvitem(websocket,itemarray)
mv item passes on a array, due to this you can actually move multiple items at the same time. Data the function handles page

payload = [
    {
    "itemInstanceID": itemid,
    "timeInSeconds": 1,
    "fadeMode": "easeOut",
    "positionX": 0.2,
    "positionY": -0.8,
    "size": 0.6,
    "rotation": 180,
    "order": -1000,
    "setFlip": True,
    "flip": False,
    "userCanStop": True
    },
    {
	"itemInstanceID": item2id,
	"timeInSeconds": 0.5,
	"fadeMode": "zip",
	"positionX": 1,
	"positionY": 1,
	"size": 0.3,
	"rotation": 0,
	"order": 25,
	"setFlip": False,
	"flip": False,
	"userCanStop": False
	}
    ]
await mvitem(websocket,payload)

change model color

TintArtM(websocket,r,g,b,a,tintall,num,exactarray,conarray,tagexactarray,tagconarray)
tintall is a bool that checks is you want to color all art meshes, if True all settings that aren't rgb and alpha can be left as "", if False you need to define those slots using mesh information you get from listArtM
data the function handles page

await TintArtM(websocket,255,150,0,255,True,"","","","","")