SRL Archive - OSR Help

Need help with Error: Exception: Type Mismatch


bud_wis_er_420

2012-01-05 16:40:07

Ok I thought one of the resons I was getting theError: Exception: Type Mismatch at line 303' error:
until(IsUpTextMultiCustom([text]))or(rightcount >= 9)
is because the TStringArray variable text was empty so I was getting the Type Mismatch message. adding 'var' to the Get_Herb_Info procedure should have fixed this because it wasn't passing the variable along. But it it is now passing it(I tested it with a for loop) but I'm still getting the same error.

What this script should do as it is, is with the bank open, it will search each bank slot one by one for a herb dtm with a custom color depending on the herb type. ATM all herb types are set for clean guams's while in testing phase. if it finds a close match it moves mouse to the main point to check uptext. The uptext it looks for is setup though the Get_Herb_Info procedure as a TStringArray. The above line of code is what I'm using to search for the text, but it seems to be hanging up there for some reason.

Any ideas What I'm doing wrong?

////////////////////Ignore This Part////////////////////////
program New; //
//{$DEFINE SMART} //
{$i srl/srl.scar} //
var x,y,next :integer;



//
const //
////////////////////////////////////////////////////////////
Select_Task = 1; // 0 = Clean berbs. 1 = Make potions
Tolerance = 15;
AreaSize = 0;
AreaShape = 0;
////////////////////////////////////////////////////////////
///////////////////Begining of Script///////////////////////
////////////////////////////////////////////////////////////


function SetHerbDTM(Hcolor, Gcolor: integer): integer;
var
Sub_Pt: array[0..5] of TDTMPointDef;
Main_Pt: TDTMPointDef;
Herb_TDTM: TDTM;
begin
Main_Pt.x:=184;
Main_Pt.y:=103;
Main_Pt.areasize:=1;
Main_Pt.areashape:=0;
Main_Pt.color:=Hcolor;
Main_Pt.tolerance:=10;

Sub_Pt[0].x:=192;
Sub_Pt[0].y:=109;
Sub_Pt[0].areasize:=AreaSize;
Sub_Pt[0].areashape:=AreaShape;
Sub_Pt[0].color:=Gcolor; //This color is green or brown for clean or grimy
Sub_Pt[0].tolerance:=Tolerance;

Sub_Pt[1].x:=198;
Sub_Pt[1].y:=106;
Sub_Pt[1].areasize:=AreaSize;
Sub_Pt[1].areashape:=AreaShape;
Sub_Pt[1].color:=131072 ;
Sub_Pt[1].tolerance:=Tolerance;

Sub_Pt[2].x:=189;
Sub_Pt[2].y:=115;
Sub_Pt[2].areasize:=AreaSize;
Sub_Pt[2].areashape:=AreaShape;
Sub_Pt[2].color:=131072 ;
Sub_Pt[2].tolerance:=Tolerance;

Sub_Pt[3].x:=183;
Sub_Pt[3].y:=113;
Sub_Pt[3].areasize:=AreaSize;
Sub_Pt[3].areashape:=AreaShape;
Sub_Pt[3].color:=131072 ;
Sub_Pt[3].tolerance:=Tolerance;

Sub_Pt[4].x:=175;
Sub_Pt[4].y:=109;
Sub_Pt[4].areasize:=AreaSize;
Sub_Pt[4].areashape:=AreaShape;
Sub_Pt[4].color:=131072 ;
Sub_Pt[4].tolerance:=Tolerance;

Sub_Pt[5].x:=172;
Sub_Pt[5].y:=104;
Sub_Pt[5].areasize:=AreaSize;
Sub_Pt[5].areashape:=AreaShape;
Sub_Pt[5].color:=131072 ;
Sub_Pt[5].tolerance:=Tolerance;

Herb_TDTM.MainPoint := Main_Pt;
Herb_TDTM.SubPoints := Sub_Pt;
Result := AddDTM(Herb_TDTM);
end;


procedure Get_Herb_Info(herb:string; var Herb_Text: TStringArray; var Herb_DTM: integer);

begin
case herb of
'Guam' : begin
if(Select_Task = 1)then
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Clean g', 'ean guam', 'an guam'];
for next:=0 to high(Herb_Text) do
writeln(Herb_Text[next])
end else
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Grimy g', 'imy guam','my guam'];
end;
end;
'Marrentill' : begin
if(Select_Task = 1)then
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Clean g', 'ean guam', 'an guam'];
end else
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Grimy g', 'imy guam','my guam'];
end;
end;
'Tarromin' : begin
if(Select_Task = 1)then
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Clean g', 'ean guam', 'an guam'];
end else
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Grimy g', 'imy guam','my guam'];
end;
end;
'Harralander': begin
if(Select_Task = 1)then
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Clean g', 'ean guam', 'an guam'];
end else
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Grimy g', 'imy guam','my guam'];
end;
end;
'Ranarr' : begin
if(Select_Task = 1)then
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Clean g', 'ean guam', 'an guam'];
end else
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Grimy g', 'imy guam','my guam'];
end;
end;
'Toadflax' : begin
if(Select_Task = 1)then
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Clean g', 'ean guam', 'an guam'];
end else
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Grimy g', 'imy guam','my guam'];
end;
end;
'SpiritWeed' : begin
if(Select_Task = 1)then
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Clean g', 'ean guam', 'an guam'];
end else
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Grimy g', 'imy guam','my guam'];
end;
end;
'Irit' : begin
if(Select_Task = 1)then
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Clean g', 'ean guam', 'an guam'];
end else
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Grimy g', 'imy guam','my guam'];
end;
end;
'Wergali' : begin
if(Select_Task = 1)then
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Clean g', 'ean guam', 'an guam'];
end else
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Grimy g', 'imy guam','my guam'];
end;
end;
'Avantoe' : begin
if(Select_Task = 1)then
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Clean g', 'ean guam', 'an guam'];
end else
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Grimy g', 'imy guam','my guam'];
end;
end;
'Kwuarm' : begin
if(Select_Task = 1)then
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Clean g', 'ean guam', 'an guam'];
end else
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Grimy g', 'imy guam','my guam'];
end;
end;
'Snapdragon' : begin
if(Select_Task = 1)then
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Clean g', 'ean guam', 'an guam'];
end else
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Grimy g', 'imy guam','my guam'];
end;
end;
'Cadantine' : begin
if(Select_Task = 1)then
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Clean g', 'ean guam', 'an guam'];
end else
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Grimy g', 'imy guam','my guam'];
end;
end;
'Lantadyme' : begin
if(Select_Task = 1)then
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Clean g', 'ean guam', 'an guam'];
end else
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Grimy g', 'imy guam','my guam'];
end;
end;
'DwarfWeed' : begin
if(Select_Task = 1)then
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Clean g', 'ean guam', 'an guam'];
end else
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Grimy g', 'imy guam','my guam'];
end;
end;
'Torstol' : begin
if(Select_Task = 1)then
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Clean g', 'ean guam', 'an guam'];
end else
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Grimy g', 'imy guam','my guam'];
end;
end;
'Fellstalk' : begin
if(Select_Task = 1)then
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Clean g', 'ean guam', 'an guam'];
end else
begin
Herb_DTM := SetHerbDTM(604423, 1980229);
Herb_Text := ['Grimy g', 'imy guam','my guam'];
end;
end;
end;
end;


{function Store_Item(item: string,
begin

end; }


function Find_Item(x, y: integer; item: string): Boolean;
var
rightcount, downcount, Slotx, Sloty, DTM: integer;
text: TStringArray;
begin
Slotx := 31;
Sloty := 85;
rightcount := 0;
downcount := 0;
Get_Herb_Info(item, text, DTM);
repeat
repeat
if(FindDTM(DTM, x, y, Slotx, Sloty, Slotx + 44, Sloty + 44))then
begin
MMouse(x - 5, y - 5, 10, 10);
end;
Slotx := Slotx + 44;
rightcount := rightcount + 1;
until(IsUpTextMultiCustom([text]))or(rightcount >= 9)
Sloty := Sloty + 44;
Slotx := 31;
downcount := downcount + 1;
until(IsUpTextMultiCustom([text]))or(downcount >= 3)
if(IsUpTextMultiCustom([text]))then Result:= true;
end;

procedure Get_Item(item: string);
var
DTM,i: integer;
text: TStringArray;
begin
if(Find_Item(x,y,item))then
begin
//Store_Item(x,y,item)
Mouse(x, y, 0, 0, false);
end else writeln('Could not find ' + item);

end;


begin
ClearDebug();
//Smart_Server := 44;
SetupSRL();

Get_Item('Guam')


end.

PatDuffy

2012-01-05 16:44:45

Welllll you could do an easier way for the DTM's…

DTM Editor, and make DTM's for each herb, then do DTM -> String, you would call it like so.

  Guam := DTMFromString('fakjfi392u4932jr9d93kd093k390dk093kf');
Tarromin:=DTMFromtString('f93kd3k9nhjgt84f934kd93fjk84fj3f39f');

and such, then to find the herbs in the bank

  if FindDTM(x,y,Guam,MSX1,MSY1,MSX2,MSY2) then
if IsUpText('uam') then

and such.

bud_wis_er_420

2012-01-05 16:49:04

From: PatDuffy
Welllll you could do an easier way for the DTM's…

DTM Editor, and make DTM's for each herb, then do DTM -> String, you would call it like so.

  Guam := DTMFromString('fakjfi392u4932jr9d93kd093k390dk093kf');
Tarromin:=DTMFromtString('f93kd3k9nhjgt84f934kd93fjk84fj3f39f');

and such, then to find the herbs in the bank

  if FindDTM(x,y,Guam,MSX1,MSY1,MSX2,MSY2) then
if IsUpText('uam') then


Well each herb might need different settings, color tol, etc. Using the TDTM allows me to edit them at anytime. Plus I plan on using the same TDTM maker for all other items aswell. will make for alot shorter script and less DTMs needing to be loaded. Because only the dtms that need to be loaded will be loaded.

Edit:
When I finally get it working I won't have to add anymore procedures or functions. I will be able to handle all the items though thoses that already exist with a little tweaking.