Page 1 of 1

Simple Spell Train - Syntax Help

Posted: Mon May 24, 2004 9:24 pm
by Drumstix42
I posted this untested a day or two ago, and I decided to try it out.

I don't get any errors, but nothing seems to happen. I'm not sure if my variables are incorrect, my Sub's, or just somewhere in my syntax, but I can't seem to put a finger on it.

Code: Select all

|- spelltrain.mac 
|- by Drumstix42 
|- 5-22-2004 
|---------------------------------------------------- 
|- Useage: 
|- /macro spelltrain <"SpellNameHere"> 
|- Example: 
|- /macro spelltrain "Spirit of Wolf" 
|- Requires SpellCast.inc 
|- /endmac to stop :P 

#include SPELLCAST.inc 

/declare iManaMedPct int outer 
/declare iManaFullPct int outer 
/declare iGemNum int outer 

|-- CHANGE TO PERSONAL LIKING --- 

/varset iManaMedPct 20    |% mana to start medding at 
/varset iManaFullPct 98   |% mana to start casting again 
/varset iGemNum 1         |Gem number to mem spell to to train (1-8) 

|-- DONE CHANGING STUFF --- 

Sub Main 
   /if (!${Defined[Param0]}) { 
      /echo You must define a spell! 
      /echo Useage: /macro spelltrain <"SpellNameHere"> 
      /endmacro 
   } else { 
      /echo Training Spell: ${Param0} 
      /call Training 
   } 
/return 

Sub Training 
   /if (!${Me.Standing}) /stand 
   /if (!${Target.ID}) /target myself 
   :MainLoop 
    /if (${Me.PctMana}>${iManaMedPct}) { 
       /call cast ${Param0} gem${iGemNum} 
       /goto :MainLoop 
    } else { 
       /echo Low on Mana - Medding until ${iManaFullPct}% mana 
       /call Medding 
    } 
/return 

Sub Medding 
    :MedLoop 
     /if (${Me.PctMana}<${iManaFullPct}) { 
        /echo Medding... 
        /if (${Me.Standing}) /sit 
        /delay 7s 
        /goto :MedLoop 
     } else { 
        /echo Done medding. 
        /call Training 
     } 
/return
Any help on this would be appreciated. I've tried looking around, but I must just be missing something obvious. Maybe not...

Posted: Mon May 24, 2004 10:02 pm
by ieatacid
Try it with quotes:

"${Param0}"

Posted: Mon May 24, 2004 10:25 pm
by Drumstix42
If you meant like this:

Code: Select all

/call cast [color=red]"[/color]${Param0}[color=red]"[/color] gem${iGemNum}
Made no difference :?

Posted: Mon May 24, 2004 11:21 pm
by ieatacid
My bad

Code: Select all

/call cast "${Param0}" "gem${iGemNum}"

Posted: Tue May 25, 2004 7:40 am
by dman
Well, not looking to closely yet, but first thing I noticed is your declares/varsets are in the whitespace before Sub Main, they have to be within a sub to get executed, and I'm not sure how they affect things being outside of the sub like they are.

Edit: Also, I see a lot of calling from sub to sub back anf forth, eventually this will lead to a very large return stack and cause massive memory usage on your computer slowing things to a halt. Not a big problem on short term macroes, but if ran a while, this could become an issue.

Posted: Tue May 25, 2004 9:44 am
by Drumstix42
Yeah, I could see that. but it's not like something you'd really wanna use contantly or whatever. Just tried to right some code that works ;)

Will have to wait to get home to re-test the Quotations

Posted: Tue May 25, 2004 12:03 pm
by Preocts
On that topic, it's a fairly basic rule to follow to aviod stacking one called function ontop of another. Never call a parant sub from a child sub. Use the /return command, that's why it exists.

Code: Select all

Sub Medding 
    :MedLoop 
     /if (${Me.PctMana}<${iManaFullPct}) { 
        /echo Medding... 
        /if (${Me.Standing}) /sit 
        /delay 7s 
        /goto :MedLoop 
     } else { 
        /echo Done medding. 
        [color=red]/return[/color] 
     } 
/return
Also, I agree that you might find that the quotes are your problem (and the declare statements). The incoming arguments for the macro need to be in quotes if the spellname is more than one word. i.e. "Spirit of the Wolf". Same goes for /call statements. Just the nifty way the parser works on those :)

Posted: Tue May 25, 2004 3:40 pm
by Drumstix42
So basically, does the /return command send the reading of the code back to the top? I was never to sure of this command. Haven't really used it before. Was just kinda guessing.

Posted: Tue May 25, 2004 4:31 pm
by wassup
Drumstix42 wrote:So basically, does the /return command send the reading of the code back to the top? I was never to sure of this command. Haven't really used it before. Was just kinda guessing.
/return will return to the line immediately following the last /call command executed.

Posted: Tue May 25, 2004 7:24 pm
by Drumstix42
Ahhhh. Alrighty, thanx :)