Note that this is a very generic type, and I usually customize it according to what I need to get done.
I've seen other people use different (yet similar) types to do the same and/or different things. (
@zmon; /
@superuser; )
Hope this helps;
program LJTest;
{$include_once srl/srl.simba}
type ID = (INVENTORY, MAINSCREEN, MINIMAP);
type
SearchModel = record
Name: string;
TypeID: ID;
BestColor, Tolerance, InitialColorToleranceSpeed, MinimumPixelCount: Integer;
Hue, Sat: Extended;
Bounds: TBox;
end;
type SearchModels = array of SearchModel;
// Find symbols that change colors or have People on top of them (sometimes)
var MinimapSymbolModels: SearchModels;
const MM_SYMBOL_BANK = 0;
const MM_SYMBOL_TREE = 1;
// Idea Credit = (Generally most well-supported high level languages) or (Zmon)
function CopyPSM(Other: SearchModel): SearchModel;
begin
Result.Name := Other.Name + ' - Copy';
Result.TypeID := Other.TypeID;
Result.BestColor := Other.BestColor;
Result.Tolerance := Other.Tolerance;
Result.Hue := Other.Hue;
Result.Sat := Other.Sat;
Result.InitialColorToleranceSpeed := Other.InitialColorToleranceSpeed;
Result.Bounds := Other.Bounds;
Result.MinimumPixelCount := Other.MinimumPixelCount;
end;
// Idea Credit = (Generally most well-supported high level languages) or (Zmon)
procedure AddModel(var TheList: SearchModels; NewModel: SearchModel);
var Index: Integer;
begin
Index := Length(TheList);
SetLength(TheList, Index + 1);
TheList[Index] := CopyPSM(NewModel);
end;
procedure InitializeSearchModels();
begin
SetLength(MinimapSymbolModels, 0);
end;
procedure Setup();
var Model: SearchModel;
begin
InitializeSearchModels();
with Model do
begin
Name := 'Minimap Symbol - Bank';
TypeID := MINIMAP;
BestColor := 7777;
Tolerance := 0;
Hue := 0.00;
Sat := 0.00;
InitialColorToleranceSpeed := 2;
case TypeID of
INVENTORY: Bounds := IntToBox(MIX1, MIY1, MIX2, MIY2);
MAINSCREEN: Bounds := IntToBox(MSX1, MSY1, MSX2, MSY2);
MINIMAP: Bounds := IntToBox(MMX1, MMY1, MMX2, MMY2);
else
Writeln('Invalid ID Type to search for!');
end;
MinimumPixelCount := 0;
end;
AddModel(MinimapSymbolModels, Model);
Writeln('Added the 1st Element');
with Model do
begin
Name := 'Minimap Symbol - Tree';
TypeID := MINIMAP;
BestColor := 5050;
Tolerance := 125;
Hue := 1.11;
Sat := 7.77;
InitialColorToleranceSpeed := 2;
case TypeID of
INVENTORY: Bounds := IntToBox(MIX1, MIY1, MIX2, MIY2);
MAINSCREEN: Bounds := IntToBox(MSX1, MSY1, MSX2, MSY2);
MINIMAP: Bounds := IntToBox(MMX1, MMY1, MMX2, MMY2);
else
Writeln('Invalid ID Type to search for!');
end;
MinimumPixelCount := 5050;
end;
AddModel(MinimapSymbolModels, Model);
Writeln('Added the 2nd Element');
end;
function ModelToString(TheModel: SearchModel): string;
begin
result := '';
result := result + 'Name = ' + TheModel.Name + #13 + #10;
result := result + 'Best Color = ' + IntToStr(TheModel.BestColor) + #13 + #10;
result := result + 'Tolerance = ' + IntToStr(TheModel.Tolerance) + #13 + #10;
result := result + 'InitialCTS = ' + IntToStr(TheModel.InitialColorToleranceSpeed) + #13 + #10;
result := result + 'Hue = ' + FloatToStr(TheModel.Hue) + ', ';
result := result + 'Sat = ' + FloatToStr(TheModel.Sat) + #13 + #10;
result := result + 'Min Count = ' + IntToStr(TheModel.MinimumPixelCount) + #13 + #10;
result := result + 'Bounds = ' + ToStr(TheModel.BestColor);
end;
var i: Integer;
begin
SetupSRL;
ClearDebug;
Setup();
for i := 0 to high(MinimapSymbolModels) do
begin
Writeln('');
Writeln(ModelToString(MinimapSymbolModels[i]));
end;
end.
(Writing further methods according to what you define in your types varies.)