Ths is a weird one. Not fully sure why this is happening but figured I would report this.
Does the issue occur in the editor or during gameplay? If it occurs during gameplay, please specify which movement system is being used (free movement or grid movement):
Gameplay. Both.
Briefly describe the issue you're experiencing:
If you create an array of number values using range, and then check if the array contains a valid number, it returns always the else condition.
If you however generate a array of numbers manually, or using a for loop, the contains evaluation sees the number within the array.
Are there any errors in the in-game debug console or external console window?
No
Provide the steps necessary to reproduce the issue:
This will be much easier to share a script that shows the difference, than outline step by step.
Provide a download link to the bare bones project (if applicable):
Here is a script I wrote that demonstrates the issue with both annotated code and log_messages in game to see the results for yourself.
Just simply execute the following script.
$num_array = range(1, 101); // create an array of numbers 1- 100
log_message($num_array); // show the created array...all numbers present and valid
wait(10);
clear_log();
log_message($num_array[5]); // works like an array...returns 6 in this case
wait(5);
clear_log();
if $num_array contains 6 then
log_message("Found 6!"); // 1- 100 should contain 6
else
log_message("No 6 found inside!....despite just showing it a moment ago"); // this however will display!
end;
wait(3);
clear_log();
// ALTERNATE APPROACH THAT WORKS
//Manual Array
$manual_array = array[1, 2, 3, 4, 5, 6]; // not going to do 100...lol
//Auto Array using For Loop
$value = 1; // Number incrementer for values inside Array
$num_array = array[]; // create blank array
// loop through the range adding to array and inrementing value
for $i in range(1, 101) do
$num_array.push_back($value);
$value += 1;
end;
log_message($num_array); // show the generated result
wait(10);
clear_log();
log_message($num_array[5]); // works like an array....returns 6
wait(2);
clear_log();
if $num_array contains 6 then // EXACT same if check as the one above!!
log_message("Found 6"); // this time...it finds 6!
else
log_message("No 6 found inside!");
end;