Results 1 to 16 of 16

Thread: Global variables not being changed effectively?

  1. #1
    Join Date
    Dec 2007
    Location
    Middle of Here and There
    Posts
    417
    Mentioned
    6 Post(s)
    Quoted
    25 Post(s)

    Default Global variables not being changed effectively?

    Hai.

    I won't post the function for fear of leaking, but basically..

    It's my UBER 1337 TPA finding function. No matter what I do, it won't change the global x and y values to the ones found in the function.

    It does, for sure, find the object, and store it in x and y whilst in the function. But, the moment I exit, x and y are set to 0. I will say again, x and y are GLOBAL. Just so no one suggests it isn't.

    Any help is appreciated greatly.

    ~PoW

  2. #2
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    function FunctionName(var x, y: Integer): Boolean;

    You need the var to tell SCAR that you want to store the data inside the variables that you pass as parameters.
    :-)

  3. #3
    Join Date
    Feb 2006
    Location
    Helsinki, Finland
    Posts
    1,395
    Mentioned
    30 Post(s)
    Quoted
    107 Post(s)

    Default

    Yeah, what Method said...

    Small example:

    SCAR Code:
    function Red(var TPA: TPointArray): Boolean;
    var
      w, h: Integer;
    begin
      GetClientDimensions(w, h);
      Result:= FindColorsTolerance(TPA, 255, 0, 0, w, h, 0);
    end;

    var
      myTPA: TPointArray;
      i: Integer;

    begin
      ClearDebug;
      if(Red(myTPA))then
      begin
        WriteLn('Red[255] pixels:');
        for i:= 0 to High(myTPA) do
          WriteLn(IntToStr(myTPA[i].x) + ', ' + IntToStr(myTPA[i].y));
      end else
        WriteLn('No Red[255] pixels detected :(');
    end.

  4. #4
    Join Date
    Dec 2007
    Location
    Middle of Here and There
    Posts
    417
    Mentioned
    6 Post(s)
    Quoted
    25 Post(s)

    Default

    . . .

    I'm more intelligent than that. I do have it set in the function parameters. Here, I'll show you my function name (it's long because it's 1337)

    SCAR Code:
    function FindTPAPoW(Uptext: TStringArray; x, y, OX1, OY1, OX2, OY2, MidX, Midx, TPAW, TPAH: Integer; Colors: TIntegerArray): Boolean;

    I put bug trackers in, too. It tells me that the x and y values are more than 0 inside the function (mind you, these variables are declared GLOBALLY), but when I ask for the same values after I do an if then statement with my function, it says they're both 0.

    Believe me, I wish I could figure this out on my own, but I have no 'effing clue.

  5. #5
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    You just missed what both of us were saying. You need the VAR (did you see that?) keyword to have the values actually be retained outside of the function.
    :-)

  6. #6
    Join Date
    Dec 2007
    Location
    Middle of Here and There
    Posts
    417
    Mentioned
    6 Post(s)
    Quoted
    25 Post(s)

    Default

    but I do have the var. I just don't want to post my script because it's going to be my members app.

  7. #7
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    Nowhere in function FindTPAPoW(Uptext: TStringArray; x, y, OX1, OY1, OX2, OY2, MidX, Midx, TPAW, TPAH: Integer; Colors: TIntegerArray): Boolean; is the word var, so you obviously don't have it.
    :-)

  8. #8
    Join Date
    Dec 2007
    Location
    Middle of Here and There
    Posts
    417
    Mentioned
    6 Post(s)
    Quoted
    25 Post(s)

    Default

    oh! I understand what you're saying now!~ Sorry if I came off as rude, I just didn't get what you meant.

    Rep + for you, pimpin'

  9. #9
    Join Date
    Feb 2007
    Location
    Het ademt zwaar en moedeloos vannacht.
    Posts
    7,211
    Mentioned
    26 Post(s)
    Quoted
    72 Post(s)

    Default

    Quote Originally Posted by ProphesyOfWolf View Post
    but I do have the var. I just don't want to post my script because it's going to be my members app.
    Let me tell you a little secret:
    You don't have to write a new script for an app, you can use one you already wrote
    If you post it, we can give better feedback, means higher chance of getting into members, got it?
    I made a new script, check it out!.

  10. #10
    Join Date
    Dec 2007
    Posts
    2,766
    Mentioned
    2 Post(s)
    Quoted
    37 Post(s)

    Default

    No i think he's scared of his script being copied...

  11. #11
    Join Date
    Feb 2007
    Location
    Het ademt zwaar en moedeloos vannacht.
    Posts
    7,211
    Mentioned
    26 Post(s)
    Quoted
    72 Post(s)

    Default

    Quote Originally Posted by Dervish View Post
    No i think he's scared of his script being copied...
    Last time someone got in with a copied script was over a year ago, and if we notice someone copying -> banz0r.
    I made a new script, check it out!.

  12. #12
    Join Date
    Oct 2007
    Location
    If (Online) then Loc := ('On comp') else Loc := ('Somewhere else!');
    Posts
    2,020
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Wrong
    SCAR Code:
    function FindTPAPoW(Uptext: TStringArray; x, y, OX1, OY1, OX2, OY2, MidX, Midx, TPAW, TPAH: Integer; Colors: TIntegerArray): Boolean;

    RIGHT!!!
    SCAR Code:
    function FindTPAPoW(Var Uptext: TStringArray; x, y, OX1, OY1, OX2, OY2, MidX, Midx, TPAW, TPAH: Integer; Colors: TIntegerArray): Boolean;

    gl with ya app i will be waiting

  13. #13
    Join Date
    Feb 2007
    Location
    Het ademt zwaar en moedeloos vannacht.
    Posts
    7,211
    Mentioned
    26 Post(s)
    Quoted
    72 Post(s)

    Default

    Quote Originally Posted by Scaper View Post
    Wrong
    ScarScript:By Drunkenoldma
    function FindTPAPoW(Uptext: TStringArray; x, y, OX1, OY1, OX2, OY2, MidX, Midx, TPAW, TPAH: Integer; Colors: TIntegerArray): Boolean;

    RIGHT!!!
    ScarScript:By Drunkenoldma
    function FindTPAPoW(Var Uptext: TStringArray; x, y, OX1, OY1, OX2, OY2, MidX, Midx, TPAW, TPAH: Integer; Colors: TIntegerArray): Boolean;

    gl with ya app i will be waiting
    I'm sorry to say, but:
    Wrong

    Right:
    SCAR Code:
    function FindTPAPoW(Uptext : TStringarray; var x, y : integer; ox1, oy1, ox2, oy2, midx, midy, tpaw, tpah : integer; colors : tintegerarray) : boolean;
    I made a new script, check it out!.

  14. #14
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    I may have an answer. When you split the TPA maybe you dont specify the TPoint e.g

    SCAR Code:
    P := MiddleTpa(ATPA[I]);
    Mouse(P.x, P.y, 7, 7, True);

  15. #15
    Join Date
    Oct 2007
    Location
    If (Online) then Loc := ('On comp') else Loc := ('Somewhere else!');
    Posts
    2,020
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Markus View Post
    I'm sorry to say, but:
    Wrong

    Right:
    SCAR Code:
    function FindTPAPoW(Uptext : TStringarray; var x, y : integer; ox1, oy1, ox2, oy2, midx, midy, tpaw, tpah : integer; colors : tintegerarray) : boolean;
    oooppps im such a douch when i just wake up :s

    markus pwned me :P

  16. #16
    Join Date
    Dec 2007
    Location
    Middle of Here and There
    Posts
    417
    Mentioned
    6 Post(s)
    Quoted
    25 Post(s)

    Default

    MARKUS! I love you more <3

    Can you explain to me why you have to put var in front of X and Y to get it to work? Does that make the values set in the function correctly set to the globals or something?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Trading other players effectively
    By Jackrawl in forum OSR Help
    Replies: 5
    Last Post: 09-24-2007, 02:24 AM
  2. What are the global variables for coords?
    By R0b0t1 in forum OSR Help
    Replies: 8
    Last Post: 08-16-2007, 03:34 AM
  3. How to use forms in SCAR effectively
    By mr. pali in forum OSR Advanced Scripting Tutorials
    Replies: 21
    Last Post: 01-13-2007, 05:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •