Random Ending of Macro

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

Moderator: MacroQuest Developers

python023
a lesser mummy
a lesser mummy
Posts: 30
Joined: Sat Mar 27, 2004 12:26 pm

Random Ending of Macro

Post by python023 » Sun May 02, 2004 2:04 pm

In this smihting macro, after one or two combines, it automatically ends the macro when it should still be running. It buys the items, opens the forge, select the first item, and then does one or two combines, and then ends.

Code: Select all

#Event nocomp1 "You are missing a Small Piece of Ore"

Sub Main 

:MainLoop	
                    /call BuyItems
	/call OpenForge
	/call Combine
/end

Sub BuyItems
      | Wont put in this code b/c of AFK plat macros etc.
/return

Sub OpenForge
    	/itemtarget Forge
    	/click left item
	/doevents
	/delay 1s
	/click left 500 377
                    |The /click is the location of the recipe in the New Forge UI
/return

Sub Combine
	/delay 14
	/notify TradeskillWnd CombineButton leftmouseup
	/delay 4
	/autoinv
	/delay 3
	/autoinv
	/doevents	
/return

Sub Sell
 |Wont post this for same reason as buy sub
/return

Sub Event_nocomp1	
	/autoinv
	/delay 5
	/click left 500 364
                    |The /click is the location of the recipe in the New Forge UI
	/call Combine
/return
Why is this code ending after only one or two combines?!
thanks in advance
python

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

Post by Lax » Sun May 02, 2004 2:16 pm

Problem is a) even if it didnt stop you would crash because you'd be consistently using up more and more memory, and b) its stopping because your only method of looping appears to be if you have no ore.

Rethink it :)
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0

python023
a lesser mummy
a lesser mummy
Posts: 30
Joined: Sat Mar 27, 2004 12:26 pm

Post by python023 » Sun May 02, 2004 2:25 pm

OK I see the problem in my loop now :oops: hehe, but what do you mean I would crash because im consistently using up more memory?
Is it a certain command im calling or what?
thanks
python

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

Post by Lax » Sun May 02, 2004 2:31 pm

The problem is /doevents effectively issues a /call to each event being done.

In your event, you call /combine. In /combine, you /doevents. Assume you have an event every time. This is the same as:

Code: Select all

Sub Func1
/call Func2

Sub Func2
/call Func1
This will ONLY add to the size of the macro call stack, and it will grow to infinity (until you run out of memory and the program crashes).

To loop you should use a label in your main sub, along with /goto
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0

python023
a lesser mummy
a lesser mummy
Posts: 30
Joined: Sat Mar 27, 2004 12:26 pm

Post by python023 » Sun May 02, 2004 2:40 pm

So what i should do is change the Sub Combine to :Combine - from a routine to a label, and then instead of /call Combine every /doevents, i should use /goto :Combine
right?
thanks
python

python023
a lesser mummy
a lesser mummy
Posts: 30
Joined: Sat Mar 27, 2004 12:26 pm

Post by python023 » Sun May 02, 2004 5:09 pm

OK i changed the combine part to a label instead of sub, but now i get the error: Couldn't find label :Combine
here is the new code:

Code: Select all

#Event nocomp1 "You are missing a Small Piece of Ore"

Sub Main 

:MainLoop
	
	/call BuyItems
	/call OpenForge
	/goto :Combine

/end

Sub BuyItems
.....
/return

Sub OpenForge

    	/itemtarget Forge
    	/click left item
	/doevents
	/delay 9
	/click left 500 377

/return

:Combine

	/delay 3
	/notify TradeskillWnd CombineButton leftmouseup
	/delay 3
	/autoinv
	/delay 3
	/autoinv
	/doevents

/goto :Combine

Sub Sell
...
/return

Sub Event_nocomp1
	
	/autoinv
	/delay 5
	/click left 500 364
	/goto :Combine

/return
Whats wrong with my code now?
thanks
python

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

Post by Lax » Sun May 02, 2004 5:13 pm

you cant skip around subs with gotos.

what you want is to /call a sub, and let it /return. the macro continues from the point of the /call.

In sub main, make a loop like this:

Code: Select all

Sub Main
:MainLoop
/call BuyItems
/call OpenForge
:CombineLoop
/call Combine
/doevents
/if (something) /goto CombineLoop
/if (something) /goto MainLoop
/end
replace the "something"s with the conditions that need to be met to continue your loop.
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0

python023
a lesser mummy
a lesser mummy
Posts: 30
Joined: Sat Mar 27, 2004 12:26 pm

Post by python023 » Sun May 02, 2004 6:40 pm

ok, i got it now
thank you once again, lax