Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently September 29th, 2024, 7:25 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: easy countdown scrip
PostPosted: February 28th, 2012, 12:17 pm 
Offline

Joined: August 5th, 2010, 1:42 pm
Posts: 109
Opus: Creator v9 Opus v7
OS: windows
I have a copy of a countdown that I found in the forum some time ago.
The scrip is oly for 15 seconds. Can someone show me how to change it to minutes and seconds? Like 3 minutes countdown.
cd is the variable name.
Thanks

Code:
cd=15
cd_stop=0

while (cd>0 && cd_stop==0)
{
wait(1)
cd--
}
if (cd_stop==1)
{
// do you statements in here
}
else
{
}


Top
 Profile  
 
 Post subject: Re: easy countdown scrip
PostPosted: February 29th, 2012, 9:30 am 
Offline
Godlike
Godlike
User avatar

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

Are you for example, trying to display something like cd=315 as 5mins 15 secs instead?

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: Re: easy countdown scrip
PostPosted: February 29th, 2012, 11:05 am 
Offline

Joined: August 5th, 2010, 1:42 pm
Posts: 109
Opus: Creator v9 Opus v7
OS: windows
Hi Mack,

yes, something like cd=5mins 15 secs or cd= 5:15
so you can see the minutes and the seconds. Otherwise it'd be confusing with hundred of seconds only like cd=315, etc


Top
 Profile  
 
 Post subject: Re: easy countdown scrip
PostPosted: February 29th, 2012, 2:13 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
You can calculate it quite easily.

To find the seconds use modulus (%) -EG

315%60 = 15 seconds

Then use this to find minutes - EG

(315 - 15) / 60 = 5 minutes

Attach each result to a variable and repeat every second and then you can output however you wish.

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: but what about the scrip?
PostPosted: February 29th, 2012, 3:06 pm 
Offline

Joined: August 5th, 2010, 1:42 pm
Posts: 109
Opus: Creator v9 Opus v7
OS: windows
Hi Mack,
what I need is the scrip for the first line, for the countdown to look like 5:15 instead of 315
right now is:
cd=315
cd_stop=0
If you can show me this example I can work out how to change it but I need an example because I am useless with scripting.
I tried few things like
cd= (315 - 15) / 60 315%60
so I can get 5 and 15 (5:15)
but is wrong, obviously


Top
 Profile  
 
 Post subject: Re: easy countdown scrip
PostPosted: February 29th, 2012, 4:12 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Have a play with this:


Code:
cd = 315

while (cd >0)
   {
   
   s = cd%60 // get the seconds

   m = (cd - s) / 60 //get minutes
   
   wait(1)
   Debug.trace(m + " min " + s + " secs\n")
   cd--   
   }


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: Re: easy countdown scrip
PostPosted: March 1st, 2012, 11:09 am 
Offline

Joined: August 5th, 2010, 1:42 pm
Posts: 109
Opus: Creator v9 Opus v7
OS: windows
Hi Mack
With your example I am still seeing 315 on the variable when click prePUb instead of 5:15
I attach another countdown example from the forum showing what I am want to get.
In this example the is a clock and countdown, the countwon is triggered when the clock starts, and there hours minutes and seconds.
I am just interested in the countdown to show minutes and seconds.


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


Top
 Profile  
 
 Post subject: Re: easy countdown scrip
PostPosted: March 3rd, 2012, 2:26 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
I don't use Opus' clocks as I find the Ticker action more useful - somebody else might though.

As for the variable, if this is an on screen variable that's not in your post, have you actually assigned it to the output from the script.

Instead of...

Code:
Debug.trace(m + " min " + s + " secs\n")


Something like...

Code:
myVaraibleOnscreen = m + " min " + s + " secs"


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  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 16 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