Split macros? Or how do it do?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Marcdk
Junior Coder
Posts: 36
Joined: Sat Sep 22, 2007 10:16 pm

Split macros? Or how do it do?

Post by Marcdk » Sun Mar 02, 2008 5:36 pm

Hey again :)

Im working on a BIG bot which locates goldmines in a game called Warcraft 3, well, these goldmines is on diffrent places in each map, i have coded most of them, what i want to do with this script, is to get the Workers going to the goldmine when the game begins :)

Okay, so i will give u some of my code so you can see my problem
I have coded around 30 goldmines, and the last ones in the script takes so much time before they react because the bot is looking trough all these pixels... here is my code:

Waitkeydown>m
Getpixelcolor>303,376,Gold
IF>%Gold%=987931
Mousemove>303,376
Getcursorpos>X,Y
Mousemove>12,44
ldown
mousemove>980,550
lup
Mousemove>%X%,%Y%
wait>0.1
Rclick
endif

Getpixelcolor>676,352,Gold2
IF>%Gold2%=856605
Mousemove>676,352
Getcursorpos>X,Y
Mousemove>12,44
ldown
mousemove>980,550
lup
Mousemove>%X%,%Y%
wait>0.1
Rclick
endif

Getpixelcolor>346,475,Gold3
IF>%Gold3%=988191
Mousemove>346,475
Getcursorpos>X,Y
Mousemove>12,44
ldown
mousemove>980,550
lup
Mousemove>%X%,%Y%
wait>0.1
Rclick
endif

Getpixelcolor>633,469,Gold4
IF>%Gold4%=1185827
Mousemove>633,469
Getcursorpos>X,Y
Mousemove>12,44
ldown
mousemove>980,550
lup
Mousemove>%X%,%Y%
wait>0.1
Rclick
endif

Getpixelcolor>401,217,Gold5
IF>%Gold5%=725789
Mousemove>401,217
Getcursorpos>X,Y
Mousemove>12,44
ldown
mousemove>980,550
lup
Mousemove>%X%,%Y%
wait>0.1
Rclick
endif

Getpixelcolor>588,233,Gold6
IF>%Gold6%=1120291
Mousemove>588,233
Getcursorpos>X,Y
Mousemove>12,44
ldown
mousemove>980,550
lup
Mousemove>%X%,%Y%
wait>0.1
Rclick
endif

Getpixelcolor>370,238,Gold7
IF>%Gold7%=856350
Mousemove>370,238
Getcursorpos>X,Y
Mousemove>12,44
ldown
mousemove>980,550
lup
Mousemove>%X%,%Y%
wait>0.1
Rclick
endif

Getpixelcolor>605,484,Gold8
IF>%Gold8%=1383720
Mousemove>605,484
Getcursorpos>X,Y
Mousemove>12,44
ldown
mousemove>980,550
lup
Mousemove>%X%,%Y%
wait>0.1
Rclick
endif

Getpixelcolor>390,224,Gold9
IF>%Gold9%=724759
Mousemove>390,224
Getcursorpos>X,Y
Mousemove>12,44
ldown
mousemove>980,550
lup
Mousemove>%X%,%Y%
wait>0.1
Rclick
endif

Getpixelcolor>622,470,Gold10
IF>%Gold10%=1515050
Mousemove>622,470
Getcursorpos>X,Y
Mousemove>12,44
ldown
mousemove>980,550
lup
Mousemove>%X%,%Y%
wait>0.1
Rclick
endif

Getpixelcolor>360,242,Gold11
IF>%Gold11%=2308445
Mousemove>360,242
Getcursorpos>X,Y
Mousemove>12,44
ldown
mousemove>980,550
lup
Mousemove>%X%,%Y%
wait>0.1
Rclick
endif

Getpixelcolor>590,224,Gold12
IF>%Gold12%=1383465
Mousemove>590,224
Getcursorpos>X,Y
Mousemove>12,44
ldown
mousemove>980,550
lup
Mousemove>%X%,%Y%
wait>0.1
Rclick
endif

Getpixelcolor>586,490,Gold13
IF>%Gold13%=659225
Mousemove>586,490
Getcursorpos>X,Y
Mousemove>12,44
ldown
mousemove>980,550
lup
Mousemove>%X%,%Y%
wait>0.1
Rclick
endif

Getpixelcolor>516,215,Gold14
IF>%Gold14%=1317670
Mousemove>516,215
Getcursorpos>X,Y
Mousemove>12,44
ldown
mousemove>980,550
lup
Mousemove>%X%,%Y%
wait>0.1
Rclick
endif

Getpixelcolor>322,210,Gold15
IF>%Gold15%=2836588
Mousemove>322,210
Getcursorpos>X,Y
Mousemove>12,44
ldown
mousemove>980,550
lup
Mousemove>%X%,%Y%
wait>0.1
Rclick
endif

Getpixelcolor>458,530,Gold16
IF>%Gold16%=922913
Mousemove>458,530
Getcursorpos>X,Y
Mousemove>12,44
ldown
mousemove>980,550
lup
Mousemove>%X%,%Y%
wait>0.1
Rclick
endif
The red indicates the number of the goldmine... So this was 16 og them, i have around 30, i need all of them to react in no time, So, how do i get the last onces reacting faster? I thought about splitting them up in 2 files, or maybe 3, but if i can make it work without doing this i would prefer it...

So, if i need to split this macro, how do i do? I mean, so i click ONE file, the first one, then it goes trough the code, and then it starts the next macro (another file) And then in the last macro, it needs to jump back to macro number 1

Hope anyone can help me, and understand what i wanna do with this :)

Thx

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sun Mar 02, 2008 7:16 pm

Use the Macro> or Include> commands, or ExecuteFile> to execute the other .scp file
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Marcdk
Junior Coder
Posts: 36
Joined: Sat Sep 22, 2007 10:16 pm

Post by Marcdk » Sun Mar 02, 2008 7:33 pm

I'll try it ;) thx man

Marcdk
Junior Coder
Posts: 36
Joined: Sat Sep 22, 2007 10:16 pm

Post by Marcdk » Sat Mar 15, 2008 7:30 pm

Okay, so im a bit confused on how these works, i tried to split the code up into 3 diffrent files, then i compiled them, my main file looks like this:
Dialog>Dialog1
Caption=Marcdk's AutoGoldMining Bot
Width=339
Height=155
Top=227
Left=148
Close= 0
Resize=0
Button=Start Bot,224,8,75,25,1
Label=Close bot ==> Shift + Esc,200,40,true
Memo=msMemo1,140,88,175,25,This bot was made by: Marcdk
Memo=msMemo2,8,16,169,57,Open all the files in the zip folder, and hit the Start Bot button! Enjoy :)
EndDialog>Dialog1

Label>MainLoop
Show>Dialog1,result
If>result=1,StartBot
Goto>MainLoop

Srt>StartBot
WindowAction>Open,Warcraft III
GOTO>Start
End>StartBot



Label>Start
waitkeydown>a
send>
send>
Wait>0.2
lclick
wait>0.5
send>p
send>p
wait>0.2
send>
Getpixelcolor>303,376,Gold
IF>%Gold%=987931
Mousemove>303,376
Getcursorpos>X,Y
Mousemove>12,44
ldown
mousemove>980,550
lup
Mousemove>%X%,%Y%
wait>0.1
Rclick
endif
Then i have 2 other files with code link this:



Getpixelcolor>616,241,Gold23
IF>%Gold23%=1711909
Mousemove>616,241
Getcursorpos>X,Y
Mousemove>12,44
ldown
mousemove>980,550
lup
Mousemove>%X%,%Y%
wait>0.1
Rclick
endif

Getpixelcolor>580,510,Gold24
IF>%Gold24%=1316641
Mousemove>580,510
Getcursorpos>X,Y
Mousemove>12,44
ldown
mousemove>980,550
lup
Mousemove>%X%,%Y%
wait>0.1
Rclick
endif

Getpixelcolor>343,493,Gold25
IF>%Gold25%=1514789
Mousemove>343,493
Getcursorpos>X,Y
Mousemove>12,44
ldown
mousemove>980,550
lup
Mousemove>%X%,%Y%
wait>0.1
Rclick
endif

Getpixelcolor>386,232,Gold26
IF>%Gold26%=1842726
Mousemove>386,232
Getcursorpos>X,Y
Mousemove>12,44
ldown
mousemove>980,550
lup
Mousemove>%X%,%Y%
wait>0.1
Rclick
endif

Getpixelcolor>605,230,Gold27
IF>%Gold27%=1053727
Mousemove>605,230
Getcursorpos>X,Y
Mousemove>12,44
ldown
mousemove>980,550
lup
Mousemove>%X%,%Y%
wait>0.1
Rclick
endif

Getpixelcolor>340,470,Gold28
IF>%Gold28%=1135667
Mousemove>340,470
Getcursorpos>X,Y
Mousemove>12,44
ldown
mousemove>980,550
lup
Mousemove>%X%,%Y%
wait>0.1
Rclick
endif

Again i marked the gold red, i have 72 of these scripts, 20 in the first (main script) 20 in the file2.exe
and 32 in the last file3.exe

But when i run the main file it seems like it doesn't include the code from the other files :/ ?

Marcdk
Junior Coder
Posts: 36
Joined: Sat Sep 22, 2007 10:16 pm

Post by Marcdk » Sun Mar 16, 2008 2:02 pm

Doesn't anyone have a solution for this? :( i rly need a solution for this... else its a waste of work for me..

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sun Mar 16, 2008 4:27 pm

1. I don't see where you followed the suggestion from Marcus:
Use the Macro> or Include> commands, or ExecuteFile> to execute the other .scp file
2. A suggestion: you could make this section into a SubRoutine:
Getcursorpos>X,Y
Mousemove>12,44
ldown
mousemove>980,550
lup
Mousemove>%X%,%Y%
wait>0.1
Rclick
endif
3. And you could also make Gold%Number% and probably loop through %Number% to make the code more compact. You could have an array for the cursor positions and the desired color for each %Number% value
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Mon Mar 17, 2008 12:26 am

Thanks Bob, I was going blind trying to find where the main was calling anything else :lol:
Use the Macro> or Include> commands, or ExecuteFile> to execute the other .scp file
Marcdk: Note that the above only applies to uncompiled macros. To call a compiled macro from another compiled macro use RunProgram> (may be obvious but just thought I would mention it).

Marcdk
Junior Coder
Posts: 36
Joined: Sat Sep 22, 2007 10:16 pm

Post by Marcdk » Wed Mar 19, 2008 9:14 pm

oh lol -.- runprogram, ofc :) Thx for that, thats the reason it didn't work for me, i'll try again :)

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts