I have been trying to run a lua script to switch between displays in a source. Default source on start is basically null (not connected) in the dropdown and the second one in the dropdown is the actual monitor i want to display. How can I achieve this in lua?
If the only change is from null-source to source-with-monitor, it might be simpler to make two scenes and switch between them by calling obs_frontend_set_current_scene.
To change the configuration of a Source within a Scene
Create a Settings object for the Source by calling obs_data_create
Set the necessary parameters by calling obs_data_set_XXX (where XXX is string, bool, etc)
Update the Source with the new Settings by calling obs_source_update
To figure out WHICH settings, you can use an editor to view the .json file for your scene collection. For a "monitor capture" Source, it is "monitor_id", but the value is an ugly glob of GUIDs that you will probably need to read from your json after manually editing the Source.
As a simpler example, the script at https://github.com/OldBaldGeek/OBS-old-bald-scripts/blob/main/SimpleSlides.lua changes the "file" setting of an Image Source to implement a slide show. But the data there is a just a filespec vs your "monitor_id" The sequence of calls and memory releases should be similar, however
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.