SRL Archive - Simba (Testing) Scripts

Bitmap loader in Simba?


Blue90

2011-11-09 16:34:41

Wonder where its at, as I am reading the intermediate section of scripting*scar*version, and currently, I am unable to find bitmap loader to extract a color…

Wizzup?

2011-11-09 16:36:42

What do you mean, extract a colour?
You could simply open the bitmap and use the colour picker.

Shuttleu

2011-11-09 18:10:33

i think he means like in scar, you can put in the bitmap string and it will show the bitmap, Simba is missing this and i have mentioned it before

~shut

Wizzup?

2011-11-09 18:28:06

From: Shuttleu
i think he means like in scar, you can put in the bitmap string and it will show the bitmap, Simba is missing this and i have mentioned it before

~shut


File a bug.

Alternatively, you can just load it from string and use GetMufasaBitmap(bmp).SaveToFile(''); or even SaveBitmap(bmp);

where bmp := LoadBitmapFromString('');

Blue90

2011-11-09 19:11:16

http://villavu.com/forum/showpost.php?p=618674&postcount=3

I ment how its used in the tut

Shuttleu

2011-11-09 19:14:07

From: Blue90
http://villavu.com/forum/showpost.php?p=618674&postcount=3

I ment how its used in the tut


i see

just replace it with paint

so paste your screen in paint, select your selection and save it as a bmp

then in the tools menu in simba you can convert it to a string

~shut

Blue90

2011-11-09 19:22:16

:P i should have done that before, sorry :(

Shuttleu

2011-11-09 19:23:15

From: Blue90
:P i should have done that before, sorry :(


nothing wrong with asking for help, i do it all the time, i even asked for help on here yesterday

~shut

Blue90

2011-11-09 20:10:41

I have no clue how I can add this string this bitmap() to this script
program ClickWillowLogs;
{.include SRL/SRL.scar}//Remember to include this in ALL of your scripts if you want to use functions from SRL.

function ClickLogs: Boolean;
var
Logs, x, y : Integer;{Declared locally this time because we are only using it in this function. :)
We also need to declare 'x, y' so that the coordinates of the bitmap can be stored in them}
begin
Logs := BitmapFromString(5, 5, 'beNpzkIzwVyAShfjIQUggCvCQ' +
'9XGRtjUXc7KWACJ3B0l3AM9zEjg=');
GameTab(tab_Inv);//GameTab stands for all the different tabs in the RS interface. "(tab_Inv)" clicks on the inventory tab. A full list of the gametabs can be found in Gametab.scar in your SRL folder.
if FindBitmapToleranceIn(Logs, x, y, MIX1, MIY1, MIX2, MIY2, 15) then//Remember that MI = Main Inventory.
begin
Writeln('Found Willow log bitmap!');
MMouse(x, y, 4, 4);//Moves the mouse to the bitmap. Remember MMouse from earlier?
if IsUpText('illow') then//Checks the uptext of the object. Uptext is the text in the upper left corner of the RS main screen.
begin
Wait(200 + Random(100));//You should always have a random wait after checking an uptext because the uptext doesn't appear at the millisecond you mouse over the object.
Mouse(x, y, 0, 0, True);//No randomness is needed because the mouse is already on the object.
Result := True;//Make the result true after it has clicked the logs.
end else
Writeln('Couldn''t find the correct uptext of the logs.');
end else
Writeln('Couldn''t find the log bitmap');
FreeBitmap(Logs);//You MUST include this line. This frees the bitmap, otherwise it will say loaded and make your script much slower.
end;

begin
ClearDebug;
SetupSRL;//Don't forget this line in ANY of your RS scripts!
ActivateClient;//This is needed so the script switches to the RS window. If you have a DeclarePlayers procedure, it is not needed, as it is already built in.
Wait(1000 + Random(500));//This is just in case of possible lag, that SCAR has time to switch to the RS client.
if ClickLogs then//The condition will be true if it clicks the log. See the connection between that and the actual function?
Writeln('We have clicked the Willow logs!')
else
Writeln('We have not clicked the Willow logs.');
end.

Rick

2011-11-09 20:32:00

Tools -> Bitmap Conversion
Open the image and press the 'To String' button.

Copy the text from the debug box. Should be something like this:

Bmp := BitmapFromString(181, 157, 'a really long string');

Replace:

Logs := BitmapFromString(5, 5, 'beNpzkIzwVyAShfjIQUggCvCQ' +
'9XGRtjUXc7KWACJ3B0l3AM9zEjg=');

with the output code. Make sure you keep the variable 'Logs' though.

Blue90

2011-11-09 21:19:48

doesnt seem to click on my super str? Is there a way I can load rs on simba to test developments.
:= BitmapFromString(48, 41, 'meJzNmO1TE1cUxp3+IY46fugAOj' +
'E0I2USAyYWEAZsoShFXmISiAiVUUeEAVIoUF5SUQkJL4IEQgwIjRS' +
'GtlM/2LH/lz549Myde7Mv2fBB5pmdzeZyz2+fc87eu3n//sv6O114' +
'4czXRThCBd84RdlKL2tJGmlNhRdd50rKMBuOfEI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Sqir667JhV56LTWZ' +
'KbQP3FB5qISOSvojz7NnC2Nj01RCPl/QTBVZWE8xLRz4c/9fSUCSe' +
'KLR5YmJCJUQHuFmLLLmD/KSlQemccuDZz72HC0/PDxGJdTc3G74tp' +
'irP7xGqDwQlTQ/EuPxVbTYLyMT8Ke+vpF3RDqxxF8SzJCwRdTjVDk' +
'Ec3DwRuJZXFwbH58BTE1Nncm9ouiPIZKaNRQMrxfcYvRIXFpKAIYe' +
'hlowal7U549JYTAFIn0C+9hiaHmCEUmywqgO5Ll/5lgiG0uLRKsMm' +
'Id/iTLpjD6bKDW6uv8RJ7ScLzNSl2mdV2ZevwBDW3o60g6fJP46yh' +
'7SMP5FlEZKJ9IAsYvpIzYV4pwc4gMgk7N6');

Rick

2011-11-09 21:41:08

I would recommend making your bitmap smaller (there's a white strip along the top of the image; remove that) and possibly increasing the tolerance in 'FindBitmapToleranceIn'.

If that doesn't work, you could try to use DTM's.

Edit: And to answer your question, yes, you could include SMART. But for now I would just open the image in paint and try to recognise it there.

Try playing around with this:


program new;

var
Bmp, w, h, x, y: Integer;

begin
Bmp := *your bitmap*;

GetBitmapSize(Bmp, w, h);
DisplayDebugImgWindow(w, h);
DrawBitmapDebugImg(Bmp);

GetClientDimensions(w, h);

if FindBitmapToleranceIn(Bmp, x, y, 0, 0, w, h, 30) then
MoveMouse(x, y);

FreeBitmap(Bmp);
end.

Blue90

2011-11-09 21:42:11

oh it worked, its just the fact how do i test those on runescape?

Phran6

2011-11-09 21:53:12

Some tips:

Just use a part of the vial for the bitmap
and don't have part of inventory because it is not a static color
you can paint in black what you dont want the bitmap to look for (inventory background color).

mrpickle

2011-11-09 21:55:04

I still use Scar for its Very VERY convenient Bitmap converting function :).

KingKong

2011-11-09 23:15:47

From: Blue90
oh it worked, its just the fact how do i test those on runescape?


open up runescape client, select the client with the crosshair in simba and then run the script.

Blue90

2011-11-09 23:18:18

Yeah I selected the client, its not working tho. :(. I actually do that everytime I wanna test a procedure out… Wish there was a simba tut :( other then the beginner one.

KingKong

2011-11-09 23:32:37

What code did you try to run? because it never fails for me.

Blue90

2011-11-10 02:21:18

Um, i just deleted it, but I tried the tut code the (willow log click) procedure, instead of a willow bitmap I replaced it with a super str bitmap. I clicked the client I was going to be using and it didnt do anything but execute… heres the code
program ClickWillowLogs;
{.include SRL/SRL.scar}//Remember to include this in ALL of your scripts if you want to use functions from SRL.

function ClickLogs: Boolean;
var
Logs, x, y : Integer;{Declared locally this time because we are only using it in this function. :)
We also need to declare 'x, y' so that the coordinates of the bitmap can be stored in them}
begin
Logs := BitmapFromString(5, 5, 'beNpzkIzwVyAShfjIQUggCvCQ' +
'9XGRtjUXc7KWACJ3B0l3AM9zEjg=');
GameTab(tab_Inv);//GameTab stands for all the different tabs in the RS interface. "(tab_Inv)" clicks on the inventory tab. A full list of the gametabs can be found in Gametab.scar in your SRL folder.
if FindBitmapToleranceIn(Logs, x, y, MIX1, MIY1, MIX2, MIY2, 15) then//Remember that MI = Main Inventory.
begin
Writeln('Found Willow log bitmap!');
MMouse(x, y, 4, 4);//Moves the mouse to the bitmap. Remember MMouse from earlier?
if IsUpText('illow') then//Checks the uptext of the object. Uptext is the text in the upper left corner of the RS main screen.
begin
Wait(200 + Random(100));//You should always have a random wait after checking an uptext because the uptext doesn't appear at the millisecond you mouse over the object.
Mouse(x, y, 0, 0, True);//No randomness is needed because the mouse is already on the object.
Result := True;//Make the result true after it has clicked the logs.
end else
Writeln('Couldn''t find the correct uptext of the logs.');
end else
Writeln('Couldn''t find the log bitmap');
FreeBitmap(Logs);//You MUST include this line. This frees the bitmap, otherwise it will say loaded and make your script much slower.
end;

begin
ClearDebug;
SetupSRL;//Don't forget this line in ANY of your RS scripts!
ActivateClient;//This is needed so the script switches to the RS window. If you have a DeclarePlayers procedure, it is not needed, as it is already built in.
Wait(1000 + Random(500));//This is just in case of possible lag, that SCAR has time to switch to the RS client.
if ClickLogs then//The condition will be true if it clicks the log. See the connection between that and the actual function?
Writeln('We have clicked the Willow logs!')
else
Writeln('We have not clicked the Willow logs.');
end.
. I replaced the bitmap with this code
:= BitmapFromString(48, 41, 'meJzNmO1TE1cUxp3+IY46fugAOj' +
'E0I2USAyYWEAZsoShFXmISiAiVUUeEAVIoUF5SUQkJL4IEQgwIjRS' +
'GtlM/2LH/lz549Myde7Mv2fBB5pmdzeZyz2+fc87eu3n//sv6O114' +
'4czXRThCBd84RdlKL2tJGmlNhRdd50rKMBuOfEIkEg99CxW7K3SoC' +
'Ex/AEWRPrKkMSKPagvB4EiSotjdV9SP0sWswhjMRkdVWZ3RGo+LLP' +
'rIwOJXFFQaxveoL5FH9PBoKpfB/4rMhrG0DNHn4WxKw8zcmqHMIKm' +
'VY/JGsuqrEycgnQHfeqr0Z1BhLPOA5LSn+qTLa0hlyCO2njUeADi6' +
'+4pDDy4Ee22+7vMtIWtIojmGBazP451agMpGnjj7fzvXHMSVU6dse' +
'fFYhWGe8vE51+B06cNfi5r81rIm8VijotCXJ+bJnJJ74cIbPrvN5r' +
'DbRSTDYj4WfxCxqfFHVsO1a3U11VcrKiq8Xk9ZWa5ZYx7LxYOI7Td' +
'vsn663gik2uqrlVe8JQ6HZZ58/On034KCPp+/ra2lqemHutqaqipn' +
'aWlRQUFOPEjosfDc6ex8sRhficWg2emp8MDAJaeTigowhjwcmnjEh' +
'491pI6OntshKNDehpSVuy8ZwmQt72Ppd4TuDnWSwIOq9paX62cKMF' +
'o8RQ43bzNyFTUCpYx0q7X1RkMDmouKOdcJef3Kx5zbwUBXRxApA4+' +
'vteV6Q311ZaXb5SKLzNwpe0Xr+9EGI49+D/n9oUAAVAFfO4oH/nxf' +
'W/udx4MWy9Wis/aS7PVjAo9uChFT65up9WQqkVxaWFyIxmJz0cczv' +
'w8NDP18p0eqIrVs6ApdFPvLsjm7fxy+++//t2/e/rV/+Ho3s53aSi' +
'aSiZW1eDQWmYqMhEcki0Qe6Zx51A2hVn4lmOXl9Uzm8Eiv/97ZOUi' +
'nM6nUbmJ9a3V1E19NTj6+f/+RVqOJtvBFfg8yxFCREAgMICHhfGt7' +
'j3herL0Ez9T0bF/fIPGoVmStDeKxsAdDFARlGAiJA8/LdGZjY5t4Z' +
'mae9vcP9/Tc06lqiU16+8uJB9FFHmTt1at98CQ3dxKJNHgikbnBod' +
'He3oeGKSv+vGpovZBKCZJoMT8i7u39I4p40gLP7Ox8ODyOEsKT0mT' +
'jS+uFmDiGV93D5PBB5vlc0sTzfGXjydP46OgkSqir667JhV56LTWZ' +
'KbQP3FB5qISOSvojz7NnC2Nj01RCPl/QTBVZWE8xLRz4c/9fSUCSe' +
'KLR5YmJCJUQHuFmLLLmD/KSlQemccuDZz72HC0/PDxGJdTc3G74tp' +
'irP7xGqDwQlTQ/EuPxVbTYLyMT8Ke+vpF3RDqxxF8SzJCwRdTjVDk' +
'Ec3DwRuJZXFwbH58BTE1Nncm9ouiPIZKaNRQMrxfcYvRIXFpKAIYe' +
'hlowal7U549JYTAFIn0C+9hiaHmCEUmywqgO5Ll/5lgiG0uLRKsMm' +
'Id/iTLpjD6bKDW6uv8RJ7ScLzNSl2mdV2ZevwBDW3o60g6fJP46yh' +
'7SMP5FlEZKJ9IAsYvpIzYV4pwc4gMgk7N6');
. I will most likely do what rick said, I feel that he gave me a good direction to go towards on learning more about the code. Thanks Rick! :)

KingKong

2011-11-10 05:50:43

Try going to some other tab than inventory and see if it clicks on the inventory tab, if it does, then the script cant find the logs, if it doesn't click on inventory tab then you didn't set the client correctly.

Blue90

2011-11-10 21:17:13

From: Rick
I would recommend making your bitmap smaller (there's a white strip along the top of the image; remove that) and possibly increasing the tolerance in 'FindBitmapToleranceIn'.

If that doesn't work, you could try to use DTM's.

Edit: And to answer your question, yes, you could include SMART. But for now I would just open the image in paint and try to recognise it there.

Try playing around with this:


program new;

var
Bmp, w, h, x, y: Integer;

begin
Bmp := *your bitmap*;

GetBitmapSize(Bmp, w, h);
DisplayDebugImgWindow(w, h);
DrawBitmapDebugImg(Bmp);

GetClientDimensions(w, h);

if FindBitmapToleranceIn(Bmp, x, y, 0, 0, w, h, 30) then
MoveMouse(x, y);

FreeBitmap(Bmp);
end.



Sorry to bother you guys again, I experience this when i add the bitmap to the code.

Error: Exception: You passed a wrong xe to a finder function: 765. The client has a width of 765, thus the xe is out of bounds. at line 44
The following bitmaps were not freed: [0]

Whenever someone gets the time and feels like doing something good for the community and or someone else, I would more then appriciate some help coding :( i've been trying and trying and cant seem to get anywhere. My msn is [email]Blue_eyed_kings@hotmail.com[/email]

Error: Exception: You passed a wrong xe to a finder function: 765. The client has a width of 765, thus the xe is out of bounds. at line 45
The following bitmaps were not freed: [0]


I keep getting this error code whenever I start it.

KingKong

2011-11-11 01:48:19

Do this: if FindBitmapToleranceIn(Bmp, x, y, 0, 0, w-1, h-1, 30) then