View Full Version : Point(x:LongInt;y:LongInt):Tpont
wantonman
12-06-2012, 06:49 AM
hey, was looking at this conversion function
Point(x:LongInt;y:LongInt):Tpoint
and was wondering about the actual contents of the function
and how to go about making my own...
//13026246-grey//2737143-gold_yellow
program New;
var
mpos:tpoint;
const
mmx1=408;
mmy1=103;
mmx2=566;
mmy2=263;
function point(xx,yy:integer):tpoint;
begin
result.x:=xx;
result.y:=yy;
end;
function rpos:tpoint;
begin
case random(1)of
0:result:=point(mpos.x+Random(5),mpos.y+Random(5)) ;
1:result:=point(mpos.x-Random(5),mpos.y-Random(5));
end;
end;
begin
FindColorTolerance(mpos.x,mpos.y,13026246,mmx1,mmy 1,mmx2,mmy2,4);
MoveMouseSmooth(rpos.x,rpos.y);
end.
It's a ssimple as:
function pnt(xx,yy: integer): tpoint;
begin
result.x := xx;
result.y := yy;
end;
That what you're looking for?
KingKong
12-06-2012, 11:53 AM
^thats probably because of the last line? rpos is not defined anywhere
wantonman
12-06-2012, 08:41 PM
(i accendently deleted the above posts when i was fustrated, i was going fast and did not realize it was the wrong post)
what do you mean not defined? rpos is a function i made ... may you explain to me how to define it then?
so this granted me an access violation in scar 2.03 and apparantly it was because rpos is not defined...
//13026246-grey//2737143-gold_yellow
program New;
var
mpos:tpoint;
const
mmx1=408;
mmy1=103;
mmx2=566;
mmy2=263;
function point(xx,yy:integer):tpoint;
begin
result.x:=xx;
result.y:=yy;
end;
function rpos:tpoint;
begin
case random(1)of
0:result:=point(mpos.x+Random(5),mpos.y+Random(5)) ;
1:result:=point(mpos.x-Random(5),mpos.y-Random(5));
end;
end;
begin
FindColorTolerance(mpos.x,mpos.y,13026246,mmx1,mmy 1,mmx2,mmy2,4);
MoveMouseSmooth(rpos.x,rpos.y);
end.
waht do yu mean define?? i dont understand because it is a function.
masterBB
12-06-2012, 09:47 PM
try
//13026246-grey//2737143-gold_yellow
program New;
var
mpos:tpoint;
const
mmx1=408;
mmy1=103;
mmx2=566;
mmy2=263;
function point(xx,yy:integer):tpoint;
begin
result.x:=xx;
result.y:=yy;
end;
function rpos:tpoint;
begin
case random(1)of
0:result:=point(mpos.x+Random(5),mpos.y+Random(5)) ;
1:result:=point(mpos.x-Random(5),mpos.y-Random(5));
end;
end;
begin
FindColorTolerance(mpos.x,mpos.y,13026246,mmx1,mmy 1,mmx2,mmy2,4);
MoveMouseSmooth(rpos().x,rpos().y);
end.
or even better:
//13026246-grey//2737143-gold_yellow
program New;
var
mpos:tpoint;
const
mmx1=408;
mmy1=103;
mmx2=566;
mmy2=263;
function point(xx,yy:integer):tpoint;
begin
result.x:=xx;
result.y:=yy;
end;
function rpos:tpoint;
begin
case random(1)of
0:result:=point(mpos.x+Random(5),mpos.y+Random(5)) ;
1:result:=point(mpos.x-Random(5),mpos.y-Random(5));
end;
end;
var
rposResult: Tpoint;
begin
FindColorTolerance(mpos.x,mpos.y,13026246,mmx1,mmy 1,mmx2,mmy2,4);
rposResult := rpos();
MoveMouseSmooth(rposResult.x,rposResult.y);
end.
Also, I don't think it does what you think it does. you do realise that your attempt calls the function twice, and thus could give confusing or wrong results in more advanced functions.
wantonman
12-06-2012, 10:16 PM
Ah yes I think I get it now... hmm, so the function is being called twice with each (rpos.x,rpos.y) and causes some sort of error..
soo the solution would be to set a new variable to the result of the function so that way it is safely stored in memory rather then having those access violations... thanks NCDS KingKong MasterBB ... for now on I am going to always safely define the result of a function... this totally explains why access violations are :spot:
ultimately this is what i have
//13026246-grey//2737143-gold_yellow
program New;
var
mpos,rpos:tpoint;
const
mmx1=408;
mmy1=103;
mmx2=566;
mmy2=263;
function ran:tpoint;
begin
case random(1)of
0:begin
result.x:=mpos.x+Random(5);
result.y:=mpos.y+Random(5);
end;
1:begin
result.x:=mpos.x-Random(5);
result.y:=mpos.y-Random(5);
end;
end;
end;
begin
rpos:=ran;
FindColorTolerance(mpos.x,mpos.y,13026246,mmx1,mmy 1,mmx2,mmy2,4);
MoveMouseSmooth(rpos.x,rpos.y);
end.
*note as far as I know this method is nessesary only when a function is being
called twice in a functions function
*ie a tpont... (tpoint.x,tpoint.y)
~ive checked it out with a function resulting in an integer and so far as I've known thers no need to declare the function because your memory is not being written inspontaineously should a tpoint be.
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.