Question / Help LUA Script for a Source that executes a given Program or Script when active and shown in current Scene

Hi,
i was trying to get some more automation into my OBS, but since i was unable to compile Twitch Switcher to have OBS switch my Twitch Game and Title by Monitoring the Game Executives, i tried to find another Solution. Maybe there is a more elegant way of achieving this, or there is a plan of implementing this into obs right away, but i could not find such info. So, the following solution came into my mind: Every game has its own scene and so i tried to make a LUA Script that can execute a Program or Batch Script, in my case, when switching to a scene with this source, it should launch a Batch Script which then runs a Program (PhantomBot StreamDeck Helper) that makes my Bot (PhantomBot) send commands to Twitch, updating Game and Title.

I will have to use one script per scene and one batch file per scene also.
Yeah, many steps taken, but that is not important for me since all this only have to be done once.

But i dont get it to work. I tried reading the OBS LUA reference but i cant find the cause why only the "create" function does anything and the show, hide, activate and deactivate function do nothing.

This is my code so far:

Code:
obs = obslua

execsource = {}
execsource.id = "exec_source"
execsource.output_flags = obslua.OBS_SOURCE_DO_NOT_SELF_MONITOR

execsource.get_name = function()
    return "Exec Source"
end

execsource.create = function(source, settings)
    print("created")
end

execsource.activate = function(data)
    print("shown")
end

execsource.deactivate = function(data)
    print("hidden")
end

function script_description()
    return "Executes a given Application or Script when Source is active and shown."
end

obs.obs_register_source(execsource)

The "print" commands are just for me to be able to see which function actually worked.
 
Last edited:

koala

Active Member
I assume if you're unable to switch your game with the Twitch Switcher, you're a victim of a Twitch Switcher glitch.

(Sorry ;)
 
Haha :D

Well, the problem became obsolete by itself. I cannot use this method due to my implementation of a pause/unpause stream function.
 
Top