Results 1 to 16 of 16

Thread: Some functions...

  1. #1
    Join Date
    Nov 2007
    Location
    Chile
    Posts
    1,901
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Some functions...

    I wrote some functions:

    - function A:
    SCAR Code:
    function SmeltingScreen: boolean;
    var
      x,y : integer;
    begin
      result := FindText(x, y, 'smelt', npcchars, 155, 354, 374, 387);
    end;
    for smithing.scar.

    - function B:
    SCAR Code:
    function FindCookedFishInInv(Tol : integer; var x,y : integer; fish : string): boolean;
    begin
      GameTab(4);
      case lowercase(fish) of
        'shrimps': if FindBitmapToleranceIn(srl_GetBitmap(76), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
        'anchovies': if FindBitmapToleranceIn(srl_GetBitmap(77), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
        'tuna': if FindBitmapToleranceIn(srl_GetBitmap(78), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
        'trout': if FindBitmapToleranceIn(srl_GetBitmap(79), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
        'pike': if FindBitmapToleranceIn(srl_GetBitmap(80), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
        'salmon': if FindBitmapToleranceIn(srl_GetBitmap(81), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
        'lobster': if FindBitmapToleranceIn(srl_GetBitmap(82), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
        'swordfish': if FindBitmapToleranceIn(srl_GetBitmap(83), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
        else
        Writeln('Invalid option');
        Result := False;
      end; // case
    end;
    for cooking.scar, you have to include srl/srl/misc/bitmaps.scar, but, it gave me this error:
    Line 14: [Error] (12595:1): Duplicate identifier 'srl_Bitmaps' in script

    -function C:
    SCAR Code:
    function FindRawFishInInv(Tol : integer; var x,y : integer; fish : string): boolean;
    begin
      GameTab(4);
      case lowercase(fish) of
        'shrimps': if FindBitmapToleranceIn(srl_GetBitmap(86), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
        'anchovies': if FindBitmapToleranceIn(srl_GetBitmap(87), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
        'tuna': if FindBitmapToleranceIn(srl_GetBitmap(88), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
        'trout': if FindBitmapToleranceIn(srl_GetBitmap(89), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
        'pike': if FindBitmapToleranceIn(srl_GetBitmap(90), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
        'salmon': if FindBitmapToleranceIn(srl_GetBitmap(91), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
        'lobster': if FindBitmapToleranceIn(srl_GetBitmap(92), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
        'swordfish': if FindBitmapToleranceIn(srl_GetBitmap(93), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
        else
        Writeln('Invalid option');
        Result := False;
      end; // case
    end;
    for cooking.scar, but the same error as the function B...

    - function D:
    SCAR Code:
    function CookScreen: boolean;
    var
      x,y : integer;
    begin
     result := FindText(x, y, 'cook', npcchars, 137, 355, 384, 385);
    end;


  2. #2
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    You got the error, because you exactly are not supposed to include it - it's already being included.

    Also, it might look cleaner if you make a new integer, "bmp", and just define the bmp in the case, and then do just one FindBitmap...

  3. #3
    Join Date
    Nov 2006
    Location
    NSW, Australia
    Posts
    3,487
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    function FindCookedFishInInv(Tol : integer; var x,y : integer; fish : string): boolean;
    begin
      GameTab(4);
      case lowercase(fish) of
        'shrimps': BitmapNumber := 76;
        'anchovies': BitmapNumber := 77;
        'tuna': BitmapNumber := 78;
        'trout': BitmapNumber := 79;
        'pike': BitmapNumber := 80;
        'salmon': BitmapNumber := 81;
        'lobster': BitmapNumber := 82;
        'swordfish': BitmapNumber := 83;
      else
        Writeln('Invalid option');
        Result := False;
        Exit;
      end;
      if FindBitmapToleranceIn(srl_GetBitmap(BitmapNumber), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then
        Result := True;

      srl_FreeBitmaps;
    end;

    [CENTER][img]http://signatures.mylivesignature.com/54486/113/4539C8FAAF3EAB109A3CC1811EF0941B.png[/img][/CENTER]
    [CENTER][BANANA]TSN ~ Vacation! ~ says :I Love Santy[/BANANA][/CENTER]

    [CENTER][BANANA]Raymond - Oh rilie? says :Your smart[/BANANA][/CENTER]

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

    Default

    i use this for my bar screen. im guessing it would work with the cooking screen too.
    SCAR Code:
    Function BarScreen:boolean;
    begin
      result:=GetColor(37, 373)=10264383
    end;

  5. #5
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    From my cooker:

    SCAR Code:
    Until FindNpcChatText('aw', ClickRight);
          Wait(50 + Random(100));
          ChooseOption('All');

    FindNpcChatText should work...



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  6. #6
    Join Date
    Nov 2007
    Location
    Chile
    Posts
    1,901
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    i tried my find cook screen and find smelt screen and booth worked


  7. #7
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Instead of searching for text it might be better to search for a colour instead or check for the existance of a colour. Its a lot faster searching for a colour than searching for text.

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

    Default

    Maybe make a bitmap???
    Make it small takes less than a sec to find a well made bitmap.

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

    Default

    or do one simple getcolor as in post #4

  10. #10
    Join Date
    Nov 2007
    Location
    Chile
    Posts
    1,901
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Maybe getcolor could be faster... but i think finding a text is more accurate.


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

    Default

    not if the color is constant and never changes places and is a very odd color in the first place. (for the smithing screen - the jewel or whatever on the sword in the top right corner)

  12. #12
    Join Date
    Nov 2006
    Location
    NSW, Australia
    Posts
    3,487
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    I prefer to use a couple of GetColors, just in case anything odd happens and it finds the same colour in 2 different screens.
    [CENTER][img]http://signatures.mylivesignature.com/54486/113/4539C8FAAF3EAB109A3CC1811EF0941B.png[/img][/CENTER]
    [CENTER][BANANA]TSN ~ Vacation! ~ says :I Love Santy[/BANANA][/CENTER]

    [CENTER][BANANA]Raymond - Oh rilie? says :Your smart[/BANANA][/CENTER]

  13. #13
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    You could do a compromise - use FindTextTPA

  14. #14
    Join Date
    Nov 2006
    Location
    NSW, Australia
    Posts
    3,487
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by n3ss3s View Post
    You could do a compromise - use FindTextTPA
    I wanted to use that for ClickToContinue...but I'm not sure which chars I'm meant to be using...
    [CENTER][img]http://signatures.mylivesignature.com/54486/113/4539C8FAAF3EAB109A3CC1811EF0941B.png[/img][/CENTER]
    [CENTER][BANANA]TSN ~ Vacation! ~ says :I Love Santy[/BANANA][/CENTER]

    [CENTER][BANANA]Raymond - Oh rilie? says :Your smart[/BANANA][/CENTER]

  15. #15
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    The click to continue text is NPCChars.

  16. #16
    Join Date
    Nov 2006
    Location
    NSW, Australia
    Posts
    3,487
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by ZephyrsFury View Post
    The click to continue text is NPCChars.
    Well then, I was using the right one and FindTextTPA was being stupid
    [CENTER][img]http://signatures.mylivesignature.com/54486/113/4539C8FAAF3EAB109A3CC1811EF0941B.png[/img][/CENTER]
    [CENTER][BANANA]TSN ~ Vacation! ~ says :I Love Santy[/BANANA][/CENTER]

    [CENTER][BANANA]Raymond - Oh rilie? says :Your smart[/BANANA][/CENTER]

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Functions
    By lordsaturn in forum OSR Help
    Replies: 1
    Last Post: 08-13-2007, 10:12 PM
  2. Help with some functions
    By Pinqvin in forum OSR Help
    Replies: 6
    Last Post: 03-06-2007, 01:34 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
  •