SRL Archive - RS3 Outdated / Broken Scripts

loadus converter


Here

2007-08-31 16:39:46

I don't really have time for a description, so here you go. If you run it, the explanation is all there. Real easy too.

//By Here

//DFM form parsed by Ron

//Idea credit to RsN
//(as well as used for his script)

//Form help from jhildy's tut

//Thanks to: WT-Fakawi and Freddy1990
//for making SCAR and SRL what it is.

//But most of all, Lord Greg,
//for helping me all the way.

//{.include SRL/SRL.scar}
//I didn't use it because it
//might be a part of SRL one day.

//Update: I took Stupid3ooo's
//marktime and gettimefrommark
//functions from SRL.


var
line1, sfolder1, sfolder2: string;
ftext1, ftext2, poop, sconverted, globalTime,globalLines,linen1: integer;
timelint, ttimelint, timelint2: longint;
fnamesarr: array of string;
degub: boolean;
// InitForm variables.
frmDesign: TForm;
Label1, Label2, Label3, Label4, Label5, Label6: TLabel;
Scripts, modified: TEdit;
CheckBox1: TCheckBox;
Button1: TButton;
Memo1: TMemo;

function readFileLine(GregFile: integer): string;//By Greg Hendrickson!
var
s, bigs: string;
begin
while not EndOfFile(GregFile) do
begin
ReadFileString(GregFile, s, 1);
bigs := bigs + s;
if (s = #10) then
begin
Result := bigs;
exit;
end;
if (degub) then
writeln(bigs);
end;
end;

{*******************************************************************************
procedure MarkTime(var TimeMarker: Integer);
By: Stupid3ooo
Description: Sets TimeMarker to current system time
*******************************************************************************}

procedure MarkTime(var TimeMarker: integer);
begin
TimeMarker := GetSystemTime;
end;

{*******************************************************************************
function TimeFromMark(var TimeMarker: Integer): Integer;
By: Stupid3ooo
Description: returns Milliseconds since MarkTime was set
*******************************************************************************}

function TimeFromMark(var TimeMarker: integer): integer;
begin
Result := GetSystemTime - TimeMarker;
end;


procedure StartClick(Sender: TObject);
begin
sfolder1 := Scripts.Text ;
sfolder2 := modified.Text;
if CheckBox1.Checked then
degub := True
else
degub := False;
frmDesign.ModalResult := mrOk; // Closes the form
end;


// This form was parsed using: DFM Form Parser v.23 by Ron.
procedure InitForm;
var
TimeInitForm: integer;
begin
TimeInitForm := GetSystemTime;
frmDesign := CreateForm;
with frmDesign do
begin
Position := poScreenCenter;
BorderStyle := bsSingle;
BorderIcons := [biMinimize, biSystemMenu];
ClientWidth := 415;
ClientHeight := 475;
Caption := 'Here'#39's '#39'loadus'#39' Convertor';
Color := clBtnFace;
Font.Color := clWindowText;
Font.Height := -11;
Font.Name := 'MS Sans Serif';
Font.Style := [];
PixelsPerInch := 96;
end;
Label1 := TLabel.Create(frmDesign);
with Label1 do
begin
Parent := frmDesign;
Left := 40;
Top := 48;
Width := 240;
Height := 13;
Caption := 'Name of folder your scripts are in (Scripts is default)';
end;
Label2 := TLabel.Create(frmDesign);
with Label2 do
begin
Parent := frmDesign;
Left := 40;
Top := 96;
Width := 253;
Height := 13;
Caption := 'Name of folder your scripts are in (in the Scripts folder)';
end;
Label3 := TLabel.Create(frmDesign);
with Label3 do
begin
Parent := frmDesign;
Left := 40;
Top := 144;
Width := 127;
Height := 13;
Caption := '(No trailing slash on either!)';
end;
Label4 := TLabel.Create(frmDesign);
with Label4 do
begin
Parent := frmDesign;
Left := 40;
Top := 168;
Width := 359;
Height := 13;
Caption :=
'Look in "C:\Program Files\SCAR 3.xx\Scripts\modified " with defau' +
'lt settings';
end;
Label5 := TLabel.Create(frmDesign);
with Label5 do
begin
Parent := frmDesign;
Left := 24;
Top := 16;
Width := 377;
Height := 18;
Caption := 'Here'#39's '#39'declareplayers'#39' into '#39'loadus'#39' Converter';
Font.Color := clWindowText;
Font.Height := -15;
Font.Name := 'Myriad Pro';
Font.Style := [];
ParentFont := False;
end;
Label6 := TLabel.Create(frmDesign);
with Label6 do
begin
Parent := frmDesign;
Left := 40;
Top := 216;
Width := 355;
Height := 13;
Caption :=
'Debugging makes it look better, but slows it up, especially with' +
' many scripts';
end;
Scripts := TEdit.Create(frmDesign);
with Scripts do
begin
Parent := frmDesign;
Left := 40;
Top := 64;
Width := 121;
Height := 21;
TabOrder := 8;
Text := 'Scripts';
end;
modified := TEdit.Create(frmDesign);
with modified do
begin
Parent := frmDesign;
Left := 40;
Top := 112;
Width := 121;
Height := 21;
TabOrder := 9;
Text := 'modified';
end;
CheckBox1 := TCheckBox.Create(frmDesign);
with CheckBox1 do
begin
Parent := frmDesign;
Left := 40;
Top := 192;
Width := 97;
Height := 17;
Caption := 'Debugging On';
TabOrder := 10;
end;
Button1 := TButton.Create(frmDesign);
with Button1 do
begin
Parent := frmDesign;
Left := 164;
Top := 245;
Width := 75;
Height := 25;
Caption := 'Start';
TabOrder := 11;
OnClick := @StartClick;
end;
Memo1 := TMemo.Create(frmDesign);
with Memo1 do
begin
Parent := frmDesign;
Left := 32;
Top := 280;
Width := 364;
Height := 188;
with Memo1.Lines do
begin
Add('Since 3/14/2006 a new and powerful SRL function has been released');
Add('by RsN. Instead of being forced to laboriously fill out a player');
Add('array form for every scar script, we can now just use a "LoadUs"');
Add('and not have to worry about it. This will load up all of the ');
Add('players information already stored inside Chars.srl.');
Add('');
Add('This means having to fill out your chars only once, and it also ');
Add('means the ability to update all of the player arrays in your');
Add('scripts at once.');
Add('');
Add('How do you create this magical Chars.srl file? Inside');
Add('SCAR 3.xx\includes\srl\srl\misc\, there is a form by RSN made');
Add('to do this for you (names UsersManager.scar)');
Add('');
Add('But now, in order to use this new style of player declaration,');
Add('you have to edit every single one of your scripts. This could take');
Add('many hours. Enter this script, which will automatically comment');
Add('out the player array and all the unnecessary stuff, and insert');
Add('the LoadUs function automatically in your script.');
Add('But now, in order to use this new style of player declaration, y');
Add('');
Add('It has never been so easy to achieve such great convenience');
Add('and utilize a modular approach!');
end;
ReadOnly := True;
ScrollBars := ssVertical;
TabOrder := 12;
end;
WriteLn('InitForm compiled in ' + IntToStr(GetSystemTime - TimeInitForm) +
' milliseconds!');
end;

procedure SafeInitForm;
var
V: TVariantArray;
begin
SetArrayLength(V, 0);
ThreadSafeCall('InitForm', V);
end;

procedure ShowInitFormModal;
begin
frmDesign.ShowModal;
end;

procedure SafeShowInitFormModal;
var
V: TVariantArray;
begin
SetArrayLength(V, 0);
ThreadSafeCall('ShowInitFormModal', V);
end;


procedure MainInitForm;
begin
try
SafeInitForm;
SafeShowInitFormModal;
finally
FreeForm(frmDesign);
except
WriteLn('An error seems to have occurred in: InitForm');
end;
end;


procedure CopyPaste(ssname1:Array of string);
var linec1, lltime1, xd: integer;
begin
linen1 := 0;
linec1 := 10;
marktime(lltime1);
while not EndOfFile(ftext1) do
begin
linen1 := linen1 + 1;
globalLines:=globalLines+1;
line1 := readFileLine(ftext1);

if (degub) then
writeln(IntToStr(RegexPos(line1, '[pP][lL][aA][Yy][Ee][rR][sS]\[[0-9{1,9}]')));
//my debugging
if (RegexPos(line1, '[pP][lL][aA][Yy][Ee][rR][sS]\[[0-9{1,9}]') > 0) then
begin
line1 := '//' + line1;
end;
if (degub) then
writeln(IntToStr(RegexPos(line1,
'[nN][uU][mM][bB][eE][rR][oO][fF][Pp][lL][aA][yY][eE][rR][sS][(]\s{0,900}[hH][oO][wW][mM][aA][nN][yY][pP][lL][aA][yY][eE][rR][sS]\s{0,900}[)]'))); //my debugging
if (RegexPos(line1,
'[nN][uU][mM][bB][eE][rR][oO][fF][Pp][lL][aA][yY][eE][rR][sS]\s{0,900}[(]\s{0,900}[hH][oO][wW][mM][aA][nN][yY][pP][lL][aA][yY][eE][rR][sS]\s{0,900}[)]') > 0) then
begin
line1 := '//' + line1;
end;
if (degub) then
writeln(IntToStr(RegexPos(line1,
'[hH][oO][wW][mM][aA][nN][yY][pP][lL][aA][yY][eE][rR][sS]\s{0,900}[:=]\s{0,900}')));
//my debugging
if (RegexPos(line1,
'[hH][oO][wW][mM][aA][nN][yY][pP][lL][aA][yY][eE][rR][sS]\s{0,900}[:=]\s{0,900}') >
0) then
begin
line1 := 'loadus;' + #10 + '//' + line1;
end;
//ReadFileString (ftext1, line1, FileSize(ftext1));
WriteFileString(ftext2, line1);
if((linen1 mod linec1)=0) then
Status('Time for our script :' + IntToStr(timefrommark(lltime1)) +
'ms. | Lines done of our script: '+intToStr(linen1)+' ||| Global Time Running: '+
inttostr(timefrommark(globalTime))+'ms | Global Lines Completed: '+inttoStr(globalLines));
end;
xd := 0;
//writeln (inttostr(linen1) + ' lines converted in ' + ssname1[xd]); made them gloab vars...
//addtoReport('Done->'+ssname1[xd]+'|'+inttostr(linen1) + ' lines');
xd := xd + 1;
end;


begin
//SetupSRL;
ClearDebug;
GetSelf.WindowState := wsMinimized;
MainInitForm;
GetSelf.WindowState := wsNormal;
writeln('');
sconverted := 0;
ttimelint := 0;
fnamesarr := GetFiles(AppPath + 'Scripts\', 'scar');
MarkTime(globalTime); //added these two lines
globalLines:=0;
ClearDebug;
ClearReport;
for poop := 0 to (GetArrayLength(fnamesarr) - 1) do
begin
ftext1 := OpenFile(AppPath + sfolder1 + '\' + fnamesarr[poop], False);
ftext2 := RewriteFile(AppPath + sfolder1 + '\' + sfolder2 + '\' +
fnamesarr[poop], False);
marktime(timelint);
if (ftext1 > -1) then
CopyPaste(fnamesarr);
timelint2 := timefrommark(timelint);
writeln(fnamesarr[poop] + '('+inttoStr(linen1)+' lines) was converted in ' + IntToStr(timelint2) +
' milliseconds.');
addtoReport(fnamesarr[poop]+'|'+inttostr(timelint2) + 'ms|'+inttoStr(linen1)+' lines');
CloseFile(ftext1);
CloseFile(ftext2);
sconverted := sconverted + 1;
ttimelint := ttimelint + timelint2;
end;
writeln('');
writeln(IntToStr(sconverted) + ' scripts changed with the loadus converter in ' +
IntToStr(ttimelint) + ' milliseconds.');
writeln('Look in your SCAR folder, then in ' + sfolder1 + '\' +
sfolder2 + ' for your scripts.');
writeln('Remember to set your players array with RsN'#39's UsersManager.scar in includes\SRL\SRL\scripts\Misc\');
writeln('');
end.

Killerdou

2007-08-31 16:41:42

here is back!! nice comback script:)

ShowerThoughts

2007-08-31 16:44:17

nice…

LordGregGreg

2007-08-31 17:30:41

Q.
So does this mean i don;t ever have to fill in another player array ever again to run a script?! And I can use this for any srl script?!

A.
Yes.

rotflmfwao

2007-08-31 20:11:39

I just use the one in Users.scar….. but this is cool nonetheless.

LordGregGreg

2007-08-31 20:48:19

From: rotflmfwao
I just use the one in Users.scar….. but this is cool nonetheless.


I don't think you quite get the point. This is a script processor. It takes all of the scripts in your folder that do not use the "Loadus" command, and converts them to a script that does. (and saves in a diferent folder).

This makes it rediculously easy to replace all of the player array stuff with the loadus command instead, which allows you to only have to have your players stored once, and to have thier locations, statistics, and everything automagically updated universally.

rotflmfwao

2007-08-31 21:21:00

Oh. lmao, sorry, I feel retarded, give me noob points.

I didn't look over the script closely enough. This = most pwnage ever. ('cept 4 me)

LordGregGreg

2007-08-31 21:37:06

From: rotflmfwao
Oh. lmao, sorry, I feel retarded, give me noob points.

I didn't look over the script closely enough. This = most pwnage ever. ('cept 4 me)

hey, its cool dude, just gave me a chance to explain to some others who didnt read. no problem :D

Dan Cardin

2007-08-31 21:41:50

wow, great(though i dont think it worked for me) to bad ur already a member cuz thisd get u in…unless it didnt cuz its not rs…(why do u have to submit a rs script to get in membs?or else u wont have antiban,antirandoms and stuff)

Smartzkid

2007-08-31 21:47:26

Awesome!
Oooo…Regexes

  for poop := 0 to (GetArrayLength(fnamesarr) - 1) do

haha

LordGregGreg

2007-08-31 22:13:38

From: Smartzkid
Awesome!
Oooo…Regexes

  for poop := 0 to (GetArrayLength(fnamesarr) - 1) do

haha

lol, yep, "poop" "crap" "foo" are always great variable names for incrimentors. :P

Oh yeah, @ dan, we though of that too, we were trying to make a members worht y script without making her play rs, so we cam up with this, lol.

But yeah, it would not qualify alone to be members material, (no srl, no antirandoms, etc)

Dan Cardin

2007-08-31 22:19:29

From: lordgreggreg
lol, yep, "poop" "crap" "foo" are always great variable names for incrimentors. :P

Oh yeah, @ dan, we though of that too, we were trying to make a members worht y script without making her play rs, so we cam up with this, lol.

But yeah, it would not qualify alone to be members material, (no srl, no antirandoms, etc)


which i think is stupid, the antirandoms and stuff should only apply on rs scripts. Then on other game scripts u judge harder cuz it doesnt need to worry about those(most likely). and on non-game scripts u judge the hardest, and even if they were judged the hardest i think she'd be in.

but w/e that might not even make sense cuz i dont feel like re-reding it so, good job again, and does this mean she's back? or just a quick stop on the comp to post it then away again?(or did she ever even leave:confused:)

Boreas

2007-08-31 23:16:35

Pwnage.

Other devs: put in SRL?

LordGregGreg

2007-09-01 00:19:14

From: Boreas
Pwnage.

Other devs: put in SRL?


*wink*

told ya Here!

@dan, yeah.. but i think those requirment for members are there for good rreasons, here and i had a bit of a dicussion, and we agreed to. Besides, rules are for the majority, not the minorty, which is why here is a member, and doesnt play rs :P

Yes, i think this is srl worthy, because it has my method in there ofcourse :P

Bobarkinator

2007-09-01 03:10:39

This is amazing Here.

Hugolord

2007-09-01 03:52:10

wait hold up so this edit a script without opening it??

LordGregGreg

2007-09-01 09:10:15

From: hugolord
wait hold up so this edit a script without opening it??


lol, hugo, :P

Yes, this script uses a couple of regular expresions to read every script and make modofications to it, so you don't have to manually if you wish to use the loadus command.

Here

2007-09-07 16:33:58

From: Boreas
Pwnage.

Other devs: put in SRL?

Thanks, but it's not worthy. Not that I know the real worth of SRL. Sorry.

As for everyone else, thanks for the positive feedback. It took quite a (little) bit of work.

mat_de_b

2007-09-10 14:44:06

Put it in the scripting tools folder, with the radial walk aid etc…

LordGregGreg

2007-09-12 02:13:44

From: mat_de_b
Put it in the scripting tools folder, with the radial walk aid etc…

hmm.. its not really a scritping tool.

i mean, a good scripter can easily convert his script..

this is more of a convinence thing, an updater.
it can edit 1000s of script while u sleep.

so im not sure where this should go..

hmm

Here

2007-11-20 01:33:08

Has this passed to obsoletion?

LordGregGreg

2007-11-20 13:48:00

Yes unfortunatly.

Idont think the people here had time enough to actually THINK and realiza the convinience this provides.

Instead of seeing it savethem tons fo time, they get caught up on the initial start up time that it takes to download it and run it (like, 20 seconds guys! wtf?)

I am still quite proud of the qualitiy of this program.

Perhaps we could get permision to move it to the leechers section?

Darevaine

2007-11-21 01:14:46

Does this still work properly? If so… Then this is just frigging awesome!
I was about to start writing a script that would fill in the relevant fields automatically in each new script I set up to try out. And then this gets bumped up… Talk about great timing. Heck, I'm just going to try this out and see if it works, I can't wait to see!

Here

2007-11-21 12:44:11

Nice to see SOMEBODY using it. You don't even need to give me credit. (If I remember correctly, I believe my program already does that, but you can edit it out if you really want. It's just a line I believe.)

LordGregGreg

2007-11-21 15:01:18

From: Darevaine
Does this still work properly? If so… Then this is just frigging awesome!
I was about to start writing a script that would fill in the relevant fields automatically in each new script I set up to try out. And then this gets bumped up… Talk about great timing. Heck, I'm just going to try this out and see if it works, I can't wait to see!

he he, yes, it does work.

remember, it does not fill in the player forms for you, it replaces them with a "loadus" command.

That command loads up your players that you have stored in a database.

Don't have a database of your players? Then you need to make one using the program form mentioned above. (you already have that scri[pt, it is included with srl)

Darevaine

2007-11-22 02:26:33

From: LordGregGreg
he he, yes, it does work.

remember, it does not fill in the player forms for you, it replaces them with a "loadus" command.

That command loads up your players that you have stored in a database.

Don't have a database of your players? Then you need to make one using the program form mentioned above. (you already have that scri[pt, it is included with srl)


Yepyep! I actually already stored a few of my chars in a DB using the script you mentioned. And I know this one won't fill in forms… It does something even better! ;) As soon as I have time to look through SRL to find the 'loadus' procedure(so the scripts this thing converts are useful, and I can enter more chars into the DB), I'm going to script me a GUI to handle all my scripts/players from one interface… Talk about a time-saver. Woho!

This is sorta off-topic, but now the built-in form to edit my 'armies' isn't working. It gives me the same error that any other script with 'loadus' does. Namely, that it can't find 'loadus.' I realize that this is most likely because I'm not including the correct library(or whatever they're called), but I figured I'd ask for advice, since the script made especially to manage players is no longer working for me. Any ideas on how to fix it would be greatly appreciated.

Here

2007-11-22 22:15:32

Either you're not using SRL correctly, or the new updates screwed it. I don't know, you'd have much more support with other members. I'm not exactly a SCAR user.