Simple Spell Train - Syntax Help

Need help with a macro you are writing? Ask here!

Moderator: MacroQuest Developers

Drumstix42
a grimling bloodguard
a grimling bloodguard
Posts: 808
Joined: Mon May 03, 2004 4:25 pm

Simple Spell Train - Syntax Help

Post by Drumstix42 » Mon May 24, 2004 9:24 pm

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...

User avatar
ieatacid
Developer
Developer
Posts: 2727
Joined: Wed Sep 03, 2003 7:44 pm

Post by ieatacid » Mon May 24, 2004 10:02 pm

Try it with quotes:

"${Param0}"

Drumstix42
a grimling bloodguard
a grimling bloodguard
Posts: 808
Joined: Mon May 03, 2004 4:25 pm

Post by Drumstix42 » Mon May 24, 2004 10:25 pm

If you meant like this:

Code: Select all

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

User avatar
ieatacid
Developer
Developer
Posts: 2727
Joined: Wed Sep 03, 2003 7:44 pm

Post by ieatacid » Mon May 24, 2004 11:21 pm

My bad

Code: Select all

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

dman
a hill giant
a hill giant
Posts: 181
Joined: Fri Dec 05, 2003 12:54 pm

Post by dman » Tue May 25, 2004 7:40 am

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.

Drumstix42
a grimling bloodguard
a grimling bloodguard
Posts: 808
Joined: Mon May 03, 2004 4:25 pm

Post by Drumstix42 » Tue May 25, 2004 9:44 am

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

Preocts
a snow griffon
a snow griffon
Posts: 312
Joined: Thu Jan 29, 2004 1:02 pm

Post by Preocts » Tue May 25, 2004 12:03 pm

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 :)

Drumstix42
a grimling bloodguard
a grimling bloodguard
Posts: 808
Joined: Mon May 03, 2004 4:25 pm

Post by Drumstix42 » Tue May 25, 2004 3:40 pm

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.

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Post by wassup » Tue May 25, 2004 4:31 pm

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.

Drumstix42
a grimling bloodguard
a grimling bloodguard
Posts: 808
Joined: Mon May 03, 2004 4:25 pm

Post by Drumstix42 » Tue May 25, 2004 7:24 pm

Ahhhh. Alrighty, thanx :)