Jump to content
Sign in to follow this  
-TS-

Script forgetting values

Recommended Posts

-TS-

I am calling a func to check info, then after info is found, the func is ended an goes back main part of script thats needs the info values, but on returning from a func, my script forgets the info values. Am I missing some OPT command to permently have the script remember the value? or am I stuck with values that ar from func, cant be carried to other funcs/parts of script? Having to remotely store a few hundred groups of values will be a grand inconvenience to me.

Func nk()
 loc();this function is called alot an consists of a lengthy subscript

If $loc[0] = x then; a value retreaved from loc(), which gives me an error "varible used without being declared", even tho I have added tooltip on loc() to confirm the value is properly used

Share this post


Link to post
Share on other sites
SuneC

Care to show some more of your code? 'Cause it's hard guessing what you're doing already otherwise.

Share this post


Link to post
Share on other sites
Authenticity

The x is typo or it's just for example?

Anyway, you can't reference variable the is declared withing a function because it gets destroyed upon function exit as the stack frame gets dismantled.

Keep them in global scope or pass them ByRef to the function or any other valid method. maybe you can tr EVal or Assign for this purpose.

Share this post


Link to post
Share on other sites
-TS-

Func nk()
    Do
    Location()
    If $loc = 10049984 Then; this is where it says value is not declared
        $clear = PixelGetColor(613, 171)
        MouseMove(613, 171,1)
        $clear2 = PixelGetColor(613, 171)
        If $clear = $clear2 Then
            MouseClick("left",613, 171,1,1)
            Sleep(5000)
            dump()
        EndIf
    ElseIf $loc = 10059984 Then
        $clear = PixelGetColor(30, 280)
        MouseMove(30, 280,1)
        $clear2 = PixelGetColor(30, 280)
        If $clear = $clear2 Then
            MouseClick("left",30, 280,1,1)
            Sleep(5000)
        Else
            MouseMove(0,0,1)
            Sleep(500)
        EndIf
    ElseIf $loc = 10059983 Then
        $clear = PixelGetColor(402, 468)
        MouseMove(402, 468,1)
        $clear2 = PixelGetColor(402, 468)
        If $clear = $clear2 Then
            MouseClick("left",402, 468,1,1)
            Sleep(5000)
        Else
            MouseMove(0,0,1)
            Sleep(500)
        EndIf
    ElseIf $loc = 10059982 Then
        $clear = PixelGetColor(402, 468)
        MouseMove(402, 468,1)
        $clear2 = PixelGetColor(402, 468)
        If $clear = $clear2 Then
            MouseClick("left",402, 468,1,1)
            Sleep(5000)
        Else
            MouseMove(0,0,1)
            Sleep(500)
        EndIf
    ElseIf $loc = 10059981 Then
        $clear = PixelGetColor(401, 468)
        MouseMove(401, 468,1)
        $clear2 = PixelGetColor(401, 468)
        If $clear = $clear2 Then
            MouseClick("left",401, 468,1,1)
            Sleep(5000)
        Else
            MouseMove(0,0,1)
            Sleep(500)
        EndIf
    ElseIf $loc = 10059980 Then
        $clear = PixelGetColor(347, 468)
        MouseMove(347, 468,1)
        $clear2 = PixelGetColor(347, 468)
        If $clear = $clear2 Then
            MouseClick("left",347, 468,1,1)
            Sleep(5000)
        Else
            MouseMove(0,0,1)
            Sleep(500)
        EndIf
    ElseIf $loc = 10059979 Then
        $clear = PixelGetColor(297, 468)
        MouseMove(297, 468,1)
        $clear2 = PixelGetColor(297, 468)
        If $clear = $clear2 Then
            MouseClick("left",297, 468,1,1)
            Sleep(5000)
        Else
            MouseMove(0,0,1)
            Sleep(500)
        EndIf
    ElseIf $loc = 10059978 Then
        $clear = PixelGetColor(296, 468)
        MouseMove(296, 468,1)
        $clear2 = PixelGetColor(296, 468)
        If $clear = $clear2 Then
            MouseClick("left",296, 468,1,1)
            Sleep(5000)
        Else
            MouseMove(0,0,1)
            Sleep(500)
        EndIf
    ElseIf $loc = 10059977 Then
        $clear = PixelGetColor(456, 469)
        MouseMove(456, 469,1)
        $clear2 = PixelGetColor(456, 469)
        If $clear = $clear2 Then
            MouseClick("left",456, 469,1,1)
            Sleep(5000)
        Else
            MouseMove(0,0,1)
            Sleep(500)
        EndIf
    ElseIf $loc = 10059976 Then
        $clear = PixelGetColor(349, 467)
        MouseMove(349, 467,1)
        $clear2 = PixelGetColor(349, 467)
        If $clear = $clear2 Then
            MouseClick("left",349, 467,1,1)
            Sleep(5000)
        Else
            MouseMove(0,0,1)
            Sleep(500)
        EndIf
    ElseIf $loc = 10059975 Then
        $clear = PixelGetColor(509, 469)
        MouseMove(509, 469,1)
        $clear2 = PixelGetColor(509, 469)
        If $clear = $clear2 Then
            MouseClick("left",509, 469,1,1)
            Sleep(5000)
        Else
            MouseMove(0,0,1)
            Sleep(500)
        EndIf
    EndIf
    until $loop=1
EndFunc



Func Location()
$m1= PixelGetColor(380,520)
$m2= PixelGetColor(400,520)
$m3= PixelGetColor(420,520)
$m4= PixelGetColor(440,520)
$m5= PixelGetColor(460,520)
;
$m6= PixelGetColor(380,540)
$m7= PixelGetColor(400,540)
$m8= PixelGetColor(420,540)
$m9= PixelGetColor(440,540)
$m10= PixelGetColor(460,540)
;
$m11= PixelGetColor(380,560)
$m12= PixelGetColor(400,560)
$m13= PixelGetColor(420,560)
$m14= PixelGetColor(440,560)
$m15= PixelGetColor(460,560)
;
$m16= PixelGetColor(380,580)
$m17= PixelGetColor(400,580)
$m18= PixelGetColor(420,580)
$m19= PixelGetColor(440,580)
$m20= PixelGetColor(460,580)
If $m1= 14401441 And $m2= 14797231 And $m3= 14863543 And $m4= 15061433 And $m5= 14730931 And $m6= 14665912 And $m7= 14205861 And $m8= 14929334 And $m9= 14798011 And $m10= 14730919 And $m11= 14798009 And $m12= 14797759 And $m13= 5779212 And $m14= 14732468 And $m15= 14863542 And $m16= 14531734 And $m17= 14335899 And $m18= 13479818 And $m19= 6960387 And $m20= 14338236 Then
ToolTip("10059975",0,0)
$loc = 10059975
EndIf
If $m1 = 13349517 And $m2 = 14798775 And $m3 = 14863539 And $m4 = 13416093 And $m5 = 13808782 And $m6 = 12757131 And $m7 = 14863543 And $m8 = 14863540 And $m9 = 14204318 And $m10 = 14863543 And $m11 = 6503190 And $m12 = 6372636 And $m13 = 9993566 And $m14 = 14731700 And $m15 = 15060407 And $m16 = 13412995 And $m17 = 9598035 And $m18 = 6379073 And $m19 = 13412995 And $m20 = 15191474 Then 
ToolTip("10059976",0,0)
$loc = 10059976
EndIf
If $m1 = 14995127 And $m2 = 14731955 And $m3 = 14797750 And $m4 = 14863800 And $m5 = 13481369 And $m6 = 14863543 And $m7 = 15060666 And $m8 = 5517845 And $m9 = 14666679 And $m10 = 14863543 And $m11 = 12953985 And $m12 = 13412995 And $m13 = 13281669 And $m14 = 6763520 And $m15 = 14863543 And $m16 = 13281923 And $m17 = 11375728 And $m18 = 13412996 And $m19 = 4603438 And $m20 = 14667197 Then 
ToolTip("10059977",0,0)
$loc = 10059977
EndIf
;theres about 2500 different $loc value options, Im just working on a small piece atm to debug before I expand
EndFunc

Share this post


Link to post
Share on other sites
SuneC

Yup, you simply need to declare $loc in Global scope, where you do it is your own choice, I like to keep my globals at the beginning of my scripts though.

Global $loc

Share this post


Link to post
Share on other sites
Authenticity

It's clear as black on white lol.

Function nk doesn't know what Location function does. All it knows that it might return value or not :)

Either pass $loc by reference i.e. Func Location(ByRef $myloc) and make a variable $loc inside nk and pass $loc to the Location function.

Share this post


Link to post
Share on other sites
-TS-

Yup, you simply need to declare $loc in Global scope, where you do it is your own choice, I like to keep my globals at the beginning of my scripts though.

Global $loc
I was never quite sure what global did, even tho I used to for some appications like pause script

Global, sticks a value to carry/work anywhere thru out the whole script, yes?

Edited by -TS-

Share this post


Link to post
Share on other sites
SuneC

Or...

You could simply return a value from Location(), be it the $loc variable, so instead of setting that variable within the Location function you just Return it and in nk() you will need to have a variable receiving the return from Location().

$loc = Location()

...

Return 10059975;For example

EDIT: To answer your last question, yes, it makes it permanent for use throughout the entire lifespan of the script and for use everywhere in it.

Edited by SuneC

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.