PDA

View Full Version : Newbie Form Tutorial



Da 0wner
03-25-2008, 04:56 AM
Ok, so you want to learn forms huh? Well i'm gonna make this nice and easy. Just stay with me and you might learn something :rolleyes:

Important Notes:

Don't forget to

http://i29.tinypic.com/14bksna.jpg

Rate thread excellent, and rep me :D.

If you are a leecher, i encourage you to keep reading so that you can make a script for something someone might not have made. :p.

* means that I will not be going over this on this lesson.

So let's get started!

First lets take you to the form editor.

http://i25.tinypic.com/23licdl.jpg

After you go there look at this picture. I will explain each number and what the item on top of it is.

http://i26.tinypic.com/348onm1.jpg

1: This is a label. You can use it to label an edit box or somewhere along those lines.

2: This is an edit box. This is where you can make people type a short amount of information.

3: This is a memo box. This is where you can display proggys, help etc. You can also make people post a large amount of information.

4: This is a button. You can make people click on it and it will perform an action.

5: This is a checkbox. Multiple amounts of these can be checked. You can make it if a user checks it something will happen.

6: This is a radio box. Only 1 of these may be checked. You can make people choose from a type of things to do. Etc, Use Hotkeys, Use Repeat.

7: This is a list box. Things are listed in here and you can get what the user clicked on.*

8: This is a combobox. You can make mutliple options in this etc, Red, Blue, Green.

9: This is a scroll bar. You can use this to change the amount of minutes before sleeping in a script etc.*

10: This is a groupbox. You can use this to easily group objects together.

11: This is a panel. I have no use for this....*

Now that you know what everything is we can get to actually making the form.

So go ahead and drag a 2 labels, 2 edit buttons, and a button onto the form, so it should look like this,

http://i29.tinypic.com/2mhirgj.jpg

Then click Label1 and find where it says caption in the object inspector near the left. Type in 'Username:'. Then for Label2 go to caption and type in 'Password:'. Then on the button make the caption 'Login'.

After you've named everything and placed them like this,

http://i26.tinypic.com/2elf2xk.jpg

save it as 'FormTut1' by clicking the disk thing on the Form Designer.

Now, you are probably wondering 'How the hell do i make this work?'. This is what you do.

First of all close the form window, go to Tools -> Load DFM Form. Then find what you saved yours as and click it. Then you should find a bunch of text in your debug box. Now paste this into your scar window


Program New;

Var



Procedure InitForm;
Begin



End;

Procedure SafeInitForm;
Var
v: TVariantArray;
Begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
End;

Procedure ShowFormModal;
Begin
frmDesign.ShowModal;
End;

Procedure SafeShowFormModal;
Var
v: TVariantArray;
Begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
End;

Begin

SafeInitForm;
SafeShowFormModal;

End.


Then paste the text below where it says



//Add these objects to variable declarations
var


below the var in the script above. Then find where it says



///////////////// Generated from: (your form here).dfm


Copy all that text into the InitForm procedure. Now if you run that you see that it only shows for a second then closes. In the debug box you'll find that it says



[Runtime Error] : Exception: Cannot make a visible window modal in line xx in script C:\Documents and Settings\KyLe\Desktop\Untitled.scar


To fix that just find where it says


FrmDesign.Visible := True;


and change it to


FrmDesign.Visible := False;


You must remember to ALWAYS change that or else your form will never work :).

Now you're wondering 'yea it shows, but it dosent do anything'.

Now it's not going to actually login but it will write in the debug to the text you typed.

So here's how you do that.

Below where it says


Button1.TabOrder := 8;


put


Button1.OnClick := @Test;


The @ symbol means action which sends the name of the sender to the procedure Test.

Now here's what the procedure test is so far


Procedure Test(Sender : TObject);
Begin
End;


To make it say what the text you typed do this in it


Writeln('In username you typed: ' + Edit1.Text);
Writeln('In password you typed: ' + Edit2.Text);


That will write to the debug box what you typed in the boxes.
Now press run and see what happens.

Now to explain these procedures


Procedure SafeInitForm;
Var
v: TVariantArray;
Begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
End;

Procedure ShowFormModal;
Begin
frmDesign.ShowModal;
End;

Procedure SafeShowFormModal;
Var
v: TVariantArray;
Begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
End;


You need this procedures to safely call a form. That way if the form has an errror it won't mess up scar. (Well sometimes)

I don't really know actually what they do (:garfield:) but I no that you ALWAYS need them. So whenever you want to make a form show up make these procedures and put this in your main loop


SafeInitForm;
SafeShowFormModal;


***This tutorial is not complete yet. I will show you examples of all the types. I have to go to sleep now so I will finish this tomarrow ;)***

Iron Man
03-25-2008, 04:58 AM
Nice tutorial, your pretty good at forms so your the person to learn from :P.

skilld u
03-25-2008, 07:47 PM
great tut. da 0wner makes ownage forms.

Cazax
03-25-2008, 09:51 PM
Nice tut, can you explain how to add tabs?

ShowerThoughts
03-25-2008, 09:57 PM
srl player form is not bad to..., but nice tut!

Da 0wner
03-25-2008, 10:08 PM
*** NOT DONE YET!!! ***

This will be the greatest form tut you will ever read. (Besides widgets :p)

@ Hermpie - This isn't for players only. Personally i like to use the way i structure my player manager because i don't use armys and all of that. I'm not done with tut gonna explain all the types of items from dialogs to canvas to buttons. But thanks for pos comment :p.

@ Iron Man Ftw - Ty :p yw for making your form

@ Skilld u - Yay! tyvm Your welcome for making your form

@ Caz I'll make a tut on adding tabs or maybe add to this one :stir:

mixster
03-25-2008, 10:17 PM
There's already a tut for adding tabs (check the advanced section - lots of interesting form tuts there) and I personally can make cooler forms :)
Otherwise, nice start and I hope you explain timer's at some point (even though I know how to use them etc. from Delphi, but it's awesome for making things forms that look cool).

Cazax
03-25-2008, 10:23 PM
There's already a tut for adding tabs (check the advanced section - lots of interesting form tuts there)

I searched but i still dont understand Sky Scripter tut.

Da 0wner
03-25-2008, 11:13 PM
Ok i added a tab tut. Hope you like it :p Tried to make people friendly xD

the scar noob
03-25-2008, 11:13 PM
Haven't seen you around before, you're pretty new. How does it come that you can handle forms that quickly? Do you have any experience with (Turbo)Delphi or are you an old banned member?:p

-Tsn.

Da 0wner
03-25-2008, 11:17 PM
I'm new. I've been temp banned for like a week tho ;p. I just like forms and catch on to them in about 10 minutes.

ShowerThoughts
03-25-2008, 11:19 PM
Haven't seen you around before, you're pretty new. How does it come that you can handle forms that quickly? Do you have any experience with (Turbo)Delphi or are you an old banned member?:p

-Tsn.
No, this is not my second account!!!
oops wrong account :p

i learned DTM and walking very fast he does it with forms;)

Da 0wner
03-25-2008, 11:20 PM
No, this is not my second account!!!
oops wrong account :p

i learned DTM and walking very fast he does it with forms;)

Hehe i learn dtms in 15 seconds. Walking took a bit longer ;) About 20 minutes :(. Too get radius right and all that. I want to get tut writers award. So i'm gonna release about 10 form tuts ;) Then i'll stop once i get it.

Iron Man
03-26-2008, 05:16 AM
My awesome form:


program New;
var
frmDesign : TForm;
Label1 : TLabel;
Label2 : TLabel;
Edit1 : TEdit;
Edit2 : TEdit;
Button1 : TButton;

procedure InitForm;
begin
frmDesign := CreateForm;
frmDesign.Left := 250;
frmDesign.Top := 114;
frmDesign.Width := 696;
frmDesign.Height := 480;
frmDesign.Caption := 'frmDesign';
frmDesign.Color := clBtnFace;
frmDesign.Font.Color := clWindowText;
frmDesign.Font.Height := -11;
frmDesign.Font.Name := 'MS Sans Serif';
frmDesign.Font.Style := [];
frmDesign.Visible := False;
frmDesign.PixelsPerInch := 96;
Label1 := TLabel.Create(frmDesign);
Label1.Parent := frmDesign;
Label1.Left := 104;
Label1.Top := 56;
Label1.Width := 57;
Label1.Height := 13;
Label1.Caption := 'Username';
Label2 := TLabel.Create(frmDesign);
Label2.Parent := frmDesign;
Label2.Left := 104;
Label2.Top := 96;
Label2.Width := 57;
Label2.Height := 13;
Label2.Caption := 'Password:';
Edit1 := TEdit.Create(frmDesign);
Edit1.Parent := frmDesign;
Edit1.Left := 176;
Edit1.Top := 56;
Edit1.Width := 121;
Edit1.Height := 21;
Edit1.TabOrder := 8;
Edit1.Text := 'Edit1';
Edit2 := TEdit.Create(frmDesign);
Edit2.Parent := frmDesign;
Edit2.Left := 176;
Edit2.Top := 96;
Edit2.Width := 121;
Edit2.Height := 21;
Edit2.TabOrder := 9;
Edit2.Text := 'Edit2';
Button1 := TButton.Create(frmDesign);
Button1.Parent := frmDesign;
Button1.Left := 176;
Button1.Top := 136;
Button1.Width := 113;
Button1.Height := 33;
Button1.Caption := 'Start the l33t script';
Button1.TabOrder := 10;
end;



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

procedure ShowFormModal;
begin
frmDesign.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
SafeInitForm;
SafeShowFormModal;
end.

skilld u
03-26-2008, 05:17 AM
nice, your form doesn't do anything :p when you click the button it doesn't even exit.

faster789
03-26-2008, 05:27 AM
No, this is not my second account!!!
oops wrong account :p

i learned DTM and walking very fast he does it with forms;)


yess!! ur the person to come toooo!! lol btw didnt u self-ban? anyways lol i'm going to be bothering you now a lot!:p becuz i luv seeing a script walking ! i wana learn soooo badd i like printed all of the map walking tuts out but still dont understand :( ...i think i alredy added u on msn..but yea ima be disturbing u a lot!

and btw awsum form tut! rep++

Richard
03-28-2008, 06:20 PM
Great tut mate, I repped you :)

Btw, do you still you those procedure names in forms like when I sort of taught you some bits, more like I sent you my script for you to look at it, then you became the form master lol

Torrent of Flame
03-28-2008, 07:41 PM
I dont get the Password bit and stuff? Abotu how you make it work.

You should release a full one. I mean like, showing how to add colours and stuff.

Richard
03-28-2008, 08:12 PM
I dont get the Password bit and stuff? Abotu how you make it work.

You should release a full one. I mean like, showing how to add colours and stuff.

Colours is simple, you just have to know the right line. Forms is my main strong point in scripting as well :p

I'll edit this in a sec and show you how to add colours because its quite simple once you know how.

EDIT: Here you go with how to change colours.

To change the background colour find this line

frmDesign.Color := clMaroon;

The current colour there is maroon (taken from my fletcher). You MUST keep the cl at the beggining.


The change text colour find this line (usually right below the above)

frmDesign.Font.Color := clRed;

Once again keep the cl at the front.

Da 0wner
03-28-2008, 10:41 PM
@ DR Thanks :p.

@ TOF: What you mean? To make it look like a password like ****? You just do Editx.PasswordChar := '*'; or whatever you want the password char to be ;p.

Torrent of Flame
03-29-2008, 10:04 AM
No, how you make it so that when you click Login it actually starts

Da 0wner
03-29-2008, 10:04 PM
Like how you make it do a procedure? On the button stuff put Buttonx.OnClick := @UrProcedure;

And on ur procedure put the name like


Procedure UrProcedure(Sender : TObject);


Sender is what the @ symbol fills out and @ means action ;).

mixster
03-29-2008, 10:12 PM
Or you just put the form startup bit before your script and when the form closes, it will continue with the script (as the form runs in its own loop until closed). Similarly, it's good to offer a 'start' button that sets a global boolean to true then closes the form, so that the user doesn't close the form to cancel the setup and then run it as I have an 'if not StartBool then TerminateScript;' just after the form bit but before the mainloop.

Da 0wner
03-29-2008, 10:21 PM
Mixster, please don't keep posting thinking you know everything. You may not know but i am probably better then you at forms so just please nicly sthu :). And you would probably want other settings too....

mixster
03-29-2008, 10:31 PM
I don't think I know everything, I just posted an alternative way to do it. Also, I would say you have no idea what I know about forms, so it's probably not better to say you probably know more. I've played around with Delphi a lot and am currently writing a game in Scar using forms. Lastly, you would input other settings before clicking the 'login' button, so you would probably want the form to close when you click login so the rest of the script can continue.

Da 0wner
03-29-2008, 10:38 PM
Ok...But don't just be all smart alec and think you know more than me because like you said i have no idea how good you are and you know how good i am. ;)

KoKouKo
03-29-2008, 11:24 PM
Can you teach me how to use CheckBoxes and RadioButtons pl0x?

I will <3 you 4 ever!!! :D

Da 0wner
03-29-2008, 11:28 PM
Yes


If RadioButton1.Checked then writeln('checked');
If CheckBox1.Checked then writeln('checked');


If you need more explained add me on msn
kylewollaston@hotmail.com

drizzt
03-30-2008, 12:28 AM
very nice, this tut along with the adding tab to forms helped me make this one :p all i gotta do is figure out ini files now ^_^ and nevermind all the hints, i have it setup so i can copy/paste it in my script with all the vars because i dunno .ini yet
program New;
{.include srl/srl.scar}
var
Logs, Knife, Axe, CboxDTM, LC, SC, LB, TD, TA, Tree, Tinderbox, Longbow: integer;
frmDesign : TForm;
PageControl1 : TPageControl;
Tabs : Array of TTabSheet;
Label1 : array of TLabel;
Edit1, Edit2, Edit3, Edit4 : array of TEdit;
Edit5, Edit6: TEdit;
RadioButton1 : array of TRadioButton;
ComboBox1, ComboBox2 : array of TComboBox;
Button1, Button2, Button3 : TButton;

Const
Rundirection = 'n';


Procedure FormStuff; forward;
Procedure DeclarePlayers; forward;

Procedure AddPlayer(sender : Tobject);
var t: integer;
begin
inc(howmanyplayers);

SetArrayLength(Tabs, Howmanyplayers);
SetArrayLength(Label1, Howmanyplayers);
SetArraylength(Edit1, Howmanyplayers);
SetArraylength(Edit2, Howmanyplayers);
SetArraylength(Edit3, Howmanyplayers);
SetArraylength(Edit4, Howmanyplayers);
SetArraylength(RadioButton1, Howmanyplayers);
SetArrayLength(ComboBox1, Howmanyplayers);
SetArraylength(ComboBox2, Howmanyplayers);

t := howmanyplayers - 1;

Tabs[t] := TTabSheet.Create(frmDesign);
Tabs[t].PageControl := PageControl1;
Tabs[t].Caption := 'Player ' + inttostr(howmanyplayers);

Label1[t] := TLabel.Create(frmdesign);
Label1[t].Parent := Tabs[t];
Label1[t].Left := 128;
Label1[t].Top := 133;
Label1[t].Width := 105;
Label1[t].Height := 17;
Label1[t].Caption := 'Before Logging Out';

Edit1[t] := TEdit.Create(frmdesign);
Edit1[t].Parent := tabs[t];
Edit1[t].Left := 64;
Edit1[t].Top := 21;
Edit1[t].Width := 137;
Edit1[t].Height := 21;
Edit1[t].TabOrder := 0;
Edit1[t].Text := 'Name';

Edit2[t] := TEdit.Create(frmdesign);
Edit2[t].Parent := tabs[t];
Edit2[t].Left := 64;
Edit2[t].Top := 61;
Edit2[t].Width := 137;
Edit2[t].Height := 21;
Edit2[t].TabOrder := 1;
Edit2[t].Text := 'Password';

Edit3[t] := TEdit.Create(frmdesign);
Edit3[t].Parent := tabs[t];
Edit3[t].Left := 64;
Edit3[t].Top := 101;
Edit3[t].Width := 57;
Edit3[t].Height := 21;
Edit3[t].TabOrder := 2;
Edit3[t].Text := 'Nick';

RadioButton1[t] := TRadioButton.Create(frmdesign);
RadioButton1[t].Parent := tabs[t];
RadioButton1[t].Left := 64;
RadioButton1[t].Top := 229;
RadioButton1[t].Width := 81;
RadioButton1[t].Height := 25;
RadioButton1[t].Caption := ' Active?';
RadioButton1[t].Checked := True;
RadioButton1[t].TabOrder := 3;
RadioButton1[t].TabStop := True;

Edit4[t] := TEdit.Create(frmdesign);
Edit4[t].Parent := tabs[t];
Edit4[t].Left := 64;
Edit4[t].Top := 133;
Edit4[t].Width := 57;
Edit4[t].Height := 21;
Edit4[t].TabOrder := 4;
Edit4[t].Text := 'Loads';

ComboBox1[t] := TComboBox.Create(frmdesign);
ComboBox1[t].Parent := tabs[t];
ComboBox1[t].Left := 64;
ComboBox1[t].Top := 165;
ComboBox1[t].Width := 145;
ComboBox1[t].Height := 21;
ComboBox1[t].ItemHeight := 13;
ComboBox1[t].TabOrder := 5;
ComboBox1[t].Text := 'Type of Tree';
ComboBox1[t].Items.Add('Tree');
ComboBox1[t].Items.Add('Oak');
ComboBox1[t].Items.Add('Willow');
ComboBox1[t].Items.Add('Yew');

ComboBox2[t] := TComboBox.Create(frmdesign);
ComboBox2[t].Parent := tabs[t];
ComboBox2[t].Left := 64;
ComboBox2[t].Top := 197;
ComboBox2[t].Width := 145;
ComboBox2[t].Height := 21;
ComboBox2[t].ItemHeight := 13;
ComboBox2[t].TabOrder := 6;
ComboBox2[t].Text := 'Action on Logs';
ComboBox2[t].Items.Add('Fletch');
ComboBox2[t].Items.Add('Burn');
ComboBox2[t].Items.Add('Drop');

PageControl1.ActivePageIndex := t;
end;

Procedure StartButton(sender : Tobject);
begin
FrmDesign.modalresult := mrOk;
end;

Procedure Form;
var t: integer;
begin
frmDesign := CreateForm;
frmDesign.Left := 296;
frmDesign.Top := 164;
frmDesign.Width := 439;
frmDesign.Height := 325;
frmDesign.Caption := 'Power! by Drizzt';
frmDesign.Color := clBtnFace;
frmDesign.Font.Color := clWindowText;
frmDesign.Font.Height := -11;
frmDesign.Font.Name := 'MS Sans Serif';
frmDesign.Font.Style := [];
frmDesign.Visible := False;
frmDesign.PixelsPerInch := 96;

PageControl1 := TPageControl.Create(frmDesign);
PageControl1.Parent := frmDesign;
PageControl1.Left := 0;
PageControl1.Top := 0;
PageControl1.Width := 273;
PageControl1.Height := 289;
PageControl1.TabOrder := 0;

SetArrayLength(Tabs, 1);
SetArrayLength(Label1, 1);
SetArraylength(Edit1, 1);
SetArraylength(Edit2, 1);
SetArraylength(Edit3, 1);
SetArraylength(Edit4, 1);
SetArraylength(RadioButton1, 1);
SetArrayLength(ComboBox1, 1);
SetArraylength(ComboBox2, 1);
Howmanyplayers := 1;

Tabs[0] := TTabSheet.Create(frmDesign);
Tabs[0].PageControl := PageControl1;
Tabs[0].Caption := 'Player ' + inttostr(howmanyplayers);

Label1[0] := TLabel.Create(frmdesign);
Label1[0].Parent := Tabs[0];
Label1[0].Left := 128;
Label1[0].Top := 133;
Label1[0].Width := 105;
Label1[0].Height := 17;
Label1[0].Caption := 'Before Logging Out';

Edit1[0] := TEdit.Create(frmdesign);
Edit1[0].Parent := tabs[0];
Edit1[0].Left := 64;
Edit1[0].Top := 21;
Edit1[0].Width := 137;
Edit1[0].Height := 21;
Edit1[0].TabOrder := 0;
Edit1[0].Text := 'Name';

Edit2[0] := TEdit.Create(frmdesign);
Edit2[0].Parent := tabs[0];
Edit2[0].Left := 64;
Edit2[0].Top := 61;
Edit2[0].Width := 137;
Edit2[0].Height := 21;
Edit2[0].TabOrder := 1;
Edit2[0].Text := 'Password';

Edit3[0] := TEdit.Create(frmdesign);
Edit3[0].Parent := tabs[0];
Edit3[0].Left := 64;
Edit3[0].Top := 101;
Edit3[0].Width := 57;
Edit3[0].Height := 21;
Edit3[0].TabOrder := 2;
Edit3[0].Text := 'Nick';

RadioButton1[0] := TRadioButton.Create(frmdesign);
RadioButton1[0].Parent := tabs[0];
RadioButton1[0].Left := 64;
RadioButton1[0].Top := 229;
RadioButton1[0].Width := 81;
RadioButton1[0].Height := 25;
RadioButton1[0].Caption := ' Active?';
RadioButton1[0].Checked := True;
RadioButton1[0].TabOrder := 3;
RadioButton1[0].TabStop := True;

Edit4[0] := TEdit.Create(frmdesign);
Edit4[0].Parent := tabs[0];
Edit4[0].Left := 64;
Edit4[0].Top := 133;
Edit4[0].Width := 57;
Edit4[0].Height := 21;
Edit4[0].TabOrder := 4;
Edit4[0].Text := 'Loads';

ComboBox1[0] := TComboBox.Create(frmdesign);
ComboBox1[0].Parent := tabs[0];
ComboBox1[0].Left := 64;
ComboBox1[0].Top := 165;
ComboBox1[0].Width := 145;
ComboBox1[0].Height := 21;
ComboBox1[0].ItemHeight := 13;
ComboBox1[0].TabOrder := 5;
ComboBox1[0].Text := 'Type of Tree';
ComboBox1[0].Items.Add('Tree');
ComboBox1[0].Items.Add('Oak');
ComboBox1[0].Items.Add('Willow');
ComboBox1[0].Items.Add('Yew');

ComboBox2[0] := TComboBox.Create(frmdesign);
ComboBox2[0].Parent := tabs[0];
ComboBox2[0].Left := 64;
ComboBox2[0].Top := 197;
ComboBox2[0].Width := 145;
ComboBox2[0].Height := 21;
ComboBox2[0].ItemHeight := 13;
ComboBox2[0].TabOrder := 6;
ComboBox2[0].Text := 'Action on Logs';
ComboBox2[0].Items.Add('Fletch');
ComboBox2[0].Items.Add('Burn');
ComboBox2[0].Items.Add('Drop');

Button1 := TButton.Create(frmDesign);
Button1.Parent := frmDesign;
Button1.Left := 288;
Button1.Top := 216;
Button1.Width := 121;
Button1.Height := 33;
Button1.Caption := 'Start';
Button1.TabOrder := 9;
Button1.onclick := @StartButton;

Button2 := TButton.Create(frmDesign);
Button2.Parent := frmDesign;
Button2.Left := 288;
Button2.Top := 128;
Button2.Width := 121;
Button2.Height := 33;
Button2.Caption := 'Add Player';
Button2.TabOrder := 10;
Button2.OnClick := @Addplayer;

Edit5 := TEdit.Create(frmDesign);
Edit5.Parent := frmDesign;
Edit5.Left := 288;
Edit5.Top := 72;
Edit5.Width := 121;
Edit5.Height := 21;
Edit5.Font.Color := clWindowText;
Edit5.Font.Height := -11;
Edit5.TabOrder := 3;
Edit5.Text := 'SRL ID';

Edit6 := TEdit.Create(frmDesign);
Edit6.Parent := frmDesign;
Edit6.Left := 288;
Edit6.Top := 32;
Edit6.Width := 121;
Edit6.Height := 21;
Edit6.TabOrder := 4;
Edit6.Text := 'SRL Password';

Pagecontrol1.Activepageindex := 0;
end;

Procedure DeclarePlayers;
var p : integer;
begin
NumberOfplayers(howmanyplayers);
Currentplayer := 0

for p := 0 to Howmanyplayers - 1 do
begin
Players[p].Name := Edit1[p].text; //username
Players[p].Pass := Edit2[p].text; //password
Players[p].Nick := Edit3[p].text; //3-4 letters from your username
Players[p].Integers[0] := StrToInt(Edit4[p].text); //loads per logout
Players[p].Strings[1] := Combobox1[p].text; //Tree, Willow, Yew, Etc.
Players[p].Strings[0] := Combobox2[p].text; //What to do? Ex.'Fletch','Burn','Drop'
Players[p].Active := Radiobutton1[p].checked;
end;
end;

Procedure SafeInitForm;
Var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('Form', v);
end;

Procedure ShowFormModal;
Begin
frmDesign.ShowModal;
end;

Procedure SafeShowFormModal;
Var
v: TVariantArray;
Begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

Procedure FormStuff;
begin
safeinitform;
SafeShowFormModal;
end;

begin
SetupSRL;
FormStuff;
end.

KoKouKo
03-30-2008, 12:38 AM
very nice, this tut along with the adding tab to forms helped me make this one :p all i gotta do is figure out ini files now ^_^ and nevermind all the hints, i have it setup so i can copy/paste it in my script with all the vars because i dunno .ini yet
program New;
{.include srl/srl.scar}
var
Logs, Knife, Axe, CboxDTM, LC, SC, LB, TD, TA, Tree, Tinderbox, Longbow: integer;
frmDesign : TForm;
PageControl1 : TPageControl;
Tabs : Array of TTabSheet;
Label1 : array of TLabel;
Edit1, Edit2, Edit3, Edit4 : array of TEdit;
Edit5, Edit6: TEdit;
RadioButton1 : array of TRadioButton;
ComboBox1, ComboBox2 : array of TComboBox;
Button1, Button2, Button3 : TButton;

Const
Rundirection = 'n';


Procedure FormStuff; forward;
Procedure DeclarePlayers; forward;

Procedure AddPlayer(sender : Tobject);
var t: integer;
begin
inc(howmanyplayers);

SetArrayLength(Tabs, Howmanyplayers);
SetArrayLength(Label1, Howmanyplayers);
SetArraylength(Edit1, Howmanyplayers);
SetArraylength(Edit2, Howmanyplayers);
SetArraylength(Edit3, Howmanyplayers);
SetArraylength(Edit4, Howmanyplayers);
SetArraylength(RadioButton1, Howmanyplayers);
SetArrayLength(ComboBox1, Howmanyplayers);
SetArraylength(ComboBox2, Howmanyplayers);

t := howmanyplayers - 1;

Tabs[t] := TTabSheet.Create(frmDesign);
Tabs[t].PageControl := PageControl1;
Tabs[t].Caption := 'Player ' + inttostr(howmanyplayers);

Label1[t] := TLabel.Create(frmdesign);
Label1[t].Parent := Tabs[t];
Label1[t].Left := 128;
Label1[t].Top := 133;
Label1[t].Width := 105;
Label1[t].Height := 17;
Label1[t].Caption := 'Before Logging Out';

Edit1[t] := TEdit.Create(frmdesign);
Edit1[t].Parent := tabs[t];
Edit1[t].Left := 64;
Edit1[t].Top := 21;
Edit1[t].Width := 137;
Edit1[t].Height := 21;
Edit1[t].TabOrder := 0;
Edit1[t].Text := 'Name';

Edit2[t] := TEdit.Create(frmdesign);
Edit2[t].Parent := tabs[t];
Edit2[t].Left := 64;
Edit2[t].Top := 61;
Edit2[t].Width := 137;
Edit2[t].Height := 21;
Edit2[t].TabOrder := 1;
Edit2[t].Text := 'Password';

Edit3[t] := TEdit.Create(frmdesign);
Edit3[t].Parent := tabs[t];
Edit3[t].Left := 64;
Edit3[t].Top := 101;
Edit3[t].Width := 57;
Edit3[t].Height := 21;
Edit3[t].TabOrder := 2;
Edit3[t].Text := 'Nick';

RadioButton1[t] := TRadioButton.Create(frmdesign);
RadioButton1[t].Parent := tabs[t];
RadioButton1[t].Left := 64;
RadioButton1[t].Top := 229;
RadioButton1[t].Width := 81;
RadioButton1[t].Height := 25;
RadioButton1[t].Caption := ' Active?';
RadioButton1[t].Checked := True;
RadioButton1[t].TabOrder := 3;
RadioButton1[t].TabStop := True;

Edit4[t] := TEdit.Create(frmdesign);
Edit4[t].Parent := tabs[t];
Edit4[t].Left := 64;
Edit4[t].Top := 133;
Edit4[t].Width := 57;
Edit4[t].Height := 21;
Edit4[t].TabOrder := 4;
Edit4[t].Text := 'Loads';

ComboBox1[t] := TComboBox.Create(frmdesign);
ComboBox1[t].Parent := tabs[t];
ComboBox1[t].Left := 64;
ComboBox1[t].Top := 165;
ComboBox1[t].Width := 145;
ComboBox1[t].Height := 21;
ComboBox1[t].ItemHeight := 13;
ComboBox1[t].TabOrder := 5;
ComboBox1[t].Text := 'Type of Tree';
ComboBox1[t].Items.Add('Tree');
ComboBox1[t].Items.Add('Oak');
ComboBox1[t].Items.Add('Willow');
ComboBox1[t].Items.Add('Yew');

ComboBox2[t] := TComboBox.Create(frmdesign);
ComboBox2[t].Parent := tabs[t];
ComboBox2[t].Left := 64;
ComboBox2[t].Top := 197;
ComboBox2[t].Width := 145;
ComboBox2[t].Height := 21;
ComboBox2[t].ItemHeight := 13;
ComboBox2[t].TabOrder := 6;
ComboBox2[t].Text := 'Action on Logs';
ComboBox2[t].Items.Add('Fletch');
ComboBox2[t].Items.Add('Burn');
ComboBox2[t].Items.Add('Drop');

PageControl1.ActivePageIndex := t;
end;

Procedure StartButton(sender : Tobject);
begin
FrmDesign.modalresult := mrOk;
end;

Procedure Form;
var t: integer;
begin
frmDesign := CreateForm;
frmDesign.Left := 296;
frmDesign.Top := 164;
frmDesign.Width := 439;
frmDesign.Height := 325;
frmDesign.Caption := 'Power! by Drizzt';
frmDesign.Color := clBtnFace;
frmDesign.Font.Color := clWindowText;
frmDesign.Font.Height := -11;
frmDesign.Font.Name := 'MS Sans Serif';
frmDesign.Font.Style := [];
frmDesign.Visible := False;
frmDesign.PixelsPerInch := 96;

PageControl1 := TPageControl.Create(frmDesign);
PageControl1.Parent := frmDesign;
PageControl1.Left := 0;
PageControl1.Top := 0;
PageControl1.Width := 273;
PageControl1.Height := 289;
PageControl1.TabOrder := 0;

SetArrayLength(Tabs, 1);
SetArrayLength(Label1, 1);
SetArraylength(Edit1, 1);
SetArraylength(Edit2, 1);
SetArraylength(Edit3, 1);
SetArraylength(Edit4, 1);
SetArraylength(RadioButton1, 1);
SetArrayLength(ComboBox1, 1);
SetArraylength(ComboBox2, 1);
Howmanyplayers := 1;

Tabs[0] := TTabSheet.Create(frmDesign);
Tabs[0].PageControl := PageControl1;
Tabs[0].Caption := 'Player ' + inttostr(howmanyplayers);

Label1[0] := TLabel.Create(frmdesign);
Label1[0].Parent := Tabs[0];
Label1[0].Left := 128;
Label1[0].Top := 133;
Label1[0].Width := 105;
Label1[0].Height := 17;
Label1[0].Caption := 'Before Logging Out';

Edit1[0] := TEdit.Create(frmdesign);
Edit1[0].Parent := tabs[0];
Edit1[0].Left := 64;
Edit1[0].Top := 21;
Edit1[0].Width := 137;
Edit1[0].Height := 21;
Edit1[0].TabOrder := 0;
Edit1[0].Text := 'Name';

Edit2[0] := TEdit.Create(frmdesign);
Edit2[0].Parent := tabs[0];
Edit2[0].Left := 64;
Edit2[0].Top := 61;
Edit2[0].Width := 137;
Edit2[0].Height := 21;
Edit2[0].TabOrder := 1;
Edit2[0].Text := 'Password';

Edit3[0] := TEdit.Create(frmdesign);
Edit3[0].Parent := tabs[0];
Edit3[0].Left := 64;
Edit3[0].Top := 101;
Edit3[0].Width := 57;
Edit3[0].Height := 21;
Edit3[0].TabOrder := 2;
Edit3[0].Text := 'Nick';

RadioButton1[0] := TRadioButton.Create(frmdesign);
RadioButton1[0].Parent := tabs[0];
RadioButton1[0].Left := 64;
RadioButton1[0].Top := 229;
RadioButton1[0].Width := 81;
RadioButton1[0].Height := 25;
RadioButton1[0].Caption := ' Active?';
RadioButton1[0].Checked := True;
RadioButton1[0].TabOrder := 3;
RadioButton1[0].TabStop := True;

Edit4[0] := TEdit.Create(frmdesign);
Edit4[0].Parent := tabs[0];
Edit4[0].Left := 64;
Edit4[0].Top := 133;
Edit4[0].Width := 57;
Edit4[0].Height := 21;
Edit4[0].TabOrder := 4;
Edit4[0].Text := 'Loads';

ComboBox1[0] := TComboBox.Create(frmdesign);
ComboBox1[0].Parent := tabs[0];
ComboBox1[0].Left := 64;
ComboBox1[0].Top := 165;
ComboBox1[0].Width := 145;
ComboBox1[0].Height := 21;
ComboBox1[0].ItemHeight := 13;
ComboBox1[0].TabOrder := 5;
ComboBox1[0].Text := 'Type of Tree';
ComboBox1[0].Items.Add('Tree');
ComboBox1[0].Items.Add('Oak');
ComboBox1[0].Items.Add('Willow');
ComboBox1[0].Items.Add('Yew');

ComboBox2[0] := TComboBox.Create(frmdesign);
ComboBox2[0].Parent := tabs[0];
ComboBox2[0].Left := 64;
ComboBox2[0].Top := 197;
ComboBox2[0].Width := 145;
ComboBox2[0].Height := 21;
ComboBox2[0].ItemHeight := 13;
ComboBox2[0].TabOrder := 6;
ComboBox2[0].Text := 'Action on Logs';
ComboBox2[0].Items.Add('Fletch');
ComboBox2[0].Items.Add('Burn');
ComboBox2[0].Items.Add('Drop');

Button1 := TButton.Create(frmDesign);
Button1.Parent := frmDesign;
Button1.Left := 288;
Button1.Top := 216;
Button1.Width := 121;
Button1.Height := 33;
Button1.Caption := 'Start';
Button1.TabOrder := 9;
Button1.onclick := @StartButton;

Button2 := TButton.Create(frmDesign);
Button2.Parent := frmDesign;
Button2.Left := 288;
Button2.Top := 128;
Button2.Width := 121;
Button2.Height := 33;
Button2.Caption := 'Add Player';
Button2.TabOrder := 10;
Button2.OnClick := @Addplayer;

Edit5 := TEdit.Create(frmDesign);
Edit5.Parent := frmDesign;
Edit5.Left := 288;
Edit5.Top := 72;
Edit5.Width := 121;
Edit5.Height := 21;
Edit5.Font.Color := clWindowText;
Edit5.Font.Height := -11;
Edit5.TabOrder := 3;
Edit5.Text := 'SRL ID';

Edit6 := TEdit.Create(frmDesign);
Edit6.Parent := frmDesign;
Edit6.Left := 288;
Edit6.Top := 32;
Edit6.Width := 121;
Edit6.Height := 21;
Edit6.TabOrder := 4;
Edit6.Text := 'SRL Password';

Pagecontrol1.Activepageindex := 0;
end;

Procedure DeclarePlayers;
var p : integer;
begin
NumberOfplayers(howmanyplayers);
Currentplayer := 0

for p := 0 to Howmanyplayers - 1 do
begin
Players[p].Name := Edit1[p].text; //username
Players[p].Pass := Edit2[p].text; //password
Players[p].Nick := Edit3[p].text; //3-4 letters from your username
Players[p].Integers[0] := StrToInt(Edit4[p].text); //loads per logout
Players[p].Strings[1] := Combobox1[p].text; //Tree, Willow, Yew, Etc.
Players[p].Strings[0] := Combobox2[p].text; //What to do? Ex.'Fletch','Burn','Drop'
Players[p].Active := Radiobutton1[p].checked;
end;
end;

Procedure SafeInitForm;
Var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('Form', v);
end;

Procedure ShowFormModal;
Begin
frmDesign.ShowModal;
end;

Procedure SafeShowFormModal;
Var
v: TVariantArray;
Begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

Procedure FormStuff;
begin
safeinitform;
SafeShowFormModal;
end;

begin
SetupSRL;
FormStuff;
end.
SRLPlayerForm?

I didn't really look at the form but wouldnt it be easier to just implement SRLPlayerForm then use another form for the other things like runaway direction and SRL Stat stuff

Hackwhore
03-30-2008, 12:46 AM
Nice tut, I'll be trying this out soon.

drizzt
03-30-2008, 12:54 AM
it would be easier..but, not as fr34k1n sw33t?

also, i have nothing better to do..so..

Da 0wner
03-30-2008, 01:02 AM
Hmm drizzt we both could work on something like that. I already know ini files see the player manager i made in public test corner. Add me on msn

kylewollaston@hotmail.com

drizzt
03-30-2008, 01:08 AM
added, haha i had just sent you a pm asking for your MSN, or maybe i said AIM but i meant MSN

Noob xp1
04-05-2008, 09:18 PM
Nice thx it help alot

P1nky
04-06-2008, 04:22 AM
MUST REP AND 5 STAR!!!!!

dude thanks so much!

Runescapian321
04-10-2008, 04:32 AM
Very nice. I'll definitely be using this :) Rep++

PB and J
04-10-2008, 04:49 AM
lol sup kyle ty for letting me come here (i no him in irl) it looks nice but im noob and can't understand i will later. you own at form stuff lol rep+ wanna tutor me some more?

PB and J
04-10-2008, 04:50 AM
sorry can someone tell me were the edit button is? i saw on other forums but where here? after that i will delete this

hey at kickball tomarrow its me. u, greg, vs all. and if this is spam delte?

Awkwardsaw
06-29-2008, 05:17 AM
your awesome.. haha great tut :D

tls
05-04-2009, 07:39 AM
***This tutorial is not complete yet. I will show you examples of all the types. I have to go to sleep now so I will finish this tomarrow ***
... never happened? Thanks for this, I just decided to learn how to make a form! :headbang: I did not know that there was a form editor... I feel very, very, very, very, very nooby.

Da 0wner
05-04-2009, 09:01 AM
Er, yea I quit SRL for a few months after this :p.
I don't feel like finishing it right now though. Lol.

tom99
12-07-2009, 11:15 AM
I used your code, with your example, a form did not apear the script did run but nothing happened, didnt even get the errormessage you sad. really nice tut.

tom99
12-14-2009, 12:24 PM
Why do i keep getting unknown identifier on the procedure witch is supose to perform the action chosed when you click on the button???

Sex
12-14-2009, 09:28 PM
Post everything you have.

Daniel
12-15-2009, 05:48 AM
I used your code, with your example, a form did not apear the script did run but nothing happened, didnt even get the errormessage you sad. really nice tut.


Why do i keep getting unknown identifier on the procedure witch is supose to perform the action chosed when you click on the button???

Copying the code won't get you any where. This tutorial was designed so you have to read through it, as the final output is currently in fragments in this tutorial.