Posts: 3
Threads: 1
Joined: Apr 2009
Can I not stack loops like this? The end command just ends the entire macro.
rep 99999999999999
3
key+ w
rep 2
key 4
key+ S
1
lef
7
key- S
key 1
key+ S
1
rep 4
lef
3
key- S
key 2
key+ S
1
lef
5
key- S
key 4
key+ S
1
lef
7
key- S
key 1
key+ S
1
rep 6
lef
3
key- S
key 4
key+ S
1
lef
8
key- S
1
key- w
1
key s
1
key r
1
key 5
1
lef
145
key w
3
key r
Posts: 67
Threads: 24
Joined: Feb 2009
rep
,3
,key+ w
,rep 2
,key 4
,key+ S
You need the spaces in there or it will not repeat. Now it will constantly repeat, instead of 999999999999999 just have it look like shwon above, that will be unlimited
Posts: 58
Threads: 19
Joined: Mar 2005
Your code is difficult to read formatted as is.
In Quick Macros, highlight your portion of code, click Edit->Other Formats->Copy for QM Forum
Loops can be nested in QM using proper indentation.
Use the keyword "break" to exit the current loop(if this loop is nested the outer loop will continue to run)
Alternatively you can use the keyword goto to immediately go to a specified label and continue the program from that label
Also, if you want your loop to repeat infinitely, you can leave the # blank (instead of 99999999)
Macro
int outercount = 0
int innercount = 0
str output
rep 4 ;;outerloop
,outercount + 1
,output + outercount
,output + ":"
,rep 4 ;;innerloop
,,innercount + 1
,,output + " "
,,output + innercount
,,if innercount = 6
,,,break
,,if innercount = 11
,,,out output
,,,goto finish
,out output
,output = ""
;finish
out "finished"
Posts: 3
Threads: 1
Joined: Apr 2009
Thanks for all the replies. I'll post my macro after I'm done adding your suggestions.
Posts: 3
Threads: 1
Joined: Apr 2009
rep
,rep 2
,,rep 25 ;; Main loop
,,,key+ w
,,,key+ c
,,,key r
,,,2
,,,key 1
,,,rep 15
,,,,lef
,,,,2
,,,1
,,,key- w
,,,key+ s
,,,0.1
,,,key- s
,,,key- c
,,,1
,,,key r
,,,2
,,,key 5
,,,2
,,,lef
,,,100
,,,key w
,,,3
,,key 7 ;; Key pressed to change to 2nd weapon
,,1
,key 8 ;; Key pressed to change to 3rd weapon
,1
Simply this macro does the main loop 25 times then presses 7 to change to a new weapon and does the main loop 25 times and presses 8 to change to a new weapon to do the loop 25 times.
I would like to setup an array.
Where if I had 2 weapons it would run the main loop twice or if I had 4 weapons then it would run the main loop 4 times instead of having to stack these unsophisticated loops. I would like the array to allow me to change the amount of times the main loop reps per weapon.
For instance:
key 7; 25
key 8; 20
key 9; 15
key 0; 30
I'm not sure if this is something easily done in QM. Thanks for your help.
Posts: 12,074
Threads: 141
Joined: Dec 2002
Macro
out; key CE ;;remove (this is for testing in QM)
type WEAPON nextWeaponKey nRep
ARRAY(WEAPON) a
a.create(2) ;;2 weapons
a[0].nextWeaponKey='7'
a[0].nRep=25
a[1].nextWeaponKey='8'
a[1].nRep=20
int i
rep
,for i 0 a.len ;;for each weapon
,,out "weapon %i" i
,,
,,rep a[i].nRep ;;Main loop
,,,out "."
,,,0.1
,,,;...
,,,
,,key (a[i].nextWeaponKey) ;; Key pressed to change to next weapon
,,1
#if 0 ;;remove (this is for testing in QM)
|