SRL Archive - SRL Suggestions

ChatBox additions


slushpuppy

2012-05-26 11:22:23

function ChatBoxgetNameAt(lineNum : Integer) : String;
var str : String;
begin
str := GetChatBoxText(lineNum,clMessage);
Result := trim(ReplaceRegExpr('\W?([A-Za-z0-9_\ ]*)\W?', str, '$1', True));
end;
function ChatBoxConvoLine(lineNum,color : Integer) : array of String;
var
tempstr : String;
begin
tempstr := GetChatBoxText(lineNum,color);
if tempstr <> '' then
begin
SetArrayLength(Result,2);

Result[0] := ChatBoxgetNameAt(lineNum);
Result[1] := tempstr;
end
end;
function ChatBoxConvoArray(color : Integer) : array of array of String;
var I,index: Integer;
begin

for I := 1 to 8 do
begin
index := Length(Result);
SetArrayLength(Result,index + 1);
Result[index] := ChatBoxConvoLine(I,color);
end;
end;


ChatBoxConvoLine(lineNum,color : Integer) // returns conversations in chat box in the format ['RSN', 'whatever he/she said']

function ChatBoxConvoArray(color : Integer) // Same as above except it returns an array of conversations [['RSN1', 'whatever he/she said']['RSN2', 'whatever he/she said']]

putonajonny

2012-06-04 05:35:49

for this:
         SetArrayLength(Result,2);

Result[0] := ChatBoxgetNameAt(lineNum);
Result[1] := tempstr;
why not just:
Result := [ChatBoxgetNameAt(lineNum), tempstr];

for this:
  for I := 1 to 8 do
begin
index := Length(Result);
SetArrayLength(Result,index + 1);
Result[index] := ChatBoxConvoLine(I,color);
end;
why not just do:

SetArrayLength(Result, 8);
for I := 1 to 8 do
Result[I] := ChatBoxConvoLine(I,color);