Results 1 to 7 of 7

Thread: Find and Typing - From Arrays

  1. #1
    Join Date
    Feb 2007
    Posts
    849
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Find and Typing - From Arrays

    What is the inbuilt code for searching for an array of texts and then replying one 'item' of another array EG

    SCAR Code:
    FindText1('hey','hi','hello');
    ReplyTxt1('hey','hi','hello');

    Thanks.
    ________________________________________
    14:19 < cycrosism> I wonder what she would have done without it
    14:19 < cycrosism> without me*
    Cycrosism is now an it.
    Quote Originally Posted by Dervish View Post
    /Facedesk.

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

    Default

    InStrArr I think.

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

    Default

    Haven't tested this, but it should work -
    SCAR Code:
    program New;
    {.include SRL/SRL.scar}
    var
      StrArr, Search, Reply : TStringArray;
      n : integer;
    procedure GetChatTexts(var arr:TStringArray);
    var
      x, y, i: Integer;
      textP: TPoint;
      chat : string;
    begin
      SetArrayLength(Arr, 1);
      for i := 1 to 8 do
      begin
        textP := TextCoords(8);
        if findcolor(x, y, 16711680, textp.x, textp.y, textp.x + 200, textp.y + 14) then
        begin
          chat := LowerCase(Trim(GetTextAtEx(x - 3, textp.y - 2, 0, SmallChars, False,

          False, -1, 1, 16711680, 60, False, tr_allChars)));
          arr[GetArrayLength(arr)-1] := chat;
        end;
      end;
    end;

    begin
      SetUpSRL;
      ActivateClient;
      GetChatTexts(StrArr);
      for n := 0 to High(StrArr) do
      begin
        Writeln(StrArr[n]);
      end;
      Search := ['hi','hey','hello'];
      Reply  := ['ih','yeh','olleh'];
      for n := 0 to High(Search) do
      begin
        if(InStrArr(Search[n], StrArr, false))then
        begin
          TypeSend(Reply[n]);
          Break;
        end;
      end;
    end.

    Will find most recent chats in the chat box, then check if they are the ones you want to reply to, then give the corresponding reply, as mentioned.

  4. #4
    Join Date
    Jul 2007
    Location
    Ottawa, Canada
    Posts
    930
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I don't understand the question... can you please elaborate?
    ~ Metagen

  5. #5
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    I think he means an autoresponder: if you see any of these, reply with one of those.

  6. #6
    Join Date
    Feb 2007
    Posts
    849
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    A G E N T 83, that looks pretty epic

    Anyway of turning it into an include and just adding the

    Search := ['hi','hey','hello'];
    Reply := ['ih','yeh','olleh'];
    Part? Thanks.
    ________________________________________
    14:19 < cycrosism> I wonder what she would have done without it
    14:19 < cycrosism> without me*
    Cycrosism is now an it.
    Quote Originally Posted by Dervish View Post
    /Facedesk.

  7. #7
    Join Date
    May 2008
    Posts
    1,345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Save this:

    SCAR Code:
    var
      StrArr: TStringArray;
      n : integer;
     
    procedure GetChatTexts(var arr:TStringArray);
    var
      x, y, i: Integer;
      textP: TPoint;
      chat : string;
    begin
      SetArrayLength(Arr, 1);
      for i := 1 to 8 do
      begin
        textP := TextCoords(8);
        if findcolor(x, y, 16711680, textp.x, textp.y, textp.x + 200, textp.y + 14) then
        begin
          chat := LowerCase(Trim(GetTextAtEx(x - 3, textp.y - 2, 0, SmallChars, False,

          False, -1, 1, 16711680, 60, False, tr_allChars)));
          arr[GetArrayLength(arr)-1] := chat;
        end;
      end;
    end;

    Procedure RespondToChat(Search, Reply : Array of String);
    begin
      GetChatTexts(StrArr);
      for n := 0 to High(StrArr) do
      begin
        Writeln(StrArr[n]);
      end;
      Search := ['hi','hey','hello'];
      Reply  := ['ih','yeh','olleh'];
      for n := 0 to High(Search) do
      begin
        if(InStrArr(Search[n], StrArr, false))then
        begin
          TypeSend(Reply[n]);
          Break;
        end;
      end;
    end;

    As Responding.scar. It MUST be saved just inside the Includes folder.

    Then do this:

    SCAR Code:
    Program New;
    {.include srl/srl.scar}
    {.include Responding.scar}

    Begin
    SetupSrl;
    RespondToChat(['Hello', 'Hi', 'Yo'], ['olleH', 'iH', 'oY']);
    End.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Typing in RS
    By GhostofReality in forum OSR Help
    Replies: 27
    Last Post: 09-01-2008, 03:14 PM
  2. Arrays, stuck on arrays
    By Camaro' in forum OSR Help
    Replies: 1
    Last Post: 03-08-2008, 02:02 AM
  3. Not Typing?
    By Hey321 in forum OSR Help
    Replies: 5
    Last Post: 02-23-2007, 11:01 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
  •