• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

SOLVED Check if a variable equals any value in a array?

mrredleg0

Member
So I have an array:
shake_messages = [2,3,15,16,19,20,22,23];
I want to check if a variable equals any of the numbers in the array.
How would I do this?
 

Evanski

Raccoon Lord
Forum Staff
Moderator
GML:
for loop check array index count
{
    check current value against count in array
    increase count
    if value is the same as value do something about it
}
 

mrredleg0

Member
Thank you but I figured it out.
if(ds_list_find_index(shake_messages,msg_num) != -1) {

{
This is what I needed.
 

Nidoking

Member
As long as the thing you called an array is actually a list rather than the array you said it was, that would work. You need to ask the right questions if you want useful answers.
 
Top