Results 1 to 17 of 17

Thread: Which Procedure is better?

  1. #1
    Join Date
    Aug 2009
    Posts
    242
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Which Procedure is better?

    Well for my power miner i have made two procedures to check and find x,y of a ore which is better?
    They should look for a ore, move the mouse over it then call a procedure named ClickOre

    How would i turn them in to Function because i want to call for them and see if i can find them but i see no need for the (parameters) do you have to have them? I just need to see if i can my mouse over one Would be great if you could make the Function for me and show me what has been changed thanks

    So here are the two procedure's

    SCAR Code:
    Procedure MineRockColour;
    Begin
      If (not LoggedIn) then
      Exit;
          SetRock;
            If FindColorSpiralTolerance(x, y, Rock, MSX1, MSY1, MSX2, MSY2, 39) Then
              Begin
                MMouse(x,y,5,5);
                AntiBan;
                If IsUpTextMultiCustom(['Rock', 'ock', 'ck']) Then
                Begin
                ClickOre;
                Exit;
                End;
            //      If not(FindColorSpiralTolerance(x, y, Rock, MSX1, MSY1, MSX2, MSY2, 39)) Then

    End;
    Sorry still making failsafes

    SCAR Code:
    Procedure MineRockTPA;
    Var
      MyTPA : TPointArray;
      MyPoint : TPoint;
      i, F : Integer;
    Begin
      SetRock;
      FindColorsSpiralTolerance(MSCx, MSCy, MyTPA, Rock, MSx1, MSy1, MSx2, MSy2, 17);
      If Length(MyTPA) = 0 then FindColorsTolerance(MyTPA, Rock2, MSX1, MSY1, MSX2, MSY2, 17);
      For i := 0 to High(MyTPA)do
      Begin
        MyPoint := MyTPA[i]
        MMouse (MyPoint.x, MyPoint.y, 3, 3);
        if (IsUpTextMultiCustom(['ine', 'ore'])) then
        Begin
        ClickOre;
        Exit;
        End Else
        Inc(F);
        If (F => 7) then
        Exit;
      End;
    End;
    May have missed a end not sure if it compiles as its with my half made not working scirpt

    Thanks for any help i may get

    ~Rya
    I see Now, says the blind man

  2. #2
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    ROFL! Not even a question, second one by far! TPAs ftw

  3. #3
    Join Date
    Aug 2009
    Posts
    242
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by YoHoJo View Post
    ROFL! Not even a question, second one by far! TPAs ftw
    Well their was a question it was then with the better one how would i make it in to a Function plz
    I see Now, says the blind man

  4. #4
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    You can make it return a boolean simply like this, but you would also have to make you "ClickOre" function return a Boolean also.
    SCAR Code:
    Procedure MineRockTPA: Boolean;
    Var
      MyTPA : TPointArray;
      MyPoint : TPoint;
      i, F : Integer;
    Begin
      SetRock;
      FindColorsSpiralTolerance(MSCx, MSCy, MyTPA, Rock, MSx1, MSy1, MSx2, MSy2, 17);
      If Length(MyTPA) = 0 then FindColorsTolerance(MyTPA, Rock2, MSX1, MSY1, MSX2, MSY2, 17);
      For i := 0 to High(MyTPA)do
      Begin
        MyPoint := MyTPA[i]
        MMouse (MyPoint.x, MyPoint.y, 3, 3);
        if (IsUpTextMultiCustom(['ine', 'ore'])) then
        Begin
          Result := ClickOre;
          Exit;
        End Else
          Inc(F);
        If (F => 7) then
          Exit;
      End;
    End;
    You also may want to add some more code in you FindColorsTolerance, so it will find and click the ore, not just find it.

  5. #5
    Join Date
    Apr 2007
    Location
    UK
    Posts
    2,295
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by rya View Post
    Well their was a question it was then with the better one how would i make it in to a Function plz
    Something like this?

    SCAR Code:
    Function MineRockTPA(Var Color: TIntegerArray): Boolean;
     Var
      MyTPA: TPointArray;
      MyPoint: TPoint;
      i, F: Integer;
    Begin
      SetRock;
      If (GetArrayLength(Color) < 2) Then Exit;
      FindColorsSpiralTolerance(MSCx, MSCy, MyTPA, Color[0], MSx1,
        MSy1, MSx2, MSy2, 17);
      If Length(MyTPA) = 0 Then FindColorsTolerance(MyTPA, Color[1],
         MSX1, MSY1, MSX2, MSY2, 17);
      For i := 0 To High(MyTPA) Do
      Begin
        MyPoint := MyTPA[i]    MMouse(MyPoint.x, MyPoint.y, 3, 3);
        If (IsUpTextMultiCustom(['ine', 'ore'])) Then
        Begin
          Result := True;
          Exit;
        End Else Inc(F);
        If (F = > 7) Then Result := False;
      End;
    End;

    SCAR Code:
    If(MineRockTPA([212121,252521]))Then ClickOre;

    Rogeruk's Al-Kharid Tanner V1.1 [Released]
    Rogeruk's Barbarian Crafter [Coming Soon]
    Rogeruk's Guild Fisher [Coming Soon]
    !! - Taking Requests - !!

  6. #6
    Join Date
    Aug 2009
    Posts
    242
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Edit:
    rogeruk Made just what i was looking for thanks

    Also for the bit rogeruk made could i do
    SCAR Code:
    If(MineRockTPA(RockColour))Then ClickOre;
    with RockColour already being declared

    off or maybe on topic because its asking for help
    how would i check for my woodcutting level
    Last edited by rya; 11-02-2009 at 10:08 PM.
    I see Now, says the blind man

  7. #7
    Join Date
    Apr 2007
    Location
    UK
    Posts
    2,295
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Procedures cant return booleans.

    If(SomeThing)

    Basically means if SomeTing is TRUE.

    Me := False;
    If(Me)Then A:=1;
    Me := True;
    If(Me)Then A:=2;

    A = 2

    Rogeruk's Al-Kharid Tanner V1.1 [Released]
    Rogeruk's Barbarian Crafter [Coming Soon]
    Rogeruk's Guild Fisher [Coming Soon]
    !! - Taking Requests - !!

  8. #8
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    SCAR Code:
    Function MineRockTPA(Var Color: TIntegerArray): Boolean;
     Var
      MyTPA: TPointArray;
      MyPoint: TPoint;
      i, F: Integer;
    Begin
      SetRock;
      If (GetArrayLength(Color) < 2) Then Exit;
      FindColorsSpiralTolerance(MSCx, MSCy, MyTPA, Color[0], MSx1,
        MSy1, MSx2, MSy2, 17);
      If Length(MyTPA) = 0 Then FindColorsTolerance(MyTPA, Color[1],
         MSX1, MSY1, MSX2, MSY2, 17);
      For i := 0 To High(MyTPA) Do
      Begin
        MyPoint := MyTPA[i]    MMouse(MyPoint.x, MyPoint.y, 3, 3);
        Result := (IsUpTextMultiCustom(['ine', 'ore']))
        End Else Inc(F);
        If (F = > 7) Then Result := False;
      End;
    End;
    Is better

  9. #9
    Join Date
    Aug 2009
    Posts
    242
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by YoHoJo View Post
    SCAR Code:
    Function MineRockTPA(Var Color: TIntegerArray): Boolean;
     Var
      MyTPA: TPointArray;
      MyPoint: TPoint;
      i, F: Integer;
    Begin
      SetRock;
      If (GetArrayLength(Color) < 2) Then Exit;
      FindColorsSpiralTolerance(MSCx, MSCy, MyTPA, Color[0], MSx1,
        MSy1, MSx2, MSy2, 17);
      If Length(MyTPA) = 0 Then FindColorsTolerance(MyTPA, Color[1],
         MSX1, MSY1, MSX2, MSY2, 17);
      For i := 0 To High(MyTPA) Do
      Begin
        MyPoint := MyTPA[i]    MMouse(MyPoint.x, MyPoint.y, 3, 3);
        Result := (IsUpTextMultiCustom(['ine', 'ore']))
        End Else Inc(F);
        If (F = > 7) Then Result := False;
      End;
    End;
    Is better
    Ok but how would i set my rocks its being a real pain

    SCAR Code:
    Procedure SetRock;
    Begin
       Case lowercase(Players[CurrentPlayer].Strings[0]) Of
       'clay'     : Begin
                    Colour := [4389,3462]//need 2 colours
                    End;
       'copper'   : Begin
                    Colour := ;
                    End;
       'tin'      : Begin
                    Colour := ;
                    End;
       'iron '    : Begin
                    Colour := ;
                    End;
       End;
    End;
    how would i get that to work?
    I see Now, says the blind man

  10. #10
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Function RockColor:Integer;
    Begin
    Case lowercase(Players[CurrentPlayer].Strings[0]) Of
    'clay' : Colour := [4389,3462]//need 2 colours
    'copper' : Colour := ;
    'tin' : Colour := ;
    'iron ' : Colour := ;
    End;
    End;

    If FindColor(RockColor) Then bla bla bla

  11. #11
    Join Date
    Feb 2009
    Location
    Hungary (GMT + 1)
    Posts
    1,774
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by YoHoJo View Post
    Function RockColor:Integer;
    Begin
    Case lowercase(Players[CurrentPlayer].Strings[0]) Of
    'clay' : Colour := [4389,3462]//need 2 colours
    'copper' : Colour := ;
    'tin' : Colour := ;
    'iron ' : Colour := ;
    End;
    End;

    If FindColor(RockColor) Then bla bla bla
    Colour should be Result('clay': Result := [46848, 65418]; ) and you can't use that like your example(I am pretty sure you just want him to get it ) but we must note that if we are using arrays for the color we have to either loop through the colors and use a color finding function with each(to TPA or whatever you want) or use a function that already uses Integer Arrays for color.

  12. #12
    Join Date
    Aug 2009
    Posts
    242
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Sabzi View Post
    Colour should be Result('clay': Result := [46848, 65418]; ) and you can't use that like your example(I am pretty sure you just want him to get it ) but we must note that if we are using arrays for the color we have to either loop through the colors and use a color finding function with each(to TPA or whatever you want) or use a function that already uses Integer Arrays for color.
    What would the Var be i think im going wonrg with
    SCAR Code:
    Var Colours:integer;
    and could i still use it in the Function that was posted like
    SCAR Code:
    If MineRockTPA(colours) Then
    I see Now, says the blind man

  13. #13
    Join Date
    Feb 2009
    Location
    Hungary (GMT + 1)
    Posts
    1,774
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by rya View Post
    What would the Var be i think im going wonrg with
    SCAR Code:
    Var Colours:integer;
    and could i still use it in the Function that was posted like
    SCAR Code:
    If MineRockTPA(colours) Then
    Correct. But than you don't need a function for that. Just a simple procedure .

    EDIT: Oh, wait. No it's not.

    SCAR Code:
    var
      Colours: TIntegerArray;
    is correct. As mentioned before it's an array of integers(colors here).

  14. #14
    Join Date
    Aug 2009
    Posts
    242
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Sabzi View Post
    Correct. But than you don't need a function for that. Just a simple procedure .

    EDIT: Oh, wait. No it's not.

    SCAR Code:
    var
      Colours: TIntegerArray;
    is correct. As mentioned before it's an array of integers(colors here).
    i think i follow you but i would still need to make Procedure to put the colours in so i can change it for clay, copper, iron, tin with out mega changes
    I see Now, says the blind man

  15. #15
    Join Date
    Feb 2009
    Location
    Hungary (GMT + 1)
    Posts
    1,774
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by rya View Post
    i think i follow you but i would still need to make Procedure to put the colours in so i can change it for clay, copper, iron, tin with out mega changes
    What YoHoJo posted before is fine. The only change is that you don't need it to be a function.

  16. #16
    Join Date
    Feb 2007
    Location
    Access Violation at 0x00000000
    Posts
    2,865
    Mentioned
    3 Post(s)
    Quoted
    18 Post(s)

    Default

    doesn't he need a SplitTpa or something in there? Just saying... Else it'll go through all the colours matches, with SplitTpa it just groups the found points and you can do a MiddleTpa to get the midpoints of those groups.
    Ce ne sont que des gueux


  17. #17
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    SCAR Code:
    function colorRock: TIntegerArray;
    begin
       case lowercase(Players[CurrentPlayer].Strings[0]) of
         'clay'     : Result := [4389,3462];//as many as you want :P
         'copper'   : Result := [];
         'tin'      : Result := [];
         'iron '    : Result := [];
       end;
    end;

    function MineRockATPA: Boolean;
    var
      A : T2DPointArray;
      MyTPA: TPointArray;
      C : TIntegerArray;
      P: TPoint;
      i, h, x, y: Integer;
    begin
      C := colorRock;
      for h := 0 to High(C) do
        if FindColorsTolerance(MyTPA, C[h], MSX1, MSY1, MSX2, MSY2, 17) then
          begin
            A := SplitTPA(MyTPA, 15);//set your own length
            P := Point(MSCX, MSCY);
            SortATPAFrom(A, P);
            for i := 0 to High(A) do
            begin
              MiddleTPAEx(A[i], x, y);
              MMouse(x, y, 5, 5);
              Result := (IsUpTextMultiCustom(['ine', 'ore']));
              if Result then
              begin
                GetMousePos(x, y);
                Mouse(x, y, 0, 0, True);
                WriteLn('Rock Clicked');
                Exit;//otherwise it will keep clicking
              end;
            end;
          end;
    end;

    My own improvement to your stuff... anyone correct me if I muffed something up.

Thread Information

Users Browsing this Thread

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

Posting Permissions

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