SRL Archive - SRL Archives

SRLProgressReport


Sir R. M8gic1an

2009-06-09 20:51:52

Also take the time to check out the Player Report!


[php]
[ =============================== ]
[ Extremely Long Test Script 1.00 ]
[ by Rasta Magician ]
[ =============================== ]
[ Fishies: 123 ]
[ Location: Falador ]
[ Active: False ]
[ =============================== ]
[ Extremely Long Test Script 1.00 ]
[ =============================== ]
[/php]


const
ResultDebugBox = 0;
ResultReportBox = 1;
ResultString = 2;

Function SRLProgressReport(ResultType:integer; ScriptName, ScriptAuthor, ScriptVersion: String;
VarNames: TStringArray; VarValues: TVariantArray ): Variant;
var
TSA : TStringArray;
s : string;
i, i2 : integer;
begin
if length(VarNames) <> Length(VarValues) then
begin
SRL_Warn('SRLProgressReport', 'VarNames and VarValues must be the same length', warn_AllVersions);
exit;
end;
SetLength(TSA, 3 + Length(VarNames) + 4);

TSA[0] := '=';
TSA[1] := Capitalize(ScriptName)+' '+ScriptVersion;
TSA[2] := 'by '+ScriptAuthor;
TSA[3] := '=';

i2 := 3 + Length(VarNames);
for i:= 4 to i2 do
begin
s := VarValues[i-4];
TSA[i] := Capitalize(VarNames[i-4])+': '+ Capitalize(s);
end;

TSA[i2+1] := '=';
TSA[i2+2] := Capitalize(ScriptName)+' '+ScriptVersion;
TSA[i2+3] := '=';

i2 := 0;
for i:= 0 to High(TSA) do
i2 := Max(i2, Length(TSA[i]));

TSA[0] := Replicate('=', i2);
TSA[3] := TSA[0];
TSA[High(TSA)-2] := TSA[0];
TSA[High(TSA)] := TSA[0];

TSA[2] := Replicate(' ', round((i2 - Length(TSA[2]))/2) ) + TSA[2]; //centering by ScriptAuthor

for i:= 0 to High(TSA) do
case ResultType of
ResultDebugBox : writeln ('[ '+Padr(TSA[i], i2)+' ]');
ResultReportBox : AddToReport ('[ '+Padr(TSA[i], i2)+' ]');
ResultString : Result := Result + '[ '+Padr(TSA[i], i2)+' ]' + chr(13);
else SRL_Warn('SRLProgressReport', 'Invalid Result Type', warn_AllVersions);
end;
if not ResultType = ResultString then Result := true;
{
[ ========================= ]
[ ScriptName ScriptVersion ]
[ by ScriptAuthor ]
[ ========================= ]
[ VarName[0] : VarValues[0] ]
[ VarName[1] : VarValues[1] ]
[ VarName[2] : VarValues[2] ]
[ VarName[3] : VarValues[3] ]
[ VarName[4] : VarValues[4] ]
[ ========================= ]
[ ScriptName ScriptVersion ]
[ ========================= ]
}

end;

if you wish to test for yourself

program new;
{.include srl/srl.scar}

const
ResultDebugBox = 0;
ResultReportBox = 1;
ResultString = 2;

Function SRLProgressReport(ResultType:integer; ScriptName, ScriptAuthor, ScriptVersion: String;
VarNames: TStringArray; VarValues: TVariantArray ): Variant;
var
TSA : TStringArray;
s : string;
i, i2 : integer;
begin
if length(VarNames) <> Length(VarValues) then
begin
SRL_Warn('SRLProgressReport', 'VarNames and VarValues must be the same length', warn_AllVersions);
exit;
end;
SetLength(TSA, 3 + Length(VarNames) + 4);

TSA[0] := '=';
TSA[1] := Capitalize(ScriptName)+' '+ScriptVersion;
TSA[2] := 'by '+ScriptAuthor;
TSA[3] := '=';

i2 := 3 + Length(VarNames);
for i:= 4 to i2 do
begin
s := VarValues[i-4];
TSA[i] := Capitalize(VarNames[i-4])+': '+ Capitalize(s);
end;

TSA[i2+1] := '=';
TSA[i2+2] := Capitalize(ScriptName)+' '+ScriptVersion;
TSA[i2+3] := '=';

i2 := 0;
for i:= 0 to High(TSA) do
i2 := Max(i2, Length(TSA[i]));

TSA[0] := Replicate('=', i2);
TSA[3] := TSA[0];
TSA[High(TSA)-2] := TSA[0];
TSA[High(TSA)] := TSA[0];

TSA[2] := Replicate(' ', round((i2 - Length(TSA[2]))/2) ) + TSA[2]; //centering by ScriptAuthor

for i:= 0 to High(TSA) do
case ResultType of
ResultDebugBox : writeln ('[ '+Padr(TSA[i], i2)+' ]');
ResultReportBox : AddToReport ('[ '+Padr(TSA[i], i2)+' ]');
ResultString : Result := Result + '[ '+Padr(TSA[i], i2)+' ]' + chr(13);
else SRL_Warn('SRLProgressReport', 'Invalid Result Type', warn_AllVersions);
end;
if not ResultType = ResultString then Result := true;
{
[ ========================= ]
[ ScriptName ScriptVersion ]
[ by ScriptAuthor ]
[ ========================= ]
[ VarName[0] : VarValues[0] ]
[ VarName[1] : VarValues[1] ]
[ VarName[2] : VarValues[2] ]
[ VarName[3] : VarValues[3] ]
[ VarName[4] : VarValues[4] ]
[ ========================= ]
[ ScriptName ScriptVersion ]
[ ========================= ]
}

end;

begin
ClearDebug;
SRLProgressReport(ResultDebugBox, 'Extremely long test script', 'Rasta Magician', '1.00', ['Fishies', 'location', 'active'], [123, 'falador', false]);
end.


so what do you guys think? :) This idea is not originally mine, but i guess i just decided to do it and post.

~RM

Dynamite

2009-06-09 20:55:07

Sweet :)
Cheers RM :D

T~M

Quickmarch

2009-06-09 20:55:38

MylesMadness already made one of these.

Sir R. M8gic1an

2009-06-09 21:00:02

From: Quickmarch
MylesMadness already made one of these.


that's what i meant by it's not originally my idea. link please?

~RM

Da 0wner

2009-06-09 21:06:43

http://villavu.com/forum/showthread.php?t=38442

Naike

2009-06-09 21:35:52

From: Da 0wner
http://villavu.com/forum/showthread.php?t=38442


No offence to Mylessmadness, but RM took the concept to the next level.

Nice work RM ;)

Da 0wner

2009-06-09 21:48:07

Yeah, that one is kind of simple :p.

Edit: Now make one to make multi player progress reports (h).

Sir R. M8gic1an

2009-06-09 22:02:12

From: Da 0wner
Yeah, that one is kind of simple :p.

Edit: Now make one to make multi player progress reports (h).


that's what i am currently doing ;) wait until you see my final project for this.

~RM

ian.

2009-06-09 22:12:17

From: Rasta Magician
that's what i am currently doing ;) wait until you see my final project for this.

~RM


When will it be done? ^^

Floor66

2009-06-09 22:20:49

imo this > milesmadness' one.

Dynamite

2009-06-09 22:23:21

From: Floor66
imo this > milesmadness' one.


Alright it has been said, no need to flame MM ;)
lol

T~M

Floor66

2009-06-09 22:31:21

That wasn't a flame xD
Flaming is…
omg omg myles' one really S U C K E D!@@@ omg omg hes sooooooooo bad <– don't mean any of that.

Sir R. M8gic1an

2009-06-10 02:39:56

From: 99_
When will it be done? ^^


http://www.villavu.com/forum/showthread.php?t=46363

;)

~RM

ZephyrsFury

2009-06-10 09:22:21

OMG:

1. You're taking the fun out of scripting!
2. You're supposed to be inactive.

Well done though. :)