castgem practice macro

Need some help with that macro you're working on or aren't quite sure how to get your macro to do something? Ask here!

Moderator: MacroQuest Developers

bob_the_builder
a hill giant
a hill giant
Posts: 275
Joined: Tue Jul 22, 2003 1:22 pm

castgem practice macro

Post by bob_the_builder » Sat Oct 11, 2003 10:30 am

Tried converting from the old format, Not quiet familiar with new format.

More curious if I have the syntax correct, I haven't run the macro yet, Im having macro woes after compile. More curious if I am understanding the new syntax for macros. I have some other old macros that I need to convert.

Code: Select all

|  Spell Practice by m0nk 
| Revised by bob_the_builder     
| /macro castgest gem# 
| castgem.mac 10/11/03

#turbo 
#Event NoMana    "Insufficient Mana to cast this spell" 
#Event Sitting   "You must be standing to cast a spell." 
#Event Recovered "You haven't recovered yet..." 
#Event BusyCast  "You can't use that command while casting..." 

Sub Main (GemNumber) 
   /if n $strlen("@GemNumber")<=0 { 
      /echo Usage: /macro castgem gem# 
      /endmacro 
   } 
   /declare Gem1 global 
   /varset Gem1 @GemNumber 
   /stand 
   /call Loop 
/return 


Sub Loop 
   :Loop 
   /doevents 
   /if n $char(gem,"@Gem1")<0 /goto :Loop 

   :CheckCursor 
   /delay 0s 
   /if $cursor()==TRUE { 
      |/click left auto 
      /autoinv
      /delay 1s 
      /goto :CheckCursor 
   } 

   /cast @Gem1 

   /goto :Loop 
/return 

Sub Event_NoMana 
   /sit off 
   /sit on 

   :Med 
   /delay 30s 
   /if n $char(mana,pct)<90 /goto :Med 
   /stand 
/return 

Sub Event_Sitting 
   /stand 
   /delay 2s 
/return 

Sub Event_Recovered 
   /delay 5s 
/return 

Sub Event_BusyCast 
   /delay 5s 
/return  
Thank you in advance

EDIT - updated macro

By the way, i added

Code: Select all

   /varset Gem1 @GemNumber 
Just to see if I understand how /varset works, I dont think it is necessary to change GemNumber to Gem1.
Last edited by bob_the_builder on Sat Oct 11, 2003 12:10 pm, edited 3 times in total.

Spectre
orc pawn
orc pawn
Posts: 21
Joined: Tue Sep 02, 2003 10:31 am

Post by Spectre » Sat Oct 11, 2003 12:00 pm

Code: Select all

/if n $strlen("@p0")<=0 { 
@p0 doesn't exist. Plaz has also posted that this method of checking for params may not work anymore. I'd suggest something like this:

Code: Select all

Sub Main(GemNumber)
   /if $defined(GemNumber)==FALSE {
        /echo Usage: /macro cast gem# 
        /endmacro 
   } 
   /declare Gem1 global 
   /declare Gem2 global 
   /varset Gem1 @GemNumber
Hope this helps, if you still have problems, please be more specific about what errors you're getting. Something more than "This macro is not working" is helpful when troubleshooting someone else's code.

Bio_War
a lesser mummy
a lesser mummy
Posts: 36
Joined: Sun Sep 29, 2002 1:03 pm

here is a working version

Post by Bio_War » Sat Oct 11, 2003 12:41 pm

ok, this is working for me, give it a try

Code: Select all

|  Spell Practice by m0nk     
| /macro castgem #
| castgem.mac 10/10/03

#turbo
#Event NoMana    "Insufficient Mana to cast this spell"
#Event Sitting   "You must be standing to cast a spell."
#Event Recovered "You haven't recovered yet..."
#Event BusyCast  "You can't use that command while casting..."

Sub Main
   /if $defined(@Param0)<1 { 
      /echo Usage: /macro castgem #
      /endmacro
   }
   /declare Gem1 global
   /declare Gem2 global
   /varset Gem1 @Param0
   /varset Gem2 "$char(gem,@Gem1)"
   /stand
   /call Loop
/return

Sub Loop

   :Loop
   /doevents
   /if n $char(gem,"@Gem2")<0 /goto :Loop
   :CheckCursor
   /delay 0s
   /if $cursor()==TRUE {
      |/click left auto
      /autoinv
      /delay 1s
      /goto :CheckCursor
   }
   /cast @Gem1
   /goto :Loop
/return

Sub Event_NoMana
   /sit off
   /sit on
   :Med
   /delay 30s
   /if n $char(mana,pct)<90 /goto :Med
   /stand
/return

Sub Event_Sitting
   /stand