with mode 1 you need to ask the user for a number, with mode 2 you need a color. This is a common issue when you start adding different modes of operation for a script, e.g. Now a snippet to hide an existing property upon change of another property.
I still have a small backlog of code to share so let's continue. That is why after entry = obslua.os_readdir(dir) it is possible to use entry.d_name There are getters and setters defined automatically in SWIG for struct data, including os_dirent. This next entry is of type struct os_dirent or simply os_dirent in Lua. Then, obslua.os_readdir returns the next entry in the directory (or nil if no more entry). Obslua.os_closedir(dir)The function obslua.os_opendir returns an object of type os_dir_t * treated as opaque userdata by Lua. Table.insert(filenames, obslua.obs_data_get_string(script_settings, "obsdoc"). If entry and not entry.directory and obslua.os_get_path_extension(entry.d_name)=".rst" then Local dir = obslua.os_opendir(obslua.obs_data_get_string(script_settings, "obsdoc"))
The whole purpose of this thread is to share the tricks on how to use the OBS C API.
But the OBS C API is full of platform-independent functions. Actually I do not know how to add a non-pure-lua library to the Lua environment. The main drawbacks of Lua are its poor standard library and the difficulty to add libraries.
The Lua syntax does not rely on indentation and is quite readable.
In addition, Lua is the script language of the LÖVE2D game engine, Roblox and Wireshark, so learning it can be useful. Lua supports adding OBS sources (input, filter or transition), typically using shaders, and apparently Python does not.Lua is completely integrated into OBS, there is no need for an external scripting engine in a particular version (namely Python 3.6).Regarding the choice Python vs Lua, although I know Python very well and I'm convinced it is more powerful and compact than Lua, there are 2 main reasons to prefer Lua: The only advantage of a plugin compared to a script is speed, but if shaders can be used for computing-intensive operations, then speed is no issue anymore. The hurdles linked to plugin development and maintenance make it no viable alternative for me. Writing a plugin implies to setup a compilation environment, potentially for several target platforms (I don't have a mac), and to care about installation issues in various user environments. To implement new functionalities in OBS there are actually 3 options: plugins, Python scripts or Lua scripts. Other similar OBS plugins have the same limitations or are not working at all, because the last released version is not compatible anymore with the latest OBS version. In addition it will not support dedicated pre-processing like extracting colors from an input picture.
It is convenient for simple things but looks quickly cluttered with a large number of shader parameters. I started my OBS journey writing shaders in StreamFX ( I like shaders). Sometimes it is not so trivial so here we are. As of today (OBS v26.0.2 released October 6th 2020), the online documentation describes the OBS API in its original C form, and it is left as an exercise for the scripting enthusiast to figure out how data types are converted in the scripting environment. I start this thread to share my main advancements with Lua scripting.