Results 1 to 10 of 10

Thread: Function():TPoint ?

  1. #1
    Join Date
    Feb 2007
    Location
    Toronto, Ontario, Canada
    Posts
    586
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Function():TPoint ?

    Can it be done?
    That is, can a function result in a TPoint, or is this not doable?
    Thanks,
    A83

  2. #2
    Join Date
    Aug 2007
    Posts
    429
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Yes.


    EX.
    SCAR Code:
    Function FindAColor(Color: Integer): TPoint;
    var
      dx, dy : Integer;
    begin
      if FindColor(dx, dy, Color, MSX1, MSY1, MSX2, MSY2) then
      begin
        Result.x := dx;
        Result.y := dy;
      end;
    end;

  3. #3
    Join Date
    Oct 2006
    Location
    finland, helsinki
    Posts
    2,501
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    SCAR Code:
    Function IntToTP(X, Y: Integer): TPoint;
    Begin
      Result.X := X;
      Result.Y := Y;
    End;

    Simple one

    Code:
    • Narcle: I recall Jukka releasing a bunch of scripts like this before... Its how he rolls I think. rofl
    • Solarwind: Dude, you are like... t3h s3x.
    • Hy71194: JuKKa you're a machine! You released 3 scripts in 10 minutes! :O
    • benjaa: woah.... Jukka is the man Guildminer pwns all
    • NaumanAkhlaQ: And JuKKa Is my Her0!

  4. #4
    Join Date
    Feb 2007
    Location
    Toronto, Ontario, Canada
    Posts
    586
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks for the quick answers.
    (Both of ya )

  5. #5
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    Point(X, Y: LongInt): TPoint;
    IntToPoint(X, Y: LongInt): TPoint;

    Those are built in to SCAR, the source probably looks something like this:

    SCAR Code:
    function Point(X, Y: LongInt): TPoint;
    begin
      Result.X := X;
      Result.Y := Y;
    end;

    SCAR Code:
    function IntToPoint(X, Y: LongInt): TPoint;
    begin
      Result := Point(X, Y);
    end;

  6. #6
    Join Date
    Feb 2007
    Location
    Toronto, Ontario, Canada
    Posts
    586
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Oh dear... why does
    THIS
    SCAR Code:
    function TreeLoc(var Color1, Color2, Color3 : integer): TPoint;
    var i : integer;
    begin
      for i := 1 to 5 do
      begin
        if FindColorSpiral(x,y,Color1,MSX1,MSY1,MSX2,MSY2) or
          Findcolorspiral(x,y,Color2,MSX1,MSY1,MSX2,MSY2) or
          Findcolorspiral(x,y,Color3,MSX1,MSY1,MSX2,MSY2) then
            begin
              MMouse(x,y,5,5);
              if IsUpText('Willow') then
                begin
                  Writeln('Found tree.');
                  Result.x := x;
                  Result.y := y;
                  Break;
                end else
                begin
                  Result.x := 0;
                  Result.y := 0;
                  Writeln('Did not find tree.');
                end;
            end else
            begin
              i := i + 1;
            end;
      end;
    end;

    function CheckTreeLoc : boolean;
    var
      TP : TPoint;
    begin
      TP := TreeLoc(TreeColor1, TreeColor2, TreeColor3);
      if (TP.x = 0) and (TP.y = 0) then Result := False;
      else
      Result := True;
    end;


    Return Variable Expected?

  7. #7
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    "if (TP.x = 0) and (TP.y = 0) then Result := False;"

    Delete ;.

  8. #8
    Join Date
    Aug 2007
    Posts
    429
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    I got Identifier expected on this procedure
    SCAR Code:
    function CheckTreeLoc : boolean;
    var
      TP: TPoint;
      TreeColor1, TreeColor2, TreeColor3 : integer;
    begin
      TP := TreeLoc(TreeColor1, TreeColor2, TreeColor3);
      if (TP.x = 0) and (TP.y = 0) then Result := False; //<- delete that
      else
      Result := True;
    end;

    but just cuz u had an extra semicolon =]

  9. #9
    Join Date
    Feb 2007
    Location
    Toronto, Ontario, Canada
    Posts
    586
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    =) Thanks a lot, it was really bugging me!

  10. #10
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Glad Derek and I could help

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. TPoint
    By Shuttleu in forum OSR Help
    Replies: 6
    Last Post: 08-07-2008, 05:38 PM
  2. Seperate Tpoint
    By 13om13e12 in forum OSR Help
    Replies: 2
    Last Post: 06-07-2008, 04:29 PM
  3. Tpoint help.
    By Wade007 in forum OSR Help
    Replies: 3
    Last Post: 02-22-2008, 06:20 PM
  4. help with Tpoint error
    By stampede10343 in forum OSR Help
    Replies: 3
    Last Post: 02-09-2008, 09:34 PM
  5. function MyFunction: Tpoint; possible????
    By sherlockmeister in forum OSR Help
    Replies: 3
    Last Post: 08-04-2007, 07:28 PM

Posting Permissions

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