whats wrong with this 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

Guest

whats wrong with this macro?

Post by Guest » Sat Nov 08, 2003 9:20 am

Code: Select all

Sub Main
			
			:SpawnCheck
			/if $searchspawn(Corudoth,npc)==null {
				/call CheckFail
			} else {
				/call CheckPass
			}
			
	:Loop
		/delay 5m
		/goto :SpawnCheck

	/goto :Loop
		
			
/return


Sub CheckPass
	/beep
	/target npc "Corudoth"
	/echo $target(x), $target(y), $target(z)
	/echo at $time()
	/goto :Loop
/return

Sub CheckFail
	/goto :Loop
/return
well there it is, critique is begged

Falco
orc pawn
orc pawn
Posts: 23
Joined: Fri Sep 26, 2003 5:25 am

Post by Falco » Sat Nov 08, 2003 9:28 am

Dagnabbbit! i knew i would forget something bein this tired

koad
Plugins Czar
Posts: 127
Joined: Fri May 16, 2003 8:32 pm

Post by koad » Sat Nov 08, 2003 9:40 am

AHHHHH!!!.. you really dont want to goto :Labels in other functions

the other reason your macro may not be doing anything is you where waiting 5minutes before the first check was made.

and $searchspawn returns the ID of a mob if it finds one, 0 if not.. you wanted to use subs in your code, here is an example that trys to follow your structure:

Code: Select all

Sub Main           
  :Loop 
    /call SpawnCheck Corudoth
    /delay 5m 
  /goto :Loop  
/return 

sub SpawnCheck(pSpawn)
  /declare SpawnID local
  /varset  SpawnID $searchspawn("@pSpawn",npc)
  /if n @SpawnID==0 { 
    /call CheckFail @SpawnID
  } else { 
    /call CheckPass @SpawnID
  } 
/return

Sub CheckPass(pID)
   /beep 
   /target id @pID
   /echo $target(name)(id: @pID)
   /echo $target(x), $target(y), $target(z) 
   /echo at $time() 
/return 

Sub CheckFail(pID)
   |if you want to do something when check fails, enter here..
/return

GeoffreyF67
a lesser mummy
a lesser mummy
Posts: 70
Joined: Tue Nov 04, 2003 6:07 pm

Post by GeoffreyF67 » Sat Nov 08, 2003 10:03 am

Beat me to it :)

Here's one a bit more cleaned up and what not.

Code: Select all

| See if a mob is in the zone or not.  This would be useful to check every so often to see
| if a mob has spawned and get a record of when it was last killed.
|
Sub Main
   /if $defined(Param0)==false /call ExecError 

   :SpawnCheck
     /if $searchspawn(@Param0,npc)==0 {
       /call SpawnNotFound
     } else {
       /call SpawnFound @Param0
     } 
          
   :Loop 
      /delay 5m
      /goto :SpawnCheck 
          
/return 


| Add any special handling you might want to do if the spawn is there.
Sub SpawnFound 
   /beep 
   /target npc @Param0 
   /echo Found @Param0 at $time() at location $target(x), $target(y), $target(z) 
/return 

| Add any special handling you might want to do if the spawn is not there.
Sub SpawnNotFound
/return

Sub ExecError
   /echo Usage: CheckSpawn <Mob Name>
   /endmacro
/return