Old 05-03-2021, 01:35 AM   #1
Kaxaze music
Human being with feelings
 
Kaxaze music's Avatar
 
Join Date: Sep 2020
Posts: 99
Default How to design a step in reascript (Fixed)

Like cycle action editor where a step is used to make a toggle, similarly any way to make that in reascript?

Edited - Ok so, i found what i wanted and here's what it end up looking like
Code:
function step_1()
--code that will happen at first iteration and so on...
end

function step_2()
--code that will happen at Second iteration and so on...
end

function main()
 
  local a = reaper.GetToggleCommandState("of some action")
  
  if a == 0 then
    step_1()
    
  end
  
  if a == 1 then
    step_2()
    a = a - 1 --or a = 0
  
  end
  
end
main()

Last edited by Kaxaze music; 05-05-2021 at 03:33 PM.
Kaxaze music is offline   Reply With Quote
Old 05-04-2021, 11:48 PM   #2
jrk
Human being with feelings
 
Join Date: Aug 2015
Posts: 1,858
Default

You need to be a bit clearer / more specific.

But to do a toggle - i.e. Your script does "something" when first run, then "un-does" it the next time, and so on - you'd need to save some state between invocations.

Perhaps have a look at SetExtState / GetExtState
__________________
it's meant to sound like that...

Last edited by jrk; 05-04-2021 at 11:59 PM.
jrk is online now   Reply With Quote
Old 05-05-2021, 01:54 AM   #3
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,121
Default

media_cue_state = reaper.GetToggleCommandState( 40691) -- View: Toggle show media cues in items

you can get the media_cue_state to toggle and change button color in a GUI.

If that's not it then you will have to give more info.

Full Screen


Code:
media_cue_state = reaper.GetToggleCommandState( 40691) -- View: Toggle show media cues in items

if media_cue_state == 0 then
  reaper.Main_OnCommand( 40691, 0)
end
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com

Last edited by MusoBob; 05-05-2021 at 02:03 AM.
MusoBob is offline   Reply With Quote
Old 05-05-2021, 02:23 PM   #4
jrk
Human being with feelings
 
Join Date: Aug 2015
Posts: 1,858
Default

Oh, querying a toggle state? or what?
__________________
it's meant to sound like that...
jrk is online now   Reply With Quote
Old 05-05-2021, 02:48 PM   #5
Kaxaze music
Human being with feelings
 
Kaxaze music's Avatar
 
Join Date: Sep 2020
Posts: 99
Default

Ok so, i found what i wanted and here's what it end up looking like
Code:
function step_1()
--code that will happen at first iteration and so on...
end

function step_2()
--code that will happen at Second iteration and so on...
end

function main()
 
  local a = reaper.GetToggleCommandState("of some action")
  
  if a == 0 then
    step_1()
    
  end
  
  if a == 1 then
    step_2()
    a = a - 1 --or a = 0
  
  end
  
end
main()

Last edited by Kaxaze music; 05-05-2021 at 03:33 PM.
Kaxaze music 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 05:38 PM.


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