[Lua] Why can't I delete a scene item ?

AlexeyLua

New Member
Why can't I delete a scene item ?
What I miss ?


Code:
obs = obslua
name = "image"

function script_load(settings)
    local src = obs.obs_get_source_by_name(name)
    local scene = obs.obs_scene_from_source(src)
    local sceneItem = obs.obs_scene_find_source(scene, source)
    obs.obs_sceneitem_remove(sceneItem)
end
 

upgradeQ

Member
Why can't I delete a scene item ?
What I miss ?


Code:
obs = obslua
name = "image"

function script_load(settings)
    local src = obs.obs_get_source_by_name(name)
    local scene = obs.obs_scene_from_source(src)
    local sceneItem = obs.obs_scene_find_source(scene, source)
    obs.obs_sceneitem_remove(sceneItem)
end
You are missing scene context, try using this functions

current_scene = obs.obs_frontend_get_current_scene() source = obs.obs_get_source_by_name(name) scene = obs.obs_scene_from_source(current_scene)
and then release

obs.obs_scene_release(scene) obs.obs_source_release(source)
 
Top