Page 1 of 1

isnt there an easier way for params?

Posted: Tue May 18, 2004 10:15 am
by loadingpleasewait
isnt there an easier/smarter way to do the toggle parameters of a macro?

I have my auto archery macro that does all sortsa stuff that are toggled via parameters when starting the macro. but the code is messy, it works, but ya gotta enter the params in a specified order and stuff.. I know theres got to be an easier way.. can you help?

Code: Select all

/if (${Defined[Param0]} && ${String[${Param0}].Equal[snare]}) { 
   /echo "Auto-Snare enabled" 
   /varset snaretoggle 1
   /varset needsnare 1
   } 
/if (${Defined[Param0]} && ${String[${Param0}].Equal[taunt]}) { 
   /echo "Auto-Taunt enabled" 
   /varset taunttoggle 1
   } 
/if (${Defined[Param1]} && ${String[${Param1}].Equal[taunt]}) { 
   /echo "Auto-Taunt enabled" 
   /varset taunttoggle 1
   } 
/if (${Defined[Param0]} && ${String[${Param0}].Equal[forage]}) { 
   /echo "Auto-Forage enabled" 
   /varset foragetoggle 1
   } 
/if (${Defined[Param1]} && ${String[${Param1}].Equal[forage]}) { 
   /echo "Auto-Forage enabled" 
   /varset foragetoggle 1
   } 
/if (${Defined[Param2]} && ${String[${Param2}].Equal[forage]}) { 
   /echo "Auto-Forage enabled" 
   /varset foragetoggle 1
   } 
thats how I have it set up now, but its bulky..

Posted: Tue May 18, 2004 10:36 am
by dman
While untested I think this is closer to what you are looking for, benefits include not having to have a specifc order as well and easier to add in new commands.

Code: Select all

/declare i int local
/for i 0 to 2
  /if (${Defined[Param${i}]}) {
     /if (${Param${i}.Equal[snare]}) {
         /echo "Auto-Snare enabled" 
         /varset snaretoggle 1 
         /varset needsnare 1 
         }
      /if (${Param${i}.Equal[taunt]}) {
         /echo "Auto-Taunt enabled" 
         /varset taunttoggle 1 
         }
      /if (${Param${i}.Equal[forage]}) {
         /echo "Auto-Forage enabled" 
         /varset foragetoggle 1 
         }
   }
/next i

Posted: Tue May 18, 2004 11:05 am
by loadingpleasewait
Exactly what I was looking for, tested it, and it works = ) thanks so very much!

Posted: Tue May 18, 2004 2:51 pm
by Lax
You can also use ${Macro.Params} (gives you the # of parameters passed) in your /for instead of using the ${Defined} thing