I am coding in Gamemaker Studio 2 and this is my code:
if selected {
value = clamp((mouse_x-x)/sprite_width, 0, max_value);
}
if value < 0 and value >= 0.1 {
avLevels = 1
} else {
if value < 0.1 and value >= 0.2 {
avLevels = 2
} else {
if value < 0.2 and value >= 0.3 {
avLevels = 3
} else {
if value < 0.3 and value >= 0.4 {
avLevels = 4
} else {
if value < 0.4 and value >= 0.5 {
avLevels = 5
} else {
if value < 0.5 and value >= 0.6 {
avLevels = 6
} else {
if value < 0.6 and value >= 0.7 {
avLevels = 7
} else {
if value < 0.7 and value >= 0.8 {
avLevels = 8
} else {
if value < 0.8 and value >= 0.9 {
avLevels = 9
} else {
if value < 0.9 and value >= 1 {
avLevels = 10
} else {
return
}
}
}
}
}
}
}
}
}
}
}
And on the last line (the last curly bracket) there is a "malformed assignment" syntax error. Does anyone know what this is and how I deal with it?
I think the last curly bracket isn't necessary, as it's not assigned with another curly bracket. (The formatting already shows that the curly bracket is out of place, and pasting the code in notepad shows that the curly bracket is not connected.)
However, I think your code block is also unnecessary complicated, as it has a lot of repeating code (that you'll also need to repeat for each level).
It also looks like your code is looking if the value is smaller than the smallest number, and higher than the highest number. Instead of, presumingly, the value inbetween.
Like Tangentially Perpendicular mentioned, you can summarise the whole if-statement nesting with a single line of code using
ceil()(Which lets you round the number to upper).