Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 7:26 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: Loop Scripting
PostPosted: October 15th, 2009, 12:35 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi,

I am trying to create a small utility to help the user slow their breathing in order to relax. A bar moves up and down which can be used to pace breathing. I've attached a sample .imp.

The goal is to reduce breaths per minute to 6 per minute from wherever the user begins and do this incrementally, a minute of exercise at a time, over a 15 minute time span.

So, if the user enters into an input box, 12 breaths per minute (bpm), then over the next 15 minutes, when they start the exercise, the bar would first move up and down for 60 seconds at 12 bpm, then it would move up and down for 60 seconds at 11 bpm, then for 60 seconds at 10 bpm, etc. until it reached 6 bpm at which point it would continue at 6 bpm for as many minutes necessary to fill out the 15 minutes of exercise.

I've figured out the basic loop for a 60 second segment for any bpm rate:

Code:
var bar2 = 60/bar1
for (loop = 0;loop<bar1;loop++)
{
Vector1.MoveY(-350, bar2*.3)
wait (bar2*.05)
Vector1.MoveY(350, bar2*.6)
wait (bar2*.05)
}


What I cannot figure out is how to now script this single 60 second exercise into a larger script that will (1) check if bar1 > 6, (2) if > 6 it will decrement it by 1 (--), (3) it will run the above loop with the newly decremented bpm value and (4) not decrement if bpm/bar1 = 6, and (5) continue this looping until 15 minutes of exercise time is reached.

This seems to be a challenging bit of scripting! I've tried "while" looping, but without success. Maybe it cannot be done? Or, maybe there is a better design?

I would appreciate any suggestions, help.

Kind Regards,


You do not have the required permissions to view the files attached to this post.

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: October 15th, 2009, 1:41 pm 
Offline

Joined: March 4th, 2007, 7:17 pm
Posts: 132
I can not help with the script, but I do have one piece of advice.
I once practiced in yoga. For better relaxation is desirable to breathe square breathing: inhale (15% of the total cycle time of breath) - breath holding at inspiration (35%) - exhale (35%) - delay in expiration (15%). Naturally, you must first start with the other proportions (25/25/25/25), and then gradually increase the time of expiration and breath-holding.

follow with interest the topic ...

_________________
Opus Pro 5.5
Win XP


For this message Volgar has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: October 15th, 2009, 2:00 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi Volgar,

Yes, that would be another way to create the intervals. But, I am using, for now, a standard formula found in breath pacer training which is 30%, 5%,60%, 5%. Maybe, once it is working, I can vary the formula as you suggest or offer options.

By the way, I had tried a time line to try to get this working, without success.

Stay tuned!

Kind Regards,

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: October 15th, 2009, 3:33 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Hi Stephen,

Change the script action on 'start' button to this.

while (bar1>6)
{
var bar2 = 60/bar1
for (loop = 0;loop<bar1;loop++)
{
Vector1.MoveY(-350, bar2*.3)
wait (bar2*.05)
Vector1.MoveY(350, bar2*.6)
wait (bar2*.05)
}
bar1--
}


Regards,

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: October 15th, 2009, 4:04 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi Mack,

Thanks for your reply. I was on to a similar, but more awkward version: see the newly attached sample which has a start button lower left with my more awkward attempt (plus some standard action looping) and your suggestion in the start button upper right.

In the new attachment in the upper right start button, I added an "if" script to the "while" script to get the bpm to stop decrementing if = 6 bpm.
The problem now is to get some way to time the entire exercise from when the start button is pressed to total 15 minutes. So far, in my upper right start button script, if the user starts at 7 bpm, a one minute exercise is run at 7 bpm, followed by one minute of six bpm. The next 13 minutes should repeat at 13 X one minute exercises at 6 bpm, then stop. (This works a lot better when the user begins at for example 12 bpm, is "stepped down" by one minute decrements to 6 bpm, and has 9 one minute cycles at 6 bpm each, totaling 15 minutes.)

The challenge is now building in this decrementing one minute repeating until 6 is reached, repeating at 6 bpm until totaling 15 minutes.

Any way to script this?

I appreciate your help.

Kind Regards,


You do not have the required permissions to view the files attached to this post.

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Last edited by Stephen on October 15th, 2009, 4:24 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: October 15th, 2009, 4:20 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Stephen wrote:
decrement by -1


I'd have thought that decrementing a negative number would have increased the result :-)

Seriously though, I'd keep it simple and run a 15 minute ticker action. Every 60s break the decrementing for-loop you already have unless bar1 = 6 in which case I'd simply run a different loop for the regulated breathing.

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: October 15th, 2009, 4:25 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi Mack,

Yes, I was just reminding myself of Occam's Razor and simplicity yesterday.
:)

I can give this new suggestion a try, but I am not sure yet how to use the ticker and "break" with this.

I am attaching the newest sample imp which has progress. The remaining challenge is getting it to all total 15 minutes of one minute exercises, then stop. Once bpm = 6, I need to figure out how to get it to "know" how much time out of the 15 mins are used (since exercise start button clicked), and repeat at 6 bpm until totaling 15.

Not sure how to achieve this. Any suggestions appreciated.

Kind Regards,


You do not have the required permissions to view the files attached to this post.

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Loopy Loops
PostPosted: October 15th, 2009, 7:55 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
You don't half pick interesting concepts. I've sent you a workable solution :-)

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: October 15th, 2009, 8:31 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Thanks, Mack.

Very impressive solution!!!

Is there any way to set up a clock or timer so that it automatically stops the exercises after 15 minutes? I've tried to add in a clock and have not been successful.

Again, thanks much! :)

Kind Regards,

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: October 16th, 2009, 9:04 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Cheers Stephen,

I've tweaked the recursion and sent you an updated version.

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: October 16th, 2009, 12:31 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Thanks, Mack.

Wow! Very impressive scripting! :)

Kind Regards,

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: October 16th, 2009, 1:21 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Yes that Mack is quite a gent.

For a bit of 'distraction', here's a relevant blonde joke:
http://www.helium.com/items/700465-jokes-blonde-jokes
(scroll down to find)
"#4:
A Blonde woman walks into a Hair salon to get her hair cut, wearing a set of headphones in her ears connected to a tape player. After sitting in the chair...."

cheers.

_________________
_good things come to those who wait(0)_


For this message Lar_123 has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: October 16th, 2009, 1:41 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi, Larry.

Yes, a funny story very much related to the breathing tool.
:D

And, Mack can certainly make Opus "sing" with his brilliant scripting!

Kind Regards,

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 46 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group