SRL Archive - OSR Help

MMouse and TPoints..


Element17

2013-04-03 13:26:11

procedure MiddlePoint;
var
mpx,mpy:integer;
ax,ay: Tpoint;
begin
mpx := ax.x;
mpy := ay.y;
mpx := ((606 + 649)/2);
writeln('mp X' + ToStr(mpx));
if mpx > 0 then writeln('yay') else writeln('boo');
mpy := ((15 + 15)/2);
writeln('mp Y' +ToStr(mpy));

MMouse(ax.x,ay.y,0,0); // or MMouse(mpx, mpy, 0, 0) Both move to top left
end;

begin
SetupSRL;
MiddlePoint;

When I do this it just moves the mouse to the top left. Not sure why?

tealc

2013-04-03 13:36:45

You never give ax.x or ay.y a value so you basically called mmouse(0,0,0,0)

Element17

2013-04-03 13:41:16

mpx := ax.x;
mpy := ay.y;

So this should be different?

Haxz

2013-04-03 13:43:42

When you do
mpx := ((606 + 649)/2);
mpy := ((15 + 15)/2);

I think mpx and mpy has changed to whatever you declared it to be after.

Element17

2013-04-03 13:46:31

So I'm guessing this then?



mpx := ((606 + 649)/2);
mpx := ax.x;

Haxz

2013-04-03 13:51:47

When you do mpx := ((606 + 649)/2); , mpx will be equal to 627. But after that if you do mpx := ax.x;, mpx will no longer be 627, it will now be ax.x, which is 0 because you haven't give it anything.


Try this.

Procedure midddddd;
var
x, y: Integer;
box: TBox;
middle: TPoint;
begin
middle := MiddleBox(IntToBox(x1, y1, x2, y2));
MMouse(middle.x, middle.y, 0, 0);
end;

Element17

2013-04-03 13:57:32

I'm not making a box. I'm using this in a triangle.

Just trying to find the Middle point of the line and click it.

**Edit NM….hold on trying something.

Le Jingle

2013-04-03 13:59:35

Is there any more context to this?
For the originally posted code, I'd simply do:

{$include_once srl/srl.simba}
begin
SetupSRL;
MMouse(Round((606 + 649) / 2), Round((15 + 15) / 2), 0, 0);
end.

Haxz

2013-04-03 14:01:06

Have no idea about triangles in Simba. Thought you were finding the middle point of a box since you have 2 xs and 2 ys. Sorry :p