Question / Help Python aficionados needed

Adam W

New Member
Hello all. I am trying to remap a midi pad for use inside of OBS. I have come across Lebaston's python script. This seems to do everything that I am looking for, but there is an area of code that doesn't seem to be functioning appropriately with OBS. I do not know this language and my experience is limited but....

The area of the script has to do with turning on/off named sources in the list. For example, I am looking to assign a key to make a source visible/invisible. The script will make the source invisible, but will not toggle the source back on. Even when assigning separate keys for each function. Please take a look as the chunk of code I found responsible for this toggle action inside of the python program. Do any of you see where the problem might be?

Code:
elif action == "SetSourceRender": #fertig
        updateSceneList()
        tempSceneList = []
        for scene in sceneListLong:
            for line in scene["sources"]:
                if line["name"] not in tempSceneList:
                    tempSceneList.append(line["name"])
        source = printArraySelect(tempSceneList)
        renderArray = ["0 (Invisible)", "1 (Visible)"]
        render = printArraySelect(renderArray)
        if render == "0 (Invisible)":
            render = 1
        else:
            render = 1
        sceneListShort.append("--Current--")
        scene = printArraySelect(sceneListShort)
        if scene != "--Current--":
            render = str(render) + ', "scene-name": "' + scene + '"'
        action = jsonArchive["SetSourceRender"] % (source, render)
        saveButtonToFile(msgType, NoC, "button" , action)
 
Last edited:
Hi Adam W,
The first thing I noticed with the script is one of the IF statements.
if render == "0 (Invisible)":
render = 1
else:
render = 1

I believe that should be:
if render == "0 (Invisible)":
render = 1
else:
render = 0 #emphasis on this line

Unfortunately without seeing more of the source, such as what "printArraySelect", I'm not sure what else may be causing the issue.
 
Back
Top