Results 1 to 9 of 9

Thread: Making your first Eating procedure

  1. #1
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default Making your first Eating procedure

    Eat Food

    1. Have food in your inventory
    2. Take a screenshot (Print screen, Prt Scr)
    3. In SCAR top menu, go to Tools -> Picture to String
    4. Hit the 'Paste' button. Search your food there, and select the area you want to be searched. Take only a small area to save memory and prevent lag
    5. Hit OK
    6. Look at SCAR debug box. Its full of strange code. It is the bitmap we just took in a text format. Now we have the bitmap to look for, lets do the procedure!


    SCAR Code:
    procedure EatFood;
    var
      FoodBMP: integer; // Declare a variable for the food. Must be integer!
      x, y: integer; // We need these too
    begin
      // Copy this from Debug box
      FoodBMP := BitmapFromString(12, 10, 'beNoBaAGX/jg0e2lbeWNWf' +
           '2pZeWRTfGlabl5OY1hGWVE+ZFlHZVpIXFBAUEQ0eGhZemdZd2RTcF' +
           'tKaVhIdGRUbmFQbGFPbWJQZltJW1A+UEQ0d2FWf2NYgmRZjG5jdVt' +
           'KfmlWc2dRdGlVaVxLc2ZWZVhIVUg4eWJUknZqfWBQhmtagmhZgWxb' +
           'ZFQ9Z1tFYVZAHxcEMicVRzstzKadv5SNjmZcd1FGf11TdVdMalVCb' +
           'FtJZllIXVFBXU9CW01ArIZ9vpOMzKCXzaKZvJaLclJFdlxLb1xLYV' +
           'FCYVNGXU9EWEo/tIeCr356w5CMk2JdkmdgtpGIeFpPYko+aFdNXU9' +
           'GZ1lQV0lArYJ8vo2JqXhzu4qFjF9ZkWtiqYl+d1xRY1FDZlVLUUU5' +
           'XlFJrIeBoXVyrIB9q398tI2IsZCJrpOMlYF6WklBWElCXE9HSz42r' +
           'ISCrYGAq3+ApHh5qoF/soyLooWBZ05KWUdDV0hDTEE9Q/bVkzs=');
      GameTab(tab_Inv); // Obviously go to inventory tab
      wait(100+random(20)); // Wait, just in case of a lagspike
      // It will search FoodBMP in area [MIX1, MIY1, MIX2, MIY2] with bitmaptolerance of 20.
      // If found, it will save the cords to x, y. Tolerance 20 is ok, don't care about that. :)
      if FindBitmapToleranceIn(FoodBMP, x, y, MIX1, MIY1, MIX2, MIY2, 20) then
      begin
        Mouse(x, y, 2, 2, true); // leftclick food
        writeln('Ate food successfully!');
        wait(1500+random(200));
      end;
      FreeBitmap(FoodBMP); // Remember to free your bitmaps, or they consume your RAM!
    end;

    EDIT: Sorry guys, i forgot FreeBitmap lawl how did i get the scripters cup
    Last edited by marpis; 08-16-2009 at 10:29 PM.

  2. #2
    Join Date
    Oct 2006
    Posts
    206
    Mentioned
    2 Post(s)
    Quoted
    45 Post(s)

    Default

    Nice good job!, and what if i wanted to check the total amount of money in the inventory. so lets say it uses the bitmap of the money, how do i check what the amount of money it is?

    GR Eduard

  3. #3
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Eduard View Post
    Nice good job!, and what if i wanted to check the total amount of money in the inventory. so lets say it uses the bitmap of the money, how do i check what the amount of money it is?

    GR Eduard
    Not rly related to this topic but i can answer.
    go to your SCAR folder /Includes/SRL/SRL/core/Amount.scar
    There you find function CoinAmount(area: string): integer.

    Here's how to use it:
    SCAR Code:
    procedure CheckMyMoney;
    var
      cash: integer; // variable for our money amount (integer = number)
    begin
      cash := CoinAmount('inv'); // counts coins in our inventory and saves the result to the variable 'cash'
      writeln('We have '+IntToStr(cash)+' dollarz'); // writes the result in debug box
    end;

  4. #4
    Join Date
    Jan 2007
    Posts
    834
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I wonder what gave you this idea to make this tutorial

  5. #5
    Join Date
    Mar 2008
    Location
    New Jersey
    Posts
    1,673
    Mentioned
    1 Post(s)
    Quoted
    9 Post(s)

    Default

    yea, I wonder... lol, but so people don't make the mistake Junkj did, (not meaning to call you out, just using you as an example since it came from your thread, and you made the mistake) you should add in that they should free the bitmap

  6. #6
    Join Date
    Feb 2010
    Posts
    46
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Nice tutorial, easy to understand!

    Trying to make it work so if my health falls under 3/4 it eats, any ideas

  7. #7
    Join Date
    Jan 2007
    Posts
    834
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Try,

    SCAR Code:
    if(hppercent<20)then

    Or which ever percent your HP falls under. I could give you my fighting script to look at.

  8. #8
    Join Date
    Feb 2010
    Posts
    46
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Junkj View Post
    Try,

    SCAR Code:
    if(hppercent<20)then

    Or which ever percent your HP falls under. I could give you my fighting script to look at.
    If it's fairly easy to understand drop me a pm . I want to add something to my pickpocket script now where if it can't find the colours of the target it presumes it is logged out, so it automatically jumps to the login procedure.

  9. #9
    Join Date
    Mar 2007
    Posts
    6
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Just curious. + I'm new to scripting. Couldn't you change:

    FoodBMP: integer; // Declare a variable for the food. Must be integer!
    x, y: integer; // We need these too
    To...

    FoodBMP, x, y: Integer;
    I'm not sure if that is do-able, just curious.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •