SRL Archive - OSR Help

Confused over Mouse functions


Abu

2013-12-06 13:06:59

This is the piece of code which according to my logic should theoretically work, and did work for me on srl 5 (bout a year ago):

  Arr := findTPACluster([3426430, 2899564, 2129051], 25, mainScreen.getCenterPoint(), -1, -1, 1, 12, True, mainscreen.getBounds());

for a := 0 to high(Arr) do
begin
smartImage.drawCircle(MiddleTPA(Arr[a]), 10, False, clred);
x := middleTPA(Arr[a]).x;
y := middleTPA(Arr[a]).y;
mouse(point(p.x, p.y), MOUSE_RIGHT, MOUSE_ACCURATE);
if isMouseOverText(['ron'], 3000) then
begin
fastClick(MOUSE_RIGHT);
chooseOption.select(['ron'], 3000);
result := True;
break;
end else
begin
writeLn('Error finding uptext, exiting function');
result := False;
exit;
end;

SMART Debug draws a circle around the exact point where I want to click, lovely jubbly. However, here is where my problem lies, when the mouse function is called it moves to a completely random ass location like in the minimap or top-left corner of the screen. Why is this?

Debug shows my TPA is where I want it to be, so why will my mouse not move to the middle of my TPA? Why does it wonder off to some wayward location?

Also, just to confirm, is isMouseOverText() the replacement function for isUptext, or am I calling the completely wrong function here.

Oh and whatever happened to MSX1, MSY1 etc.. I've replaced them with mainScreen.getBounds(), am I correct in doing so? I've also replaced MIX1, MIY1 etc.. with gameTabs.getArea(), is that correct?

A lot of questions I know but I'm still trying to get familiar with srl 6.

Cheers.

bonsai

2013-12-06 14:12:55

From: abu_jwka

x := middleTPA(Arr[a]).x;
y := middleTPA(Arr[a]).y;
mouse(point(p.x, p.y), MOUSE_RIGHT, MOUSE_ACCURATE);


You're telling the mouse to move to an uninitialized variable.

Either:

x := middleTPA(Arr[a]).x;
y := middleTPA(Arr[a]).y;
mouse(point(x, y), MOUSE_RIGHT, MOUSE_ACCURATE);

or

p.x := middleTPA(Arr[a]).x;
p.y := middleTPA(Arr[a]).y;
mouse(p, MOUSE_RIGHT, MOUSE_ACCURATE);

bonsai

2013-12-06 14:17:22

Just noticed that middleTPA returns a point.

No reason to break it out.

p := middleTPA(Arr[a]);
mouse(p, MOUSE_RIGHT, MOUSE_ACCURATE);

mouse(middleTPA(Arr[a]), MOUSE_RIGHT, MOUSE_ACCURATE);

Abu

2013-12-06 15:12:54

From: bonsai
You're telling the mouse to move to an uninitialized variable.


Wow, I can't believe I actually did that and then failed to realise it myself… *slaps head repeatedly*


mouse(middleTPA(Arr[a]), MOUSE_RIGHT, MOUSE_ACCURATE);

^ Cheers for that also, I feel like an idiot, I'm really off my game right now ya see :frusty:


EDIT: You must spread some Reputation around before giving it to bonsai again.

The Mayor

2013-12-06 15:17:12

You cant just write functions freely like you used to. Everything is backwards haha :)

Abu

2013-12-06 15:47:49

From: The Mayor
You cant just write functions freely like you used to. Everything is backwards haha :)


But, but, I liked it like that :crying:

KeepBotting

2013-12-06 18:26:51

isMouseOverText is the new IsUpText, correct. RS no longer has UpText, if you look you'll see it isn't there ;)

MouseOverText is the text in the box that appears when your mouse rolls over an object.

Also MSX1, etc has been replaced with mainscreen.x1, etc.