Skip to content

Instantly share code, notes, and snippets.

@JustinLove
Created May 23, 2018 14:26
Show Gist options
  • Save JustinLove/0f45f026c0c3f00b6bbbe364962d2774 to your computer and use it in GitHub Desktop.
Save JustinLove/0f45f026c0c3f00b6bbbe364962d2774 to your computer and use it in GitHub Desktop.
OBS Lua dump fields available on obslua table
obs = obslua
local function script_log(message)
obs.script_log(obs.LOG_INFO, message)
end
local function dump_obs()
local keys = {}
for key,_ in pairs(obs) do
keys[#keys+1] = key
end
table.sort(keys)
local output = {}
for i,key in ipairs(keys) do
local value = type(obs[key])
if value == 'number' then
value = obs[key]
elseif value == 'string' then
value = '"' .. obs[key] .. '"'
end
output[i] = key .. " : " .. value
end
script_log(table.concat(output, "\n"))
end
-- A function named script_description returns the description shown to
-- the user
local description = [[Dump all symbols exposed in the obs library to the script log (takes a few seconds when run)
]]
function script_description()
return description
end
-- A function named script_properties defines the properties that the user
-- can change for the entire script module itself
function script_properties()
script_log("props")
local props = obs.obs_properties_create()
local ref = obs.obs_properties_add_button(props, "dump", "Dump OBS table", dump_obs)
obs.obs_property_set_long_description(ref, "Takes a few seconds")
return props
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment