Page 1 of 2 12 LastLast
Results 1 to 25 of 46

Thread: Newbie Form Tutorial

  1. #1
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Newbie Form Tutorial

    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

    Important Notes:

    Don't forget to



    Rate thread excellent, and rep me .

    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. .

    * 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.



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



    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,



    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,



    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

    SCAR Code:
    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

    Code:
    //Add these objects to variable declarations
    var
    below the var in the script above. Then find where it says

    Code:
    ///////////////// 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

    Code:
    [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

    SCAR Code:
    FrmDesign.Visible := True;

    and change it to

    SCAR Code:
    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

    SCAR Code:
    Button1.TabOrder := 8;

    put

    SCAR Code:
    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

    SCAR Code:
    Procedure Test(Sender : TObject);
    Begin
    End;

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

    SCAR Code:
    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

    SCAR Code:
    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 () 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

    SCAR Code:
    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 ***

  2. #2
    Join Date
    Jan 2008
    Location
    Alberta
    Posts
    727
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Nice tutorial, your pretty good at forms so your the person to learn from :P.

  3. #3
    Join Date
    Aug 2007
    Location
    Georgia, U.S.
    Posts
    890
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    great tut. da 0wner makes ownage forms.

  4. #4
    Join Date
    Nov 2007
    Location
    Chile
    Posts
    1,901
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Nice tut, can you explain how to add tabs?


  5. #5
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    srl player form is not bad to..., but nice tut!
    ~Hermen

  6. #6
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    *** NOT DONE YET!!! ***

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

    @ 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 .

    @ Iron Man Ftw - Ty 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:

  7. #7
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    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).
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  8. #8
    Join Date
    Nov 2007
    Location
    Chile
    Posts
    1,901
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by mixster05 View Post
    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.


  9. #9
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ok i added a tab tut. Hope you like it Tried to make people friendly xD

  10. #10
    Join Date
    Oct 2006
    Posts
    2,297
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    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?

    -Tsn.
    [QUOTE=Santa_Clause;277761]I love you too TSN :p[/QUOTE]
    [CENTER][URL="http://www.stats.srl-forums.com/sigs"][IMG]http://www.stats.srl-forums.com/sigs/1324.png[/IMG][/URL][/CENTER]

  11. #11
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    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.

  12. #12
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by the scar noob View Post
    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?

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

    i learned DTM and walking very fast he does it with forms
    ~Hermen

  13. #13
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by hermpie View Post
    No, this is not my second account!!!
    oops wrong account

    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.

  14. #14
    Join Date
    Jan 2008
    Location
    Alberta
    Posts
    727
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    My awesome form:

    SCAR Code:
    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.

  15. #15
    Join Date
    Aug 2007
    Location
    Georgia, U.S.
    Posts
    890
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    nice, your form doesn't do anything when you click the button it doesn't even exit.

  16. #16
    Join Date
    Mar 2007
    Posts
    1,223
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

    Quote Originally Posted by hermpie View Post
    No, this is not my second account!!!
    oops wrong account

    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! 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++

  17. #17
    Join Date
    Dec 2007
    Location
    192.168.1.73
    Posts
    2,439
    Mentioned
    6 Post(s)
    Quoted
    119 Post(s)

    Default

    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

  18. #18
    Join Date
    Feb 2007
    Location
    South East England
    Posts
    2,906
    Mentioned
    2 Post(s)
    Quoted
    8 Post(s)

    Default

    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.
    Jus' Lurkin'

  19. #19
    Join Date
    Dec 2007
    Location
    192.168.1.73
    Posts
    2,439
    Mentioned
    6 Post(s)
    Quoted
    119 Post(s)

    Default

    Quote Originally Posted by Torrent of Flame View Post
    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

    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

    SCAR Code:
    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)

    SCAR Code:
    frmDesign.Font.Color := clRed;

    Once again keep the cl at the front.

  20. #20
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    @ DR Thanks .

    @ 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.

  21. #21
    Join Date
    Feb 2007
    Location
    South East England
    Posts
    2,906
    Mentioned
    2 Post(s)
    Quoted
    8 Post(s)

    Default

    No, how you make it so that when you click Login it actually starts
    Jus' Lurkin'

  22. #22
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Like how you make it do a procedure? On the button stuff put Buttonx.OnClick := @UrProcedure;

    And on ur procedure put the name like

    SCAR Code:
    Procedure UrProcedure(Sender : TObject);

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

  23. #23
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    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.
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  24. #24
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    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....

  25. #25
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    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.
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. THE big form tutorial ~ by MK
    By MasterKill in forum OSR Advanced Scripting Tutorials
    Replies: 125
    Last Post: 08-04-2013, 07:32 PM
  2. Complete Form Tutorial
    By BobboHobbo in forum OSR Advanced Scripting Tutorials
    Replies: 10
    Last Post: 05-29-2012, 01:36 PM
  3. The Form Tutorial
    By Dan Cardin in forum OSR Advanced Scripting Tutorials
    Replies: 28
    Last Post: 03-03-2011, 04:42 AM
  4. Form TPopupMenu tutorial
    By Freddy1990 in forum OSR Advanced Scripting Tutorials
    Replies: 13
    Last Post: 12-14-2009, 07:25 PM
  5. Ultimate form tutorial
    By jhildy in forum OSR Advanced Scripting Tutorials
    Replies: 9
    Last Post: 02-21-2008, 05:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •