The initial problem I was pointing out is that your script didn't have an end if statement, it looked like this
Code: Select all
if whichCard = 1 then
go to card "FR1"
else go to card "FR20"
so I changed it to this
Code: Select all
put random(2) into whichCard
if whichcard = 1 then
go to card "FR1"
else
go to card "FR20"
end if
While i'm not sure exactly where you're going with this, here is a script that will randomly go through every card the specified number of times in random order with a small delay so that its easier to see the cards change.
I placed this script in the stack. Would work equally well in the card script.
Code: Select all
local tStop --a script local variable that determines if the loop should stop or not
--tstop is used to exit the loop if needed
###pVar is a passed variable that contains the number of times to display each card
command gorandomcards pVar
####sets the initial value of tStop to false (puts true in it then sets it to not true the first time around)
if tStop is empty then put true into tStop
put not tStop into tStop
####I'm just using all cards for this. If you wished to do specific cards you would have to adjust the contents of tCardList
put the cardnames of this stack into tCardList
## if the list of cards is not empty
## and we haven't put true into tStop, the repeat loop will continue
repeat while tCardList is not empty and tStop is not true
### waiting with messages so that you can see
### the cards flip as well as allowing itme
### to do other things (like set tStop to true so that the loop will stop)
wait 100 milliseconds with messages
###get a random number based on the number of cardnames
### that are in the tCardList variable
put random(the number of lines in tCardList) into tLine
###go to the card named in the random
###Line number chosen from above
go card (line tLine of tCardList)
###tCardA is an array variable. We use it to keep track
### of how many times a specific card has been seen
### If card "fred" has just been selected
### we add 1 to tCardA["fred"] and then check to see if the value of tCardA["fred"]
### is greater than the value we passed to the command in pVar
### of course if line 4 of tCardList contains cardname "Fred" then
### the key value of 'tCardA[line tLine of tCardlist]' would be fred. tCardA["fred"]
add 1 to tCardA[line tLine of tCardList]
### if the value is > than pVar delete the card name from the list
if tCardA[line tLine of tCardList] > pVar then
delete line tLine of tCardlist
end if
###eventually, all card names are removed from the list
### so the repeat loop will exit.
end repeat
### ensure that our tStop variable is set to true so that we can start fresh
### next time
put true into tStop
end gorandomcards
To use this command just have a button that calls the command gorandomcards with a number defining the number of times to display each card
Code: Select all
on mouseUp
gorandomcards 5
end mouseup
For more info on arrays and how to use them go here.
http://lessons.runrev.com/s/lessons/tags?tag=array
There are other ways to do this, and its hard to know exactly what you're going for, but hopefully something in here will help.