For any that are wanting to update any existing macros for existing undeclared variables I can only reference the following thread on Macroquest2.com
Macro warnings from MQ2-20170908.zip - MacroQuest
This explains some added functionality that most users probably didn't even know exists as it has been in the shadow of undeclared variables. Additionally, it explains the reason undeclared variables are suddenly an issue and why it was updated. Typically it's as simple as declaring your variables.
Additionally, any for loops that have multiple /next var need to be updated per the following.
Code:
/for i 0 to 5
/if (thisVar) {
/next i
} else /if (thatVar) {
/goto :skip
} else /if (theOtherVar) {
/dosomething
}
:skip
/next i
When you want to go to the next var mid loop you use /continue, when you want to exit the current for loop you use /break (as in break the loop). There should never be more than one /next var
IE:
Code:
/for i 0 to 5
/if (thisVar) {
/continue
} else /if (thatVar) {
/break
} else /if (theOtherVar) {
/dosomething
}
/next i
is that same block of code but corrected to reflect the changes I mentioned.
These were the two major changes that broke 90% of all macros.
Undeclared variables are a problem no matter what language you use, the macro script shouldn't be an exception. The code in the second block shown for proper usage of for loops is easier to read and is less confusing to the script. Chances are fixing these two things will fix any macro that was broken during those major updates.
Just declaring a variable isn't good enough! Make sure you initialize it. IE:
Code:
/declare targetID int outer
is not initialized. You have only assigned it a type and a scope. If you don't give it a value at some point then the variable is not usable!!
Code:
/declare targetID int outer ${Target.ID}
the last bit actually assigned it a value and thus it is now initialized and usable.
Of course knowing what to declare a variable as is important. So it will likely take some time depending on the size of the macro. Using those two basic priciples is what got bot40.mac moving in a forward direction when I started working on it.
As a side note. Sometimes it's more intuitive to check to see if a variable has been defined before trying to declare it. To do this you can type /if (!${Defined[VariableName]}) /declare VariableName type scope value.
IE: /if (!${Defined[MyTargetID]}) /declare MyTargetID int outer ${Target.ID}
Then to use it would be obviously ${MyTargetID}
Additionally, despite EQMule saying that unused parameters default to "NULL" they don't actually default to NULL. All parameters should be used because they default to "" nothing. Thus instead of checking for NULL you should use a bool wrapper. IE:
Code:
/if (!${Bool[Param0]}) {
/varset Param0 "default"
}
where Param0 is a string in main. In this way you can check to see if a parameter was left blank. Then if the value is NULL or not used at all then it will return false. Using the bool wrapper immediately after the beginning of the sub will check it for a valid value, and if it isn't a valid value then set it to whatever default you want to use.
Please be sure to read the post on the link I provided for the macroquest website regarding undefined variables and using a Sub name as a function and the purpose of the update for the variables being defined.
If you take on a project to update a macro, make sure you have an original so that you have something to compare it to or have something to revert back to. Also, don't be afraid to ask questions while taking on one of those projects, answers are easier to provide than actually updating the macro personally. Nobody has taken up bot40.mac in my place while I'm getting caught up on my RL. But I get on here about once a day to check posts and respond to questions if there are any. So please dive in!