Skip to main content

A small library to interface with CVR Melon Loader OSC mod API

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cvr_osc_lib-0.0.9.tar.gz (22.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cvr_osc_lib-0.0.9-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

Details for the file cvr_osc_lib-0.0.9.tar.gz.

File metadata

  • Download URL: cvr_osc_lib-0.0.9.tar.gz
  • Upload date:
  • Size: 22.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for cvr_osc_lib-0.0.9.tar.gz
Algorithm Hash digest
SHA256 ef32c50d52eeeb423738c46072c45872a5cd0d6c1b9990e7a2cf6e39ddf019ff
MD5 096ea8c635c674228a92c7aef12b8708
BLAKE2b-256 d7ef7d3b563ded7dd6d91eec888a7382291989be8118346ea73876f9b81ee740

See more details on using hashes here.

File details

Details for the file cvr_osc_lib-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: cvr_osc_lib-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 21.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for cvr_osc_lib-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 38e5269195b3f82291b68be181c6acffd9c771c8e6fbd95eb003dec4891c58a2
MD5 49e2b7999d6f390af129f6c3113f01ff
BLAKE2b-256 d0c5b35f9daf6c1a322b391d4743c4ce7dc287d091886d4f193996b6fbc5511e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page