SRL Archive - OSR Outdated Tutorials

Making your first Eating procedure


marpis

2009-08-14 14:06:29

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!


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 :p lawl how did i get the scripters cup

Eduard

2009-08-15 19:42:53

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

marpis

2009-08-15 22:20:10

From: Eduard
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:

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;

Mr. Doctor

2009-08-16 09:40:34

I wonder what gave you this idea to make this tutorial :p

Baked0420

2009-08-16 09:50:09

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 ;)

L2Program

2010-02-25 22:02:12

Nice tutorial, easy to understand!

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

Mr. Doctor

2010-02-25 22:03:57

Try,


if(hppercent<20)then

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

L2Program

2010-02-25 22:13:54

From: Junkj
Try,


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.

toto89

2012-03-06 14:57:14

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.