PDA

View Full Version : MakeDTTM(var TheDTM:integer;TheDDTM: TIntegerArray);



mastaraymond
07-10-2007, 02:25 PM
I made a function to reduce the space of DDTM's declaring in your script:

Procedure MakeDDTM(var TheDTM:integer;TheDDTM: TIntegerArray);
var
TempLength,i:integer;
DDTM:TDTM;
begin;
TempLength:= (Length(TheDDTM) div 6);
If (TempLength < 2) then exit;
DDTM.MainPoint.x:= TheDDTM[0];
DDTM.MainPoint.y:= TheDDTM[1];
DDTM.MainPoint.AreaSize:= TheDDTM[2];
DDTM.MainPoint.AreaShape:= TheDDTM[3];
DDTM.MainPoint.Color:= TheDDTM[4];
DDTM.MainPoint.Tolerance:= TheDDTM[5];
SetArrayLength(DDTM.SubPoints, 0);
for i := 0 to TempLength -2 do
begin
SetArrayLength(DDTM.SubPoints, Length(DDTM.SubPoints) +1);
DDTM.SubPoints[Length(DDTM.SubPoints) -1].x:= TheDDTM[(I+1)*6 + 0];
DDTM.SubPoints[Length(DDTM.SubPoints) -1].y:= TheDDTM[(I+1)*6 + 1];
DDTM.SubPoints[Length(DDTM.SubPoints) -1].AreaSize:= TheDDTM[(I+1)*6 + 2];
DDTM.SubPoints[Length(DDTM.SubPoints) -1].AreaShape:= TheDDTM[(I+1)*6 + 3];
DDTM.SubPoints[Length(DDTM.SubPoints) -1].Color:= TheDDTM[(I+1)*6 + 4];
DDTM.SubPoints[Length(DDTM.SubPoints) -1].Tolerance:= TheDDTM[(I+1)*6 + 5];
end;
TheDTM := AddDTM(DDTM);
end;

If you want o use this you must use the following parameters:
Ofcourse the variable of the DTM you are going to declare. Then you make a array of integers : [454,6475,4754,045,4564,456,2463456] Like that. Ofcourse you must place the integers on a specific place:
The 1st integer is the x, the 2nd y, the 3th is AreaSize, the 4th is AreaShape, the 5th is Color and the 6th is Tolerance. The mainpoint are the first 6 integers, the others are all subpoints. I made a example script:
program New;

var
TheDTM2,x,y:Integer;
bla:extended;

const
RockColor = 4283535;
TreeColor = 4224848;

Procedure MakeDDTM(var TheDTM:integer;TheDDTM: TIntegerArray);
var
TempLength,i:integer;
DDTM:TDTM;
begin;
TempLength:= (Length(TheDDTM) div 6);
If (TempLength < 2) then exit;
DDTM.MainPoint.x:= TheDDTM[0];
DDTM.MainPoint.y:= TheDDTM[1];
DDTM.MainPoint.AreaSize:= TheDDTM[2];
DDTM.MainPoint.AreaShape:= TheDDTM[3];
DDTM.MainPoint.Color:= TheDDTM[4];
DDTM.MainPoint.Tolerance:= TheDDTM[5];
SetArrayLength(DDTM.SubPoints, 0);
for i := 0 to TempLength -2 do
begin
SetArrayLength(DDTM.SubPoints, Length(DDTM.SubPoints) +1);
DDTM.SubPoints[Length(DDTM.SubPoints) -1].x:= TheDDTM[(I+1)*6 + 0];
DDTM.SubPoints[Length(DDTM.SubPoints) -1].y:= TheDDTM[(I+1)*6 + 1];
DDTM.SubPoints[Length(DDTM.SubPoints) -1].AreaSize:= TheDDTM[(I+1)*6 + 2];
DDTM.SubPoints[Length(DDTM.SubPoints) -1].AreaShape:= TheDDTM[(I+1)*6 + 3];
DDTM.SubPoints[Length(DDTM.SubPoints) -1].Color:= TheDDTM[(I+1)*6 + 4];
DDTM.SubPoints[Length(DDTM.SubPoints) -1].Tolerance:= TheDDTM[(I+1)*6 + 5];
end;
TheDTM := AddDTM(DDTM);
end;


Procedure LoadTheDTM(WhichOne:string);
begin;
Case WhichOne of
'bank' : MakeDDTM(TheDTM2,[669,86,0,0,5995142,300,
655,81,1,0,195836,0,
646,96,2,0,15661038,30,
677,96,2,0,15661038,30,
708,108,2,0,15661038,30,
669,119,7,0,TreeColor,0]);
'range' : MakeDDTM(TheDTM2,[670,38,0,0,5470128,300,
675,78,4,0,TreeColor,0,
629,83,1,0,195836,0,
661,61,2,0,RockColor,0,
629,87,1,0,195836,0]);
end;
end;

begin
LoadTheDTM('range');
if FindDTMRotated(TheDTM2,x,y,MMX1,MMY1,MMX2,MMY2,0,2 *pi,0.05, bla) then MoveMouse(x,y);
FreeDTM(TheDTM2);
end.

~Raymond

LordGregGreg
07-10-2007, 02:33 PM
Hey! That is pretty cool! I like how you bundled everything into one, thats always very tricky to do!
Great job!
Mind if i use it sometimes?

Edit: Ok, i looked at it some more.. i REALLY like it, thanks

mastaraymond
07-10-2007, 02:49 PM
Hey! That is pretty cool! I like how you bundled everything into one, thats always very tricky to do!
Great job!
Mind if i use it sometimes?

Edit: Ok, i looked at it some more.. i REALLY like it, thanks

No problem to use it ;). As long as you credit it ;). Glad you like it!

EDIT: That was why i made it, to reduce the space DDTMs take in your script ;).

~Raymond

LordGregGreg
07-10-2007, 05:07 PM
No problem to use it ;). As long as you credit it ;). Glad you like it!

EDIT: That was why i made it, to reduce the space DDTMs take in your script ;).

~Raymond
Will do ! Thanks :)