Results 1 to 16 of 16

Thread: Need something that returns a Boolean depending on whether you walk or mine.

  1. #1
    Join Date
    Sep 2007
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Need something that returns a Boolean depending on whether you walk or mine.

    Just started scripting in Pascal with SCAR yesterday and it's really fun although I need some help to complete my guild miner.

    1. Is there anything that I could use to return a Boolean depending on whether your character is moving or not (walking somewhere)?

    I made a function where I tried setting out 4 points that would detect a change in color every 500ms and if all 4 would return true the function would return true but the problem is that sometimes ground like grass or sand has exactly the same color so even if you walk it doesn't detect it.

    2. I need about the same thing for mining where you have a Boolean that tells you if your character is currently swinging the pick.

  2. #2
    Join Date
    Sep 2007
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    oh wait, I think I solved the 1st problem by having a function that detects the red destination flag in the minimap.

  3. #3
    Join Date
    Sep 2006
    Posts
    916
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Try If(InChat('ou swing'))Then Result:=True

    or something like that?

  4. #4
    Join Date
    Sep 2007
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by hey321 View Post
    Try If(InChat('ou swing'))Then Result:=True

    or something like that?
    ok, which include file is that function part of?

  5. #5
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    2,984
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Of SRL

    Text.scar if im not mistaking...
    Administrator's Warning:


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

    Default

    For walking i guess you could select a few co-ords, get their color and then after X time, recheck them if they have changed you are moving?, wouldnt be very accurate tho (could be another player moving)

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

  7. #7
    Join Date
    Sep 2007
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks for all the help but now when I try to include text.scar I get this error
    SCAR Code:
    [Error] (144:34): Unknown identifier 'upchars' in script D:\Program\SCAR 2.03\includes\SRL\SRL\core\Text.scar

    So, what do I need to include for the include to work? All the core includes or something?

    Quote Originally Posted by rogeruk View Post
    For walking i guess you could select a few co-ords, get their color and then after X time, recheck them if they have changed you are moving?, wouldnt be very accurate tho (could be another player moving)
    That's what I tried as I tried to explain in the first post.

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

    Default

    Any errors, you have to post the line/script that it is erroring on.

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

  9. #9
    Join Date
    Sep 2007
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by rogeruk View Post
    Any errors, you have to post the line/script that it is erroring on.
    Ehm, but the error isn't in the script but in the include, isn't it?

    Anyways, full error:
    SCAR Code:
    Failed when compiling
    Line 142: [Error] (142:34): Unknown identifier 'upchars' in script D:\Program\SCAR 2.03\includes\SRL\SRL\core\Text.scar

    Script (The SRL Text.scar include):
    SCAR Code:
    //-----------------------------------------------------------------//
    //--               Scar Standard Resource Library                --//
    //--               ยป Text Routines                               --//
    //-----------------------------------------------------------------//
    // * procedure TypeByte(k: Byte);                  // * by Mutant Squirrle
    // * procedure TypeSend(Text: String);             // * by Mutant Squirrle
    // * function SendText2(Text: String): Boolean;    // * by RSN | Modded By: Spky
    // * procedure SendText(Text: String);             // * by RSN
    // * function GetOption: String;                   // * by WT-Fakawi
    // * function GetUpText: String;                   // * by WT-Fakawi
    // * function Option2(Text: String): Boolean;      // * by Freddy1990
    // * function IsUpText(UpText: String): Boolean;   // * by Masquerader
    // * function IsUpTextMulti(UT1, UT2, UT3: String): Boolean; // * by WT-Fakawi
    // * function FindText(var cx, cy: Integer; txt: String; font, xs, ys, xe, ye: Integer): Boolean; // * by Stupid3ooo
    // * function FindNpcChatText(txt: String): Boolean; // * by Kernel Klink or Stupid3000, font by Masquerader
    // * function ClickNpcChatText(txt: String): Boolean; // * by Kernel Klink or Stupid3000, font by Masquerader
    // * function FindInventoryText(txt: String): Boolean; // * by Stupid3ooo
    // * function ChooseOption(x, y: Integer; txt: String): Boolean; // * by Stupid3ooo
    // * function ChooseOptionEx(txt: String): Boolean; // * by Freddy1990
    // * procedure CloseWindow;                        // * by Stupid3ooo
    // * function hitkeys(send: Boolean): Integer;     // * by Pyro
    // * function HumanText(Text: String; Chance: Integer): String; // * by Pyro
    // * function LastChatter(var name: String): Boolean; // * by masquerader
    // * function GetLastChatText(var chat: String): Boolean; // * by masquerader
    // * function SaveToChatLog: Boolean;              // * by WT-Fakawi / masquerader
    // * function GetNewChatMsg: String;               // * by Stupid3ooo
    // * function ClearSpaces(Text: String): String;   // * by Mad Cow
    // * function IsChatMessage(s: String): Boolean;   // * by ?
    // * function InChat(Text: String): Boolean;       // * by WT-Fakawi
    // * function InChatMulti(Text1, Text2, Text3: String): Boolean; // * by WT-Fakawi
    // * function FindChatText(txt: String): Boolean;  // * by Stupid3ooo
    // * Function GetUpTextColor(Color, Tol: Integer; Range: TCharRange): String; // * by Wizzup?
    // * Function ChatsBlackText: Array Of String;     // * by Wizzup?
    // * Function GetBlackChatMessage: String;         // * by Wizzup?
    // * Function FindBlackChatMessage(ChatMsg: String): Boolean; // * by Wizzup?
    // * function PopUp(Option: String): Boolean;      // * by RsN
    // * function ClickOption(s: String; i: Integer): Boolean; // * by RSN
    // * function ClickText2(txt: String; font, xs, ys, xe, ye: Integer; left: Boolean): Boolean; // * by Stupid3ooo

    {*******************************************************************************
    procedure TypeByte(k: Byte);
    By: Mutant Squirrle
    Description: Types one char.
    *******************************************************************************}


    procedure TypeByte(k: Byte);
    begin
      KeyDown(k);
      Wait(10 + Random(50));
      KeyUp(k);
    end;

    {*******************************************************************************
    procedure TypeSend(Text: String);
    By: Mutant Squirrle
    Description: Types text humanlike using random timeing on keys.
    *******************************************************************************}


    procedure TypeSend(Text: string);
    var
      i: Integer;
      Shift: Boolean;
    begin
      for i := 1 to Length(Text) do
      begin
        Shift:= (Text[i] = ':')or(Text[i] = '!')or(Text[i] = '+')or
                (Text[i] = '?')or(Text[i] = '<')or(Text[i] = '>')or
                (Text[i] = '@')or(Text[i] = '#')or(Text[i] = '$')or
                (Text[i] = '&')or(Text[i] = '%')or(Text[i] = '*');
        if(Shift)then
        begin
          KeyDown(VK_Shift);
          Wait(5 + Random(20));
        end;
        TypeByte(GetKeyCode(Text[i]));
        if(Shift)then
        begin
          KeyUp(VK_Shift);
          Wait(5 + Random(20));
        end;
        Wait(50 + Random(120));
      end;
      Wait(200 + Random(500));
      TypeByte(13);
    end;

    {*******************************************************************************
    function SendText2(Text: String): Boolean;
    By: RSN | Modded By: Spky
    Description: Types text humanlike making mistakes, returns true if mistake has
    been made.
    *******************************************************************************}


    function SendText2(Text: string): Boolean;
    var
      i, j, w: Integer;
      S: string;
    begin
      for i := 1 to Length(Text) do
      begin
        S := Text[i];
        if (Random(5) + 1 = 1) and (w < 3) then
        begin
          w := w + 1;
          Result := True;
          j := Ord(S[1]);
          if (j <> 13) then
            S := Chr(j + (Random(5) + 1));
          if (S = Chr(13)) then
            S := 'l';
        end;
        SendKeys(S);
        Wait(50 + Random(100));
      end;
    end;

    {*******************************************************************************
    procedure SendText(Text: String);
    By: RSN
    Description: Types text humanlike.
    *******************************************************************************}


    procedure SendText(Text: string);
    var
      i: Integer;
    begin
      for i := 1 to Length(Text) do
      begin
        SendKeys(Text[i]);
        Wait(50 + Random(100));
      end;
    end;

    {*******************************************************************************
    function GetUpText: String;
    By: WT-Fakawi
    Description: Returns text in upperleft corner.
    *******************************************************************************}


    function GetUpText: string;
    begin
      Result := GetTextAtEx(7, 7, 100, upchars, True, True, 0, 2, -1, 50, False,
        tr_AllChars);
    end;

    {*******************************************************************************
    function Option2(Text: String): Boolean;
    By: Freddy1990
    Description: Searches for text in upperleft corner.
    *******************************************************************************}


    function Option2(Text: string): Boolean;
    begin
      Result := (Pos(Text, GetUpText) > 0);
    end;

    {*******************************************************************************
    function IsUpText(UpText: String): Boolean;
    By: Masquerader
    Description: Returns up text that might be to the right
    *******************************************************************************}


    function IsUpText(UpText: string): Boolean;
    var
      tempx, tempy: Integer;
    begin
      if (IsTextInAreaEx(7, 7, 334, 20, tempx, tempy, UpText, 100, upchars, True,
        True, 0, 2, -1)) then
        Result := True;
    end;

    {*******************************************************************************
    function IsUpTextMulti(UT1, UT2, UT3: String): Boolean;
    By: WT-Fakawi
    Description: Returns any of three UpText that might be to the right
    Usefull when text is partially masked.
    Use: IsUpTextMulti('Attack','tta','ack')
    *******************************************************************************}


    function IsUpTextMulti(UT1, UT2, UT3: string): Boolean;
    var
      tempx, tempy, I: Integer;
    var
      TheText: string;
    begin
      for I := 1 to 3 do
      begin
        case I of
          1: TheText := UT1;
          2: TheText := UT2;
          3: TheText := UT3;
        end;
        if IsTextInAreaEx(7, 7, 334, 20, tempx, tempy, TheText, 100, upchars, True,
          True, 0, 2, -1) then
          Result := True;
      end;
    end;

    {*******************************************************************************
    function FindText(var cx, cy: Integer; txt: String; font, xs, ys, xe, ye: Integer): Boolean;
    By: Stupid3ooo
    Description: Searches for text in specified box with specified font.
    *******************************************************************************}


    function FindText(var cx, cy: Integer; txt: string; font, xs, ys, xe, ye:
      Integer): Boolean; //by Stupid3ooo
    var
      S: Integer;
    begin
      S := CreateBitmapMaskFromText(txt, font);
      if xs <= 0 then xs := 0;
      if ys <= 0 then ys := 0;
      Result := FindBitmapMaskTolerance(S, cx, cy, xs, ys, xe, ye, 10, 50);
      FreeBitmap(S);
    end;

    {*******************************************************************************
    function FindNpcChatText(txt: String): Boolean;
    By: Kernel Klink or Stupid3000, font by Masquerader
    Description: Get last chat message.
    *******************************************************************************}


    function FindNpcChatText(txt: string): Boolean;
    var
      S: Integer;
    begin
      S := CreateBitmapMaskFromText(txt, npcchars);
      Result := FindBitmapMaskTolerance(S, x, y, 9, 348, 523, 471, 50, 10);
      FreeBitmap(S);
    end;

    {*******************************************************************************
    function ClickNpcChatText(txt: String): Boolean;
    By: Kernel Klink or Stupid3000, font by Masquerader
    Description: Get last chat message.
    *******************************************************************************}


    function ClickNpcChatText(txt: string): Boolean;
    var
      tx, ty, S: Integer;
    begin
      if txt <> '' then
      begin
        S := CreateBitmapMaskFromText(txt, npcchars);
        if FindBitmapMaskTolerance(S, tx, ty, 9, 348, 523, 471, 50, 10) then
        begin
          Mouse(tx + 5, ty + 8, 0, 0, True);
          Result := True;
        end;
        FreeBitmap(S);
      end;
    end;

    {*******************************************************************************
    function FindInventoryText(txt: String): Boolean;
    By: Stupid3ooo
    Description: Finds inventory text.
    *******************************************************************************}


    function FindInventoryText(txt: string): Boolean; ////Small(3)
    begin
      Result := FindText(x, y, txt, SmallChars, 553, 206, 742, 465);
    end;

    {*******************************************************************************
    function ChooseOption(x, y: Integer; txt: String): Boolean;
    By: Stupid3ooo
    Description: Finds Popup menu, then clicks on it.
    *******************************************************************************}


    function ChooseOption(x, y: Integer; txt: string): Boolean;
    var
      x1, y1, x2, y2, LeftCorner, RightCorner: Integer;
    begin
      LeftCorner := BitmapFromString(4, 4, 'z78DA33753135313137C5' +
        '411A600064715CEA914500CACE13F0');
      RightCorner := BitmapFromString(4, 4, 'z78DA33753135313137' +
        'C5200D30002E35F8C501C9C013F0');
      if (FindBitmap(LeftCorner, x1, y1)) and (FindBitmap(RightCorner, x2, y2)) then
      begin
        if (FindText(x, y, txt, upchars, x1, y1, x2, 502)) then
        begin
          Result := True;
          Mouse(x + Length(txt) * 3, y + 3, 2, 2, True);
        end
        else if (FindText(x, y, 'Cancel', upchars, x1, y1, x2, 502)) then
          Mouse(x + 9, y + 3, 2, 2, True);
      end;
      FreeBitmap(LeftCorner);
      FreeBitmap(RightCorner);
    end;

    {*******************************************************************************
    function ChooseOptionEx(txt: String): Boolean;
    By: Freddy1990
    Description: Finds Popup menu, then clicks on it.
    *******************************************************************************}


    function ChooseOptionEx(txt: string): Boolean;
    var
      x, y: Integer;
    begin
      Result := ChooseOption(x, y, txt);
    end;


    {*******************************************************************************
    procedure CloseWindow;
    By: Stupid3ooo
    Description: Closes frontmost window.
    *******************************************************************************}


    procedure CloseWindow;
    begin
      if (FindBitmapMaskTolerance(CWindow, x, y, 400, 3, 515, 100, 0, 85)) then
        Mouse(x + 8, y + 3, 3, 1, True);
    end;

    {*******************************************************************************
    function hitkeys(send: Boolean): Integer;
    By: Pyro
    Description: Hits Random 4 Keys that are random 4 dist away. Good for smelt or cook x
    *******************************************************************************}


    function hitkeys(send: Boolean): Integer;
    var
      i, k: Integer;
      full: string;
    begin
      i := Random(6) + 1;
      for k := 1 to 4 do
        full := full + IntToStr(i + Random(4));
      Result := (StrToInt(full));
      if (send) then TypeSend(IntToStr(Result));
    end;

    {*******************************************************************************
    function HumanText(Text: String; Chance: Integer): String;
    By: Pyro
    Description: Returns A text humanly. DOES NOT TYPE. But will make ACTUAL human Mistakes
                 Chance is like well think of it as 1 out of ......
    *******************************************************************************}


    function HumanText(Text: string; Chance: Integer): string;
    var
      Keyboard: array[1..8] of string;
      Tempi, i, l, NewKey: Integer;
      Temps, Newtext: string;
    begin
      keyboard[1] := '1234567890-=';
      keyboard[2] := 'qwertyuiop[]\';
      keyboard[3] := 'asdfghjkl;';
      keyboard[4] := 'zxcvbnm,./';
      keyboard[5] := '!@#$%^&*()_+';
      keyboard[6] := 'QWERTYUIOP{}|';
      keyboard[7] := 'ASDFGHJKL:"';
      keyboard[8] := 'ZXCVBNM<>?';
      for l := 1 to Length(Text) do
      begin
        Temps := Copy(Text, l, 1)
          if (Random(Chance) = 0) then
        begin
          for i := 1 to 8 do
          begin
            Tempi := Pos(Temps, keyboard[i])
              if (tempi <> 0) then
            begin
              if (Tempi = 1) then NewKey := 2
                if (Tempi = Length(keyboard[i])) then Newkey := Tempi - 1
                  if (Tempi <> 1) and (Tempi <> 10) then
                    Newkey := Tempi + Random(2) - Random(2)
                      NewText := Copy(keyboard[i], NewKey, 1)
                      break;
            end;
          end;
        end else Newtext := Temps
          Result := Result + Newtext;
      end;
    end;

    {*******************************************************************************
    function LastChatter(var name: String): Boolean;
    By: masquerader
    Description:
    *******************************************************************************}


    function LastChatter(var name: string): Boolean;
    var
      i: Integer;
    begin
      name := LowerCase(Trim(GetTextAtEx(21, 415, 0, SmallChars, False, False, 0, 0,
        0, 50, False, tr_allChars)))
        i := Pos(':', name)
        if (i <> 0) then
      begin
        Delete(name, i, i);
        Result := True;
      end;
    end;

    {*******************************************************************************
    function GetLastChatText(var chat: String): Boolean;
    By: masquerader
    Description:
    *******************************************************************************}


    function GetLastChatText(var chat: string): Boolean;
    var
      textx, texty: Integer;
    begin
      if (IsTextInAreaEx(40, 415, 130, 415, textx, texty, ':', 0, smallchars, False,
        True, 0, 0, 0)) then
      begin
        chat := LowerCase(Trim(GetTextAtEx(textx + 8, 415, 0, SmallChars, False,
          False, 0, 1, 16711680, 40, False, tr_allChars)));
        Result := True;
      end;
    end;

    procedure FixChat; forward;
    {*******************************************************************************
    function SaveToChatLog: Boolean;
    By: WT-Fakawi / masquerader
    Description: Saves chat to log file
    *******************************************************************************}


    procedure SaveToChatLog;
    begin
      FixChat;
      OldLine := TheLine;
      if (GetLastChatText(theline)) then
      begin
        if OldLine <> theLine then
        begin
          LastChatter(thename)
            WriteFileString(thefile, TheTime + ' ' + thename + ': ' + theline +
            Chr(13));
        //  writeln(thetime+' '+thename+': '+theline);
        end
      end else
      begin
        LastChatter(theline)
          if OldLine <> theLine then
        begin
          WriteFileString(thefile, TheTime + ' ' + theline + Chr(13));
      //    writeln(thetime+' '+theline);
        end
      end
    end;
    {*******************************************************************************
    function GetNewChatMsg: String;
    By: Stupid3ooo
    Description: Get last chat message.
    *******************************************************************************}


    function GetNewChatMsg: string;
    begin
      if (not (GetLastChatText(Result))) then
        LastChatter(Result);
    end;

    {*******************************************************************************
    function ClearSpaces(Text: String): String;
    By: Mad Cow
    Description: Clears spaces in an area of text(Needed in 'GetXP');
    *******************************************************************************}


    function ClearSpaces(Text: String): String;
    var
      Nums: String;
      I, II: Integer;
    begin
      Nums := '01234567890';
      for I := 1 to Length(Text) do
      begin
        for II := 1 to 10 do
        begin
          if(Copy(Text, I, 1) = Copy(Nums, II, 1)) then
            Result := Result + Copy(Text, I, 1);
        end;
      end;
    end;

    {*******************************************************************************
    function IsChatMessage(s: String): Boolean;
    By:
    Description: Checks if last chat message matches specified.
    *******************************************************************************}


    function IsChatMessage(S: string): Boolean;
    begin
      Result := (Pos(S, GetNewChatMsg) > 0);
    end;

    {*******************************************************************************
    function InChat(Text: String): Boolean;
    By: WT-Fakawi
    Description: Grabs Last Chat Line and performs checks on occurence of text
    *******************************************************************************}


    function InChat(Text: string): Boolean;
    begin
      Result := IsChatMessage(text);
    end;

    {*******************************************************************************
    function InChatMulti(Text1, Text2, Text3: String): Boolean;
    By: WT-Fakawi
    Description: Grabs Last Chat Line and performs checks on three occurences of text
    *******************************************************************************}


    function InChatMulti(Text1, Text2, Text3: string): Boolean;
    var
      temp: string;
    begin
      temp := GetNewChatMsg;
      if (Pos(Text1, temp) <> 0) or (Pos(Text2, temp) <> 0) or (Pos(Text3, temp) <> 0) then
        Result := True
    end;


    {*******************************************************************************
    function FindChatText(txt: String): Boolean;
    By: Stupid3ooo
    Description: Searches for text in chat window.
    *******************************************************************************}


    function FindChatText(txt: string): Boolean; //Chat(1)
    begin
      Result := FindText(x, y, txt, SmallChars, 9, 348, 479, 433);
    end;

    {*******************************************************************************
    function GetUpTextColor(Color, Tol: Integer; Range: TCharRange): String;
    By: Wizzup?
    Description: Performs GetTextAtEx with The chosen color, tol and TCharRange.
    *******************************************************************************}

    function GetUpTextColor(Color, Tol: Integer; Range: TCharRange): String;
    begin
      Result := Trim(GetTextAtEx(7, 7, Tol, upchars, true,
      true, 0, 2, Color, 50, True, Range));
      WriteLn(Result);
    end;

    {*******************************************************************************
    function ChatsBlackText: Array Of String;
    By: Wizzup?
    Description: Gets all text with color 0 in chatbox:
     line 1 is result[0]
     line 2 is result[1]
     line 3 is result[2]
     line 4 is result[3]
     line 5 is result[4]
    *******************************************************************************}

    function ChatsBlackText: Array Of String;
    var
      I : Byte;
    begin
      SetArrayLength(Result, 5);
      for I := 0 to 4 do
        Result[I] := Trim(GetTextAtEx(20, 415 - (14 * I), 0, SmallChars, False,
          False, 0, 1, 0, 80, False, tr_AllChars));
    end;

    {*******************************************************************************
    function IsChatBlackTextAnyLine(ChatTxt: String): Boolean;
    By: Wizzup?
    Description: Returns true if ChatTxt is found in any of the 5 lines in ChatBox.
    *******************************************************************************}


    function IsChatBlackTextAnyLine(ChatTxt: String): Boolean;
    var
      TheLines: Array Of String;
      I : Byte;
    begin
      TheLines := ChatsBlackText;
      for I := 0 To 4 Do
        if (Pos(ChatTxt, TheLines[I]) <> 0) then
        begin
          Result := True;
          Exit;
        end;
    end;

    {*******************************************************************************
    function GetBlackChatMessage: String;
    By: Wizzup?
    Description: Gets text with color 0 in last chat line.
    *******************************************************************************}


    function GetBlackChatMessage: String;
    begin
      Result := Trim(GetTextAtEx(20, 415, 0, SmallChars, False,
        False, 0, 1, 0, 80, False, tr_AllChars));
    end;

    {*******************************************************************************
    function FindBlackChatMessage(ChatMsg: String): Boolean;
    By: Wizzup?
    Description: Returns True if text with color 0 in last chat line is found.
    *******************************************************************************}


    function FindBlackChatMessage(ChatMsg: String): Boolean;
    begin
      Result := (Pos(ChatMsg, GetBlackChatMessage) <> 0);
    end;

    {*******************************************************************************
    function Capitalize(S: String): String;
    By: RSN/StarBlaster/Ron
    Description: Will Capitalize strings as Runescape i are noob = I Are Noob
    *******************************************************************************}


    function Capitalize(S: String): String;
    var
      i: Integer;
    begin
      Result := trim(s);
      Result[1] := Uppercase(Result[1])[1];
      for i := 2 to Length(Result) do
        if (Result[i] = ' ') or (Result[i] = '_') then
          Result[i + 1] := Uppercase(Result[i + 1])[1];
    end;


    {*******************************************************************************
    function PopUp(Option: String): Boolean;
    By: RsN
    Description: Finds Popup menu, then clicks Option.
    *******************************************************************************}


    function PopUp(Option: string): Boolean;
    var
      Top, Bottom: TPoint;
      dtmTop, dtmBottom, x, y: Integer;
    begin
      dtmTop := DTMFromString('78DA63146464606801622C0026CA28006435A' +
        '3AA890D7147552345841A90393D04D4880259DD04D4880359ED04' +
        'D4280059AD04FC2504644DC4AF06000DC909E0');
      dtmBottom := DTMFromString('78DA635CCCC8C070198891406C883B9886893' +
        '22E02B22EA1AA8101B89A8540D64522CCB948843984EC02B9F910' +
        '01BBA610E1AF6944D80572F311026AE6005967F0DB05007BD4134' +
        '5');
      if (FindDTM(dtmTop, Top.x, Top.y, 10, 10, 764, 502) and FindDTM(dtmBottom,
        Bottom.x, Bottom.y, Top.x, Top.y, 764, 502)) then
        if (FindText(x, y, Option, upchars, 0, 0, Bottom.x, Bottom.y)) then
        begin
          Result := True;
          Mouse(x + Length(Option) * 3, y + 2, 4, 3, True);
          Wait(150 + Random(200));
        end else
          if (FindText(x, y, 'Cancel', upchars, Top.x, Top.y, Bottom.x, Bottom.y))
            then
            Mouse(x + 3, y + 2, 4, 3, True);
      FreeDTM(dtmTop);
      FreeDTM(dtmBottom);
    end;

    {*******************************************************************************
    function ClickOption(s: String; i: Integer): Boolean;
    By: RSN
    Description: Clicks Option in Specified Area (1 for Main Screen, 2 Inventory,
    3 for Chat Window), returns True if text was found
    *******************************************************************************}


    function ClickOption(S: string; i: Integer): Boolean;
    var
      x, y, tmpMask: Integer;
    begin
      tmpMask := CreateBitmapMaskFromText(S, upchars);
      case i of
        1:
          begin
            if (FindBitmapMaskTolerance(tmpMask, x, y, 0, 0, 520, 340, 10, 50)) then
            begin
              Wait(25 + Random(50));
              Mouse(x + (Length(S) * 6 div 2), y + 5, 3, 3, True);
              Result := True;
            end;
          end;
        2:
          begin
            if (FindBitmapMaskTolerance(tmpMask, x, y, 550, 200, 750, 470, 10, 50))
              then
            begin
              Wait(25 + Random(50));
              Mouse(x + (Length(S) * 6 div 2), y + 5, 3, 3, True);
              Result := True;
            end;
          end;
        3:
          begin
            if (FindBitmapMaskTolerance(tmpMask, x, y, 0, 340, 500, 460, 10, 50))
              then
            begin
              Wait(25 + Random(50));
              Mouse(x + (Length(S) * 6 div 2), y + 5, 3, 3, True);
              Result := True;
            end;
          end;
      end;
      FreeBitmap(tmpMask);
    end;

    {*******************************************************************************
    function ClickText2(txt: String; font, xs, ys, xe, ye: Integer; left: Boolean): Boolean;
    By: Stupid3ooo
    Description: Clicks text if found in box.
    *******************************************************************************}


    function ClickText2(txt: string; font, xs, ys, xe, ye: Integer; left: Boolean):
      Boolean;
    begin
      Result := FindText(x, y, txt, font, xs, ys, xe, ye);
      if (Result) then
        Mouse(x + Length(txt) * 3, y + 3, 0, 0, left);
    end;

  10. #10
    Join Date
    Oct 2006
    Location
    Ontario,Canada
    Posts
    1,718
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    [Error] (144:34): Unknown identifier 'upchars' in script D:\Program\SCAR 2.03\includes\SRL\SRL\core\Text.scar
    why are you using 2.03? use the newest divi!

  11. #11
    Join Date
    Sep 2007
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Huh, what's divi? (As a noob I didn't know that, will google it right away, thanks. I just hope that I wont need to rewrite my script.)

  12. #12
    Join Date
    Nov 2006
    Location
    In an Amish Paradise
    Posts
    729
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Go to Freddy1990.com/scar.php and download Scar Divi 3.11. Then set up Srl 4.0 beta... If you don't know how read some 'How to Auto' Tuts

    ~Stupedspam

  13. #13
    Join Date
    Sep 2007
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ok, I got it working now but where can you find a manual/documentation for divi 3.11? like this one for 2.03: http://www.rs101.info/usermanual.html

  14. #14
    Join Date
    Feb 2006
    Location
    New Zealand
    Posts
    1,330
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by tutsban View Post
    Ok, I got it working now but where can you find a manual/documentation for divi 3.11? like this one for 2.03: http://www.rs101.info/usermanual.html
    Open scar. Press F1

  15. #15
    Join Date
    Apr 2007
    Location
    Australia
    Posts
    4,163
    Mentioned
    9 Post(s)
    Quoted
    19 Post(s)
    Just press F1 in SCAR to get to the manual.

    Now, about seeing if your character is mining. Theres no effective/efficient way to do this in SCAR, but there is something similar, which actually has better results. Basically, what we need to do is follow the rock across the screen, which is just tracking its position. To do so, we use this function:

    SCAR Code:
    function FollowOres(var x, y: Integer): Boolean;
    begin
      if not LoggedIn then Exit;
      if (x - 30) < 0 then x := 30;
      if (y - 30) < 0 then y := 30;
      ColorToleranceSpeed(CTS);
      if FindColorSpiralTolerance(x, y, OreColour, x - 20, y - 20, x + 20, y + 20, OreTol) then
      begin
        Result := True;
        Status('Rock followed');
      end else
      begin
        Result := False;
        x:= MSCX;
        y:= MSCY;
        Status('Rock not followed');
      end;
      ColorToleranceSpeed(1);
    end;

    To understand this, first we will look at the name of the function itself, FollowOres(var x, y: Integer): Boolean. The x, and y that you use when calling this function are the co-ords of the rock that you found. You would do something like this:

    SCAR Code:
    Find rock color(Mx, My....)
    FollowOres(Mx, My);

    So you find the rock at Mx, My, then FollowOres at Mx, My. The FindColorSpiralTolerance finds OreColour, starting at x, y (Mx, My in our case), in a 20 pixel box around where the Rock was found last. The co-ords of the colour are refreshed back into x, y. So if you have that in a loop, the script will be searching for the rock colour in a 20 x 20 box around the last place it found the rock.

    We would use this function like so:

    SCAR Code:
    FindRock(Mx, My, ...);
    while FlagExists do
      FollowOres(Mx, My);

    So first it finds the rock, clicks on it, then while we are moving across the screen (indicated by FlagPresent) it constantly refreshes the rocks position into Mx, My. You will need to FollowOres for about another second once the flag is gone though, because you move a little bit once the flag has gone.

    So now we know where our rock is, once we have clicked it and moved to it. How is this useful? We use this for antigas. We can also use this in a loop, Procedure WaitForRock.

    SCAR Code:
    procedure WaitForRock;
    begin
      repeat
        if FindGas(Mx, My) then YourHandleGas;
        FindRandoms;
      until not FollowOres(Mx, My);
    end;

    It repeats everything until the refreshing of the variables fails, which would mean that the rock is mined.

    So now we finish up with this piece of code:

    SCAR Code:
    FindRock(Mx, My....)
      while FlagExists do
        FollowOres(Mx, My);
      WaitForRock;

    Provided you do everything right, that will click the rock, track its position across the screen and then perform gas checks and random finding until you have finished the mining. BTW, this was the simplified version and if you copy every piece of code here it wont work and it will be very buggy. The idea is to look over the theory, use the logic and tweak it accordingly until you get something you are happy with. Check out my Varrock west miner for a more advanced version.

    Hope this helped, good luck. If you have any problems or dont understand something here, please do not hesitate to post.

    Regards.

  16. #16
    Join Date
    Sep 2007
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks for all the info! I was way to lazy too make such an advanced mining detector myself but I managed to enchance the pixeltracker I had which used to fail if it's pixel was crossed by something like a pickaxe. The following works just fine such far for my guildminer needs.

    SCAR Code:
    function Mining : Boolean;

    begin

    GetMousePos(x,y)

    if (x - 10) < 0 then x := 10;
    if (y - 10) < 0 then y := 10;

    Result := FindColorSpiralTolerance(x, y, rock1, x - 10, y - 10, x + 10, y + 10, 10) or
    FindColorSpiralTolerance(x, y, rock2, x - 10, y - 10, x + 10, y + 10, 10) or
    FindColorSpiralTolerance(x, y, rock3, x - 10, y - 10, x + 10, y + 10, 10)

    end;

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
  •