This script is supposed to toggle a LockedStatus custom variable or string in DaVinci…
- User
This script is supposed to toggle a LockedStatus custom variable or string in DaVinci Resolve at each run, but it is always "locked", it doesn't toggle. Why is that?
local resolve = app:GetResolve() local projectManager = resolve:GetProjectManager() local project = projectManager:GetCurrentProject() local timeline = project:GetCurrentTimeline()
if timeline == nil then print("No Active Timeline") return end
-- Function to get notes from the timeline local function getTimelineNotes() local notes = timeline:GetSetting("timelineNotes") print("Current Notes: " .. (notes or "No notes")) return notes or "" end
-- Function to set notes on the timeline local function setTimelineNotes(notes) timeline:SetSetting("timelineNotes", notes) print("Updated Notes: " .. notes) end
-- Function to toggle the LockedStatus within the timeline notes local function toggleLockedStatus() local notes = getTimelineNotes()
-- Debug: Print the notes in a more readable format print("Notes (split by lines):") for line in notes:gmatch("[^\r\n]+") do print(line) end -- Check if LockedStatus is already set if notes:find("LockedStatus=locked") then notes = notes:gsub("LockedStatus=locked", "LockedStatus=unlocked") print("LockedStatus switched to: unlocked") elseif notes:find("LockedStatus=unlocked") then notes = notes:gsub("LockedStatus=unlocked", "LockedStatus=locked") print("LockedStatus switched to: locked") else -- If LockedStatus is not found, add it if notes ~= "" then notes = notes .. "\n" end notes = notes .. "LockedStatus=locked" print("LockedStatus set to: locked") end setTimelineNotes(notes)end
toggleLockedStatus()
- Assistant