obs = obslua source_name = "" file_name = "" teletype_delay_ds = 1 full_display_s = 10 lines_stack = {} current_delay = 0 current_line = 1 current_char = 1 teletype_mode = false timer_deployed = false -- begin imported functions -- function courtesy Dirk Laurie -- http://lua-users.org/lists/lua-l/2014-04/msg00590.html --[[ function utf8.sub(s,i,j) i = i or 1 j = j or -1 if i<1 or j<1 then local n = utf8.len(s) if not n then return nil end if i<0 then i = n+1+i end if j<0 then j = n+1+j end if i<0 then i = 1 elseif i>n then i = n end if j<0 then j = 1 elseif j>n then j = n end end if j 0 then obs.timer_add(timer_callback, 100) timer_deployed = true end end function timer_callback() current_delay = current_delay - 1 if current_delay <= 0 then if not teletype_mode then current_line = current_line + 1 if current_line > #lines_stack then current_line = 1 end current_char = 1 teletype_mode = true current_delay = teletype_delay_ds else current_char = current_char + 1 if current_char > string.len(lines_stack[current_line]) then teletype_mode = false current_delay = full_display_s * 10 end end end update_display() end function update_display() local text_to_display = "" if teletype_mode then text_to_display = string.sub(lines_stack[current_line], 1, current_char) else text_to_display = lines_stack[current_line] end local source = obs.obs_get_source_by_name(source_name) if source ~= nil then local settings = obs.obs_data_create() obs.obs_data_set_string(settings, "text", text_to_display) obs.obs_source_update(source, settings) obs.obs_data_release(settings) obs.obs_source_release(source) end end -- end application-specific functions