Results 1 to 25 of 25

Thread: How to go though strings?

  1. #1
    Join Date
    Oct 2010
    Location
    Under a bridge
    Posts
    648
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default How to go though strings?

    Ok well im trying to return what was said last from chat.

    Simba Code:
    Function LastLineOfChat:Integer;
    Begin
      Case GetChatBoxText(8,clChat) Of
    End;

    I'm not sure what to do, i want it to search though array's and see if the chat matchs any of the arrays.

    Example

    It finds 'Hello, today is a nice day'
    and the arrays are
    ['I hate today','Today is a bad day']
    ['Its raining today','I hate the rain']
    ['Yay i leveled up','Woot 1 level closer to 99']
    ['Hello, today is a nice day','I love today']

    So it returns 4 as it matchs array 4

    Thanks

    E: saw no point in a new thread, but a new question
    For MouseBox what is the parameter clickType?
    Thanks again

    Edit: Thank a ton guys for all your help
    Im trying to send text. I needs to be from the array which is set in the parameter but can be from any in that array.
    Simba Code:
    Function Reply(A:Integer):Boolean;
    Var
        i: Integer;
        TheArrays: Array Of TStringArray;
        S: String;
    Begin

      TheArrays[0] := ['Hi', 'Hello', 'Hi all'];
      TheArrays[1] := ['Array1_1', 'Array1_2', 'Array1_3', 'Array1_4'];
      TheArrays[2] := ['Array2_1', 'Array2_2'];
      TheArrays[3] := ['Array3_1'];
      TheArrays[4] := ['Array4_1', 'Array4_2'];

      For I := High(TheArrays) DownTo 0 Do
        If I = A Then
        Begin
          TypeSendEx(TheArrays[I],True);
          writeln('Said '+TheArrays[I]);
        End;

    End;
    I tryed this but got compileing errors

    Thanks again for all your help, i know it seems like a lot but im find most my questions out my self
    Last edited by Troll; 12-19-2010 at 10:07 AM.
    Quote Originally Posted by DD on IRC
    wanted to troll the troll

  2. #2
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Split the text by ' ' (SPACE) and then for each array element, do the same, and count the words that match the chat text, then save that to TStringArray[NumberOfWordsFound] = Answer;

    Now that you have the number of words matched, you can a sort, so you get the highest count of words that were matched.

    Now you can check if the word count was atleast 50% of the actual chat text's word count, and then return the answer.
    There used to be something meaningful here.

  3. #3
    Join Date
    Oct 2010
    Location
    Under a bridge
    Posts
    648
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Umm you've lost me maybe an example? Also i want it to be 100% as this is for Khan(Srl clan) and will be talking but it will be the same scirpt that talks and replys just diffrent people
    Quote Originally Posted by DD on IRC
    wanted to troll the troll

  4. #4
    Join Date
    Dec 2007
    Location
    192.168.1.73
    Posts
    2,439
    Mentioned
    6 Post(s)
    Quoted
    119 Post(s)

    Default

    By splitting the text into the various words, he means doing and "explode":

    SCAR Code:
    srl_Explode(str, del: string);

    With str being your string, del being the character that splits the string.

  5. #5
    Join Date
    Oct 2010
    Location
    Under a bridge
    Posts
    648
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ^Umm still lost sorry
    Also why cant i just look for the full string as it has to be 100% anyway?

    Thanks for the help though
    Quote Originally Posted by DD on IRC
    wanted to troll the troll

  6. #6
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Simba Code:
    type
      T2DStringArray = array of TStringArray;

    const
      S = 'Array1_3';

    var
      TheArrays : T2DStringArray;
      I : Integer;

    function InStringArray(Str : String; sArr : TStringArray): Boolean;
    var
      I : Integer;
    begin
      for I := High(sArr) downto 0 do
        if sArr[I] = S then
        begin
          Result := True;
          Exit;
        end;
    end;

    begin
      SetLength(TheArrays, 5);
      TheArrays[0] := ['Array0_1', 'Array0_2', 'Array0_3'];
      TheArrays[1] := ['Array1_1', 'Array1_2', 'Array1_3', 'Array1_4'];
      TheArrays[2] := ['Array2_1', 'Array2_2'];
      TheArrays[3] := ['Array3_1'];
      TheArrays[4] := ['Array4_1', 'Array4_2'];
      for I := High(TheArrays) downto 0 do
        if InStringArray(S, TheArrays[I]) then
          WriteLn(I);
    end.

  7. #7
    Join Date
    Oct 2010
    Location
    Under a bridge
    Posts
    648
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks Zyt3x that helps a load

    Thanks all
    Quote Originally Posted by DD on IRC
    wanted to troll the troll

  8. #8
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    isnt there an srl function that returns the chat box into an array or something of that nature?
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  9. #9
    Join Date
    Oct 2010
    Location
    Under a bridge
    Posts
    648
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Umm do you know why this does not compile?
    Simba Code:
    Function CheckIfInChat:integer;
    Var x,y,s:integer;
        TheArrays:T2DStringArray;
    Begin
      S := GetChatBoxText(8,clfriend)
      SetLength(TheArrays, 5);
      TheArrays[0] := ['Hi', 'Hello', 'Hi all'];
      TheArrays[1] := ['Array1_1', 'Array1_2', 'Array1_3', 'Array1_4'];
      TheArrays[2] := ['Array2_1', 'Array2_2'];
      TheArrays[3] := ['Array3_1'];
      TheArrays[4] := ['Array4_1', 'Array4_2'];
        For I := High(TheArrays) DownTo 0 Do
          If InStringArray(S, TheArrays[I]) Then
            Result := I
    End;

    Thanks
    Quote Originally Posted by DD on IRC
    wanted to troll the troll

  10. #10
    Join Date
    Feb 2006
    Posts
    3,044
    Mentioned
    4 Post(s)
    Quoted
    21 Post(s)

    Smile Try this.

    Try this

    Simba Code:
    program new;
    {$i srl\srl.scar}



    // By Nava
    function InStrArray(s: String; a: TStringArray): Boolean;
    var
      i, h: Integer;
    begin
      Result := True;
      h := High(a);
      for i := 0 to h do
      begin
        if (s = a[i]) then
          Exit;
      end;
      Result := False;
    end;







    Function CheckIfInChat:integer;
    Var
        i: Integer;
        TheArrays: Array Of TStringArray;
        S: String;
    Begin
      S := GetChatBoxText(8,clfriend);
      SetLength(TheArrays, 5);
      TheArrays[0] := ['Hi', 'Hello', 'Hi all'];
      TheArrays[1] := ['Array1_1', 'Array1_2', 'Array1_3', 'Array1_4'];
      TheArrays[2] := ['Array2_1', 'Array2_2'];
      TheArrays[3] := ['Array3_1'];
      TheArrays[4] := ['Array4_1', 'Array4_2'];
        For I := High(TheArrays) DownTo 0 Do
          if InStrArray(S, TheArrays[I]) Then
            Result := I
    End;


    begin
    SetupSRL;
    CheckIfInChat;
    end.


    ~Home

  11. #11
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

  12. #12
    Join Date
    Feb 2006
    Posts
    3,044
    Mentioned
    4 Post(s)
    Quoted
    21 Post(s)

    Smile

    Quote Originally Posted by Shuttleu View Post
    im pretty sure than InStrArray is already in simba...

    ~shut
    Ye, I thought so too. But it wasn't there


    ~Home

  13. #13
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

  14. #14
    Join Date
    Feb 2006
    Posts
    3,044
    Mentioned
    4 Post(s)
    Quoted
    21 Post(s)

    Smile Okay a new one.

    Ok this one should do the trick


    Simba Code:
    program new;
    {$i srl\srl.scar}


    type
      T2DStringArray = array of TStringArray;


    var
      TheArrays : T2DStringArray;
      I : Integer;




    Function CheckIfInChat:integer;
    Var
        S: String;
    Begin
      S := GetChatBoxText(8,clfriend);
      SetLength(TheArrays, 5);
      TheArrays[0] := ['Hi', 'Hello', 'Hi all'];
      TheArrays[1] := ['Array1_1', 'Array1_2', 'Array1_3', 'Array1_4'];
      TheArrays[2] := ['Array2_1', 'Array2_2'];
      TheArrays[3] := ['Array3_1'];
      TheArrays[4] := ['Array4_1', 'Array4_2'];
        For I := High(TheArrays) DownTo 0 Do
          if InStrArr(S, TheArrays[I], False) Then
            Result := I
    End;


    begin
    SetupSRL;
    CheckIfInChat;
    end.


    ~Home

  15. #15
    Join Date
    Oct 2010
    Location
    Under a bridge
    Posts
    648
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    saw no point in a new thread, but a new question
    For MouseBox what is the parameter clickType?
    Thanks again
    Quote Originally Posted by DD on IRC
    wanted to troll the troll

  16. #16
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

  17. #17
    Join Date
    Dec 2009
    Location
    Newcastle, Australia
    Posts
    888
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    1 - left click
    2 - Right Click
    3 - Move Mouse

    Current Script Project
    Pot of flour gatherer - 95% done

    Can't get Simba to work? Click here for a tutorial

  18. #18
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    mouse_Left, mouse_Right or mouse_Move

  19. #19
    Join Date
    Oct 2010
    Location
    Under a bridge
    Posts
    648
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thank a ton guys for all your help
    Im trying to send text. I needs to be from the array which is set in the parameter but can be from any in that array.
    Simba Code:
    Function Reply(A:Integer):Boolean;
    Var
        i: Integer;
        TheArrays: Array Of TStringArray;
        S: String;
    Begin

      TheArrays[0] := ['Hi', 'Hello', 'Hi all'];
      TheArrays[1] := ['Array1_1', 'Array1_2', 'Array1_3', 'Array1_4'];
      TheArrays[2] := ['Array2_1', 'Array2_2'];
      TheArrays[3] := ['Array3_1'];
      TheArrays[4] := ['Array4_1', 'Array4_2'];

      For I := High(TheArrays) DownTo 0 Do
        If I = A Then
        Begin
          TypeSendEx(TheArrays[I],True);
          writeln('Said '+TheArrays[I]);
        End;

    End;
    I tryed this but got compileing errors

    Thanks again for all your help, i know it seems like a lot but im find most my questions out my self
    Quote Originally Posted by DD on IRC
    wanted to troll the troll

  20. #20
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    TheArrays is an array of array of String, meaning if you want to use it with TypeSendEx() you'll have to do TypeSendEx(TheArray[Index1][Index2], True);

    It doesn't look like you're even using the other arrays, so I assume you meant to do TypeSendEx(TheArrays[0][I], True); but in that case you're gonna end up with a runtime error because you have to change stuff in the loop too

    I hope you understand what I'm saying here..
    You could try reading a tutorial on arrays if you're having troubles

  21. #21
    Join Date
    Sep 2008
    Location
    My House
    Posts
    519
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Sorry to intrude on your thread but I dont want to make another. What is "Indent : Integer" and "IdentType : String"
    Still learning to code in Simba.

  22. #22
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Quote Originally Posted by death12652 View Post
    Sorry to intrude on your thread but I dont want to make another. What is "Indent : Integer" and "IdentType : String"
    In what procedure/function?
    There used to be something meaningful here.

  23. #23
    Join Date
    Nov 2010
    Location
    Australia
    Posts
    1,472
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Quote Originally Posted by death12652 View Post
    Sorry to intrude on your thread but I dont want to make another. What is "Indent : Integer" and "IdentType : String"
    They're variables......Or did you mean to ask what they're used for.

  24. #24
    Join Date
    Sep 2008
    Location
    My House
    Posts
    519
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    In WithdrawItem() I know there variables yes what there used for.
    Still learning to code in Simba.

  25. #25
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    I think the first one could be a DTM/Bitmap, and the type would be 'dtm' or 'bitmap'.
    There used to be something meaningful here.

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
  •