Jump to content
Sign in to follow this  
Gotrek

PixelGetColor and If then statement help needed

Recommended Posts

Gotrek

I've been trying to get a simple test to work before I implement it into my macro. I'm trying to get the macro to read the color of a single pixel and put the decimal version in $cargo. There are two colors that the pixels displays at this location but the pixel has many different shades. I wanted to know how to do a does not equal any number in range sort of thing. But with the to between the two numbers it doesn't see it as an indication of a range but a mistake because this macro errors out saying that if statements require thens. Any help would be much appreciated.

$cargo = PixelGetColor(768,821)
If $cargo <> 6990000 to 6600000 then 
    MsgBox(0,"Cargohold Status","Empty")
elseif $cargo <> 12600000 to 12300000 Then
    msgbox(0,"Cargohold Status","Full")
EndIf

Share this post


Link to post
Share on other sites
dbzfanatic
Gotrek

Why not just add the range into the PixelGetColor()? It has an optional parameter for shade difference.

How does one do that though I've never really had any experience dealing with this command.

Share this post


Link to post
Share on other sites
dbzfanatic
Gotrek

Ok, I've improved my mining macro but it seems that now when I call a function like cargocheck it seems to ignore the if then statement within it because I run the macro it pauses for 2 seconds doesn't pop up with a message box like i told it to and then it just does function warp2station... Am I doing something wrong?

;-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-;
;Color Finder                                                                        ;
;-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-;

;If $repeat = 1 then                        ;comment all and then uncomment this if statement to find color range of your pixel
;$warp = pixelgetcolor(875,1010);
;MsgBox(0,"Dock Decimal",$warp)             ;get several of these and record them to obtain a range of color variations
;endif

;-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-;
;Declarations                                                                       ;
;-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-;

$repeat = 1
$cargo = pixelgetcolor(1620,895)
$warp = PixelGetColor(875,1010)
$dock = pixelgetcolor(17,714)
$iceincargo = PixelGetColor(1440,965)
$undock = PixelGetcolor(100,200)        ;not finished

;-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-;
;Main Code                                                                          ;
;-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-;

While $repeat = 1
    Call("cargocheck")
    Call("warp2station")
    Sleep(20000)                                    ;align time
    Call("warpcheck")
    Call("dockbug")
    Sleep(5000)
    Call("icecheck")
    Call("undockwarp2bookmark")
    Sleep(15000)
    Call("warpcheck")
    Call("setup")
    
WEnd

;-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-;
;Functions                                                                          ;
;-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-;

Func cargocheck()
If $cargo <= 12000000 Or $cargo >= 13500000 then    ;color range:13019237 12953445 12756593 1295002 12492637 12426843 12229466 12229465 12163672 12163929 12097879 12097623 12032086
    sleep(2000)
ElseIf $cargo >= 12000000 and $cargo <= 13500000 Then
    MsgBox(0,"Cargo?",$cargo)
EndIf
EndFunc

Func warp2station()
MouseClick("right",800,50,1,1)                  ;Right click for menu
sleep(1000)
mousemove(900,140,1)                            ;Highlight Station
sleep(500)
mousemove(1200,140,1)                           ;Highlight first station on list
sleep(500)
mousemove(1360,145,1)                           ;Highlight warp to within 0m
sleep(500)
mouseclick("left",1360,195,1,1)                 ;click dock
EndFunc

Func warpcheck()
If $warp <= 5550000 Or $warp >= 5350000 Then        ;warp: 5410498 5476290 5476291
    Sleep(2000)
ElseIf $warp <= 535000 And $warp >= 5550000 Then
    Sleep(10000)
EndIf       
EndFunc

Func dockbug()
If $dock > 10595243 or $dock < 10585243 then    ;if docking pixel is not right then sleep and go through menu
    Sleep(3000)
    MsgBox(0,"Dock Pixel Color", $dock)
    ;mouseclick("right",800,50,1,1)             ;right click for menu(incase for dock bug)
    ;sleep(500)
    ;mousemove(900,140,1)                       ;Highlight Station(incase for dock bug)
    ;sleep(500)
    ;mousemove(1200,140,1)                      ;Highlight first station on list(incase for dock bug)
    ;sleep(500)
    ;mousemove(1360,145,1)                      ;Highlight warp to within 0m(incase for dock bug)
    ;sleep(500)
    ;mouseclick("left",1360,175,1,1)                ;click dock(incase for dock bug)
ElseIf $dock = 10595243 Then                    ;If the docking pixel is correct then
EndIf
EndFunc
    
Func icecheck()         
If $iceincargo = 0 Then
    MouseClickDrag("left",1460,960,1160,970,10)     ;Drag from Cargo to Hangar
    sleep(2000)
ElseIf $iceincargo > 0 Then
EndIf
EndFunc

Func undockchecker()    ;not finished
;detect black screen while undocking
EndFunc

Func undockwarp2bookmark()
MouseClick("left",18,1021,1,1)                  ;Click Undock
Sleep(30000)                                    ;Wait to Finish Undock(depends on lag/busy station)
MouseClick("right",800,50,1,1)                  ;Right click for menu
sleep(1000)
mousemove(900,176,1)                            ;highlight first bookmark
sleep(500)
mouseclick("left",1100,176,1,1)                 ;click warp to bookmark at 0m
EndFunc

Func setup()
mouseclick("left",1450,172,1,1)                 ;sort overview by farthest away(overview bug)
sleep(1000)
mouseclick("left",1450,172,1,1)                 ;sort overview by closest(overview bug)
sleep(1000)
mouseclick("left",1500,190,1,1)                 ;select nearest ice rock
sleep(1000)
mouseclick("left",1540,85,1,1)                  ;lock target
sleep(1000)
mouseclick("left",1409,84,1,1)                  ;approach rock(incase for bumping
sleep(1000)
send("{F1}")                                    ;activate #1 mining laser
sleep(500)
send("{F2}")                                    ;activate #2 mining laser
sleep(500)
send("{ALTDOWN}")
sleep(1000)
send("{F1}")                                    ;activate shield booster
sleep(1000)
send("{ALTUP}")
EndFunc

Share this post


Link to post
Share on other sites
Gotrek

Heres the updated code i've improved. The loops for the pixelcheck work but they don't work...

The cargocheck function does loop but when the cargocheck is true it still registers as it being false. Restarting the macro gets past this but defeats the point of a macro.

;-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-;
;Color Finder                                                                        ;
;-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-;

;If $repeat = 1 then                        ;comment all and then uncomment this if statement to find color range of your pixel
;$warp = pixelgetcolor(875,1010);
;MsgBox(0,"Dock Decimal",$warp)             ;get several of these and record them to obtain a range of color variations
;endif

;-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-;
;Declarations                                                                       ;
;-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-;

$repeat = 1
$cargo = pixelgetcolor(1620,895)
$cargonumber = 0
$cargolow = 12000000            ;12756849 12626291 12561012 12561525  12561526
$cargohigh = 13500000
$warp = PixelGetColor(875,1010)
$warpnumber = 0
$warplow = 5350000
$warphigh = 5550000
$dock = pixelgetcolor(17,714)
$docklow = 10585243
$dockhigh = 10595243
$iceincargo = PixelGetColor(1440,965)
$icecolor = 0
$undock = PixelGetcolor(100,200)        ;not finished
$undocklow = 0                          ;not finished
$undockhigh = 0                         ;not finished

;-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-;
;Main Code                                                                          ;
;-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-;

While $repeat = 1
    Do
        Sleep(5000)
        Call("cargocheck")
    Until $cargonumber = 1
    Call("warp2station")
    Sleep(20000)        ;align time
    Do
        Sleep(1000)
        Call("warpcheck")
    Until $warpnumber = 1
    Call("dockbug")
    Sleep(5000)
    Call("icecheck")
    Call("undockwarp2bookmark")
    Sleep(15000)
    Do
        Call("warpcheck")
    Until $warpnumber = 1
    Call("setup")
    
WEnd

;-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-;
;Functions                                                                          ;
;-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-;

Func cargocheck()
If $cargo > $cargolow and $cargo < $cargohigh Then
    $cargonumber = 1
ElseIf $cargo < $cargolow or $cargo > $cargohigh Then
    $cargonumber = 0
Else
    $cargonumber = 0
EndIf
EndFunc

Func warp2station()
MouseClick("right",800,50,1,1)                  ;Right click for menu
sleep(1000)
mousemove(900,140,1)                            ;Highlight Station
sleep(500)
mousemove(1200,140,1)                           ;Highlight first station on list
sleep(500)
mousemove(1360,145,1)                           ;Highlight warp to within 0m
sleep(500)
mouseclick("left",1360,195,1,1)                 ;click dock
EndFunc

Func warpcheck()
If $warp < $warplow Or $warp > $warphigh Then       ;warp: 5410498 5476290 5476291
    $warpnumber = 1
    Send("w")
Else
    $warpnumber = 0
    Send("v")
EndIf       
EndFunc

Func dockbug()
If $dock > $dockhigh or $dock < $docklow then   ;if docking pixel is not right then sleep and go through menu
    Sleep(3000)
    ;MsgBox(0,"Dock Pixel Color", $dock)
    ;mouseclick("right",800,50,1,1)             ;right click for menu(incase for dock bug)
    ;sleep(500)
    ;mousemove(900,140,1)                       ;Highlight Station(incase for dock bug)
    ;sleep(500)
    ;mousemove(1200,140,1)                      ;Highlight first station on list(incase for dock bug)
    ;sleep(500)
    ;mousemove(1360,145,1)                      ;Highlight warp to within 0m(incase for dock bug)
    ;sleep(500)
    ;mouseclick("left",1360,175,1,1)                ;click dock(incase for dock bug)
ElseIf $dock <= $dockhigh And $dock >= $docklow Then                    ;If the docking pixel is correct then
EndIf
EndFunc
    
Func icecheck()         
If $iceincargo = $icecolor Then
    MouseClickDrag("left",1460,960,1160,970,10)     ;Drag from Cargo to Hangar
ElseIf $iceincargo > $icecolor Then
EndIf
EndFunc

Func undockchecker()    ;not finished
;detect black screen while undocking
EndFunc

Func undockwarp2bookmark()
MouseClick("left",18,1021,1,1)                  ;Click Undock
Sleep(30000)                                    ;Wait to Finish Undock-will be replaced with function undockchecker()
MouseClick("right",800,50,1,1)                  ;Right click for menu
sleep(1000)
mousemove(900,176,1)                            ;highlight first bookmark
sleep(500)
mouseclick("left",1100,176,1,1)                 ;click warp to bookmark at 0m
EndFunc

Func setup()
mouseclick("left",1450,172,1,1)                 ;sort overview by farthest away(overview bug)
sleep(1000)
mouseclick("left",1450,172,1,1)                 ;sort overview by closest(overview bug)
sleep(1000)
mouseclick("left",1500,190,1,1)                 ;select nearest ice rock
sleep(1000)
mouseclick("left",1540,85,1,1)                  ;lock target
sleep(1000)
mouseclick("left",1409,84,1,1)                  ;approach rock(incase for bumping
sleep(1000)
send("{F1}")                                    ;activate #1 mining laser
sleep(500)
send("{F2}")                                    ;activate #2 mining laser
sleep(500)
send("{ALTDOWN}")
sleep(1000)
send("{F1}")                                    ;activate shield booster
sleep(1000)
send("{ALTUP}")
EndFunc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×