You are using
if-expression-syntax with parentheses here, which is recommended
. But unfortunately, you are using it wrong
Indeed, this is rather a mixup of traditional and expression if syntax.
That is why
if (current_xp > %ii%) will always be
true here. Each run of the
loop,
if will test,
if (50 > 0).
You should rather use
if (current_xp > ii) - that means, no
%s in the expression - to
compare the contents of the two variables.
If you write
%ii% here, you are doing a double de-ref: that means, even if the actual content of the variable
ii is the number
9337, for example, if will not compare it to 50.
Instead, AHK will look for a variable
named 9337 and take its contents - unfortunately the rather lax AHK syntax allows variable names that only consist of digits - and this variable will probably be blank (you didn't define any variable named 9337 in your script - I cannot blame you for that
). A blank variable will be interpreted as
0 in this comparison.
Try this to see what I mean:
Code: Select all
if (1 > %9337%) ; AHK will take the contents of the variable named 9337, which is blank --> if (1 > 0) returns true
msgbox 9337 is blank: %9337%
9337 := "test" ; see that a number really could be a variable name
msgbox %9337%
Btw, you are using two different styles to assign variables. You should go with the
expression syntax again here (the other one will be removed in AHK v2): Use
rank := i instead of
rank = %i% for consistency.