Hmm, didn't see this update, would be awesome if /finditem was made to work again :)
Anyway, I was going to make a seperate post with the folowing, but basically it is just an expansion to my bag walk thought, here goes...
So far I only have an idea, and wanted to get some expert input before actually starting, after all I know practically nothing about MQ scripting, just started last weekend.
The idea is, that since MQ cannot tell you the positions of each bag, then we need to tell it to MQ.
We do this simply by opening all our bags and possible combiners. Then placing all our bags (and combiners) as we would like them to be organized from now on and forever. Then we place our cursor at the center of the top-left slot in that container and get the /mousepos.
We feed that info to our macro by a simple variable, or in an array, haven't figured out completely yet what is best, after all when you can only make 100 v# variables you have to conserve the use of them :)
Anyway, each bag is defined with at least 2 pieces of information, perhaps 3 if UI slot distance differs, I don't know if it does, but in my default UI the exact distance between 2 slots in the bag is 40.
Then when we walk a bag we increment/decrement our x y position by 40 each time we want to look at the contents of the next slot.
The contents of each slot should be saved somewhere (in an array was my idea) so that we don't have to do the actual bagwalk except when we can't find the component/item we're looking for, that should make the bagwalk, walk the bags and updates their contents, so we can send the pointer directly to the right slot in the right bag.
Here is my base macro code, haven't tested it yet, but tell me what you think, and please feel free to come with suggestions and optimizations
Edit 1: I have tested the following code, and it does what it is supposed to, it walks each bag checking it's contents.
Now I need to make a routine that can look in the array for the items rather than in the bags, and then substract the items from the bag as well.
The idea is to speed up the script by not making the pointer travel to each slot to check it's contents between each combine, but only when it knows that there is something in the slot that it needs.
I just don't know if I can access the arrays as I have envisioned. With my current knowledge of MQ scripting I would think I actually have to walk my "contents" array, checking each entry for the item I need, then move the cursor to the slot.
As you can see the arrays are numbered with bag and slot numbers, ie; $a(1,1) would give me the contents of slot 1 in bag 1, so when walking my array I have to walk it in 2 loops, just like it was added.
1 loop for the bags, with a sub-loop for the slots, but will this get slower to search, than actually just moving the cursor to each bag/each slot every time?
How would it be best optimized?
Edit 2: Well, I added the chkItem sub routine, tested it and it works. It is rather slow though, perhaps it could go faster if I enable #turbo, will test after this, but perhaps someone would have an idea on how to optimize it?
Edit 3: It sure went a lot faster with #turbo enabled, so much faster that the macro forgot to drop the item picked up, into the right slot again, thereby shuffling it all 1 slot (and even 1 bag if last slot in previous) ahead. Throwing in a few delays and retesting it.
Edit 4: It just needed a single /delay 1 extra, and it most certainly is faster to search the array than the actual bags. Fixed the example below with the new /delay.
Edit 5:Okay, was thinking a bit about the combiners (containers to combine in). The easiest way for to find the destroy button is to do a minor calculation:
/varcalc btnDestroyX x+20
/varcalc btnDestroyY y+((s/2)*40)+35
Where:
x is the X coordinate of the top-left slot (the slot we know the coordinates of).
y is the Y coordinate of the top-left slot (the slot we knoe the coordinates of).
s is the total number of slots in the current combiner.
Remember, all these numbers are if using the default UI, or at least default bag UI.
Code: Select all
#turbo
#define totBags v1
#define curBag v2
#define curSlot v3
#define mouseX1 v4
#define mouseX2 v5
#define mouseY v6
#define chkCol v7
#define temp v8
sub main
/varset a(21,1) "1205 120"
/varset a(22,1) 10
/varset a(21,2) "1105 120"
/varset a(22,2) 10
/varset a(21,3) "1005 120"
/varset a(22,3) 10
/varset a(21,4) "905 120"
/varset a(22,4) 10
/varset a(21,5) "805 120"
/varset a(22,5) 10
/varset a(21,6) "705 120"
/varset a(22,6) 10
/varset a(21,7) "605 120"
/varset a(22,7) 10
/varset a(21,8) "505 120"
/varset a(22,8) 10
/varset totBags 7
/varset chkCol 0
/varset temp "Pearl"
/call bagWalk
/delay 2s
/echo Searching for $temp
/call chkItem
/return
sub chkItem
/varset curBag 1
:bagLoop
/varset curSlot 1
:slotLoop
/if "$a($curBag,$curSlot)"~~"$temp" {
/echo Found << $a(1$curBag,$curSlot)x $a($curBag,$curSlot) >> in bag $curBag, slot $curSlot
/goto :End
} else /if n $curSlot<$a(22,$curBag) {
/varadd curSlot 1
/goto :slotLoop
}
/if n $curBag<$totBags {
/varadd curBag 1
/goto :bagLoop
}
:End
/return
sub bagWalk
/varset curBag 1
:bagLoop
/mouseto $a(21,$curBag)
/varset curSlot 1
/varset mouseX1 $mouse(X)
/varset mouseX2 $mouse(X)
/varadd mouseX2 40
/varset mouseY $mouse(Y)
:slotLoop
/varcalc chkCol $curSlot%2
/if n $chkCol==1 /mouseto $mouseX1 $mouseY
/if n $chkCol==0 /mouseto $mouseX2 $mouseY
/sendkey down shift
/click left
/sendkey up shift
/delay 1
/if "$cursor()"!="NULL" {
/varset a($curBag,$curSlot) "$cursor(name)"
/varset a(1$curBag,$curSlot) $cursor(stack)
/if n $chkCol==1 /mouseto $mouseX1 $mouseY
/if n $chkCol==0 /mouseto $mouseX2 $mouseY
/click left
/delay 1
} else {
/varset a($curBag,$curSlot) "empty"
/varset a(1$curBag,$curSlot) 0
}
/if n $curSlot<$a(22,$curBag) {
/varadd curSlot 1
/if n $chkCol==0 /varadd mouseY 40
/goto :slotLoop
}
/if n $curBag<$totBags {
/varadd curBag 1
/goto :bagLoop
}
:End
/echo Finished indexing the bags.
/return