SRL Archive - SRL Archives

GetXP fix


Coh3n

2010-03-28 14:57:06

It wasn't working due to the defined search area for the text. Since where the window pops up is pretty random, I changed it to search the inventory for the 'urrent' text.


{*******************************************************************************
function GetXP(Skill: Variant): Integer;
By: Nielsie95
Description: Returns current xp for a skill. Returns -1 if failed.
*******************************************************************************}

function GetXP(Skill: Variant): Integer;
var
p: TPoint;
tx, ty, x, y: Integer;
begin
Result := -1;
if (not TabExists(tab_Stats)) then exit;
GameTab(tab_Stats);
if (GetCurrentTab <> tab_Stats) then exit;
P := SkillToCoords(True, Skill);
if (P.x < 1) then exit;
MMouse(P.x, P.y + 5, 12, 4);
if (not WaitFindColor(x, y, 10551295, MIX1, MIY1, MIX2, MIY2, 0, 4000)) then exit;
Wait(200 + Random(150));
if IsTextInAreaEx(MIX1, MIY1, MIX2, MIY2, tx, ty, 'urrent', 0, SmallChars, False, False, 0, 1, 0) then
Result := StrToIntDef(GetNumbers(GetTextAtEx(tx, ty, 0, SmallChars, False, True, 0, 1, 0, 50, False, tr_AllChars)), -1);
end;
There may be a better way to do it, but this works. :)

Frement

2010-03-28 15:05:08

It worked fine for me without a fix.

Coh3n

2010-03-28 16:07:27

From: Frement
It worked fine for me without a fix.

What skill did you do? I did Woodcutting and every time it would return -1.

Frement

2010-03-28 16:11:04

Attack, worked fine :/

Coh3n

2010-03-28 16:13:03

Try one of the lower skills (Woodcutting, Slayer, etc), the ones that when hovered, the xp box appears above the mouse rather than below.

E: I've been testing the current version more, and it seems to work ~70ish% of the time, else it will return -1.

Frement

2010-04-21 11:34:38

From: Coh3n
Try one of the lower skills (Woodcutting, Slayer, etc), the ones that when hovered, the xp box appears above the mouse rather than below.

E: I've been testing the current version more, and it seems to work ~70ish% of the time, else it will return -1.


Yes, I have been experiencing this same problem alot lately. Mostly using SMART.

Nava2

2010-04-21 11:42:08

Does a box not pop up? Why not search for the box using a find colour, thus you have the top left corner, then you could do some math, perhaps another find colour to create a box to search for text in.

Theoretically would be faster than doing text searching, as it has a tendency to be slow.

Frement

2010-04-21 11:44:22

From: Nava2
Does a box not pop up? Why not search for the box using a find colour, thus you have the top left corner, then you could do some math, perhaps another find colour to create a box to search for text in.

Theoretically would be faster than doing text searching, as it has a tendency to be slow.


The box pops up but it cant read the text correctly.

NCDS

2010-04-21 12:08:02

From: Nava2
Does a box not pop up? Why not search for the box using a find colour, thus you have the top left corner, then you could do some math, perhaps another find colour to create a box to search for text in.

Theoretically would be faster than doing text searching, as it has a tendency to be slow.


Love that idea.

Nava2

2010-04-21 12:45:49

From: Frement
The box pops up but it cant read the text correctly.


I'm not saying to read from that point, but to find the point from there. ;)

Frement

2010-04-21 12:50:46

From: Nava2
I'm not saying to read from that point, but to find the point from there. ;)


I was answering to your question
Does a box not pop up?

Nava2

2010-04-21 13:33:43

From: Frement
I was answering to your question


I'm confused, does a box pop up, but the text inside the box cannot be read?

Frement

2010-04-21 13:36:28

From: Nava2
I'm confused, does a box pop up, but the text inside the box cannot be read?


Yes, the text reading part fails.

Nava2

2010-04-21 13:41:57

From: Frement
Yes, the text reading part fails.


Oh okay, it probably means that the coords are off. Which makes sense as they require them to be top left I believe.

Either way, its arbitrary to fix that issue. Kinda comes with the new process ;)

NCDS

2010-04-21 16:06:44

From: Nava2
Oh okay, it probably means that the coords are off. Which makes sense as they require them to be top left I believe.

Either way, its arbitrary to fix that issue. Kinda comes with the new process ;)


Do you (or anyone else) plan on making what you described above? or can I have some fun? :sasmokin:

Coh3n

2010-04-21 16:08:09

From: NCDS
Do you (or anyone else) plan on making what you described above? or can I have some fun? :sasmokin:

Isn't that what the original function did? All I did was change where it looked for the text. I'm pretty sure before, it looked from the top left corner of the "popup" box to something like halfway down it (or wherever the text ends).

Nava2

2010-04-21 17:55:47

Go NCDS Go!

NCDS

2010-04-21 17:59:53

From: Coh3n
Isn't that what the original function did? All I did was change where it looked for the text. I'm pretty sure before, it looked from the top left corner of the "popup" box to something like halfway down it (or wherever the text ends).


Hmmm..I guess so. I never really looked at the original function I guess.

What Nava was explaining just sounded fun :redface: