Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 05-15-2019, 11:09 AM   #1
earhax
Human being with feelings
 
earhax's Avatar
 
Join Date: Nov 2015
Location: earth
Posts: 471
Default Make this script not change undo history or create an undo point?

I altered a lua script to add a playspeed reset. It doesn't create an undo point if the playspeed is already 1.0. However, if I change the playspeed, then run this script, it will create an undo point for "set project playspeed". How should I alter this script so that there will never be a change to the undo state when I run it?

Reason: sometimes I need to undo a few steps, and use a script to play and listen to something at different rates, but without changing the undo history so that I can redo the last few edits I made after listening to the sound at different rates.

Here's the script as I have it now. Hopefully there is a simple fix to make this not create an undo point when the playspeed is changed.

Code:
local reaper = reaper

function NoUndoPoint() end 

local playstate = reaper.GetPlayState()
if playstate > 0 then
  -- check "amagalma_Toggle behavior of Play-Stop buttons" state
  local cmdID = reaper.NamedCommandLookup("_RS4b332fb0ea338b4991de7e2e9cd81032d79647da")
  local script_state = reaper.GetToggleCommandStateEx(0,cmdID)
  if script_state == 1 then
    reaper.Main_OnCommand(40434, 0) --View: Move edit cursor to play cursor
    reaper.Main_OnCommand(1016, 0) --Transport: Stop
    reaper.CSurf_OnPlayRateChange( 1 )
    local pos = reaper.GetCursorPosition()
    reaper.SetExtState("Play-Stop with memory", "Position2", tostring(pos), 0)
  else
    local pos =  reaper.GetPlayPosition()
    reaper.Main_OnCommand(1016, 0) --Transport: Stop
    reaper.SetExtState("Play-Stop with memory", "Position2", tostring(pos), 0)
    reaper.CSurf_OnPlayRateChange( 1 )
  end
else
  local pos = reaper.GetCursorPosition()
  reaper.SetExtState("Play-Stop with memory", "Position", tostring(pos), 0)
  reaper.CSurf_OnPlayRateChange( 1 )
  reaper.Main_OnCommand(1007, 0) -- Transport: Play
end
reaper.defer(NoUndoPoint)
earhax is offline   Reply With Quote
Old 05-15-2019, 12:27 PM   #2
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Afaik (someone may correct me) for certain calls in scripts there's no way to control if an undo point is created or not currently.
There's a related FR:
https://forum.cockos.com/showthread.php?t=215672
nofish is offline   Reply With Quote
Old 05-16-2019, 04:18 AM   #3
earhax
Human being with feelings
 
earhax's Avatar
 
Join Date: Nov 2015
Location: earth
Posts: 471
Default

Quote:
Originally Posted by nofish View Post
Afaik (someone may correct me) for certain calls in scripts there's no way to control if an undo point is created or not currently.
There's a related FR:
https://forum.cockos.com/showthread.php?t=215672
Oh I see. I wonder then if there is maybe some other command/script I could use to reset the playspeed without creating an undo point? Does anyone know?
earhax is offline   Reply With Quote
Old 05-20-2019, 09:08 AM   #4
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Probably not. So the best option is to support the Feature Request on that.
This would help us scripters very much, as we also run into such troubles time and again.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 05-20-2019, 09:13 AM   #5
earhax
Human being with feelings
 
earhax's Avatar
 
Join Date: Nov 2015
Location: earth
Posts: 471
Default

Quote:
Originally Posted by mespotine View Post
Probably not. So the best option is to support the Feature Request on that.
This would help us scripters very much, as we also run into such troubles time and again.
Replied in the FR post. Hopefully it gets enough attention that we see this functionality soon.
earhax is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 06:45 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.