just a simple snippet that converts strings to ids.
I made this because you cant pickup ground items with a string, only with IDs (with the current include).
its using itemdb.biz to get the IDs.
usage:
Simba Code:
stringToIDs([]); {add a array of items you want the id of}
stringToIDs(['Rune scimitar', 'Rune platelegs']); {make sure you have CORRECT capitals}
stringToIDs(['Iron bar*', 'Iron ore*']); {if you want to add a noted item add * at the end of the name}
Simba Code:
{author: Hoodz}
function StringToID(StringName: string): Integer;
var
I: Integer;
S, Ls, Cs: string;
SArray: TStringArray;
Noted: Boolean;
begin
Noted := false;
if (StringMatch('*', StringName) > 0) then
begin
Noted := true;
StringName := Replace(StringName, '*', '', []);
end;
LS := Replace(StringName, ' ', '+', []);
S := GetPage('http://itemdb.biz/index.php?search=' + LS);
Cs := Between('<div id="content">', '</font></', S);
Cs := Between('<font color=''', '''>', Cs);
if (Cs = 'red') then
begin
Writeln(StringName + ' Could not be found');
Result := - 1;
Exit;
end;
S := Between('<td><center>', StringName + '<', S);
SArray := Explode('<b>', S);
S := SArray[High(SArray)];
SArray := Explode('</b>', S);
S := SArray[0];
if (S = '') then
begin
Writeln(StringName + ' Could not be found');
Result := - 1;
Exit;
end;
I := StrToInt(S);
if (Noted) then
begin
Inc(I);
Writeln('Item loaded: ' + StringName + ' (noted) - ' + ' (' + IntToStr(I) + ')');
end
else
Writeln('Item loaded: ' + StringName + ' - ' + ' (' + S + ')');
Result := I;
end;
function StringToIDs(StringArray: array of string): array of Integer;
var
I, IntReturn: Integer;
IntArray: array of Integer;
begin
for I := 0 to High(StringArray) do
begin
IntReturn := StringToID(StringArray[I]);
if (IntReturn = - 1) then
continue;
SetLength(IntArray, Length(IntArray) + 1);
IntArray[High(IntArray)] := intReturn;
end;
Result := IntArray;
end;
note: might not work 100%, if this is the case, please say it
EDIT: might add some exceptions like coins if wanted