-- Function to toggle source visibility functionon_event(event) if event == obs.OBS_FRONTEND_EVENT_STREAMING_STARTED then -- show live -- hide record and free show_source(source_name_live) hide_source(source_name_record) hide_source(source_name_free) end if event == obs.OBS_FRONTEND_EVENT_STREAMING_STOPPED then -- hide live -- show free hide_source(source_name_live) show_source(source_name_free) end if event == obs.OBS_FRONTEND_EVENT_RECORDING_STARTED then -- show record -- hide live and free show_source(source_name_record) hide_source(source_name_live) hide_source(source_name_free) end if event == obs.OBS_FRONTEND_EVENT_RECORDING_STOPPED then -- hide record -- show free hide_source(source_name_record) show_source(source_name_free) end end
functionhide_source(source_name) local source = obs.obs_get_source_by_name(source_name) if source ~= nilthen obs.obs_source_set_enabled(source, false) end obs.obs_source_release(source) end
functionshow_source(source_name) local source = obs.obs_get_source_by_name(source_name) if source ~= nilthen obs.obs_source_set_enabled(source, true) end obs.obs_source_release(source) end
-- Function to toggle source visibility functionon_event(event) if event == obs.OBS_FRONTEND_EVENT_STREAMING_STARTED then -- show live -- hide record and free show_source(source_name_live) hide_source(source_name_record) hide_source(source_name_free) end if event == obs.OBS_FRONTEND_EVENT_STREAMING_STOPPED then -- hide live -- show free hide_source(source_name_live) show_source(source_name_free) end if event == obs.OBS_FRONTEND_EVENT_RECORDING_STARTED then -- show record -- hide live and free show_source(source_name_record) hide_source(source_name_live) hide_source(source_name_free) end if event == obs.OBS_FRONTEND_EVENT_RECORDING_STOPPED then -- hide record -- show free hide_source(source_name_record) show_source(source_name_free) end end
-- A function named script_properties defines the properties that the user -- can change for the entire script module itself functionscript_properties() local props = obs.obs_properties_create() obs.obs_properties_add_text(props, "source_name_record", "Record icon source name", obs.OBS_TEXT_DEFAULT) obs.obs_properties_add_text(props, "source_name_live", "Live icon source name", obs.OBS_TEXT_DEFAULT) obs.obs_properties_add_text(props, "source_name_free", "Free icon source name", obs.OBS_TEXT_DEFAULT) return props end
-- A function named script_description returns the description shown to -- the user functionscript_description() return"Toggles visibility of sources based on streaming and recording status\n\n\nMade by Jz0ojiang" end
-- A function named script_update will be called when settings are changed functionscript_update(settings) source_name_record = obs.obs_data_get_string(settings, "source_name_record") source_name_live = obs.obs_data_get_string(settings, "source_name_live") source_name_free = obs.obs_data_get_string(settings, "source_name_free") end
-- A function named script_defaults will be called to set the default settings functionscript_defaults(settings) obs.obs_data_set_default_string(settings, "source_name_record", "record_icon") obs.obs_data_set_default_string(settings, "source_name_live", "live_icon") obs.obs_data_set_default_string(settings, "source_name_free", "free_icon") end
functionscript_load(settings) obs.obs_frontend_add_event_callback(on_event) end