Log in

View Full Version : Checking multiple items with the same colour.



WillyJenkins
01-11-2012, 02:04 PM
Hey guys, I'm working on a chinchompa hunting script, its all going splendidly so far, but now I'm wondering what the best method would be to check each trap after its been placed.

The traps won't always be in the same place, seeing as the script tries to place them in a specific pattern (like the number 5 on a dice), but if there is something like a plant in the way it moves one square to the left and places it there instead. I suppose I could try and use specific spots without any plants with more accurate DTMs but if it isn't necessary I'll try without.

Basically I need my script to enter a trap checking loop, where it checks each trap, probably by hovering the mouse and checking up-text, then either dismantles failed traps, re-lays fallen traps or checks and re-lays successful traps.

The problem I'm having is that I don't know how to check each trap, I though I could use FindColor first as there doesn't seem to be any similar colours to the traps, however I don't know how I would do this to check each trap in sequence? Surely every time I use FindColor it will just find the same single trap. So I guess what I'm asking is what would be the best way to check each trap I've laid (if they aren't in any specific pattern) in sequence from 1 through 5.

Thanks in advance for any info.

Willy Jenkins.

loser69
01-11-2012, 02:14 PM
if the uptext of the traps change when they fall or fail then you could probably use

if IsUpText('') then

and perhaps make a dtm for the boxtraps in the inventory and make the script always click on them.

If FindDTM(trap, X, Y, MIX1, MIY1, MIX2, MIY2) then
begin


mouse( x, y, 3, 3, true);
FreeDTM(trap)
end;

these are just a few examples

WillyJenkins
01-11-2012, 02:22 PM
Sorry loser69 I might not have made it clear what my problem is. I'm fully aware of how I can check the traps themselves, however the problem I'm having is that I need to check 5 traps, that might not always be in the same place.

If I used FindDTM or FindColour, would it not find the same single trap each time? I need to look at each 5 traps in sequence.

loser69
01-11-2012, 02:29 PM
findcolour finds the colour your looking for so it would be finding the traps in a random order , I think.

WillyJenkins
01-11-2012, 02:31 PM
Ahh I see, I thought it searched the screen in a particular way so would just find the same trap first every time. Does FindDTM do the same?

Harry
01-11-2012, 02:33 PM
FindColors will put all the colors found into a TPA, FindDTMs etc will also do the same.

WillyJenkins
01-11-2012, 02:50 PM
Does FindColors check the screen in a uniform way, like does it start at the top left then check right and down? So for example if I did FindColors once then did it again at the same spot, would each trap be in the same element within each of the arrays?

Harry
01-11-2012, 02:51 PM
I think so. Use FindColorsSpiral (I think) will search from a point outwards.

WillyJenkins
01-11-2012, 02:53 PM
Great, thanks for the help guys I'll give that a go.

Edit: Actually one more quick question, is there a method to find the size of a TPA, I'm used to Java so I'd normally use TPA.length, is there something similar?

Kyle Undefined
01-11-2012, 03:05 PM
Length(TPA); :)

WillyJenkins
01-11-2012, 03:06 PM
Delish, cheers :D.