SRL Archive - Research & Development Lounge

Another Function may be usefull??


Dracody

2008-06-03 16:08:23

Well I kind of made this function, its like IsUpTextMultiCustom, I think it may be usefull, so well I posted here to see what you guys think about it :p



{*******************************************************************************
function FindNPCChatTextMC(Text: TStringArray, Action: fnct_ActionOptions): Boolean;
By: Dracody
Description: Similar to FindNPCChatText but you can input as many strings in an array as you like
Writes the amount of matches in the debug
Use: FindNPCChatTextMC(['Att', 'ttac', 'ack', 'monst', 'ster'])
*******************************************************************************}

function FindNPCChatTextMC(txt: TStringArray; Action: fnct_ActionOptions): boolean;
var
i , l , match: Integer;
begin
Result := false;
l := GetArrayLength(txt);
for i := 0 to l -1 do
if(FindNPCChatText(txt[i], Action)) then
begin
match := match + 1;
end;
if(match = l) then
begin
Result := true;
writeLn('Succesfully matched ' + intToStr(match)+ '/' + intToStr(l));

Timothegreat

2008-06-03 18:40:30

changing

length(txt)

to

GetArrayLength(txt)

will make it faster

Dracody

2008-06-03 19:04:35

Thanks dude I already edited it thanks for the tip :D

Timothegreat

2008-06-03 22:14:54

Shortened up version… imo that match stuff isnt needed



{*******************************************************************************
function FindNPCChatTextMC(Text: TStringArray, Action: fnct_ActionOptions): Boolean;
By: Dracody
Description: Similar to FindNPCChatText but you can input as many strings in an array as you like
Writes the amount of matches in the debug
Use: FindNPCChatTextMC(['Att', 'ttac', 'ack', 'monst', 'ster'])
*******************************************************************************}

function FindNPCChatTextMC(txt: TStringArray; Action: fnct_ActionOptions): boolean;
var
i , l : Integer;
begin
Result := false;
l := GetArrayLength(txt);
for i := 0 to l -1 do
begin
if(FindNPCChatText(txt[i], Action)) then
begin
Result := true;
break;
end;
end;
end;

Dracody

2008-06-04 01:00:19

Yeah , well thats right , hehe I just added the counter to make it type something on the debug :p so it looked cooler, but yeah , the shorter , the better :D