Results 1 to 7 of 7

Thread: Finding Number in ChatText?

  1. #1
    Join Date
    Dec 2011
    Location
    Toronto, Ontario
    Posts
    6,424
    Mentioned
    84 Post(s)
    Quoted
    863 Post(s)

    Default Finding Number in ChatText?

    Here's what I have so far.



    Simba Code:
    function GetTaskAmount:Integer;
    var
      i,revAmount:Integer;
      sAmount:String;
    begin
      if not FindBlackChatMessage('assign') then
        exit;
      for i := 1 to 300 do //300 is the max number of monsters she can assign
      begin
        sAmount := IntToStr(i);
        if FindBlackChatMessage(sAmount) then
        begin
          writeLn(sAmount);
          revAmount :=  StrToInt(sAmount);
        end;
      end;
    end;

    Code:
    SRL Compiled in 0 msec
    1
    2
    5
    12
    25
    125
    Successfully executed.
    I was thinking of using High(revAmount) as the thing.

    Is there any better way to do this?

  2. #2
    Join Date
    Oct 2011
    Location
    UK
    Posts
    1,322
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Shay View Post
    Here's what I have so far.



    Simba Code:
    function GetTaskAmount:Integer;
    var
      i,revAmount:Integer;
      sAmount:String;
    begin
      if not FindBlackChatMessage('assign') then
        exit;
      for i := 1 to 300 do //300 is the max number of monsters she can assign
      begin
        sAmount := IntToStr(i);
        if FindBlackChatMessage(sAmount) then
        begin
          writeLn(sAmount);
          revAmount :=  StrToInt(sAmount);
        end;
      end;
    end;

    Code:
    SRL Compiled in 0 msec
    1
    2
    5
    12
    25
    125
    Successfully executed.
    I was thinking of using High(revAmount) as the thing.

    Is there any better way to do this?
    how about GetNumbers with StrToInt...

    so:
    Simba Code:
    for i := 1 to 8 do
      if(FindChatBoxText('assign', i, clMessage))then
        break;
      if((i = 8) and (not FindChatBoxText('assign', 8, clMessage)))then//just incase it didn't find it...
        exit;
      S := GetNumbers(GetChatBoxText(i, clMessage));
      if(S <> '')then
        i := StrToInt(i);
    Last edited by putonajonny; 06-19-2012 at 04:08 PM.

  3. #3
    Join Date
    Dec 2011
    Location
    Toronto, Ontario
    Posts
    6,424
    Mentioned
    84 Post(s)
    Quoted
    863 Post(s)

    Default

    Aha! I got it working, thank you!
    Thread can be closed..

    Simba Code:
    function GetTaskAmount:Integer;
    var
      i,hAmount,revAmount:Integer;
      sAmount:String;
    begin
      if not FindBlackChatMessage('assign') then
        exit;
      for i := 1 to 300 do //300 is the max number of monsters she can assign
      begin
        sAmount := IntToStr(i);
        if FindBlackChatMessage(sAmount) then
        begin
          writeLn(sAmount);
          revAmount :=  StrToInt(sAmount);
        end;
      end;
      Result := (revAmount)
      writeLn(IntToStr(Result));
    end;

  4. #4
    Join Date
    Oct 2011
    Location
    UK
    Posts
    1,322
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Shay View Post
    Aha! I got it working, thank you!
    Thread can be closed..
    So not my super efficient way...

  5. #5
    Join Date
    Sep 2007
    Location
    British Columbia, Canada
    Posts
    4,047
    Mentioned
    1 Post(s)
    Quoted
    2 Post(s)

    Default

    or
    Simba Code:
    find text between 'only', 'more'

    something like that (search text between).

    EDIT:
    Simba Code:
    function Between(s1, s2, str: string): string;
    Oh Hai Dar

  6. #6
    Join Date
    Dec 2011
    Location
    The Netherlands
    Posts
    1,631
    Mentioned
    47 Post(s)
    Quoted
    254 Post(s)

    Default

    Quote Originally Posted by Main View Post
    or
    Simba Code:
    find text between 'only', 'more'

    something like that (search text between).

    EDIT:
    Simba Code:
    function Between(s1, s2, str: string): string;
    I used something like this

    Simba Code:
    procedure TokensUpdate;
    var
      i: Integer;
      TokensBox: TBox;
      TokensBoxTPA: TPointArray;
      TokensGainedString: String;
      NumbersCheck: Array of String;

    begin
      TokensGainedString := GetChatBoxText(8, clBlack);
      NumbersCheck := ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'];

      for i:=0 to 10 do
        begin
          if Pos(NumbersCheck[i], TokensGainedString) > 0 then
            begin
              TokensGained := StrToInt(GetNumbers(TokensGainedString));
              Tokens := (Tokens + TokensGained);
              TokensBox := IntToBox(289, 456, 350, 470);
              TPAFromBoxWrap(TokensBox, TokensBoxTPA);
              SMART_DrawDotsEx(False, TokensBoxTPA, RGBtoColor(194, 178, 146));
              SMART_DrawText(290, 457, UpChars, ''+IntToStr(Tokens)+'', clWhite);
              Exit;
            end;
        end;
    end;
    if the line contains numbers then use GetNumbers.. way more efficient than looping through everything.

    Script source code available here: Github

  7. #7
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Easiest one line solution:

    Simba Code:
    int meh := StrToIntDef(ExtractFromStr('OurStringOfTheChatHere', NUMBERS), 1);
    I am Ggzz..
    Hackintosher

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
  •