Page 1 of 1

/doevents Problem

Posted: Wed Jun 30, 2004 8:44 pm
by python023
Maybe im just a stupid retard but ive read the post in "Conversion help" forum and looked at other ppl's macros, but i cant get my macro to actually do the events.
The output in my chat box when i want to /doevent says:
"Sorry, you..."
"You are missing a..."
Heres the code:

Code: Select all

/declare step int global 1
#event EvtNoMoreStuff "#*#you don't have everything you need for this recipe#*#"
#event EvtNoMoreStuff "#*#You are missing a#*#" 
#event inuse "#*#Someone else is using that#*#"
....
/doevents
....
Sub Event_EvtNoMoreStuff
	
	/autoinv
	/if (${step}==1) {
		/echo POOP
	}
	/if (${step}==2) {
		/delay 3
		/click left 500 335
		/varset step 3
	}
	/if (${step}==3) {
		/delay 3
		/click left 500 350
		/varset step 4
	}
	/if (${step}==4) {
		/delay 3
		/varset step 1
		/call Sell
	}

/return

Sub Event_inuse

	/echo "forge in use"
	/delay 3s
	/call OpenForge

/return
What am i doing wrong? Probably something simple, but i have no clue.
Thanks
python

Posted: Wed Jun 30, 2004 9:05 pm
by Virtuoso65
Well first off you have some stuff in the wrong places

Functions such as /declare must be inside your sub. To trigger subs that are event driven you must have /doevents in your main loop.


This is more on track for what you are trying to do.

Code: Select all

#event EvtNoMoreStuff "#*#you don't have everything you need for this recipe#*#"
#event EvtNoMoreStuff "#*#You are missing a#*#"
#event inuse "#*#Someone else is using that#*#"

Sub Event_EvtNoMoreStuff
/declare step int global 1
:loop
   /autoinv
   /if (${step}==1) {
      /echo POOP
   }
   /if (${step}==2) {
      /delay 3
      /click left 500 335
      /varset step 3
   }
   /if (${step}==3) {
      /delay 3
      /click left 500 350
      /varset step 4
   }
   /if (${step}==4) {
      /delay 3
      /varset step 1
      /call Sell
   }
/doevents
/goto :loop


/return

Sub Event_inuse

   /echo "forge in use"
   /delay 3s
   /call OpenForge

/return

Posted: Wed Jun 30, 2004 9:25 pm
by python023
Well see i need the variable "step" as a global var.

Code: Select all

/declare step int global 1
#event EvtNoMoreStuff "#*#you don't have everything you need for this recipe#*#"
#event EvtNoMoreStuff "#*#You are missing a#*#" 
#Event inuse "#*#Someone else is using that#*#"

Sub Main 

	
	/call BuyItems
	/call OpenForge
	
:CombineLoop

	/call Combine
	/doevents

/goto :CombineLoop

/end
Theres my header and main loop. I have /doevents in the main loop. Then the sub checks to see if i am out of an item and which step it is on so it knows what to buy. So step cant be reset to 1 every time either.
Only at the beginning.

Code: Select all


Sub Event_EvtNoMoreStuff
	
	/autoinv
	/if (${step}==1) {
		/echo POOP
	}
	/if (${step}==2) {
		/delay 3
		/click left 500 335
		/varset step 3
	}
	/if (${step}==3) {
		/delay 3
		/click left 500 350
		/varset step 4
	}
	/if (${step}==4) {
		/delay 3
		/varset step 1
		/call Sell
	}

/return

Sub Event_inuse

	/echo "forge in use"
	/delay 3s
	/call OpenForge

/return
And theres the rest of it. I think the problem has to do with the actual doevents. I mean to say that it is never getting to Sub Event_EvtNoMoreStuff. It is just ignoring the /doevents part.
Im probably wrong, but thats what im thinking.
Any suggestions?
thanks
python

Posted: Thu Jul 01, 2004 2:12 am
by Falco72
You can use an outer var insted of a global inside a macro, outer only exist while macro run, global exists also after /endmacro, so when you will restart this macro you will get an error for declaring an already existing var.
Then try to use a delay after your /doevents, I dont see any need to check it tens of times for sec, you are only stressing your CPU. And, I know it is strange, but sometimes my events do not start if I dont put a delay after the /doevents, even a /delay 0 works. Give it a try.

Code: Select all

#event EvtNoMoreStuff "#*#you don't have everything you need for this recipe#*#"
#event EvtNoMoreStuff "#*#You are missing a#*#"
#Event inuse "#*#Someone else is using that#*#"

Sub Main

   /declare step int outer 1
   /call BuyItems
   /call OpenForge
   
:CombineLoop

   /call Combine
   /doevents
   /delay 10
   /goto :CombineLoop

/end

Posted: Thu Jul 08, 2004 5:27 pm
by python023
Even with /delay 10 before AND after /doevents, the macro still wont call /doevents!!

Code: Select all

/declare step int outer 1
#event EvtNoMoreStuff "#*#you don't have everything you need for this recipe#*#"
#event EvtNoMoreStuff "#*#You are missing a#*#" 
#Event inuse "#*#Someone else is using that#*#"

Sub Main 

	
|	/call BuyItems
	/call OpenForge
	
:CombineLoop

	/call Combine
	/delay 10
	/doevents
	/delay 10

/goto :CombineLoop

/end

Sub BuyItems
...
/return

Sub Open
...
/delay 10
/doevents
/delay 10
...
/return

Sub Combine
...
/return

Sub Event_EvtNoMoreStuff
	
	/autoinv
	/if (${step}==1) {
		/delay 3
		/click left 500 321
		/varset step 2
	}
	/if (${step}==2) {
		/delay 3
		/click left 500 335
		/varset step 3
	}
	/if (${step}==3) {
		/delay 3
		/click left 500 350
		/varset step 4
	}
	/if (${step}==4) {
		/delay 3
		/varset step 1
		/call Sell
	}

/return

Sub Event_inuse

	/echo "forge in use"
	/delay 3s
	/call OpenForge

/return

Posted: Thu Jul 08, 2004 5:34 pm
by hytiek
i can appreciate secrecy, but it doesn't help you fix things :)

What's your Combine sub look like? can you post it? also in your coverup you have a sub called "Open" and in your macro you call "OpenForge" (i'm sure this was a hack due to your privacy .... but if you want help post the full code :) i know personally that i don't have esp)

-hytiek

Posted: Thu Jul 08, 2004 9:39 pm
by Virtuoso65
If the event isnt triggering then obviously there is something wrong with your event text or your sub. We have helped you as much as posable with what you have given.

Posted: Fri Jul 09, 2004 6:41 am
by Chill
1) You NEED to declare ALL variables from INSIDE A SUB. If you want them to persist for the life of your macro (strongly suggested) then you should declare them as outers at the beginning of your Sub Main. If you really want the variables to live on after your macro, then you need to check to see if they are ${Defined[]} before declaring them as a global, but you still need to do it inside a sub. If they are already defined, then use either /varset or /varcalc instead of /declare (look in TFM for syntax).

2) Youre kinda doing this the hard way. You technically can /click pixles on your screen and move items step by step....but honestly, its a pain in the ass. With the new tradeskill UI, its much easier to select a recipie from your favorites list and just /notify the combine button.

I have a fairly simple combines.mac posted. It requires that you have all components in inventory, open the container, and select the recipie yourself. It would not be hard to add skillup info if you want it, but it only reports success/failure info as written. If this is sufficient, I would suggest using it.

If you are looking for a more automated macro to run around, buy materials, open containers, etc. then I would look at Picks.mac as a simple example for starters and move on to some of the other Tradeskill macros in the Depot.