Skip to main content

CVR OSC Lib

This is a simple python wrapper that allows to interface with the CVR OSC Melon Loader mod.

The data structures are using data classes so if you have a smarter IDE you can get auto-completion and type checking. I also added typing hits in most places, so should be pretty easy to use.

Melon Loader OSC mod

Compatible with: v1.1.2

I also included a few examples how to use the library, they require specific prop setup, and since we're not able to publish public props yet, you will need to either upload your own or ask me to share them with you (if you happen to find me in-game).

Installation

  1. Install Python 3.9 or above.
  2. Create a venv [Optional]
  3. Run: pip install cvr-osc-lib
  4. Now the library is installed, you can start using it!

Usage

Small example of starting the osc server and client while listening to parameter and avatar changes. Then proceeds to change to one of the default robot avatars and change its color to red.

The sleeps() and inputs() are there just to keep the example working, you probably shouldn't use them when making your script.

from time import sleep
from cvr_osc_lib import OscInterface, AvatarChangeReceive, AvatarParameterChange, AvatarChangeSend


def avatar_change(data: AvatarChangeReceive):
    print(f'Changed to an avatar with the id: {data.avatar_guid}, and the json config is '
          f'located at: {data.avatar_json_config_path}')


def avatar_parameter_change(data: AvatarParameterChange):
    print(f'The parameter {data.parameter_name} has changed to the value: {data.parameter_value}')


if __name__ == '__main__':
    osc = OscInterface()

    # Prepare listeners
    # Prepare Listening to avatar changes (useful to get the avatar guid)
    osc.on_avatar_changed(avatar_change)
    # Prepare Listening to avatar parameter changes
    osc.on_avatar_parameter_changed(avatar_parameter_change)

    # Start the osc interface (starts both osc sender client and listener server)
    # If you only want to send osc msg, you don't need to call this, the sender will start
    # when you attempt to send your first OSC msg
    osc.start(start_sender=True, start_receiver=True)

    # Start sending OSC commands (needs to be done after the interface is started)
    # Inform the mod that a new osc server is listening, so it resends all the cached state
    osc.send_config_reset()
    sleep(1)  # Wait for the mod send us the current avatar event (because we reset)

    # Change avatar to a certain avatar ID
    print('\nPress Enter to change to the robot avatar...')
    input()  # Wait for <enter>
    osc.send_avatar_change(AvatarChangeSend(avatar_guid='6b86cced-e17c-4f57-8bdf-812615773ce6'))
    sleep(5)  # Wait to load the avatar (might fail if not cached/slow internet)

    print('\nPress Enter to change color to red...')
    input()  # Wait for <enter>
    osc.send_avatar_parameter(AvatarParameterChange(parameter_name='MainColor-r', parameter_value=1.0))
    osc.send_avatar_parameter(AvatarParameterChange(parameter_name='MainColor-g', parameter_value=0.0))
    osc.send_avatar_parameter(AvatarParameterChange(parameter_name='MainColor-b', parameter_value=0.0))

    # We can now wait here and listen for osc messages
    print('\nPress Enter to exit...')
    input()  # Wait for <enter>

Example Run All

This script has an interactive python console script that will iterate through all the osc endpoints. You can use as a reference on how to use a certain command or listen to a certain endpoint.

There is a small description in the python file for the example, feel free to take a look.

Example Tracked Props

This script shows a possible implementation of attaching a prop/prop sub-sync transforms to a tracked device, like vive trackers.

For the current setup I also shared a .unitypackage containing the props I used for the example. Feel free to upload them to your account, and then replace the guids in the script.

Don't forget to import the CCK 3.4 first!

I would recommend checking the script for more info, has it has a little introduction and a bit of explanation on how to configure it.

Project contribution guide points

Max line length should not exceed 120 chars Do not include IDE specific folders apart from those created by Rider

Metadata

Release files for cvr-osc-lib 0.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cvr-osc-lib 0.0.9
File Size Uploaded
cvr_osc_lib-0.0.9.tar.gz 22.6 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for cvr-osc-lib 0.0.9
File Interpreter ABI Platform
cvr_osc_lib-0.0.9-py3-none-any.whl Python 3 none any Details

Total release size: 22.6 MB

Release files / cvr_osc_lib-0.0.9.tar.gz

Download URL cvr_osc_lib-0.0.9.tar.gz
Size 22.6 MB
Tags Source
SHA-256 checksum
How to use checksums
ef32c50d52eeeb423738c46072c45872a5cd0d6c1b9990e7a2cf6e39ddf019ff
BLAKE2b-256 checksum
How to use checksums
d7ef7d3b563ded7dd6d91eec888a7382291989be8118346ea73876f9b81ee740
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release files / cvr_osc_lib-0.0.9-py3-none-any.whl

Download URL cvr_osc_lib-0.0.9-py3-none-any.whl
Size 21.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
38e5269195b3f82291b68be181c6acffd9c771c8e6fbd95eb003dec4891c58a2
BLAKE2b-256 checksum
How to use checksums
d0c5b35f9daf6c1a322b391d4743c4ce7dc287d091886d4f193996b6fbc5511e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release history Release notifications | RSS feed

This release

0.0.9 This release

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page