Package: cvr-osc-lib
CVR OSC LibThis 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 modCompatible with:v1.1.2I 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).InstallationInstall Python 3.9 or above.Create avenv[Optional]Run:pip install cvr-osc-libNow the library is installed, you can start using it!UsageSmall 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.fromtimeimportsleepfromcvr_osc_libimportOscInterface,AvatarChangeReceive,AvatarParameterChange,AvatarChangeSenddefavatar_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}')defavatar_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 changesosc.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 msgosc.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 stateosc.send_config_reset()sleep(1)# Wait for the mod send us the current avatar event (because we reset)# Change avatar to a certain avatar IDprint('\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 messagesprint('\nPress Enter to exit...')input()# Wait for <enter>Example Run AllThis 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 PropsThis 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.unitypackagecontaining 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 theCCK 3.4first!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 pointsMax line length should not exceed 120 chars
Do not include IDE specific folders apart from those created byRider