Advancing cards after a random number of seconds

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
coenzyme
Posts: 5
Joined: Thu Apr 17, 2014 9:20 pm

Advancing cards after a random number of seconds

Post by coenzyme » Thu Apr 17, 2014 9:28 pm

I would like to create a script that when a card opens it will advance to another card after a random integer of seconds in between 1 and 10.

The card script that I have written is as follows:

Code: Select all

on openCard
   global tWait
   put random(10) into tWait
   go to card 4 in tWait seconds
end openCard
The error message is:
card id 1011: compilation error at line 4 (Function: missing '('), char 20

I am new to LiveCode and am still getting used to the syntax, which is what I think is the cause of my problem.

Any help would be appreciated! Thanks!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Advancing cards after a random number of seconds

Post by jacque » Thu Apr 17, 2014 10:25 pm

Right, the syntax won't compile. You need to do the wait and then go to the card in two separate commands:

Code: Select all

wait random(10) seconds
go cd 4
Unless you're using tWait somewhere else in your stack, you probably don't need the global declaration.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: Advancing cards after a random number of seconds

Post by magice » Thu Apr 17, 2014 10:54 pm

another option is this
send "go to cd 4" to me in random(10) seconds

coenzyme
Posts: 5
Joined: Thu Apr 17, 2014 9:20 pm

Re: Advancing cards after a random number of seconds

Post by coenzyme » Fri Apr 18, 2014 2:25 am

Thanks! That's exactly what I needed!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Advancing cards after a random number of seconds

Post by jacque » Fri Apr 18, 2014 4:16 pm

magice wrote:another option is this
send "go to cd 4" to me in random(10) seconds
Does that work now? I've never been able to do that in the past.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: Advancing cards after a random number of seconds

Post by magice » Fri Apr 18, 2014 4:29 pm

jacque wrote:
magice wrote:another option is this
send "go to cd 4" to me in random(10) seconds
Does that work now? I've never been able to do that in the past.
it worked for me when I tested it.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Advancing cards after a random number of seconds

Post by jacque » Fri Apr 18, 2014 6:18 pm

So it does. I stopped using this kind of send command a long time ago because it always failed. It must have changed when I wasn't looking. Good info to have, thanks. Your way is much more concise, and I like concise.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: Advancing cards after a random number of seconds

Post by magice » Fri Apr 18, 2014 6:51 pm

jacque wrote:So it does. I stopped using this kind of send command a long time ago because it always failed. It must have changed when I wasn't looking. Good info to have, thanks. Your way is much more concise, and I like concise.
I would love to act really smart here, but the truth is, I just didn't know enough to not try it.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Advancing cards after a random number of seconds

Post by jacque » Fri Apr 18, 2014 7:34 pm

That's what newbies are for. You help the rest of us. :)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply