GREEN GIANT
2013-07-26 06:35:12
Hi Guys,
I'm a little stuck on a path walk that i'm actually quite proud of :D (as a novice)
Basically, I use a DTM to find a point on the MM that is on the path and store this color using a function DTMRColor.
I also run a function that finds the percentage of that color at radians between 270-360 (the direction im heading)Function RoadPCent.
I run that through a loop until RoadPCent falls below 5% (path ends) and continue from there.
My problem is that it works fine when i manually input the color of the path into RoadPCent function, but if i declare the color as DTMRCOLOR, it gets confused, as if the DTMRColor is only working once then trying to locate the DTM again or something.
Code is below, is it because everytime i call DTMRColor, it attempts to find the DTM? If so how do i get around it?
At present it finds the color, walks twice then ends. Whereas if i input the color into RoadPCent manually it walks fine.
I'm a little stuck on a path walk that i'm actually quite proud of :D (as a novice)
Basically, I use a DTM to find a point on the MM that is on the path and store this color using a function DTMRColor.
I also run a function that finds the percentage of that color at radians between 270-360 (the direction im heading)Function RoadPCent.
I run that through a loop until RoadPCent falls below 5% (path ends) and continue from there.
My problem is that it works fine when i manually input the color of the path into RoadPCent function, but if i declare the color as DTMRCOLOR, it gets confused, as if the DTMRColor is only working once then trying to locate the DTM again or something.
Code is below, is it because everytime i call DTMRColor, it attempts to find the DTM? If so how do i get around it?
At present it finds the color, walks twice then ends. Whereas if i input the color into RoadPCent manually it walks fine.
Function DTMRColor: integer;
var
rDTM, x, y: integer;
begin
rDTM := DTMFromString('mQwAAAHicY2ZgYKhkYmAoBeJGIHYC8o2BOBiIS3NiGEDgzx8mhv8MCMCIhIEAAAHTBno=');
FindDTM(rDTM, x, y, mmx1, mmy1, mmx2, mmy2);
Result := Getcolor(x, y);
freedtm(rDTM);
end;
function RoadPcent: integer;
begin
Result :=PercentColorMMEx(DTMRColor, 0, 270, 360, 5, 60);
end;
begin
repeat;
writeln(roadpcent);
radialwalk(DTMRColor, 280, 340, 60, x, y)
until (RoadPCent < 5)
end;