rather than having so many conditional branches just to make sure 1 variable is greater than say 5 others, is there a simpler way?
Check that 1 variable is greater than multiple variables
RPG Maker MV Support$gameVariables.value (1) > $gameVariables.value (2) && &gameVariables.value(1) > $gameVariables.value (3) &&... So on
cheers
Is there a way to combine these variables into a shorter syntax? Like a range of variables?
Ex: $gameVariables.value (1)..$gameVariables.value (120)
-Personal error-
Only if there is some sort of a sequence behind these variables.
For example if I want to find if 1 in greater than variables 2-9:
for (var i = 2; i < 10; i++) {
if ($gameVariables.value (1) > $gameVariables.value (i)) {
code happens
}
}
Or if you happen to build an array containing the values beforehand.
This will check for variables 2, 5, 8, 9.
This is basic javascript though. If you want to learn something, I recommend sololearn.com.
For example if I want to find if 1 in greater than variables 2-9:
for (var i = 2; i < 10; i++) {
if ($gameVariables.value (1) > $gameVariables.value (i)) {
code happens
}
}
Or if you happen to build an array containing the values beforehand.
This will check for variables 2, 5, 8, 9.
Code:
var arr =[2,5,8,9]
for (var i = 0; i < arr.length; i++) {
if ($gameVariables.value (1) > $gameVariables.value (arr[i])) {
code happens
}
}
This is basic javascript though. If you want to learn something, I recommend sololearn.com.
Allright. Thank you!
Welcome. However, I had to edit it, because I always forget that when I type in [-i-] (without the dashes), it is a code for italic. So I edited it, because it would otherwise be wrong 😀
Original thread: https://forums.rpgmakerweb.com/threads/check-that-1-variable-is-greater-than-multiple-variables.87990/