First of all, you are mixing two loop concepts here: the while loop and a loop implemented via restart statements. While it is most likely going to work, I still suggest that you use either one or the other to avoid potential bugs in the future.
I consider while to be a "cleaner" approach, but in your case restart might actually provide better readability due to less indentation. Note that you only need one restart statement at the end of your script. You can also make use of the else if construct for more clarity and brevity:
As for why your inner ifs don't work properly, the problem is with your expression syntax:
This will evaluate to "true" if either SanityEffectWeight == 1 or 2 evaluates to true. Since 2 is considered to be a truthy value, this expression always evaluates to "true".
The correct syntax is: If(SanityEffectWeight == 1 || SanityEffectWeight == 2).
Alternatively, use a chain of else ifs like in the previous example, and compare with <=:
I consider while to be a "cleaner" approach, but in your case restart might actually provide better readability due to less indentation. Note that you only need one restart statement at the end of your script. You can also make use of the else if construct for more clarity and brevity:
Code:
int Sanity = CheckInventory("Sanity");int SanityEffectWeight = Random(1, 6);Delay(35);if (Sanity < 80 && Sanity >= 60){ ...}else if (Sanity >= 40){ ...}else if (Sanity >= 20){ ...}else if (Sanity >= 1){ ...}else{ ...}Restart;
Code:
If(SanityEffectWeight == 1 || 2)
The correct syntax is: If(SanityEffectWeight == 1 || SanityEffectWeight == 2).
Alternatively, use a chain of else ifs like in the previous example, and compare with <=:
Code:
if (SanityEffectWeight <= 2) // 1 or 2{ ...}else if (SanityEffectWeight <= 4) // 3 or 4{ ...}else // 5 or 6{ ...}
Statistics: Posted by Player701 — Wed Jan 15, 2025 1:55 am