Last active
December 21, 2023 08:43
-
-
Save catboy1357/c36cfd73e62fecb0476bc2db63006839 to your computer and use it in GitHub Desktop.
Quick example code to send a single parameter in vrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# requires the python-osc library. If you need to install the modual use: | |
# "pip install python-osc" | |
# You can find the values in: | |
# "~\AppData\LocalLow\VRChat\VRChat\OSC\{userId}\Avatars\{avatarId}.json" | |
from pythonosc.udp_client import SimpleUDPClient | |
def get_user_input(): | |
address = input('Parameter Name: ') | |
data_type = input('Type: 1 int, 2 bool, 3 float: ') | |
value = input('Value Number: ') | |
return address, data_type, value | |
def parse_data(data_type, value): | |
if data_type == '1': | |
return int(value) | |
elif data_type == '2': | |
return bool(int(value)) | |
elif data_type == '3': | |
return float(value) | |
def send_data(client, path, data): | |
print(f'Sent {data} to /avatar/parameters/{path}: {data}') | |
client.send_message(f'/avatar/parameters/{path}', data) | |
print('\n', '----------------------------', '\n') | |
def main(): | |
client = SimpleUDPClient("127.0.0.1", 9000) # Default VRChat ip & port | |
print('Input path, type, and value.') | |
print('Parameter names are case sensitive') | |
print('Use ctrl + C to exit', '\n') | |
while True: | |
address, data_type, value = get_user_input() | |
data = parse_data(data_type, value) | |
send_data(client, address, data) | |
if __name__ == '__main__': | |
try: | |
main() | |
except KeyboardInterrupt: | |
print('\n\n', "Exit") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code was made into a full repo:
https://github.com/catboy1357/VRC-OSC-Test-Parameters