Results 1 to 17 of 17

Thread: Playerform checkbox always returning false

  1. #1
    Join Date
    Sep 2014
    Posts
    74
    Mentioned
    2 Post(s)
    Quoted
    34 Post(s)

    Default Playerform checkbox always returning false

    Hey,

    I have a problem where my checkboxes on the playerform always return false, no matter if they are checked or not, always false.

    My code:
    Simba Code:
    var
     CHECKBOX: boolean;

    procedure initPlayerForm();
    begin
      with playerForm do
      begin
        name := 'Player form';
        scriptSettingsPath := AppPath + 'Scripts\Settings.txt';

        editBoxLabels := ['World', 'number'];

        editBoxDefaults := ['58', '8'];

        checkBoxLabels := ['Checkbox'];

        checkBoxDefaults := ['True'];

      end;
    end;

    procedure declarePlayers();
    begin
      wait(randomRange(1000,2000));
      players.setup(playerform.players);
      currentPlayer := 0;

      with players[0] do
      begin
        CHECKBOX := StrToBool(playerForm.players[0].settings[2]);
      end;
    end;

    writeLn(CHECKBOX);

    Don't know what's wrong :S

  2. #2
    Join Date
    Sep 2014
    Posts
    74
    Mentioned
    2 Post(s)
    Quoted
    34 Post(s)

    Default

    Sorry, please move this to SRL Development and Help.

  3. #3
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    Quote Originally Posted by TomTop View Post
    Sorry, please move this to SRL Development and Help.
    Are you running this:

    Simba Code:
    initPlayerForm();
      runPlayerForm();

      if (not playerForm.isScriptReady) then
        exit;

    Before you call declarePlayers?

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

  4. #4
    Join Date
    Sep 2014
    Posts
    74
    Mentioned
    2 Post(s)
    Quoted
    34 Post(s)

    Default

    Quote Originally Posted by 3Garrett3 View Post
    Are you running this:

    Simba Code:
    initPlayerForm();
      runPlayerForm();

      if (not playerForm.isScriptReady) then
        exit;

    Before you call declarePlayers?
    Yeah I am, but instead of exit i have " terminatescript;".

  5. #5
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    Quote Originally Posted by TomTop View Post
    Yeah I am, but instead of exit i have " terminatescript;".
    I don't see any immediate differences so I'll show you what works for me.

    Simba Code:
    procedure declarePlayers();
    var
      i: integer;
    begin
      players.setup(playerForm.players);
      currentPlayer := 0;

      for i := 0 to high(players) do
        with players[i] do
        begin
          integers[SET_RESTFOR] := strToInt(playerForm.players[i].settings[0]) * 60 * 1000;
          integers[SET_RESTEVERY] := strToInt(playerForm.players[i].settings[1]) * 60 * 1000;
          integers[SET_SLEEPFOR] := strToInt(playerForm.players[i].settings[2]) * 60 * 1000;
          integers[SET_SLEEPEVERY] := strToInt(playerForm.players[i].settings[3]) * 60 * 1000;
          integers[SET_SWITCHEVERY] := strToInt(playerForm.players[i].settings[4]) * 60 * 1000;
          world := strToInt(playerForm.players[i].settings[5]);

          booleans[SET_RESTING] := strToBool(playerForm.players[i].settings[6]);
          booleans[SET_SLEEPING] := strToBool(playerForm.players[i].settings[7]);
         end;

      Debug := strToBool(playerForm.players[0].settings[8]);
    end;

    That's at the top of the script.

    At the bottom of the script:

    Simba Code:
    procedure initPlayerForm();
    begin
      with playerForm do
      begin
        name := '3Garrett3''s Evergreen Chopper'; // the title of the SPF, usually the name of your script
        scriptHelpThread := '';           // a link to a help thread, if set to '' will link to my setup guide
        scriptSettingsPath := '';         // where you want the settings file to be saved; saved in script's path by default

        editBoxLabels := ['Minutes to Rest for', 'Minutes before Resting', 'Minutes to Sleep for', 'Minutes before Sleeping', 'Switch After', 'World']; // edit boxes are created for each array element
        editBoxDefaults := ['30', '90', '180', '180', '180', '-1'];                                             // optional default values for each edit box; array length must equal editBoxLabel length
        checkBoxLabels := ['Break', 'Sleep', 'Debug'];        // same as editBoxLabels but for check boxes
        checkBoxDefaults := ['True', 'True', 'False'];
      end;
    end;

    and

    Simba Code:
    initPlayerForm();
      runPlayerForm();

      if (not playerForm.isScriptReady) then
        terminateScript;

      //...

      declarePlayers();
      setupSRL();

    If everything matches your layout, it's something over my head.

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

  6. #6
    Join Date
    Sep 2014
    Posts
    74
    Mentioned
    2 Post(s)
    Quoted
    34 Post(s)

    Default

    Quote Originally Posted by 3Garrett3 View Post
    ~snip~
    I just had a go, with your code, then I wanted to test it, with
    Simba Code:
    writeln(players[CurrentPlayer].booleans[MULTI]);

    But I get the error of "Error: Access violation at line 792".

    Any ideas?

  7. #7
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    Quote Originally Posted by TomTop View Post
    I just had a go, with your code, then I wanted to test it, with
    Simba Code:
    writeln(players[CurrentPlayer].booleans[MULTI]);

    But I get the error of "Error: Access violation at line 792".

    Any ideas?
    Hmm, depending on what "MULTI" means, it could be that. But it's likely that the index doesn't exist. Either currentPlayer doesn't exist (maybe setupSRL hasn't been called?) or the MULTI index doesn't exist, meaning the form didn't properly run and save the variable.

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

  8. #8
    Join Date
    Sep 2014
    Posts
    74
    Mentioned
    2 Post(s)
    Quoted
    34 Post(s)

    Default

    Quote Originally Posted by 3Garrett3 View Post
    Hmm, depending on what "MULTI" means, it could be that. But it's likely that the index doesn't exist. Either currentPlayer doesn't exist (maybe setupSRL hasn't been called?) or the MULTI index doesn't exist, meaning the form didn't properly run and save the variable.
    The mutli is
    Simba Code:
    booleans[MULTI] := strToBool(playerForm.players[i].settings[6]);
    I call both declarePlayers (Which makes the currentPlayer), and then I call setupSRL.

    :S

  9. #9
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    Quote Originally Posted by TomTop View Post
    The mutli is
    Simba Code:
    booleans[MULTI] := strToBool(playerForm.players[i].settings[6]);
    I call both declarePlayers (Which makes the currentPlayer), and then I call setupSRL.

    :S
    So you're calling it exactly like my main loop?

    The only access violation I can think of is the MULTI index. Are you assigning a number to Multi? I assume it's a constant and you've assigned it like 0 or something right?

    If that is returning the error then it's probably because the playerform is not properly initializing the variables and I'm not sure if I could help you in that case. @Olly is the only person that comes to mind when I brainstorm about who knows the playerform really well.

    Olly, help? ^^

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

  10. #10
    Join Date
    Sep 2014
    Posts
    74
    Mentioned
    2 Post(s)
    Quoted
    34 Post(s)

    Default

    Quote Originally Posted by 3Garrett3 View Post
    So you're calling it exactly like my main loop?

    The only access violation I can think of is the MULTI index. Are you assigning a number to Multi? I assume it's a constant and you've assigned it like 0 or something right?

    If that is returning the error then it's probably because the playerform is not properly initializing the variables and I'm not sure if I could help you in that case. @Olly is the only person that comes to mind when I brainstorm about who knows the playerform really well.

    Olly, help? ^^
    I have MULTI defined as a boolean.
    If I PM you some snippets, would you be able to find the problem?

  11. #11
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    Quote Originally Posted by TomTop View Post
    I have MULTI defined as a boolean.
    If I PM you some snippets, would you be able to find the problem?
    MULTI has to be an integer.

    It should be something like:

    booleans[0] := strToBool(playerForm.players[i].settings[6]);

    It is the index of an array, not a boolean. This is probably why it's throwing an access violation for you.

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

  12. #12
    Join Date
    Sep 2014
    Posts
    74
    Mentioned
    2 Post(s)
    Quoted
    34 Post(s)

    Default

    Quote Originally Posted by 3Garrett3 View Post
    MULTI has to be an integer.

    It should be something like:

    booleans[0] := strToBool(playerForm.players[i].settings[6]);

    It is the index of an array, not a boolean. This is probably why it's throwing an access violation for you.
    But, Isn't a boolean a True or False?
    I thought checkboxes returned True or False, not 1 or 0, never the less, I'll give it a try by changing my booleans to integers.

  13. #13
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    Quote Originally Posted by TomTop View Post
    But, Isn't a boolean a True or False?
    I thought checkboxes returned True or False, not 1 or 0, never the less, I'll give it a try by changing my booleans to integers.
    Sorry, I'm not explaining really well.

    When you have the following:

    Simba Code:
    players[currentPlayer].booleans[X]

    The "booleans" is a type "Array of Boolean". That means you have to treat it like any other array. You can have a bunch of booleans in there, each being true or false. But the first boolean is #0 (booleans[0]) and the next is #1 , etc.

    So when you are setting the players.booleans[X] variable, you have to set X to be an integer. You can set it to be 0 if it's the first boolean you use. You can set it to be 1 if it's the second, etc.

    So:

    Simba Code:
    players[currentPlayer].booleans[0]

    This returns a boolean. The Boolean #0 in the player array is still a boolean, but you can't say:

    Simba Code:
    players[currentPlayer].booleans[True]

    Because that will cause an error in Simba.

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

  14. #14
    Join Date
    Sep 2014
    Posts
    74
    Mentioned
    2 Post(s)
    Quoted
    34 Post(s)

    Default

    Quote Originally Posted by 3Garrett3 View Post
    Sorry, I'm not explaining really well.

    When you have the following:

    Simba Code:
    players[currentPlayer].booleans[X]

    The "booleans" is a type "Array of Boolean". That means you have to treat it like any other array. You can have a bunch of booleans in there, each being true or false. But the first boolean is #0 (booleans[0]) and the next is #1 , etc.

    So when you are setting the players.booleans[X] variable, you have to set X to be an integer. You can set it to be 0 if it's the first boolean you use. You can set it to be 1 if it's the second, etc.

    So:

    Simba Code:
    players[currentPlayer].booleans[0]

    This returns a boolean. The Boolean #0 in the player array is still a boolean, but you can't say:

    Simba Code:
    players[currentPlayer].booleans[True]

    Because that will cause an error in Simba.
    Oooh, I get it now. Thanks, I'll give it a shot!

  15. #15
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    Quote Originally Posted by TomTop View Post
    Oooh, I get it now. Thanks, I'll give it a shot!
    Let me know how it goes!

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

  16. #16
    Join Date
    Sep 2014
    Posts
    74
    Mentioned
    2 Post(s)
    Quoted
    34 Post(s)

    Default

    Quote Originally Posted by 3Garrett3 View Post
    Let me know how it goes!

    Same error, access violation..

  17. #17
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Simba Code:
    {$i srl-6/srl.simba}
    {$i srl-6/lib/misc/srlplayerform.simba}

    var
     CHECKBOX: boolean;

    procedure initPlayerForm();
    begin
      with playerForm do
      begin
        name := 'Player form';
        scriptSettingsPath := AppPath + 'Scripts\Settings.txt';

        editBoxLabels := ['World', 'number'];

        editBoxDefaults := ['58', '8'];

        checkBoxLabels := ['Checkbox'];

        checkBoxDefaults := ['True'];

      end;
    end;

    procedure declarePlayers();
    begin
      wait(randomRange(1000,2000));
      players.setup(playerform.players);
      currentPlayer := 0;

      with players[0] do
      begin
        CHECKBOX := StrToBool(playerForm.players[0].settings[2]);
      end;
    end;

    begin
      initPlayerForm();
      runPlayerForm();

      DeclarePlayers();

      Writeln(CHECKBOX);
    end.

    Works fine for me.

Thread Information

Users Browsing this Thread

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

Posting Permissions

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