Random images but deducting each time

strangealienstrangealien Member Posts: 40
edited November -1 in Working with GS (Mac)
I have say, 20 images, and I want them to appear randomly, but, say "image8" appears, how do I make it that the next time the random attribute chooses another image, that it doesn't choose the same image again and actually deducts this image from the random number. So you might start off with 1-20 images, but then the next image it chooses is "image8", the random attribute then has 1,2,3,4,5,6,7,9,10,11,12,13,14,15,16,17,18,19,20 images to choose from. Does anyone know how to make an attribute/rule for this?

The next random number might be "image11".
We now have "image8", "image11" which have been chosen at random and the next time the random attribute/rule works, I want these 2 images to be taken out of the equation. So then the random attribute now has fewer numbers to choose from: 1,2,3,4,5,6,7,9,10,12,13,14,15,16,17,18,19,20.

Thanks in advance,

Comments

  • strangealienstrangealien Member Posts: 40
    Anyone know how to do this?
  • strangealienstrangealien Member Posts: 40
    Well, I had to do some looking up on the Internet as I couldn't find any answers here. Seems like you need to do a "shuffle" code, but not sure if you can do it on GS? I tried to replace the ,random' expression with 'shuffle' and then used the numbers that I wanted to shuffle, but that didn't work. It doesn't look like the 'shuffle' is within the set of expressions. Anyone know the answer to my question above? It might be that I'll just have to use 'random' for now and change the min and max every now and then.
  • Rob2Rob2 Member Posts: 2,402
    There are probably a few ways of doing this but one way would be to use a text attribute to store a record of the chosen image numbers and than you can use 'contains' as a test in a rule to refire the selection if the number appears in your list already..

    [Basically if your number has already appeared you choose again, normally this would be ok but depending on what else is going on could produce the odd stutter and in theory could send you into an endless loop!!]

    You would be using .. which is the catenation operator and joins things together. So for instance

    "image".."12"..".png" becomes image12.png

    There is a truly magnificent project here http://gamesalad.com/forums/topic.php?id=31218 which is well documented - don't be afraid of unlocking actors to dig into them.

    Hopefully this will get you started but if you are new to GS and don't come from a logic background you may need to watch some of TSBs superb videos first.
  • strangealienstrangealien Member Posts: 40
    Hi Rob,

    I cannot say how much I'm grateful to you for this. Thanks for giving me an explanation about this. I just looked at this project and whilst I'll need to study it a bit more, it really looks like what I've been searching for. I'm not from a programming/logic background, so the link to this project is really helpful to know and understand.

    Thanks again.
    Back to the drawing board!
Sign In or Register to comment.