Last active
February 27, 2024 22:12
-
-
Save acuifex/bf9092b2bdbc1894e1a0b4171c7b3f8f to your computer and use it in GitHub Desktop.
Example of communication between OBS scripts/plugins.
This file contains 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
# State of this module actually persists between script deletions. | |
# I think it's loaded the first time it's imported, | |
# and is kept until OBS shutdown or until OBS somehow deinitializes python. | |
# You'll probably have to reload this module to reset its state. | |
# https://stackoverflow.com/questions/437589/how-do-i-unload-reload-a-python-module | |
globalcount = 0 | |
def print_global(who): | |
print(who, globalcount) | |
def add_to_global(who, count): | |
global globalcount | |
print(who) | |
globalcount += count |
This file contains 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
import obspython as obs | |
import examplelib | |
def print_val(props, prop): | |
examplelib.print_global("script1") | |
def add_val(props, prop): | |
examplelib.add_to_global("script1", 2) | |
def script_properties(): | |
props = obs.obs_properties_create() | |
obs.obs_properties_add_button(props, "printbtn", "print", print_val) | |
obs.obs_properties_add_button(props, "addbtn", "add 2", add_val) | |
return props |
This file contains 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
import obspython as obs | |
import examplelib | |
def print_val(props, prop): | |
examplelib.print_global("script2") | |
def add_val(props, prop): | |
examplelib.add_to_global("script2", 3) | |
def script_properties(): | |
props = obs.obs_properties_create() | |
obs.obs_properties_add_button(props, "printbtn", "print", print_val) | |
obs.obs_properties_add_button(props, "addbtn", "add 3", add_val) | |
return props |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment