SRL Archive - SRL Bugs

ToggleXPBar


Shuttleu

2012-01-01 11:48:46

Currently it returns false if it is already open (if you set Open to true) or if it is already closed (if you set Open to false)


{*******************************************************************************
function ToggleXPBar(Open: Boolean): Boolean;
By: Narcle & IceFire908
Description: Opens or closes the XP Bar, true if had to toggle.
*******************************************************************************}

function ToggleXPBar(Open: Boolean): Boolean;
var
TPA: TPointArray;
P: TPoint;
T: Integer;
begin
if Open xor IsXPBarOpen then
begin
TPA := TPAFromBox(IntToBox(521, 51, 546, 75));
FilterPointsPie(TPA, 0, 360, 0, 12, 534, 63);
P := TPA[Random(Length(TPA))];
Mouse(P.X, P.Y, 0, 0, true);
T := GetSystemTime + 300;
repeat
wait(1);
Result := Open = IsXPBarOpen;
until Result or (GetSystemTime > t);
end else
result:= True;
end;

this fixes it

~shut

Narcle

2012-01-01 11:56:51

From: Shuttleu
Currently it returns false if it is already open (if you set Open to true) or if it is already closed (if you set Open to false)


{*******************************************************************************
function ToggleXPBar(Open: Boolean): Boolean;
By: Narcle & IceFire908
Description: Opens or closes the XP Bar, true if had to toggle.
*******************************************************************************}

function ToggleXPBar(Open: Boolean): Boolean;
var
TPA: TPointArray;
P: TPoint;
T: Integer;
begin
if Open xor IsXPBarOpen then
begin
TPA := TPAFromBox(IntToBox(521, 51, 546, 75));
FilterPointsPie(TPA, 0, 360, 0, 12, 534, 63);
P := TPA[Random(Length(TPA))];
Mouse(P.X, P.Y, 0, 0, true);
T := GetSystemTime + 300;
repeat
wait(1);
Result := Open = IsXPBarOpen;
until Result or (GetSystemTime > t);
end else
result:= True;
end;

this fixes it

~shut


Yes I know, this is in SRL5. All my efforts have been on SRL5 for release.

Shuttleu

2012-01-01 11:57:57

ok, and SRL5 is going to be released in a couple of days?

~shut

Narcle

2012-01-01 12:02:57

From: Shuttleu
ok, and SRL5 is going to be released in a couple of days?

~shut


SRL5 is basically ready now. I'm just waiting on Wizzup and them to push it forward. I think they have other things they want done for release as well. (don't quote me on that)

Wanted

2012-01-01 13:38:09

"Description: Opens or closes the XP Bar, true if had to toggle."

Meaning it would tell if you if it performed a toggle….

Currently it returns false if it is already open (if you set Open to true)


Already open, set to open = no toggle = false.

or if it is already closed (if you set Open to false)


Already closed, set to close = no toggle = false.

Does exactly as it describes, also note that returning if it's open or not is absolutely useless to the end user when using that function. If you did need that you have IsXPBarOpen but you wouldn't need to use that at the same time you are toggling it. What is useful to the end user of the function is whether or not action was taken.

Narcle

2012-01-01 14:50:29

How would it be useful to know if its been toggled or not? Its only used for reading the XP amount. There's no reason to KNOW if it had to be toggled, only to make sure that its open or closed (to read the XP). That or make sure its closed (with confirmation) so its not in the way of the main screen.

Also that's the old description needs to be changed.

E:
I guess with that IsXPBarOpen could be removed.

Wanted

2012-01-01 15:04:31

From: Narcle
How would it be useful to know if its been toggled or not? Its only used for reading the XP amount. There's no reason to KNOW if it had to be toggled, only to make sure that its open or closed (to read the XP). That or make sure its closed (with confirmation) so its not in the way of the main screen.

Also that's the old description needs to be changed.

E:
I guess with that IsXPBarOpen could be removed.


It's important to know if it's toggled so you know if any time passed and also so it can be returned to it's original state. Really it should be a procedure if anything.

It's bug because people miss used it like adding this to GetXPBarTotal

begin
if not ToggleXPBar(True) then
Exit;

without reading the description or looking at the source of the function they are using first.

Confirming whether or not it 'worked' or whatever is pointless

Here's an example of what I'm talking about of usefulness to the end user if done properly:

function GetXPBarTotal: LongInt;
var
Previous: Boolean;
TPA: TPointArray;
B: TBox;
P: TPoint;
begin
Previous := ToggleXPBar(True);
if (Previous) then
if (not (WaitFunc(@IsXPBarOpen, True, 10, 15, 1500, 1750))) then
Exit;
FindColorsTolerance(TPA, clWhite, 342, 55, 510, 69, 1);
B := GetTPABounds(TPA);
B := IntToBox(B.X1 - 2, B.Y1 - 2, B.X2 + 2, B.Y2 + 2);
IsTextInAreaEx(B.X1, B.Y1, B.X2, B.Y2, P.X, P.Y, 'XP', 0, XPChars, False, False, 0, 1, clWhite);
Result := StrToIntDef(GetNumbers(GetTextAtEx(P.X, P.Y, 1, XPChars, False, False, 0, 2, clWhite, 60, False, tr_AllChars)), 0);
if (not (Previous)) then
Exit;
WaitRR(500, 1500);
ToggleXPBar(False);
end;

No unnecessary looping and waiting.

Shuttleu

2012-01-01 15:26:23

From: Wanted
"Description: Opens or closes the XP Bar, true if had to toggle."

Meaning it would tell if you if it performed a toggle….



Already open, set to open = no toggle = false.



Already closed, set to close = no toggle = false.

Does exactly as it describes, also note that returning if it's open or not is absolutely useless to the end user when using that function. If you did need that you have IsXPBarOpen but you wouldn't need to use that at the same time you are toggling it. What is useful to the end user of the function is whether or not action was taken.


from looking at the name i would have thought that it would return whether it is in the correct state

and thats probably what most other people think

~shut

Wanted

2012-01-01 17:14:02

From: Shuttleu
from looking at the name i would have thought that it would return whether it is in the correct state

and thats probably what most other people think

~shut


Yea maybe but then you could never do awesome stuff like this

Previous := ToggleXPBar(True);

Narcle

2012-01-01 18:21:04

From: Wanted
Yea maybe but then you could never do awesome stuff like this

Previous := ToggleXPBar(True);


Previous := IsXPBarOpen;

Shuttleu

2012-01-01 18:40:42

From: Wanted
Yea maybe but then you could never do awesome stuff like this

Previous := ToggleXPBar(True);

like this

Previous:= IsXPBarOpen
ToggleXPBar(True);
Previous:= Previous xor IsXPBarOpen

~shut

Wanted

2012-01-02 02:01:56

From: Narcle
Previous := IsXPBarOpen;


Lol well that doesn't move the XPBar for you =P

I guess really what I meant in this thread was in a way this is subjective.

I see it as ToggleXPBar will never fail and even if it did you're thing is going to fail anyways… you may as well utilize another type of information in it that may be of some use because honestly I rewrote that code in my post about 6 times if you don't believe me look at the edit history. There's so many ways to do things differently it would blow your mind. I've seen details and discovered things you could not imagine by taking such a close look at things.

Anyways