SRL Archive - RS3 Magic

Fady's Alch-O-Matic


fady

2015-03-11 01:10:11

Fady's Alch-O-Matic
Updated on: March 19th 2015
Last Tested on: May 5th 2015
Status: Fully Functional


Features:
  • Alchs all items in slots 1 to 26 in your backpack.
  • SRL Player Form support.
  • Break Support.
  • Antiban.
  • Not time dependent.
  • Should work great, even with a little lag.
  • Stops when you run out of either items to alch or nature runes.
  • Proggy based on High Alchemy.
  • Calculates profit using the GE prices of the items and the nature runes.

Directions:
  • Make sure your graphics/interface settings follow this guide.
  • Have your players set up using Rafiki.
  • Have your noted items in inventory slots 1 to 26, and your nature runes in slot 27 or 28. (slot 1 being top left, and 28 being bottom right).
  • Press play and fill out the Player Form.
  • Let the magic XP and the money flow!

CREDITS!!
  • @The Mayor for his tutorial, the breaking mechanism in his VEB Miner, and the item name grabber in his alcher from which mine was modeled.
  • @Camel for the Antiban procedure from his AirCrafter, which I have slightly modified.
  • @KeepBotting for part of the end detection in his iAlch script.

[spoiler=Change Log]
V1.01:
Modified the trigger for the initial alch after every antiban, every break, and at the initiation stage.
V1.02:
Fixed a bug where "Items left to Alch" on proggy didn't show the correct number when the script performed the login procedure.
V1.03:
Added Per Hour stats, a profit calculator. As well as some modifications to the flow of the script so it runs smoother[/spoiler]

Post those Proggys and let me know how it's going

niekasnieko

2015-03-11 07:36:52

Congratulations on the release Fady. :) Going to give it a try in a couple days.

General_Patrick

2015-03-11 12:27:25

Congratulations on release! Been looking for a high alc bot to use. I cannot wait to test it out and see how well it works.

Edit : Sadly, this bot suffers a similar problem to KeepBotting's alc bot where lag can accidentally put the bot to clicking on the noted item instead of alcing it. In other words, it shows up on the noted item,using hard leather boots as an example, use hard leather boots -> hard leather boots.

fady

2015-03-11 12:44:27

From: alkorith
Congratulations on release! Been looking for a high alc bot to use. I cannot wait to test it out and see how well it works.

Edit : Sadly, this bot suffers a similar problem to KeepBotting's alc bot where lag can accidentally put the bot to clicking on the noted item instead of alcing it. In other words, it shows up on the noted item,using hard leather boots as an example, use hard leather boots -> hard leather boots.


When does this usually happen? right at the beginning? after an antiban? after switching slots? or just during the middle of the process?
Also how bad of lag are we talking?

EDIT:

Try the updated version which is in the OP now, The script shouldn't be clicking the mouse for the following alch, unless it detects a change in Item count, or if the delay is more than 7 seconds (which can be increased if you wish). only the initiation process didn't have that feature because the item count change is almost instant. I had feared that it wouldn't be fast enough to detect it, but upon further testing, I have concluded that it is a stable addition to the script!

Try the new one and let me know how it goes!

General_Patrick

2015-03-11 19:02:57

From: fady
When does this usually happen? right at the beginning? after an antiban? after switching slots? or just during the middle of the process?
Also how bad of lag are we talking?


To answer your questions, the problem happens at around the beginning of the bot after 10-20 alcs. I have not let the bug continue until the bot reaches it's anti-bot phase and/or after switching spots. The lag is minimal, but there was probably some server lag that caused the bot to break.

I have yet your update, but hopefully it will fix my small gripes. Can't wait to try it out!

Edit:

I tested out the break feature, anti-ban feature, and item transition. Everything works as expected and the bug seems to be gone now with the delay you added. Thanks for the update!

The Mayor

2015-03-11 19:12:55

Looks nice ;) In my alcher I think I checked the mouseOverText before I clicked the item. Supposedly it still works even though it's in the outdated section

fady

2015-03-12 00:14:01

From: alkorith
To answer your questions, the problem happens at around the beginning of the bot after 10-20 alcs. I have not let the bug continue until the bot reaches it's anti-bot phase and/or after switching spots. The lag is minimal, but there was probably some server lag that caused the bot to break.

I have yet your update, but hopefully it will fix my small gripes. Can't wait to try it out!

Edit:

I tested out the break feature, anti-ban feature, and item transition. Everything works as expected and the bug seems to be gone now with the delay you added. Thanks for the update!


You're very welcome! Show me some Progress reports if you can! :D

From: The Mayor
Looks nice ;) In my alcher I think I checked the mouseOverText before I clicked the item. Supposedly it still works even though it's in the outdated section


Oh thats a good idea! I wonder if I can use that to make the script detect the item name, figure out GE/Alch prices and then calculate profit based on the number of alchs in that slot!!

Actually the more I think about that, the more complicated it seems to be lol.

General_Patrick

2015-03-12 01:23:12

From: fady
You're very welcome! Show me some Progress reports if you can! :D


Here is a recent progress report of the bot. I set the bot to run for only about 1.5 hours, but it worked like a charm!

Number of Alchs done: 1126
Items Left to go: -1125
XP Gained if High Alch: 73190
XP Gained if Low Alch: 34906
Time Running: 1 Hour, 39 Minutes and 42 Seconds
Antibans Done: 25
Breaks Taken: 2
Next Break in: 0h 18m 7s

The Mayor

2015-03-12 02:34:07

From: fady
You're very welcome! Show me some Progress reports if you can! :D



Oh thats a good idea! I wonder if I can use that to make the script detect the item name, figure out GE/Alch prices and then calculate profit based on the number of alchs in that slot!!

Actually the more I think about that, the more complicated it seems to be lol.


Well my script actually grabbed the item name, go look at it :p

fady

2015-03-19 01:26:35

From: The Mayor
Well my script actually grabbed the item name, go look at it :p


It took me a couple of days! but I finally figured It out! Turned out to be rather simple-ish once I finally figured it out tbh. Thank you for pointing me in that direction!!

The Mayor

2015-03-19 06:06:05

From: fady
It took me a couple of days! but I finally figured It out! Turned out to be rather simple-ish once I finally figured it out tbh. Thank you for pointing me in that direction!!


Looks nice!

webkinzdogs5

2015-03-24 16:28:59

Items Left to go: 45361
Alchs done: 10469 Done/H: 1004
XP Gained: 680485 XP/H: 65260
Profit: -2606781 Profit/H: -250034
Time Running: 10 Hours, 25 Minutes and 32 Seconds
We Have Done: 243 Antibans, and Taken: 1 Breaks
Next Break in: 10h 21m 4s
Successfully executed.

fady

2015-03-24 17:06:27

From: webkinzdogs5
Items Left to go: 45361
Alchs done: 10469 Done/H: 1004
XP Gained: 680485 XP/H: 65260
Profit: -2606781 Profit/H: -250034
Time Running: 10 Hours, 25 Minutes and 32 Seconds
We Have Done: 243 Antibans, and Taken: 1 Breaks
Next Break in: 10h 21m 4s
Successfully executed.


Nice proggy dude!! :D Glad you're enjoying the script!! Did the profit get messed up or did you use non profitable items?

CandleKitty0

2015-04-06 13:31:08

So I'm having trouble with the script I keep getting a "Error: File "srl-6/srl.simba" not found at line 28
Compiling failed." when I run the script after setting it up and following the instructions. Please help :c I'm new to SRL and simba

fady

2015-04-06 13:39:43

From: CandleKitty0
So I'm having trouble with the script I keep getting a "Error: File "srl-6/srl.simba" not found at line 28
Compiling failed." when I run the script after setting it up and following the instructions. Please help :c I'm new to SRL and simba


Have you followed the instructions on THIS PAGE exactly? Sounds like a setup problem not a script problem.

Does any other script work for you?

make sure you have the SRL.sex extension Enabled and updated

CandleKitty0

2015-04-06 13:51:34

I have followed the instructions I get the same msg

No, same problem with any other script

And yesI have but when I enable it it stays N/A. Could that be a problem?

CandleKitty0

2015-04-06 13:56:04

I hope my post shows this time

Yes I have followed the instructions just like any other SRL script has told me to

No, no other script works I get the same error

I have it enabled but it stays N/A Idk if thats a serious problem or not

CandleKitty0

2015-04-06 17:34:34

Ok so I solved my own problem I noticced I was missing 2 important files in includes like a dumby, downloaded them manually the script works! Now when I press play all the settings are greyed out and all I can do is type in the player slot but I do not have a "army" when I hit start it does nothing :c

fady

2015-04-06 17:48:33

From: CandleKitty0
Ok so I solved my own problem I noticced I was missing 2 important files in includes like a dumby, downloaded them manually the script works! Now when I press play all the settings are greyed out and all I can do is type in the player slot but I do not have a "army" when I hit start it does nothing :c


to be able to use this script you need to have a player set-up using rafiki. In case you haven't already, follow these instructions:


Adding players to Rafiki (Player Manager)


Adding players to the player manager is very, very easy. It is a very basic form, but does allow multiple player files to be saved/loaded, as well and username and password encryption. It also means you will never have to enter your username and password in a script ever again. Open Simba and go to SRL > Player Manager. A script will open and a form should pop up:




The setup is pretty straight forward:

Click the green "+" button to add a player.
Edit the players information on the right. You'll notice only the login name and password are required. I recommend you also enter a nickname. This nickname can be used to load your player into a script, otherwise you will have to use your login name. The display name is used only for debugging.
Choose whether or not you want to use encryption.
Save your players!
You can add/delete players from the list at any time.

Note that the Player Manager opens a new script file and runs it. It will still run if you're running another script in the same instance of Simba.

If you want to access the file that stores your player information, open Simba/settings.xml.


How to setup a script that uses the SRL Player Form

For the most part setting up this form is really straight forward, but there's always the possibility for confusion. Hopefully this will clear some things up. There are two things you need to worry about: the player file and your players. Any other settings should be explained by the author of the script you're using.

The player file

The player file is the file you saved using the Rafiki player manager (from above). Simply type in the name of the file you want to use. You'll know it's a valid file if the red X turns into a green checkmark:


When you see a green checkmark, click Load Players, and the player list below should populate with all the players you have in that file.


Your players

It is very simple to select which players you want to use. Check the box next to their name and you will be able to set specific script settings for that player.



let me know if it still doesnt work after that

Deluu11

2015-04-10 12:14:17

I ran the script, client starts up & logs in, I've nats and item placed on correct slots but it does nothing for like 1-2 minutes and then just closes?
First time for me using Simba..

Thanks in advance.

fady

2015-04-10 13:40:24

From: Deluu11
I ran the script, client starts up & logs in, I've nats and item placed on correct slots but it does nothing for like 1-2 minutes and then just closes?
First time for me using Simba..

Thanks in advance.


Have you followed all the instructions correctly? Can you show me a picture of your interface?

Deluu11

2015-04-11 02:34:58

I'll try in a second.
http://i.gyazo.com/8c1b5df2a792f516b7612769f6fe3003.png
http://i.gyazo.com/8030c4975184b939e18a6d60db3ec5e0.png

Deluu11

2015-04-11 02:41:32

From: fady
Have you followed all the instructions correctly? Can you show me a picture of your interface?


http://i.gyazo.com/8030c4975184b939e18a6d60db3ec5e0.png
http://i.gyazo.com/8c1b5df2a792f516b7612769f6fe3003.png

here, take a look.

Deluu11

2015-04-12 16:02:53

I got it working now, I had legacy settings on… lol.

Definitely needs anti-ban, else looks good.

fady

2015-04-12 16:44:34

From: Deluu11
I got it working now, I had legacy settings on… lol.

Definitely needs anti-ban, else looks good.


It should already have anti-ban, it should do about 2-3 antibans / 1000 alchs. Is it not doing that for you?


EDIT: don't forget to show me a proggy!! :D

Deluu11

2015-04-13 16:17:22

From: fady
It should already have anti-ban, it should do about 2-3 antibans / 1000 alchs. Is it not doing that for you?


EDIT: don't forget to show me a proggy!! :D


Sorry, I ran it only like 30 mins, and did not see any.. It has nice little anti-ban, fairly enough.

Items Left to go: 2077
Alchs done: 2921 Done/H: 1082
XP Gained: 189865 XP/H: 70330
Profit: 394335 Profit/H: 146031
Time Running: 2 Hours, 42 Minutes and 1 Second
We Have Done: 58 Antibans, and Taken: 0 Breaks
Next Break in: 2h 53m 29s
Successfully executed.

Dragon bolts (e) or Magic shieldbows (130k/h) are good items to alch for profit!

lucient

2015-04-17 07:22:26

I have the same problem, but the only difference is that I am on EoC, logs me in and selects world and that's that. 1 minute later it just closes. Have done everything I could possibly think of.

KeepBotting

2015-04-17 07:29:39

From: lucient
I have the same problem, but the only difference is that I am on EoC, logs me in and selects world and that's that. 1 minute later it just closes. Have done everything I could possibly think of.

Post a screenshot of your graphics settings (the menu) and your interface settings (in-game)

lucient

2015-04-17 07:46:35

[ATTACH=CONFIG]25654[/ATTACH] and [ATTACH=CONFIG]25655[/ATTACH]

KeepBotting

2015-04-17 07:51:22

From: lucient
[ATTACH=CONFIG]25654[/ATTACH] and [ATTACH=CONFIG]25655[/ATTACH]


I'm going to suggest you read this.

Deluu11

2015-04-18 13:46:51

In past few days this script often crash after ~500-1000 alches. Can you look into it?

fady

2015-04-18 15:09:46

From: Deluu11
In past few days this script often crash after ~500-1000 alches. Can you look into it?


Can you go down to line 380, and change
disableSRLDebug := true;  // Change this to false to enable SRL Debug!
to
disableSRLDebug := false;  // Change this to false to enable SRL Debug!

and let me know what is in the debug box when it crashes?

Deluu11

2015-04-18 15:25:02

From: fady
Can you go down to line 380, and change
disableSRLDebug := true;  // Change this to false to enable SRL Debug!
to
disableSRLDebug := false;  // Change this to false to enable SRL Debug!

and let me know what is in the debug box when it crashes?


I'll try that. Thanks.


This new tab pops up:
{$loadlib libtesseract2_}

{$f-}

(*
type TTesseractFilter
~~~~~~~~~~~~~~~~~~~~~

A record that stores filtering to apply onto a image.

Example:

.. code-block:: pascal

var
myTesseractFilter: TTesseractFilter;
begin
with (myTesseractFilter) do
begin
multiplerW := 3;
multiplerH := 3;

with (thresholdSettings) do
begin
invert := False;
amount := 20;
method := TM_Mean;
end;
end;

writeln(Tesseract_GetText(100, 100, 200, 200, myTesseractFilter));
end;
*)
type
TTesseractFilter = record
multiplerW, multiplerH: integer;
thresholdSettings: record invert: boolean; amount: byte; method: TBmpThreshMethod; end;
end;

(*
const Tesseract
~~~~~~~~~~~~~~~

String constants that store the data path, language and whitelist presets.

Example:

.. code-block:: pascal

print(TESS_DATA_PATH);
*)
const
TESS_DATA_PATH = AppPath + 'tessdata';
TESS_LANGUAGE = 'eng';

const
TESS_WHITELIST_NUMBERS = '0123456789';
TESS_WHITELIST_LETTERS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
TESS_WHITELIST_NONE = '';

(*
const Filter presets
~~~~~~~~~~~~~~~~~~~~

Constants of TTesseractFilter that are filter presets

Example:

.. code-block:: pascal

Tesseract_GetText(100, 100, 200, 200, TESS_FILTER_SMALL_CHARS);
*)
const
TESS_FILTER_SMALL_CHARS: TTesseractFilter = [3, 3, [false, 50, TM_Mean]];
TESS_FILTER_SMALL_CHARS_2: TTesseractFilter = [5, 5, [false, 55, TM_Mean]];
TESS_FILTER_NPC_CHAT_CHARS: TTesseractFilter = [3, 3, [true, -50, TM_Mean]];

{*
var Tesseract
~~~~~~~~~~~~~

Internal variables for use by the Tesseract.
*}
var
__tesseractPtr: pointer := nil;
__tesseractIsSetup: boolean = false;

(*
_Tesseract_Setup
~~~~~~~~~~~~~~~~

.. code-block:: pascal

procedure _Tesseract_Setup();

Setups our instance of tesseract-ocr. Is automaticly called if using functions
from this file.

.. note::

- by Olly
- Last updated: July. 26th, 2014 by Olly

Example:

.. code-block:: pascal

_Tesseract_Setup();
*)
procedure _Tesseract_Setup();
begin
if (__tesseractIsSetup) then
exit();

__tesseractPtr := Tesseract_Create();

if (__tesseractPtr = nil) then
print('Failed to create a tesseract instance', TDebug.FATAL);

if (Tesseract_Init(__tesseractPtr, TESS_DATA_PATH, TESS_LANGUAGE) <> 0) then
print('Unable to initizalse tesseract, check Simba console for more infomation', TDebug.FATAL);

addOnTerminate('_Tesseract_Free');
__tesseractIsSetup := true;
end;

(*
_Tesseract_Free
~~~~~~~~~~~~~~~

.. code-block:: pascal

procedure _Tesseract_Free();

Frees our instance of tesseract-ocr. Is automaticly called on terminate if
_Tesseract_Setup() has been called.

.. note::

- by Olly
- Last updated: July. 26th, 2014 by Olly

Example:

.. code-block:: pascal

_Tesseract_Free();
*)
procedure _Tesseract_Free();
begin
if (__tesseractPtr = nil) or (not __tesseractIsSetup) then
exit();

Tesseract_End(__tesseractPtr);
Tesseract_Delete(__tesseractPtr);
__tesseractPtr := nil;
__tesseractIsSetup := false;
end;

(*
Tesseract_ApplyFilter
~~~~~~~~~~~~~~~~~~~~~

.. code-block:: pascal

procedure Tesseract_ApplyFilter(const BMP: integer; const filter: TTesseractFilter);

Applys the tesseract filter onto the bitmap.

.. note::

- by Olly
- Last updated: September. 9th, 2014 by Olly

Example:

.. code-block:: pascal

Tesseract_ApplyFilter(BMP, MyTesseractFilter);
*)
procedure Tesseract_ApplyFilter(const BMP: integer; const filter: TTesseractFilter);
var
w, h: integer;
begin
if (not BitmapExists(BMP)) then
Exit();

GetBitmapSize(BMP, w, h);
if (Filter.multiplerW > 0) and (Filter.multiplerH > 0) then
ResizeBitmapEx(BMP, RM_Bilinear, Filter.multiplerW * w, Filter.multiplerH * h);

ThresholdAdaptiveBitmap(bmp, 0, 255, Filter.thresholdSettings.invert,
Filter.thresholdSettings.method,
Filter.thresholdSettings.amount);
end;

(*
Tesseract_GetText
~~~~~~~~~~~~~~~~~

.. code-block:: pascal

function Tesseract_GetText(const bmp: integer): string;

Runs tesseract on the bitmap 'bmp'.

.. note::

- by Olly
- Last updated: July. 26th, 2014 by Olly

Example:

.. code-block:: pascal

writeln(Tesseract_GetText(bmp));
*)
function Tesseract_GetText(const bmp: integer; const Whitelist: String = TESS_WHITELIST_NONE): string;
var
w, h, i: integer;
textLen: UInt32;
textPtr: PChar = nil;
begin
if (not __tesseractIsSetup) then
_Tesseract_Setup();

if (Whitelist <> TESS_WHITELIST_NONE) then
Tesseract_SetVariable(__tesseractPtr, 'tessedit_char_whitelist', WhiteList);

result := '';
getBitmapSize(bmp, w, h);

if (w < 10) or (h < 10) then
Exit;

try
Tesseract_SetImage(__tesseractPtr, getMufasaBitmap(bmp).getData(), w, h, 4, Integer(w * 4));
try
textPtr := Tesseract_GetUTF8Text(__tesseractPtr, textLen);
except
TextPtr := nil;
end;

if (TextPtr <> nil) then
begin
setLength(result, textLen);
if (textLen > 0) then
begin
for i := 1 to textLen do
result[i] := textPtr[i - 1]^;

result := trim(stringReplace(result, #10, #13#10, [rfReplaceAll]));
end;
end;
finally
if (textPtr <> nil) then
begin
Tesseract_FreeUTF8Text(textPtr);
Tesseract_Clear(__tesseractPtr);
end;

if (Whitelist <> TESS_WHITELIST_NONE) then // reset to default
begin
_Tesseract_Free();
_Tesseract_Setup();
end;
end;
end;

(*
Tesseract_GetText; overload
~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: pascal

function Tesseract_GetText(const xs, ys, xe, ye: integer; filter: TTesseractFilter): string; overload;

Overloaded method that searches on the client with a filter to read text.

.. note::

- by Olly
- Last updated: July. 26th, 2014 by Olly

Example:

.. code-block:: pascal

writeln(Tesseract_GetText(100, 100, 200, 200, TESS_FILTER_SMALL_CHARS));
*)
function Tesseract_GetText(const xs, ys, xe, ye: integer; filter: TTesseractFilter; Whitelist: String = TESS_WHITELIST_NONE): string; overload;
var
bmp, w, h: Integer;
t, tt: LongWord;
begin
bmp := bitmapFromClient(xs, ys, xe, ye);
GetBitmapSize(bmp, w, h);
if (w < 10) or (h < 10) then
Exit('');

try
t := getSystemTime();
Tesseract_ApplyFilter(bmp, filter);

t := (getSystemTime() - t);
tt := getSystemTime();

result := Tesseract_GetText(bmp, Whitelist);
{$IFDEF TESSERACT_DEBUG}
printf('Tesseract_GetText(): Filtering took: %d ms, Tesseract Took: %d ms, Total Time: %d ms.', [t, (getSystemTime() - tt), (getSystemTime() - tt) + t]);
printf('Tesseract_GetText(): Text found: %s', [result]);
{$ENDIF}
finally
{$IFDEF TESSERACT_DEBUG}
clearDebugImg();
displayDebugImgWindow(getMufasaBitmap(bmp).getWidth(), getMufasaBitmap(bmp).getHeight());
drawBitmapDebugImg(bmp);
{$ENDIF}
freeBitmap(bmp);
end;
end;

(*
Tesseract_GetText; overload
~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: pascal

function Tesseract_GetText(const area: TBox; filter: TTesseractFilter): string; overload;

Overloaded method that searches on the client with a filter and accepts a TBox
as an area parameter rather than x1, y1, x2, y2.

.. note::

- by Olly
- Last updated: July. 26th, 2014 by Olly

Example:

.. code-block:: pascal

writeln(Tesseract_GetText(box, TESS_FILTER_SMALL_CHARS));
*)
function Tesseract_GetText(const area: TBox; filter: TTesseractFilter; Whitelist: String = TESS_WHITELIST_NONE): string; overload;
begin
result := Tesseract_GetText(area.x1, area.y1, area.x2, area.y2, filter, Whitelist);
end;

// keep old versions working
// deprecated use the TTesseractFilter presets
const
FILTER_SMALL_CHARS: TTesseractFilter = TESS_FILTER_SMALL_CHARS;
FILTER_NPC_CHAT_CHARS: TTesseractFilter = TESS_FILTER_NPC_CHAT_CHARS;
FILTER_SMALL_CHARS_2: TTesseractFilter = TESS_FILTER_SMALL_CHARS_2;

// deprecated use Tesseract_GetText().
function tesseractGetText(const searchBox: tbox; filterMethod: TTesseractFilter): string;
begin
result := Tesseract_GetText(searchBox, filterMethod);
end;

// deprecated use Tesseract_GetText().
function tesseractGetText(const x1, y1, x2, y2: integer; filterMethod: TTesseractFilter; config: string = ''): string; overload;
begin
result := Tesseract_GetText(x1, y1, x2, y2, filterMethod, config);
end;

{$f+}
After Stopping it this pops up in lower textbar.


[B]The following bitmaps were not freed: [Minimap Mask, Gametab Bitmap[0], Gametab Bitmap[1], Gametab Bitmap[2], Gametab Bitmap[3], Gametab Bitmap[4], Gametab Bitmap[5], Gametab Bitmap[6], Gametab Bitmap[7], Gametab Bitmap[8], Gametab Bitmap[9], Gametab Bitmap[10], Gametab Bitmap[11], Gametab Bitmap[12], Gametab Bitmap[13], 15]
File[C:\Simba\Includes\SRL-6/logs/SRL log (18-04-15 at 10.26.23 PM).txt] has not been freed in the script, freeing it now.

fady

2015-04-18 15:33:54

From: Deluu11
I'll try that. Thanks.


This new tab pops up:
{$loadlib libtesseract2_}

{$f-}

(*
type TTesseractFilter
~~~~~~~~~~~~~~~~~~~~~

A record that stores filtering to apply onto a image.

Example:

.. code-block:: pascal

var
myTesseractFilter: TTesseractFilter;
begin
with (myTesseractFilter) do
begin
multiplerW := 3;
multiplerH := 3;

with (thresholdSettings) do
begin
invert := False;
amount := 20;
method := TM_Mean;
end;
end;

writeln(Tesseract_GetText(100, 100, 200, 200, myTesseractFilter));
end;
*)
type
TTesseractFilter = record
multiplerW, multiplerH: integer;
thresholdSettings: record invert: boolean; amount: byte; method: TBmpThreshMethod; end;
end;

(*
const Tesseract
~~~~~~~~~~~~~~~

String constants that store the data path, language and whitelist presets.

Example:

.. code-block:: pascal

print(TESS_DATA_PATH);
*)
const
TESS_DATA_PATH = AppPath + 'tessdata';
TESS_LANGUAGE = 'eng';

const
TESS_WHITELIST_NUMBERS = '0123456789';
TESS_WHITELIST_LETTERS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
TESS_WHITELIST_NONE = '';

(*
const Filter presets
~~~~~~~~~~~~~~~~~~~~

Constants of TTesseractFilter that are filter presets

Example:

.. code-block:: pascal

Tesseract_GetText(100, 100, 200, 200, TESS_FILTER_SMALL_CHARS);
*)
const
TESS_FILTER_SMALL_CHARS: TTesseractFilter = [3, 3, [false, 50, TM_Mean]];
TESS_FILTER_SMALL_CHARS_2: TTesseractFilter = [5, 5, [false, 55, TM_Mean]];
TESS_FILTER_NPC_CHAT_CHARS: TTesseractFilter = [3, 3, [true, -50, TM_Mean]];

{*
var Tesseract
~~~~~~~~~~~~~

Internal variables for use by the Tesseract.
*}
var
__tesseractPtr: pointer := nil;
__tesseractIsSetup: boolean = false;

(*
_Tesseract_Setup
~~~~~~~~~~~~~~~~

.. code-block:: pascal

procedure _Tesseract_Setup();

Setups our instance of tesseract-ocr. Is automaticly called if using functions
from this file.

.. note::

- by Olly
- Last updated: July. 26th, 2014 by Olly

Example:

.. code-block:: pascal

_Tesseract_Setup();
*)
procedure _Tesseract_Setup();
begin
if (__tesseractIsSetup) then
exit();

__tesseractPtr := Tesseract_Create();

if (__tesseractPtr = nil) then
print('Failed to create a tesseract instance', TDebug.FATAL);

if (Tesseract_Init(__tesseractPtr, TESS_DATA_PATH, TESS_LANGUAGE) <> 0) then
print('Unable to initizalse tesseract, check Simba console for more infomation', TDebug.FATAL);

addOnTerminate('_Tesseract_Free');
__tesseractIsSetup := true;
end;

(*
_Tesseract_Free
~~~~~~~~~~~~~~~

.. code-block:: pascal

procedure _Tesseract_Free();

Frees our instance of tesseract-ocr. Is automaticly called on terminate if
_Tesseract_Setup() has been called.

.. note::

- by Olly
- Last updated: July. 26th, 2014 by Olly

Example:

.. code-block:: pascal

_Tesseract_Free();
*)
procedure _Tesseract_Free();
begin
if (__tesseractPtr = nil) or (not __tesseractIsSetup) then
exit();

Tesseract_End(__tesseractPtr);
Tesseract_Delete(__tesseractPtr);
__tesseractPtr := nil;
__tesseractIsSetup := false;
end;

(*
Tesseract_ApplyFilter
~~~~~~~~~~~~~~~~~~~~~

.. code-block:: pascal

procedure Tesseract_ApplyFilter(const BMP: integer; const filter: TTesseractFilter);

Applys the tesseract filter onto the bitmap.

.. note::

- by Olly
- Last updated: September. 9th, 2014 by Olly

Example:

.. code-block:: pascal

Tesseract_ApplyFilter(BMP, MyTesseractFilter);
*)
procedure Tesseract_ApplyFilter(const BMP: integer; const filter: TTesseractFilter);
var
w, h: integer;
begin
if (not BitmapExists(BMP)) then
Exit();

GetBitmapSize(BMP, w, h);
if (Filter.multiplerW > 0) and (Filter.multiplerH > 0) then
ResizeBitmapEx(BMP, RM_Bilinear, Filter.multiplerW * w, Filter.multiplerH * h);

ThresholdAdaptiveBitmap(bmp, 0, 255, Filter.thresholdSettings.invert,
Filter.thresholdSettings.method,
Filter.thresholdSettings.amount);
end;

(*
Tesseract_GetText
~~~~~~~~~~~~~~~~~

.. code-block:: pascal

function Tesseract_GetText(const bmp: integer): string;

Runs tesseract on the bitmap 'bmp'.

.. note::

- by Olly
- Last updated: July. 26th, 2014 by Olly

Example:

.. code-block:: pascal

writeln(Tesseract_GetText(bmp));
*)
function Tesseract_GetText(const bmp: integer; const Whitelist: String = TESS_WHITELIST_NONE): string;
var
w, h, i: integer;
textLen: UInt32;
textPtr: PChar = nil;
begin
if (not __tesseractIsSetup) then
_Tesseract_Setup();

if (Whitelist <> TESS_WHITELIST_NONE) then
Tesseract_SetVariable(__tesseractPtr, 'tessedit_char_whitelist', WhiteList);

result := '';
getBitmapSize(bmp, w, h);

if (w < 10) or (h < 10) then
Exit;

try
Tesseract_SetImage(__tesseractPtr, getMufasaBitmap(bmp).getData(), w, h, 4, Integer(w * 4));
try
textPtr := Tesseract_GetUTF8Text(__tesseractPtr, textLen);
except
TextPtr := nil;
end;

if (TextPtr <> nil) then
begin
setLength(result, textLen);
if (textLen > 0) then
begin
for i := 1 to textLen do
result[i] := textPtr[i - 1]^;

result := trim(stringReplace(result, #10, #13#10, [rfReplaceAll]));
end;
end;
finally
if (textPtr <> nil) then
begin
Tesseract_FreeUTF8Text(textPtr);
Tesseract_Clear(__tesseractPtr);
end;

if (Whitelist <> TESS_WHITELIST_NONE) then // reset to default
begin
_Tesseract_Free();
_Tesseract_Setup();
end;
end;
end;

(*
Tesseract_GetText; overload
~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: pascal

function Tesseract_GetText(const xs, ys, xe, ye: integer; filter: TTesseractFilter): string; overload;

Overloaded method that searches on the client with a filter to read text.

.. note::

- by Olly
- Last updated: July. 26th, 2014 by Olly

Example:

.. code-block:: pascal

writeln(Tesseract_GetText(100, 100, 200, 200, TESS_FILTER_SMALL_CHARS));
*)
function Tesseract_GetText(const xs, ys, xe, ye: integer; filter: TTesseractFilter; Whitelist: String = TESS_WHITELIST_NONE): string; overload;
var
bmp, w, h: Integer;
t, tt: LongWord;
begin
bmp := bitmapFromClient(xs, ys, xe, ye);
GetBitmapSize(bmp, w, h);
if (w < 10) or (h < 10) then
Exit('');

try
t := getSystemTime();
Tesseract_ApplyFilter(bmp, filter);

t := (getSystemTime() - t);
tt := getSystemTime();

result := Tesseract_GetText(bmp, Whitelist);
{$IFDEF TESSERACT_DEBUG}
printf('Tesseract_GetText(): Filtering took: %d ms, Tesseract Took: %d ms, Total Time: %d ms.', [t, (getSystemTime() - tt), (getSystemTime() - tt) + t]);
printf('Tesseract_GetText(): Text found: %s', [result]);
{$ENDIF}
finally
{$IFDEF TESSERACT_DEBUG}
clearDebugImg();
displayDebugImgWindow(getMufasaBitmap(bmp).getWidth(), getMufasaBitmap(bmp).getHeight());
drawBitmapDebugImg(bmp);
{$ENDIF}
freeBitmap(bmp);
end;
end;

(*
Tesseract_GetText; overload
~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: pascal

function Tesseract_GetText(const area: TBox; filter: TTesseractFilter): string; overload;

Overloaded method that searches on the client with a filter and accepts a TBox
as an area parameter rather than x1, y1, x2, y2.

.. note::

- by Olly
- Last updated: July. 26th, 2014 by Olly

Example:

.. code-block:: pascal

writeln(Tesseract_GetText(box, TESS_FILTER_SMALL_CHARS));
*)
function Tesseract_GetText(const area: TBox; filter: TTesseractFilter; Whitelist: String = TESS_WHITELIST_NONE): string; overload;
begin
result := Tesseract_GetText(area.x1, area.y1, area.x2, area.y2, filter, Whitelist);
end;

// keep old versions working
// deprecated use the TTesseractFilter presets
const
FILTER_SMALL_CHARS: TTesseractFilter = TESS_FILTER_SMALL_CHARS;
FILTER_NPC_CHAT_CHARS: TTesseractFilter = TESS_FILTER_NPC_CHAT_CHARS;
FILTER_SMALL_CHARS_2: TTesseractFilter = TESS_FILTER_SMALL_CHARS_2;

// deprecated use Tesseract_GetText().
function tesseractGetText(const searchBox: tbox; filterMethod: TTesseractFilter): string;
begin
result := Tesseract_GetText(searchBox, filterMethod);
end;

// deprecated use Tesseract_GetText().
function tesseractGetText(const x1, y1, x2, y2: integer; filterMethod: TTesseractFilter; config: string = ''): string; overload;
begin
result := Tesseract_GetText(x1, y1, x2, y2, filterMethod, config);
end;

{$f+}


the tab opened up when you changed it to false? or the tab comes up every time it crashes? I have a feeling the crashes might be related to text finding, so just let me know what the debug box says before the crash comes up.

Deluu11

2015-04-18 16:28:40

From: fady
the tab opened up when you changed it to false? or the tab comes up every time it crashes? I have a feeling the crashes might be related to text finding, so just let me know what the debug box says before the crash comes up.


No, this pops up after crash.

stupid question but where is this debug box located?

fady

2015-04-18 16:47:24

From: Deluu11
No, this pops up after crash.

stupid question but where is this debug box located?


The white box under the script that contains the proggy

Deluu11

2015-04-18 17:16:24

I already posted what pops up, but this doesn't happen always. Often it does couple hundred alches and then just sits there, doing nothing and my player gets afk logged.


he following bitmaps were not freed: [Minimap Mask, Gametab Bitmap[0], Gametab Bitmap[1], Gametab Bitmap[2], Gametab Bitmap[3], Gametab Bitmap[4], Gametab Bitmap[5], Gametab Bitmap[6], Gametab Bitmap[7], Gametab Bitmap[8], Gametab Bitmap[9], Gametab Bitmap[10], Gametab Bitmap[11], Gametab Bitmap[12], Gametab Bitmap[13], 15]
File[C:\Simba\Includes\SRL-6/logs/SRL log (18-04-15 at 10.26.23 PM).txt] has not been freed in the script, freeing it now.

KeepBotting

2015-04-18 17:20:09

From: Deluu11
I already posted what pops up, but this doesn't happen always. Often it does couple hundred alches and then just sits there, doing nothing and my player gets afk logged.


he following bitmaps were not freed: [Minimap Mask, Gametab Bitmap[0], Gametab Bitmap[1], Gametab Bitmap[2], Gametab Bitmap[3], Gametab Bitmap[4], Gametab Bitmap[5], Gametab Bitmap[6], Gametab Bitmap[7], Gametab Bitmap[8], Gametab Bitmap[9], Gametab Bitmap[10], Gametab Bitmap[11], Gametab Bitmap[12], Gametab Bitmap[13], 15]
File[C:\Simba\Includes\SRL-6/logs/SRL log (18-04-15 at 10.26.23 PM).txt] has not been freed in the script, freeing it now.

What's the actual error? It's got to throw an error (probably above what you just posted in the debug) before opening the new tab and stopping the script.

It's probably a access-violation or other runtime error, we need the error to diagnose

fady

2015-04-18 17:22:31

From: Deluu11
I already posted what pops up, but this doesn't happen always. Often it does couple hundred alches and then just sits there, doing nothing and my player gets afk logged.


he following bitmaps were not freed: [Minimap Mask, Gametab Bitmap[0], Gametab Bitmap[1], Gametab Bitmap[2], Gametab Bitmap[3], Gametab Bitmap[4], Gametab Bitmap[5], Gametab Bitmap[6], Gametab Bitmap[7], Gametab Bitmap[8], Gametab Bitmap[9], Gametab Bitmap[10], Gametab Bitmap[11], Gametab Bitmap[12], Gametab Bitmap[13], 15]
File[C:\Simba\Includes\SRL-6/logs/SRL log (18-04-15 at 10.26.23 PM).txt] has not been freed in the script, freeing it now.


Oh! I didn't see your edit! Can you go a little earlier and show me some more of what it says, with Line 380 set to false! I want to know at which part in specific it crashes so I can make a work around for you.

Deluu11

2015-04-19 02:36:41

From: fady
Oh! I didn't see your edit! Can you go a little earlier and show me some more of what it says, with Line 380 set to false! I want to know at which part in specific it crashes so I can make a work around for you.


Okay, I'll try to get it to you. As I said, it sometimes crashes, sometimes just pauses and I've to close it myself.

The same thing came up I already posted earlier. It doesn't show anything earlier besides proggy.


[00:00:06]: -- setupSRL()
[00:00:06]: ---- Setting up SRL...
[00:00:06]: ---- attempting to spawn smart, attempt #: 1
[00:00:06]: ---- initSmart():
[00:00:06]: ------ Attempting to pair to a previously spawned client
[00:00:06]: ------ smartPairToExistingClient():
[00:00:06]: -------- Found no free clients to pair to
[00:00:06]: ------ smartPairToExistingClient(): result = false
[00:00:06]: ------ Attempting to spawn a new client..
[00:00:06]: ------ smartCreateClient():
[00:00:06]: ---------- smartGetParameters(): Succesfully grabbed paramters
[00:00:06]: -------- getJavaPath():
[00:00:06]: ---------- Attempting to search for your Java path
[00:00:06]: ---------- Found your java path @ C:\Program Files\Java\jre7\bin\java.exe
[00:00:06]: -------- getJavaPath()
[00:00:06]: -------- Using parameters [http://world10.runescape.com/, f4671030992258899940]
[00:00:06]: -------- Using plugins "OpenGL32.dll,d3d9.dll"
[00:00:15]: -------- Succesfully spawned a client, attempting to target
[00:00:15]: ---------- smartSetAsTarget(): Succesfully set SMART[1768] as Simba's target
[00:00:15]: ------ smartCreateClient(): result = true
[00:00:15]: ------ Succesfully initialized via spawning a new client
[00:00:15]: ---- initSmart()
[00:00:15]: ---- Waiting up to 5 minutes for RS to load...
[00:00:25]: ------ __setInputBoxes(): Set username and password boxes
[00:00:25]: ---- Client is ready.
[00:00:25]: ---- Setup SRL in 19 Seconds
[00:00:25]: -- setupSRL(): True
[00:00:25]: -- TPlayer.login()
[00:00:25]: ---- TPlayer.loginToLobby()
[00:00:25]: ------ Attempt 1: CENSOREDACCOUNT--------@XXX.Com ()
[00:00:25]: -------- Entering username...
[00:00:33]: -------- Entering password...
[00:00:38]: -------- Saving screenshot: IP_address.png
[00:00:38]: ---- TPlayer.loginToLobby(): True
[00:00:38]: ---- TRSLobby.getCurrentTab(): Current tab is 0
[00:00:38]: ---- TRSLobby.quickSelectWorld(): Found worlds [XX, X, XX]
[00:00:39]: ---- TRSLobby.quickSelectWorld(): Clicked world XX. [Index 1]
[00:00:50]: ------ TRSActionBar.__findButton(): Found the actionbar button @ {X = 566, Y = 315}
[00:00:50]: ------ TRSActionBar.__find(): result = true (height = 75)
[00:00:50]: ------ Dynamic interfaces have been set.
[00:00:50]: -- TPlayer.login(): True
[00:00:50]: -- exitTreasure()
[00:00:50]: -- exitTreasure(): result = False
[00:00:55]: ---- TRSGameTab.__initTabs(): Setup gametab properties
[00:00:57]: -- isMouseOverText()
[00:00:57]: ---- Current mouse-over text: "Wield Dragon bolts (e) 0gggBB i TXFB i IBvBI i zg"
[00:00:57]: ---- Current mouse-over text: "Wield Dragon bolts (e) 0gggBB i TXFB i IBvBI i zg"
[00:00:57]: ---- Current mouse-over text: "Wield Dragon bolts (e) 0gggBB i TXFB i IBvBI i zg"
[00:00:57]: ---- Current mouse-over text: "Wield Dragon bolts (e) 0gggBB i TXFB i IBvBI i zg"
[00:00:57]: ---- Current mouse-over text: "Wield Dragon bolts (e) 0gggBB i TXFB i IBvBI i zg"
[00:00:57]: ---- Current mouse-over text: "Wield Dragon bolts (e) 0gggBB i TXFB i IBvBI i zg"
[00:00:57]: -- isMouseOverText(): False
[00:04:54]: -- TRSGameTabs.openTab(1)
[00:04:54]: ---- Tab is already visible, bringing to front
[00:04:54]: -- TRSGameTabs.openTab(1): = True
[00:04:59]: -- TRSGameTabs.openTab(2)
[00:04:59]: ---- Tab is already visible, bringing to front
[00:05:00]: -- TRSGameTabs.openTab(2): = True
[00:05:03]: -- TRSGameTabs.openTab(2)
[00:05:03]: ---- Tab is already open, exiting
[00:05:03]: -- TRSGameTabs.openTab(2): = True
[00:18:12]: -- WARNING: getItemAmount(): Didn't find any text color, result = -1


Deluu11

2015-04-19 06:36:33

Maybe this can help you out as well…
http://gyazo.com/eb961942ad014a26ea57c218c5db2070

fady

2015-04-25 09:28:56

From: Deluu11
Maybe this can help you out as well…
http://gyazo.com/eb961942ad014a26ea57c218c5db2070


Sorry for not responding earlier, My laptop just wouldnt turn on and gave me a hard time trying to reinstall windows. Your issue seems to be with either the SRL include or with your graphics settings. Because it seems to me like its crashing at getting the item amounts which is purely an SRL function. You can try version 1.2 it might be better, but it does not have a profit calculator. Sorry for the late response