SRL Archive - OSR Help

Get a number out of the GE


Master BAW

2012-06-19 14:09:19

Hello,

I am trying to read this numbers:

On this screeen, I need to:
- find the price (84,239,920) and I need that in an Integer.
- "You sold a total of x" (5) , which also could be 21,234 (need it in an integer too)
- " for a total price of y gp" (52,649,950) and I need that in an Integer;
- Quantity: Z (8), which also could be 10,128 (need it in an integer too)

How do I get such numbers out of this screen? I hope someone knows the awnser, or at least which function I could use best. :)

Greetz,
MasterCrimez

CephaXz

2012-06-19 14:14:27

I used GetTextAtExWrap for my GE script. I believe the font is UpCharsEx.

putonajonny

2012-06-19 14:44:08

GetTextAtExWrap with GetNumbers

GetNumbers extracts numbers from a string of text (get's rid of commas etc..)

Master BAW

2012-06-19 14:57:55

From: CephaXz
I used GetTextAtExWrap for my GE script. I believe the font is UpCharsEx.


Okay :) thanks.
From: putonajonny
GetTextAtExWrap with GetNumbers

GetNumbers extracts numbers from a string of text (get's rid of commas etc..)


Ah nice! So getnumbers will make 8112235 from the string '8,112,235' ? :)

Thanks :)

CephaXz

2012-06-19 15:01:12

From: MasterCrimez
Okay :) thanks.


Ah nice! So getnumbers will make 8112235 from the string '8,112,235' ? :)

Thanks :)


Yes, and you will still need to use StrtoInt to make it into an integer.

Master BAW

2012-06-19 16:23:37

GetTextAtExWrap
function GetTextAtExWrap(const xs,ys,xe,ye, minvspacing, maxvspacing, hspacing,color, tol: integer;const font: string): string;
A wrapper function for the previously mentioned function. Required to work arounds bugs in the interpreter.

I almost understand the whole function, but what does minvspacing mean? and maxvspacing?
and hspacing?

does that have to do something with the space between the letters? and what values do I need for reading text from the GE?

J J

2012-06-19 16:31:26

If you search for the function on Google like this you often get some useful code:
https://www.google.nl/search?q=site%3Avillavu.com+%22gettextatexwrap%22&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:nl:official&client=firefox-a

function GetMidPrice: Integer;
var
Text: String;
begin
Text:= GetTextAtExWrap(296, 186, 440, 199, 0, 10, 1, 6400255, 5, 'UpCharsEx');
writeln(Text); //easier than calling the func again..
Result:= StrToIntDef(GetNumbers(Text), -1);
end;

I used this in my Gop script:
procedure GetWaitTime;
var
i: Integer;
Bound: TBox;
Pts: TPointArray;
WaitTimeString: String;
NumbersCheck: Array of String;

begin
ColorToleranceSpeed(1);
FindColorsTolerance(Pts, 0, 140, 380, 500, 450, 0);
Bound := GetTPABounds(Pts);
//SMART_DrawBox(Bound);
WaitTimeString := GetTextAtExWrap(Bound.x1 - 5, Bound.y1 - 5, Bound.x2 + 5, Bound.y2 + 5, 0, 0, 2, 0, 0, UpChars);
WriteLn(WaitTimeString);

NumbersCheck := ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];

for i:=0 to 9 do
begin
if Pos(NumbersCheck[i], WaitTimeString) > 0 then
begin
WaitTime := StrToInt(GetNumbers(WaitTimeString));
SMART_DrawDotsEx(False, ActionBoxTPA, RGBtoColor(194, 178, 146));
SMART_DrawText(290, 429, UpChars, 'kicked, waiting '+IntToStr(WaitTime)+' minutes', clWhite);
Exit;
end;
end;
end;

I believe minvspacing is the minimum vertical spacing = 0
max vertical spacing = 0 aswell becaues you are reading one line.
Hspacing = horizontal spacing = 2 because it sometimes messes up when you use 1 I believe. Hope it helps.

Master BAW

2012-06-19 17:03:14

From: J J
If you search for the function on Google like this you often get some useful code:
https://www.google.nl/search?q=site%3Avillavu.com+%22gettextatexwrap%22&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:nl:official&client=firefox-a

function GetMidPrice: Integer;
var
Text: String;
begin
Text:= GetTextAtExWrap(296, 186, 440, 199, 0, 10, 1, 6400255, 5, 'UpCharsEx');
writeln(Text); //easier than calling the func again..
Result:= StrToIntDef(GetNumbers(Text), -1);
end;

I used this in my Gop script:
procedure GetWaitTime;
var
i: Integer;
Bound: TBox;
Pts: TPointArray;
WaitTimeString: String;
NumbersCheck: Array of String;

begin
ColorToleranceSpeed(1);
FindColorsTolerance(Pts, 0, 140, 380, 500, 450, 0);
Bound := GetTPABounds(Pts);
//SMART_DrawBox(Bound);
WaitTimeString := GetTextAtExWrap(Bound.x1 - 5, Bound.y1 - 5, Bound.x2 + 5, Bound.y2 + 5, 0, 0, 2, 0, 0, UpChars);
WriteLn(WaitTimeString);

NumbersCheck := ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];

for i:=0 to 9 do
begin
if Pos(NumbersCheck[i], WaitTimeString) > 0 then
begin
WaitTime := StrToInt(GetNumbers(WaitTimeString));
SMART_DrawDotsEx(False, ActionBoxTPA, RGBtoColor(194, 178, 146));
SMART_DrawText(290, 429, UpChars, 'kicked, waiting '+IntToStr(WaitTime)+' minutes', clWhite);
Exit;
end;
end;
end;

I believe minvspacing is the minimum vertical spacing = 0
max vertical spacing = 0 aswell becaues you are reading one line.
Hspacing = horizontal spacing = 2 because it sometimes messes up when you use 1 I believe. Hope it helps.


thanks! :)
I have
quantity:= GetTextAtExWrap(80,180,230,205, 0, 0, 2, 6400255, 0, UpCharsEx);
now and it works :D
shall I use 0 tolerance ? Or just do 1 or 2 for if jagex changes colors?

putonajonny

2012-06-19 18:05:31

From: MasterCrimez
thanks! :)
I have
quantity:= GetTextAtExWrap(80,180,230,205, 0, 0, 2, 6400255, 0, UpCharsEx);
now and it works :D
shall I use 0 tolerance ? Or just do 1 or 2 for if jagex changes colors?


I'd use 0, if jagex changes the colour it will likely be dramatically so you will need to update anyway, a good way though would be to use a constant for the colour, put it just under DeclarePlayers so that you can very easily update it if there ever is a change…

Master BAW

2012-06-19 18:44:32

thanks for your advice, that's exactly how i've done it now.

But, now I have a problem… It seems to not be able to read these two:


ItemsTotalX := StrToIntDef(GetNumbers(GetTextAtExWrap(218,271,320,283, 0, 0, 2, 39372, 5, UpCharsEx)),0);//you sould/bought a total of x
PriceTotalX := StrToIntDef(GetNumbers(GetTextAtExWrap(218,286,320,299, 0, 0, 2, 39372, 5, UpCharsEx)),0);//for a total price of x gp

I'm 100% sure I've got the color right, but still it doesnt read them. maybe it's another font? How can I know? Or do the minvspacing/maxvspacing/hspacing need another value maybe?

Abu

2012-06-19 19:15:48

From: MasterCrimez

I'm 100% sure I've got the color right, but still it doesnt read them. maybe it's another font? How can I know? Or do the minvspacing/maxvspacing/hspacing need another value maybe?


Try changing the maxspacing - it shouldn't be 0. Keep putting it higher (by 1) till it can finally read it.

If ti still can't, try different fonts.

Master BAW

2012-06-19 21:15:29

ugghh this is horrible.. tried many fonts, and many vmaxspacings… but only 1 in 10 it works a little :(

Master BAW

2012-06-19 21:54:28

I will test more tomorrow and I hope I find a solution myself.

But if someone who knows a lot about fonts wants to help, I would apreciate it a lot.

I will make a test script tomorrow for it because then I can test it faster and in forloops to see many results at once :)

I really doubt if I have the right font. UpChars works better than UpCharsEx, but still very sporadic :S

Well anyway, I will post here tomozz when I have worked on it. :) cyaz

Master BAW

2012-06-20 00:00:19

Hello… I've just tested, and I think I've figured it out. Whatever I do with the minspacing and maxspacing and other things, the letters wont change. Which font I use also doesnt matter, none of them works.

0 = 0
1 = l (L lowercase)
2 = 2
3 = J or T
4 = k
5 = 5
6 = 6
7 = z
8 = 8
9 = 3
, = '

This is the outcome for the best font : UpCharsEx


So, is there a way to read these small texts?
I'm talking about: "You bought a total of XXXXXX"
and " for a total price of XXXXX"

All I really need is numbers and a comma, so can't I create a new little font myself only for these 11 characters? Would be nice if that worked.

Every help is apreciated! I really need this function, else I cannot further develop my bot! :(

Edit: the quantity and gp price DO work! Only the "You bought xxxxx for a total price of xxxxx" does not work.

Master BAW

2012-06-20 00:39:04


^ I've just made this :D What now ? :p

Wildo

2012-06-20 00:49:16

how much profit/hr is there to be made with a ge script if you start with say 50m?

Master BAW

2012-06-20 00:55:00

From: Wildo
how much profit/hr is there to be made with a ge script if you start with say 50m?


There is no working GE script ATM haha. :p Although not that I know. ;)

but anyway I just made the ,0123456789 all in bmp black and white. :) onto the next step. need to find out how to put them into my own new font.

Master BAW

2012-06-20 01:05:07

:duh::duh::duh::duh:OH MY FUCKING GOD! :duh::duh::duh::duh:
I feel so stupid!
I've made my own font, been working an hour on it, and before that I read all forums and everything because I couldn't find anything that helped! But now I have the awnser! LOL :p

The fond I need is: StatChars :wacko:

Sorry for my spamming all night … ignore it ;)

Abu

2012-06-20 01:17:07

In future, refrain from double and quadruple posting.

If you want to make another post, edit your current one.


EDIT: Like this.

Master BAW

2012-06-20 01:34:15

:bart: Okay, will do sir.
I understand how to edit, and often I do it but sometimes I forget ^^

putonajonny

2012-06-20 04:43:11

is your text recognition working now?

Master BAW

2012-06-20 12:50:12

From: putonajonny
is your text recognition working now?


YES :spot: 100%