Results 1 to 24 of 24

Thread: Forms Forms Forms Forms Forms Forms Forms

  1. #1
    Join Date
    Dec 2006
    Posts
    354
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Forms Forms Forms Forms Forms Forms Forms

    i really need help with forms, and making them call out procedures in my script.

    i'm going to begin my script by clicking a start button.. that's going to make the procedure called "mainloop" start, and it's obviously my main loop, and the other stuff in my form is a list box,with 7 options. i need help bad, this is all i need help with for my script the rest i can do on my own..


    here's what i have..

    Code:
    procedure ClickButton(Sender: TObject);
    begin
    LeatherToTan := StrToInt(Edit1.Text);
     Case ComboBox1.Text Of
       'Gloves'             : Option:= 1
       'Boots'              : Option:= 2
       'Cowl'               : Option:= 3
       'Vambraces'          : Option:= 4
       'Body'               : Option:= 5
       'Chaps'              : Option:= 6
       'Leather Body'       : Option:= 7
       'Hard Leather Body'  : Option:= 8
     end;
    end;
    
    
    
    
    ////////////////////////////////////////////////////////////////////////////
    {     MAIN LOOP!                                                            }
    ////////////////////////////////////////////////////////////////////////////
    procedure MainLoop(sender: TObject);
    begin
     SetUpSRL;
     ClearReport;
     Credits;
     DeclarePlayers;
     MouseSpeed:=15;
     if (not(LoggedIn)) Then
     LoginPlayer;
     SetChat('friends',1);
     repeat
      repeat
      Walk1;
      ToTanShop;
      TanHidez;
      Walk2;
      FindBSymbol;
      OpenBanky;
      DepositLeatha;
      WithdrawHidez;
      until (TannedLeather = (LeatherToTan));
       repeat
         Crafty;
         SelectArmor;
         Wait(2500);
         MouseSpeed:=15;
         AntiBanz;
         OpenBanky;
         Wait(1500);
         DepositGoods;
         Progress;
         LeatherSelection;
         until(LeatherToCraft=(CraftedLeather));
       until(false);
    end;
    
    
    procedure InitForm;
    begin
      frmDesign := CreateForm;
      with frmDesign do
      begin
        Position := poScreenCenter;
        BorderStyle := bsSingle;
        BorderIcons := [biMinimize,biSystemMenu];
        Width := 344;
        Height := 183;
        Caption := 'TAB Power Crafter';
        Color := 2303084;
        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 := 32;
        Top := 37;
        Width := 152;
        Height := 13;
        Caption := 'Number Of Runs Before Crafting';
      end;
      Label2 := TLabel.Create(frmDesign);
      with Label2 do
      begin
        Parent := frmDesign;
        Left := 32;
        Top := 60;
        Width := 73;
        Height := 13;
        Caption := 'What To Craft?';
      end;
      ComboBox1 := TComboBox.Create(frmDesign);
      with ComboBox1 do
      begin
        Parent := frmDesign;
        Tag := 2;
        Left := 109;
        Top := 55;
        Width := 145;
        Height := 21;
        Color := 5987527;
        DropDownCount := 7;
        ItemHeight := 13;
        TabOrder := 8;
        Text := 'Armor Type';
        with ComboBox1.Items do
        begin
          Add('Gloves');
          Add('Boots');
          Add('Cowl');
          Add('Vambraces');
          Add('Body');
          Add('Chaps');
          Add('Leather Body');
          Add('Hard Leather Body');
        end;
      end;
      Edit1 := TEdit.Create(frmDesign);
      with Edit1 do
      begin
        Parent := frmDesign;
        Left := 189;
        Top := 35;
        Width := 121;
        Height := 21;
        Color := 5987527;
        TabOrder := 9;
        Text := 'Ammount Here';
      end;
      Button1 := TButton.Create(frmDesign);
      with Button1 do
      begin
        Parent := frmDesign;
        Left := 127;
        Top := 88;
        Width := 75;
        Height := 25;
        Cursor := crHandPoint;
        Caption := 'Lets Start!';
        ModalResult := 1;
        TabOrder := 10;
        OnClick:= @ClickButton;
      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('Error in InitForm!');
      end;
    end;
    
    // Kaitnieks' SetSelfWindowState
    procedure SetSelfWindowState(state: TWindowState);
    begin
      GetSelf.WindowState := state;
    end;
    
    // Kaitnieks' SafeSetSelfWindowState
    procedure SafeSetSelfWindowState(state: TWindowState);
    var
      V: TVariantArray;
    begin
      SetArrayLength(V, 1);
      V[0] := state;
      ThreadSafeCall('SetSelfWindowState', V);
    end;
    
    begin
      ClearDebug;
      TimeInitForm := GetSystemTime;
      SafeSetSelfWindowState(wsMinimized);
      MainInitForm;
      SafeSetSelfWindowState(wsNormal);
    end.

    i'd really really appreciate it if someone could tell me how to make it so that this all work. i'm getting lost, and more frusterated


    right now it compiles fine, but when i click start, it closes out of the form box, and executes the script. i need it to call out the mainloop procedure, at the click of the start button, and ect.
    Thick As Blood

  2. #2
    Join Date
    Jul 2006
    Posts
    259
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    woa that title is xtreem !!! did you try advanced tut section
    "your always where you supposed to be"

  3. #3
    Join Date
    Dec 2006
    Posts
    354
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    lol yea, i figured most of my problem out, i made a way better form, but it wont stay up long enough to make my settings! any ideas?!?!?


    my button (start) is to the main loop btw.
    Thick As Blood

  4. #4
    Join Date
    Jul 2006
    Posts
    259
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    sry cant help at all (most unhelpful post ever)
    "your always where you supposed to be"

  5. #5
    Join Date
    Dec 2006
    Posts
    354
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    man, i got excited too, because someone posted...


    can anyone help me?


    the thing that's happening now is...

    i press START in my form, and my SCAR freezes for a second, and then the scar window changes size to fit my progress report/signature, and then it freezes for good..

    if anyone wants to help, please post!
    Thick As Blood

  6. #6
    Join Date
    Mar 2006
    Posts
    13,241
    Mentioned
    228 Post(s)
    Quoted
    267 Post(s)

    Default

    i see you used the form parcer, but you said u got a new form post that or send it to me...and i can help maybe
    STOP PM'ING ME

  7. #7
    Join Date
    Feb 2006
    Location
    London, England
    Posts
    2,045
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default

    You are calling your main loop from INSIDE the form, and thats why SCAR is freezing. Since you have not told the form to close and actually start the script, SCAR is getting a bit confised as it is being told to do 2 things at once, hence it freezes.

    Main loops shouldn't be a Sender, just a normal procedure.

    try using this template for forms:

    PHP Code:
    //Global var, so that if the start button isn't clicked, the script will terminate
    Var
      
    ScriptStartBoolean;

    //All smalltime procedures and functions here
    procedure one;
    begin
    end
    ;

    function 
    twointeger;
    begin
      result 
    := 2;
    end;

    //Main loop here
    Procedure MainLoop;
    begin
      
    If (two 2then
        one
    ;
    end;

    //usual boring code for safe calling the form up
    Procedure SafeInitForm;
    var
      
    vTVariantArray;
    begin
      setarraylength
    (V0);
      
    ThreadSafeCall('InitForm'v);
    end;

    procedure ShowFormModal;
    begin
      frmDesign
    .ShowModal;
    end;

    procedure SafeShowFormModal;
    var
      
    vTVariantArray;
    begin
      setarraylength
    (V0);
      
    ThreadSafeCall('ShowFormModal'v);
    end;

    //Personal options such as Saving settings, Clicking buttons, Converting form components to Variables

    Procedure ComponentsToVariables;
    begin
    end
    ;

    procedure Start(senderTObject);
    begin
      frmDesign
    .Caption:= frmDesign.Caption '.';
      
    ComponentsToVariables;
      
    ScriptStart := True;                  //The button has been pressed, therefore it is alright to start the script
      
    frmDesign.ModalResult:= mrOk;
    end;

    //Displaying and setting form components how you want them:
    Procedure InitForm;
    begin
      
    //...
    end;

    //Anything else, such as minimising, maximizing etc.
    procedure MainInitForm;
    begin
      
    try
        
    SafeInitForm;
        
    SafeShowInitFormModal;
      finally
        
    FreeForm(frmDesign);
      
    except
        WriteLn
    ('Error in InitForm!');
      
    end;
    end;

    // Kaitnieks' SetSelfWindowState
    procedure SetSelfWindowState(stateTWindowState);
    begin
      GetSelf
    .WindowState := state;
    end;

    // Kaitnieks' SafeSetSelfWindowState
    procedure SafeSetSelfWindowState(stateTWindowState);
    var
      
    VTVariantArray;
    begin
      SetArrayLength
    (V1);
      
    V[0] := state;
      
    ThreadSafeCall('SetSelfWindowState'V);
    end;

    //main loop
    begin
      ClearDebug
    ;
      
    TimeInitForm := GetSystemTime;
      
    SafeSetSelfWindowState(wsMinimized);
      
    MainInitForm;
      
    SafeSetSelfWindowState(wsNormal);
      If (
    ScriptStart Falsethen TerminateScript;  //If the button wasn't pressed, then terminate script.
      
    Mainloop;        //Start the main loop!
    end
    Hope that helps
    SRL Wiki | SRL Rules | SRL Stats
    Ultimate SCAR Scripting Tutorial | Starblaster100's Auth System | Join the official SRL IRC now!


    Help Keep SRL Alive! Please disable Advert Blockers on SRL! Help Keep SRL Alive!


  8. #8
    Join Date
    Jan 2007
    Posts
    268
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    y u make forms?? why dont u just put const

  9. #9
    Join Date
    Jan 2007
    Posts
    526
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by macromacro123 View Post
    y u make forms?? why dont u just put const
    Forms are much more user friendly.

  10. #10
    Join Date
    Dec 2006
    Posts
    354
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    because i already did use const's and i wanted forms to keep things tidy


    basicaly to get it down to the point..


    also, help on inserting pictures? if it's in that template then sorry, i havent looked at it closely yet gunna save it now.


    thanks everyone !







    EDIT EDIT EDIT:

    i got the script to compile and all... now i have another problem...


    not enough paramiters in this? MainLoop;

    //main loop
    begin
    ClearDebug;
    SafeSetSelfWindowState(wsMinimized);
    MainInitForm;
    SafeSetSelfWindowState(wsNormal);
    If (ScriptStart = False) then TerminateScript; //If the button wasn't pressed, then terminate script.
    MainLoop;
    end.



    this is my mainloop.. ( not finished...)


    procedure MainLoop(Sender: TObject);
    begin
    If (two = 2) then
    one;
    LeatherToTan:= StrToInt(Edit2.Text);
    CraftedLeather:= StrToInt(Edit1.Text);
    Credits;
    DeclarePlayers;
    MouseSpeed:=15;
    if (not(LoggedIn)) Then
    LoginPlayer;
    SetChat('friends',1);
    repeat
    begin
    if (CheckBox10.State = cbChecked)then
    repeat
    Walk1;
    ToTanShop;
    TanHidez;
    Walk2;
    FindBSymbol;
    OpenBanky;
    DepositLeatha;
    WithdrawHidez;
    until (TannedLeather = (LeatherToTan));
    end;
    begin
    if(CheckBox9.State = cbChecked)then
    repeat
    Crafty;
    SelectArmor;
    Wait(2500);
    MouseSpeed:=15;
    AntiBanz;
    OpenBanky;
    Wait(1500);
    DepositGoods;
    Progress;
    LeatherSelection;
    until(LeatherToCraft=(CraftedLeather));
    end;
    until(false);
    end;








    EDIT. OKAY, so i used stars template, changed a few things around to get it to compile, but now the window wont stay open long enough to click a button! my form opens for 2 seconds and then dissapears, and it's sucessfully executed.. any ideas anyone?


    also, what do i put in the procedure "one" in starts template?


    procedure one;
    begin
    end;

    thanks.
    Thick As Blood

  11. #11
    Join Date
    Feb 2006
    Location
    London, England
    Posts
    2,045
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default

    The procedure names where just examples of procedures you could use.

    1) Your main loop is still a "Sender" which you don't want.
    2) Your form closes and finishes because you have to change this:
    Code:
    frmDesign.Visible := True;
    to
    Code:
    frmDesign.Visible := False;
    The main loop was just an example, you don't have to use it. The procedures where also examples. Delete them and replace them with your own procedures and functions.
    SRL Wiki | SRL Rules | SRL Stats
    Ultimate SCAR Scripting Tutorial | Starblaster100's Auth System | Join the official SRL IRC now!


    Help Keep SRL Alive! Please disable Advert Blockers on SRL! Help Keep SRL Alive!


  12. #12
    Join Date
    Dec 2006
    Posts
    354
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Line 490: [Error] (18151:27): Type mismatch in script


    procedure Setupp;
    begin
    LeatherToTan := Edit2.Text;
    CraftedLeather := Edit1.Text;
    end;


    why wont this work? that's the error i get. those vars are used in my main loop.
    Thick As Blood

  13. #13
    Join Date
    Feb 2006
    Location
    London, England
    Posts
    2,045
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default

    Lethertotan and CrafterLeather are both probably Integers, whilst Edit1 and 2.txt are both strings. You have to use StrToInt to convert them

    PHP Code:
    procedure Setupp;
    begin
    LeatherToTan 
    := StrToInt(Edit2.Text);
    CraftedLeather := StrToInt(Edit1.Text);
    end
    SRL Wiki | SRL Rules | SRL Stats
    Ultimate SCAR Scripting Tutorial | Starblaster100's Auth System | Join the official SRL IRC now!


    Help Keep SRL Alive! Please disable Advert Blockers on SRL! Help Keep SRL Alive!


  14. #14
    Join Date
    Dec 2006
    Posts
    354
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ohhh, shit. i knew that i needed to call them into the string somehow, but i wasnt sure exactly how.

    thanks star oh check your Email BTW



    EDIT:


    also, i tryed what you said, and now i get THIS error, after it compiles, and i click my "begin" button in my form, i get this error..

    [Runtime Error] : Exception: '' is not a valid integer value in line 490 in script
    Thick As Blood

  15. #15
    Join Date
    Mar 2006
    Posts
    13,241
    Mentioned
    228 Post(s)
    Quoted
    267 Post(s)

    Default

    i got that too in one of my forms...so i tried no assigning edit to var i just put it right in the think as StrToInt(edit1.txt) just like that and it sloved it for me...but if you use the variably multiple times in ur script it might be bit inconvienient to find em all and change....but give it a try if you want
    STOP PM'ING ME

  16. #16
    Join Date
    Feb 2006
    Location
    London, England
    Posts
    2,045
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Thick As Blood View Post
    ohhh, shit. i knew that i needed to call them into the string somehow, but i wasnt sure exactly how.

    thanks star oh check your Email BTW



    EDIT:


    also, i tryed what you said, and now i get THIS error, after it compiles, and i click my "begin" button in my form, i get this error..

    [Runtime Error] : Exception: '' is not a valid integer value in line 490 in script
    its because you left a edit box blank, and so it istrying to turn nothing into an integer.

    use

    PHP Code:
    StrToIntDef(StringToConvertStringDefaultIntegerIfCannotBeConvertedInteger);

    HidestoTan := StrToIntDef(Edit1.text0); 
    SRL Wiki | SRL Rules | SRL Stats
    Ultimate SCAR Scripting Tutorial | Starblaster100's Auth System | Join the official SRL IRC now!


    Help Keep SRL Alive! Please disable Advert Blockers on SRL! Help Keep SRL Alive!


  17. #17
    Join Date
    Dec 2006
    Posts
    354
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    hmm star, i replaced it with that command, and compiled it, and i also typed 120 into my form, instead of 100 (100 is what it's set at in the form) and it now gives me this error..


    [Runtime Error] : Access violation at address 0000000F.

    i'm trying to use this procedure called Setupp, to delcare the ammounts in the Edit1 and Edit2 text.

    Code:
    procedure Setupp;
    begin
    LeatherToTan := StrToIntDef(Edit2.text, 0);
    CraftedLeather := StrToIntDef(Edit1.text, 0);
    end;
    here's how i'm trying to use it in my mainloop..



    Code:
    begin
      if (CheckBox9.State = cbChecked)then
      repeat
    blah;
      until (TannedLeather = (LeatherToTan));
      end;
      begin
       if(CheckBox8.State = cbChecked)then
       repeat
     blah;
         until(LeatherToCraft=(CraftedLeather));
         end;

    blah is obviously not a real procedure.


    that's just a clip of the mainloop, also, not all.
    Thick As Blood

  18. #18
    Join Date
    Mar 2006
    Posts
    13,241
    Mentioned
    228 Post(s)
    Quoted
    267 Post(s)

    Default

    hey i got an idea...ok you know how when you make forms you can make the edits have same info everytime u open form? why dont you set them all to 0 so here is still as number and they can just change the value of the one they want
    STOP PM'ING ME

  19. #19
    Join Date
    Dec 2006
    Posts
    354
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    well they basicaly do, but like if they just want to run it to test it, they can just preg begin every time. i'll test out what you're saying also though.
    Thick As Blood

  20. #20
    Join Date
    Mar 2006
    Posts
    13,241
    Mentioned
    228 Post(s)
    Quoted
    267 Post(s)

    Default

    or what about this at the sender procedure do something like
    SCAR Code:
    if(Edit1.text > 0)then
     yourvar1:= Edit1.text
     else
     yourvar1:=0
    STOP PM'ING ME

  21. #21
    Join Date
    Dec 2006
    Posts
    354
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    with that, i get this..

    [Runtime Error] : Access violation at address 0048590B in module 'scar.exe'. Read of address FFFFFFEC in line 487 in script



    blah, i wish i could get past these runtime errors!
    Thick As Blood

  22. #22
    Join Date
    Mar 2006
    Posts
    13,241
    Mentioned
    228 Post(s)
    Quoted
    267 Post(s)

    Default

    with which1? the edit1 >0 one or the other 1...also for the latest one i psoted you would need if(StrToInt(Edit1.text)>0)then in stead of if(Edit1.text > 0) then
    STOP PM'ING ME

  23. #23
    Join Date
    Dec 2006
    Posts
    354
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    hmm, i'll try it that way too.

    hey hobbit, i think you should add me on MSN and give me some help on my script you can also check it out and see how you like it ect.


    i basicaly need help on converting const, to forms.

    thanks a lot
    Thick As Blood

  24. #24
    Join Date
    Mar 2006
    Posts
    13,241
    Mentioned
    228 Post(s)
    Quoted
    267 Post(s)

    Default

    i am on ur msn remember? i was helping w/ tanner but i'll try to be on more
    STOP PM'ING ME

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Forms
    By marre in forum OSR Help
    Replies: 2
    Last Post: 12-19-2007, 07:53 PM
  2. Need help with forms!
    By Da Der Der in forum OSR Help
    Replies: 2
    Last Post: 01-14-2007, 07:13 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
  •