- Joined
- Jul 28, 2013
- Messages
- 779
- Reaction score
- 281
- First Language
- English
- Primarily Uses
- RMMV
Hello!
Would someone be able to help me with figuring out how to use arrays with variables? I'm hoping that learning how to use them will cut down on a lot of cumbersome chains of conditional branches needed in complex eventing.
There are three different systems that I am looking to set up using arrays, which I'm hoping should give me a pretty good understanding on how to use arrays between them.
1. I'm looking to check if an array contains a string (such as "Swamp"). If it does, than the conditional branch is TRUE and nothing happens, but if it doesn't, then it is FALSE and that string is added onto the array, and I add 1 to a different variable. Also, I do want this array to be saved even after the save file is reloaded, so from what I understand this array would have to be stored in an actual variable itself, right? (The context is that I'm keeping track of the names of "random" dungeons the player beats.)
2. Set up an array to contain numbers 1-40. Then, pick a random number between 1-40. If the array has that number in it, than the conditional branch is TRUE and removes that number from the array, otherwise it is FALSE, and loops back to choose another random number. (The context is a card game, in which you have a 40 card deck. I want to make sure once you draw a certain card, you don't draw that same card again.)
3. This last one if a slightly different version of the one above. Still sets up an array with 1-40, but instead it will directly pick a random number from the array itself, skipping the step of choosing a random number from 1-40 to check if it's still in the array.
Thank you!
Would someone be able to help me with figuring out how to use arrays with variables? I'm hoping that learning how to use them will cut down on a lot of cumbersome chains of conditional branches needed in complex eventing.
There are three different systems that I am looking to set up using arrays, which I'm hoping should give me a pretty good understanding on how to use arrays between them.
1. I'm looking to check if an array contains a string (such as "Swamp"). If it does, than the conditional branch is TRUE and nothing happens, but if it doesn't, then it is FALSE and that string is added onto the array, and I add 1 to a different variable. Also, I do want this array to be saved even after the save file is reloaded, so from what I understand this array would have to be stored in an actual variable itself, right? (The context is that I'm keeping track of the names of "random" dungeons the player beats.)
2. Set up an array to contain numbers 1-40. Then, pick a random number between 1-40. If the array has that number in it, than the conditional branch is TRUE and removes that number from the array, otherwise it is FALSE, and loops back to choose another random number. (The context is a card game, in which you have a 40 card deck. I want to make sure once you draw a certain card, you don't draw that same card again.)
3. This last one if a slightly different version of the one above. Still sets up an array with 1-40, but instead it will directly pick a random number from the array itself, skipping the step of choosing a random number from 1-40 to check if it's still in the array.
Thank you!