I want to combine these two scripts 1) and 2) both works but I want the locked status…
- User
I want to combine these two scripts 1) and 2) both works but I want the locked status from 2) to be based on the label on the button from 1) instead of the external txt file.
Script 1) local ui = fu.UIManager local disp = bmd.UIDispatcher(ui)
win = disp:AddWindow( { ID = "MyWin", WindowTitle = "Playhead", BorderStyle = "None", Resizable = false, Geometry = { 100,100,220,50 }, Composition = comp, ui:VGroup { ID = "root", ui:HGroup { Weight = 0,
codeui:Button{ ID = "btnLock", Text = "PLAYHEAD FREE" }, }, }, })itm = win:GetItems()
function win.On.btnLock.Clicked(ev) if itm.btnLock.Text == "PLAYHEAD FREE" then itm.btnLock.Text = "PLAYHEAD LOCKED" else itm.btnLock.Text = "PLAYHEAD FREE" end end
function win.On.MyWin.Close(ev) disp:ExitLoop() end
win:Show()
disp:RunLoop()
win:Hide()
Script 2) local stateFilePath = "E:\Resolve\RPL.txt"
local function readState() local file = io.open(stateFilePath, "r") if file then local state = file:read("*line") file:close() return state == "true" else return false end end
local projectManager = resolve:GetProjectManager() local project = projectManager:GetCurrentProject()
local timeline = project:GetCurrentTimeline()
if timeline then local isPlayheadLocked = readState() local desiredTimecode = timeline:GetCurrentTimecode()
codelocal function lockPlayhead() while true do isPlayheadLocked = readState() if isPlayheadLocked ~= true then desiredTimecode = timeline:GetCurrentTimecode() end if isPlayheadLocked then local currentPlayheadTimecode = timeline:GetCurrentTimecode() if currentPlayheadTimecode ~= desiredTimecode then timeline:SetCurrentTimecode(desiredTimecode) end end local start = os.clock() while os.clock() - start < 0.5 do end end end lockPlayhead()else print("No timeline is open.") end
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.