Help - Search - Members - Calendar
Full Version: Need number to increment once per condition
AC Tools Everything Macro > AC Tool Macros > Macro Development
AEH
I am trying to make a macro that takes pills from the inventory and drags them to the hot bar slots.
It works with the very first one since it's hard coded constant but I look at the timestamp and the number keeps looping.

CODE
Set Constant
    $MPInv = 388
End


Procedure NewMPPills When $N = 0
    MousePos 867, $MPInv
    LeftMouseDown
    MousePos 785, 743
    LeftMouseUp
    
    Compute MPPos = $MPInv + 26
    SetConst MPInv = $MPPos
    Timestamp MPInv have $MPInv
End


I would like it to stop at "414" (which is the pixel on the X axis) until the macro drags the pills to the hot bar then go to "440" and so on.

TimeStamp: 06/16/2009 12:05:45:546 pm - MPInv have 414
TimeStamp: 06/16/2009 12:05:45:546 pm - MPInv have 440
TimeStamp: 06/16/2009 12:05:45:546 pm - MPInv have 466
TimeStamp: 06/16/2009 12:05:45:562 pm - MPInv have 492
TimeStamp: 06/16/2009 12:05:45:562 pm - MPInv have 518
TimeStamp: 06/16/2009 12:05:45:562 pm - MPInv have 544
TimeStamp: 06/16/2009 12:05:45:578 pm - MPInv have 570
TimeStamp: 06/16/2009 12:05:45:578 pm - MPInv have 596
TimeStamp: 06/16/2009 12:05:45:578 pm - MPInv have 622
TimeStamp: 06/16/2009 12:05:45:593 pm - MPInv have 648
TimeStamp: 06/16/2009 12:05:45:593 pm - MPInv have 674
TimeStamp: 06/16/2009 12:05:45:593 pm - MPInv have 700
TimeStamp: 06/16/2009 12:05:45:593 pm - MPInv have 726
TimeStamp: 06/16/2009 12:05:45:609 pm - MPInv have 752
TimeStamp: 06/16/2009 12:05:45:609 pm - MPInv have 778
TimeStamp: 06/16/2009 12:05:45:609 pm - MPInv have 804
TimeStamp: 06/16/2009 12:05:45:625 pm - MPInv have 830
TimeStamp: 06/16/2009 12:05:45:625 pm - MPInv have 856
TimeStamp: 06/16/2009 12:05:45:625 pm - MPInv have 882
DaMOB
QUOTE(AEH @ Jun 16 2009, 11:16 AM) *
I am trying to make a macro that takes pills from the inventory and drags them to the hot bar slots.
It works with the very first one since it's hard coded constant but I look at the timestamp and the number keeps looping.

CODE
Set Constant
    $MPInv = 388
End


Procedure NewMPPills When $N = 0
    MousePos 867, $MPInv
    LeftMouseDown
    MousePos 785, 743
    LeftMouseUp
    
    Compute MPPos = $MPInv + 26
    SetConst MPInv = $MPPos
    Timestamp MPInv have $MPInv
End


I would like it to stop at "414" (which is the pixel on the X axis) until the macro drags the pills to the hot bar then go to "440" and so on.

TimeStamp: 06/16/2009 12:05:45:546 pm - MPInv have 414
TimeStamp: 06/16/2009 12:05:45:546 pm - MPInv have 440
TimeStamp: 06/16/2009 12:05:45:546 pm - MPInv have 466
TimeStamp: 06/16/2009 12:05:45:562 pm - MPInv have 492
TimeStamp: 06/16/2009 12:05:45:562 pm - MPInv have 518
TimeStamp: 06/16/2009 12:05:45:562 pm - MPInv have 544
TimeStamp: 06/16/2009 12:05:45:578 pm - MPInv have 570
TimeStamp: 06/16/2009 12:05:45:578 pm - MPInv have 596
TimeStamp: 06/16/2009 12:05:45:578 pm - MPInv have 622
TimeStamp: 06/16/2009 12:05:45:593 pm - MPInv have 648
TimeStamp: 06/16/2009 12:05:45:593 pm - MPInv have 674
TimeStamp: 06/16/2009 12:05:45:593 pm - MPInv have 700
TimeStamp: 06/16/2009 12:05:45:593 pm - MPInv have 726
TimeStamp: 06/16/2009 12:05:45:609 pm - MPInv have 752
TimeStamp: 06/16/2009 12:05:45:609 pm - MPInv have 778
TimeStamp: 06/16/2009 12:05:45:609 pm - MPInv have 804
TimeStamp: 06/16/2009 12:05:45:625 pm - MPInv have 830
TimeStamp: 06/16/2009 12:05:45:625 pm - MPInv have 856
TimeStamp: 06/16/2009 12:05:45:625 pm - MPInv have 882

Need to see the other routines that call that one because that one is simply a move and it looks fine to me.
AEH
CODE
ActiveWindowCheck on
SetActiveWindow Game

//Slot 1 = 00B5EA04
//Slot 2 = 00B5EA10
//Slot 3 = 00B5EA1C
//Slot 4 = 00B5EA28

Constants
    I = 1
    J = 1
    K = 1
    L = 1
    M = 1
    N = 1
    O = 1
    
    MinHealth = 6800
    MinMana = 500
    MinPetFood = 5
    
    //HotKeys
    HPKey1 = Q
    HPKEy2 = W
    MPKey1 = E
    PetFoodKey = 4
        
    HPInv = 1
    MPInv = 388
    MPPos = 0
    
End


Procedure NewMPPills When $N = 0
    MousePos 867, $MPInv
    LeftMouseDown
    MousePos 785, 743
    LeftMouseUp
    
    Compute MPPos = $MPInv + 26
    SetConst MPInv = $MPPos
    Timestamp MPInv have $MPInv
End


Procedure NewMPPills1 When $N = 0
    
End    

Procedure HpHeal When $I < $MinHealth
  Keydown $HPKey1 100|100
End

Procedure HpHeal1 When $J < $MinHealth
  Keydown $HPKey2 100|100
End

Procedure ManaHeal When $K < $MinMana
      Keydown $MPKey1 100|100
End

While 1 = 1

// Testing Health
ReadMemoryEx I = 00B844F7, SmallInt
//Timestamp I have $I health

// Testing Health
ReadMemoryEx J = 00B844F7, SmallInt
//Timestamp J have $J health

// Testing Chi
ReadMemoryEx K = 00B844FF, SmallInt
//Timestamp K have $K health

//Slot 1
ReadMemoryEx L = 00B5EA1C, SmallInt

//Slot 2
ReadMemoryEx M = 00B5EA10, SmallInt

//Slot 3
ReadMemoryEx N = 00B5EA1C, SmallInt

//Slot 4
ReadMemoryEx O = 00B5EA28, SmallInt

ProcessMessages

End
DaMOB
Alright, what exactly is it you are trying to do? I see in your timestamps the values you need but when you say stop that means stop end of the macro. There is no restarting after a stop.

So, explain a little more by what you mean "stop" at 414 and I can help you I think.

Did you notice your L and your N are reading from the same memory location? That is a typo I think judging by your comments in that code.
AEH
QUOTE(DaMOB @ Jun 16 2009, 01:43 PM) *
Alright, what exactly is it you are trying to do? I see in your timestamps the values you need but when you say stop that means stop end of the macro. There is no restarting after a stop.

So, explain a little more by what you mean "stop" at 414 and I can help you I think.

Did you notice your L and your N are reading from the same memory location? That is a typo I think judging by your comments in that code.


The value '$MPInv' is currently 388. After the "NewMPPills" runs (the first procedure) I want '$MPInv' to increment by "26".
When it's met again I want '$MPInv' to increase by another "26" and so on.
DaMOB
CODE
Procedure NewMPPills When $N = 0
    MousePos 867, $MPInv
    LeftMouseDown
    MousePos 785, 743
    LeftMouseUp
    
    Compute MPInv = $MPInv + 26
    SetConst MPPos = $MPInv
    Timestamp MPInv have $MPInv
End
Your routine already is doing that as you can tell via the timestamp.
AEH
QUOTE(DaMOB @ Jun 16 2009, 04:18 PM) *
CODE
Procedure NewMPPills When $N = 0
    MousePos 867, $MPInv
    LeftMouseDown
    MousePos 785, 743
    LeftMouseUp
    
    Compute MPInv = $MPInv + 26
    SetConst MPPos = $MPInv
    Timestamp MPInv have $MPInv
End
Your routine already is doing that as you can tell via the timestamp.


It does work but not well.
When the procedure is first called it works great but when it comes to the procedure again the mouse goes to the second mouse position without going to the first. After a few seconds it finally goes to the mouse position at "867, $MPInv" and put pills into the hot bar.
DaMOB
QUOTE(AEH @ Jun 16 2009, 03:24 PM) *
It does work but not well.
When the procedure is first called it works great but when it comes to the procedure again the mouse goes to the second mouse position without going to the first. After a few seconds it finally goes to the mouse position at "867, $MPInv" and put pills into the hot bar.
Runs fine over here but you see what it does for you.
CODE
//Slot 1 = 00B5EA04
//Slot 2 = 00B5EA10
//Slot 3 = 00B5EA1C
//Slot 4 = 00B5EA28

Constants
    I = 1
    J = 1
    K = 1
    L = 1
    M = 1
    N = 1
    O = 1
    
    MinHealth = 6800
    MinMana = 500
    MinPetFood = 5
    
    //HotKeys
    HPKey1 = Q
    HPKEy2 = W
    MPKey1 = E
    PetFoodKey = 4
        
    HPInv = 1
    MPInv = 388
    MPPos = 0
    
End


Procedure NewMPPills When $N = 0
    MousePos 867, $MPInv
    DragTo 785, 743
    Compute MPInv = $MPInv + 26
    SetConst MPPos = $MPInv
    Timestamp MPInv have $MPInv
End


Procedure NewMPPills1 When $N = 0
    
End    

Procedure HpHeal When $I < $MinHealth
// Keydown $HPKey1 100|100
End

Procedure HpHeal1 When $J < $MinHealth
// Keydown $HPKey2 100|100
End

Procedure ManaHeal When $K < $MinMana
//     Keydown $MPKey1 100|100
End

While 1 = 1

// Testing Health
ReadMemoryEx I = 00B844F7, SmallInt
//Timestamp I have $I health

// Testing Health
ReadMemoryEx J = 00B844F7, SmallInt
//Timestamp J have $J health

// Testing Chi
ReadMemoryEx K = 00B844FF, SmallInt
//Timestamp K have $K health

//Slot 1
ReadMemoryEx L = 00B5EA1C, SmallInt

//Slot 2
ReadMemoryEx M = 00B5EA10, SmallInt

//Slot 3
ReadMemoryEx N = 00B5EA1C, SmallInt

//Slot 4
ReadMemoryEx O = 00B5EA28, SmallInt

ProcessMessages

End
I commented out the other keydowns to see where your issue might be.
Ahk
You will need to keep a list of all of the positions you want to loop through if you're looking to do each inv slot until you reach the end.

So...
First run
1

Second run
1, 2

Third run
1, 2, 3

If you see what I mean...you'll need a loop and a counter or ListCount command to keep track of how many slots you're up to. I think that's what you're after :?
DaMOB
QUOTE(Ahk @ Jun 16 2009, 05:47 PM) *
You will need to keep a list of all of the positions you want to loop through if you're looking to do each inv slot until you reach the end.

So...
First run
1

Second run
1, 2

Third run
1, 2, 3

If you see what I mean...you'll need a loop and a counter or ListCount command to keep track of how many slots you're up to. I think that's what you're after :?

Hard to tell what he is after but if that is it you are spot on.
AEH
QUOTE(Ahk @ Jun 16 2009, 06:47 PM) *
You will need to keep a list of all of the positions you want to loop through if you're looking to do each inv slot until you reach the end.

So...
First run
1

Second run
1, 2

Third run
1, 2, 3

If you see what I mean...you'll need a loop and a counter or ListCount command to keep track of how many slots you're up to. I think that's what you're after :?


I looked in the help files on how to make an array but couldn't find anything.
Is it possible to make an array of the locations I want it to grab the pills from and have the macro remove the value from the array so it does not look at the same location twice?



DaMOB
QUOTE(AEH @ Jun 16 2009, 06:22 PM) *
QUOTE(Ahk @ Jun 16 2009, 06:47 PM) *
You will need to keep a list of all of the positions you want to loop through if you're looking to do each inv slot until you reach the end.

So...
First run
1

Second run
1, 2

Third run
1, 2, 3

If you see what I mean...you'll need a loop and a counter or ListCount command to keep track of how many slots you're up to. I think that's what you're after :?


I looked in the help files on how to make an array but couldn't find anything.
Is it possible to make an array of the locations I want it to grab the pills from and have the macro remove the value from the array so it does not look at the same location twice?

Can use a list for that or a dataset (I prefer a dataset).
AEH
QUOTE(DaMOB @ Jun 16 2009, 07:26 PM) *
QUOTE(AEH @ Jun 16 2009, 06:22 PM) *
QUOTE(Ahk @ Jun 16 2009, 06:47 PM) *
You will need to keep a list of all of the positions you want to loop through if you're looking to do each inv slot until you reach the end.

So...
First run
1

Second run
1, 2

Third run
1, 2, 3

If you see what I mean...you'll need a loop and a counter or ListCount command to keep track of how many slots you're up to. I think that's what you're after :?


I looked in the help files on how to make an array but couldn't find anything.
Is it possible to make an array of the locations I want it to grab the pills from and have the macro remove the value from the array so it does not look at the same location twice?

Can use a list for that or a dataset (I prefer a dataset).



I got it to work


CODE
Procedure NewMPPills When $N = 0

    Compute $MPInv = $MPInv + 26
  Timestamp MPInv have $MPInv

    MousePos 867, $MPInv
    LeftMouseDown
    MousePos 785, 743
    LeftMouseUp
    
    delay 1 sec //<-- New
    
End


Thanks for the help. I appreciate your effort.
DaMOB
QUOTE(AEH @ Jun 16 2009, 06:54 PM) *
QUOTE(DaMOB @ Jun 16 2009, 07:26 PM) *
QUOTE(AEH @ Jun 16 2009, 06:22 PM) *
QUOTE(Ahk @ Jun 16 2009, 06:47 PM) *
You will need to keep a list of all of the positions you want to loop through if you're looking to do each inv slot until you reach the end.

So...
First run
1

Second run
1, 2

Third run
1, 2, 3

If you see what I mean...you'll need a loop and a counter or ListCount command to keep track of how many slots you're up to. I think that's what you're after :?


I looked in the help files on how to make an array but couldn't find anything.
Is it possible to make an array of the locations I want it to grab the pills from and have the macro remove the value from the array so it does not look at the same location twice?

Can use a list for that or a dataset (I prefer a dataset).



I got it to work


CODE
Procedure NewMPPills When $N = 0

    Compute $MPInv = $MPInv + 26
  Timestamp MPInv have $MPInv

    MousePos 867, $MPInv
    LeftMouseDown
    MousePos 785, 743
    LeftMouseUp
    
    delay 1 sec //<-- New
    
End


Thanks for the help. I appreciate your effort.

Ahh, too fast can be a problem at times.

btw, I would use dragto if you can.

Peace.
AEH
QUOTE(DaMOB @ Jun 17 2009, 01:55 AM) *
QUOTE(AEH @ Jun 16 2009, 06:54 PM) *
QUOTE(DaMOB @ Jun 16 2009, 07:26 PM) *
QUOTE(AEH @ Jun 16 2009, 06:22 PM) *
QUOTE(Ahk @ Jun 16 2009, 06:47 PM) *
You will need to keep a list of all of the positions you want to loop through if you're looking to do each inv slot until you reach the end.

So...
First run
1

Second run
1, 2

Third run
1, 2, 3

If you see what I mean...you'll need a loop and a counter or ListCount command to keep track of how many slots you're up to. I think that's what you're after :?


I looked in the help files on how to make an array but couldn't find anything.
Is it possible to make an array of the locations I want it to grab the pills from and have the macro remove the value from the array so it does not look at the same location twice?

Can use a list for that or a dataset (I prefer a dataset).



I got it to work


CODE
Procedure NewMPPills When $N = 0

    Compute $MPInv = $MPInv + 26
  Timestamp MPInv have $MPInv

    MousePos 867, $MPInv
    LeftMouseDown
    MousePos 785, 743
    LeftMouseUp
    
    delay 1 sec //<-- New
    
End


Thanks for the help. I appreciate your effort.

Ahh, too fast can be a problem at times.

btw, I would use dragto if you can.

Peace.


Thanks.
I'll try it out tomorrow.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.