Mr.Plaka
New Member
LUA code below
shake effect in a text source,, old API level Linux, copy the text and save under (shakeText.lua )
In OBS create your text source first, GO to Tools > Script > " + " > select your .lua file you save
well done!!!
name the source and play whit the settings and speed SHAKE . CODE BELLOW
obs = obslua
source_name = ""
shake_amount = 10
speed = 30
t = 0
----------------------------------------------------------
-- Description
----------------------------------------------------------
function script_description()
return "Infinite shake animation for a text source (OLD OBS API compatible)."
end
----------------------------------------------------------
-- Properties
----------------------------------------------------------
function script_properties()
local p = obs.obs_properties_create()
local s = obs.obs_properties_add_list(
p, "source", "Text Source",
obs.OBS_COMBO_TYPE_EDITABLE,
obs.OBS_COMBO_FORMAT_STRING
)
-- Populate with all sources
local sources = obs.obs_enum_sources()
if sources then
for _, src in ipairs(sources) do
local id = obs.obs_source_get_id(src)
if id == "text_gdiplus" or id == "text_ft2_source" then
obs.obs_property_list_add_string(s,
obs.obs_source_get_name(src),
obs.obs_source_get_name(src)
)
end
end
end
obs.source_list_release(sources)
obs.obs_properties_add_int(p, "shake_amount", "Shake Amount (px)", 1, 200, 1)
obs.obs_properties_add_int(p, "speed", "Shake Speed", 1, 200, 1)
return p
end
----------------------------------------------------------
-- Update
----------------------------------------------------------
function script_update(settings)
source_name = obs.obs_data_get_string(settings, "source")
shake_amount = obs.obs_data_get_int(settings, "shake_amount")
speed = obs.obs_data_get_int(settings, "speed")
end
----------------------------------------------------------
-- Tick (Animation)
----------------------------------------------------------
function script_tick(seconds)
if source_name == "" then return end
t = t + seconds * speed
-- Get scene item
local scene = obs.obs_frontend_get_current_scene()
if scene == nil then return end
local scene_source = obs.obs_scene_from_source(scene)
local item = obs.obs_scene_find_source(scene_source, source_name)
if item ~= nil then
local pos = obs.vec2()
pos.x = math.sin(t) * shake_amount
pos.y = math.cos(t * 1.3) * shake_amount
obs.obs_sceneitem_set_pos(item, pos)
end
obs.obs_source_release(scene)
end
shake effect in a text source,, old API level Linux, copy the text and save under (shakeText.lua )
In OBS create your text source first, GO to Tools > Script > " + " > select your .lua file you save
well done!!!
name the source and play whit the settings and speed SHAKE . CODE BELLOW
obs = obslua
source_name = ""
shake_amount = 10
speed = 30
t = 0
----------------------------------------------------------
-- Description
----------------------------------------------------------
function script_description()
return "Infinite shake animation for a text source (OLD OBS API compatible)."
end
----------------------------------------------------------
-- Properties
----------------------------------------------------------
function script_properties()
local p = obs.obs_properties_create()
local s = obs.obs_properties_add_list(
p, "source", "Text Source",
obs.OBS_COMBO_TYPE_EDITABLE,
obs.OBS_COMBO_FORMAT_STRING
)
-- Populate with all sources
local sources = obs.obs_enum_sources()
if sources then
for _, src in ipairs(sources) do
local id = obs.obs_source_get_id(src)
if id == "text_gdiplus" or id == "text_ft2_source" then
obs.obs_property_list_add_string(s,
obs.obs_source_get_name(src),
obs.obs_source_get_name(src)
)
end
end
end
obs.source_list_release(sources)
obs.obs_properties_add_int(p, "shake_amount", "Shake Amount (px)", 1, 200, 1)
obs.obs_properties_add_int(p, "speed", "Shake Speed", 1, 200, 1)
return p
end
----------------------------------------------------------
-- Update
----------------------------------------------------------
function script_update(settings)
source_name = obs.obs_data_get_string(settings, "source")
shake_amount = obs.obs_data_get_int(settings, "shake_amount")
speed = obs.obs_data_get_int(settings, "speed")
end
----------------------------------------------------------
-- Tick (Animation)
----------------------------------------------------------
function script_tick(seconds)
if source_name == "" then return end
t = t + seconds * speed
-- Get scene item
local scene = obs.obs_frontend_get_current_scene()
if scene == nil then return end
local scene_source = obs.obs_scene_from_source(scene)
local item = obs.obs_scene_find_source(scene_source, source_name)
if item ~= nil then
local pos = obs.vec2()
pos.x = math.sin(t) * shake_amount
pos.y = math.cos(t * 1.3) * shake_amount
obs.obs_sceneitem_set_pos(item, pos)
end
obs.obs_source_release(scene)
end