Thread: array.random()
View Single Post
  #2  
Old 03-16-2011, 10:18 PM
Jiroxys7 Jiroxys7 is offline
Hazard to Graal
Jiroxys7's Avatar
Join Date: Apr 2009
Posts: 343
Jiroxys7 will become famous soon enough
Maybe also a temp.array.shuffle()? This would randomize the current array, allowing you to 'draw' each individual part in a sequential order.

This would be useful in, for example, a card deck script. You'd put all the cards in temp.cards, then use temp.cards.shuffle(); to randomize them (or temp.cardshuffle = temp.card.shuffle(); to store them in a new array.). You would then be able to grab the randomized variables and leave them in that order or clear the cards that you have drawn.



I ask this as last time I had to randomize an array, I needed to do something like this. I ended up having to take each variable in the array and throw them in random areas in a new array consisting of about a hundred null variables (so that they dont overlap.. too often) along with some other nonsense scripts, then I had to run through THAT, pick up the non-null variable, and then put them in a new array. Somewhere in there I needed to shift variables down a notch which took at least 15+ lines on it's own I'm sure.

tl:dr, it was an exhausting day.
__________________
MY POSTS ARE PRONE TO EDITS!
Reply With Quote