Results 1 to 12 of 12

Thread: Is there a command for switching a boolean?

  1. #1
    Join Date
    May 2012
    Location
    Texas sounds cool.
    Posts
    53
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default Is there a command for switching a boolean?

    So I had an idea for my script. What needs to be done is having a procedure repeat once. I have it walk a path after performing the procedure, so I thought of adding a boolean. If I can make a boolean switch on the first time it does the procedure, the walkpath procedure will check if the boolean is true and repeat the original procedure which will switch the boolean to false the second time. Now this seems convenient if there is a way to switch a boolean with a simple command, otherwise there might be a better way do what I want.

    Is there a command for switching a boolean?
    ~Always remember that you are absolutely unique.
    Just like everyone else.

  2. #2
    Join Date
    Jan 2009
    Location
    Turlock/LA, California
    Posts
    1,494
    Mentioned
    3 Post(s)
    Quoted
    66 Post(s)

    Default

    testBoolean := not(testBoolean);

  3. #3
    Join Date
    May 2012
    Location
    Texas sounds cool.
    Posts
    53
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    So using
    testBoolean := not(testBoolean);
    will set the inverse of testboolean?
    ~Always remember that you are absolutely unique.
    Just like everyone else.

  4. #4
    Join Date
    Dec 2011
    Location
    New York, USA
    Posts
    1,242
    Mentioned
    12 Post(s)
    Quoted
    193 Post(s)

    Default

    Variable := false;
    Variable := true;

    ex:

    Simba Code:
    program progname;
    var
      parade: boolean;

    procedure procname;
    begin
      if (parade = false) then
      begin
        do this;
        parade := true;
      end;
    end;

  5. #5
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    Set the function to a boolean, and if result := true, result := false

  6. #6
    Join Date
    Dec 2011
    Location
    New York, USA
    Posts
    1,242
    Mentioned
    12 Post(s)
    Quoted
    193 Post(s)

    Default

    Or you could do this:

    Simba Code:
    if (parade = true) then
      parade := false
    else
      parade = true

  7. #7
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    The most convenient way to switch a boolean is to use:
    Simba Code:
    myVar := not myVar;
    There used to be something meaningful here.

  8. #8
    Join Date
    May 2012
    Location
    Texas sounds cool.
    Posts
    53
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Thank you, guys. You really help out in a pinch.


    Edit: So I changed it just slightly. And I ran into a weird bug. (at least I think It's weird)

    PHP Code:
    procedure Banking;
    var
      
    trueBankBoolean;
    begin
      repeat
        trueBank 
    := not(trueBank)
        if (
    FindDTM(GoldOre,x,y,MIX1,MIY1,MIX2,MIY2)) then
          begin
            wait
    (500+Random(1000));
            if (
    FindBSpot(x,y)) Then
              begin
                Writeln
    ('Attempting to deposit Gold Ore ');
                
    ClickMouse2(True);
                
    Wait(RandomRange(22502750));
                if (
    FindDTM(GoldOrexyMSX1MSY1MSX2MSY2)) then
                  begin
                    Mouse
    (x,y,3,3,False);
                    
    Wait(RandomRange(700,850));
                    
    ChooseOption('ll');
                    
    wait(400 Random(150));
                  
    end
              
    end else
              
    begin
                SymbolAccuracy 
    := 0.35
                FindSymbol
    (x,y,'bank');
                
    Mouse(x,y,0,0,true);
                
    Wait(RandomRange(1000,1300));
                
    SymbolAccuracy := 0.80
                wait
    (1500+Random(1000));
                
    Banking;
              
    end;
          
    end;
      
    until(trueBank False)
      
    GoToGold;
    end
    What happens is that it will repeat "GoToGold;" too. I thought that putting "until(trueBank = False)" would repeat everything before it.
    Last edited by Parade; 07-03-2012 at 06:12 AM.
    ~Always remember that you are absolutely unique.
    Just like everyone else.

  9. #9
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    It should only repeat the things you put in before it, but you seem to call the 'Banking' procedure again at the bottom of that repeat loop? I think this is where the problem lies as it tries to complete the entire procedure again if that makes sense?

  10. #10
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    I dont get what u are trying to do? You want it to repeat FindDTM and FindBspot until it banks? then you should just put 'Break;' after the Banking;
    The way u reverse the boolean its going to repeat twice and stop (false to true, then to false again)

  11. #11
    Join Date
    May 2012
    Location
    Texas sounds cool.
    Posts
    53
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    I dont get what u are trying to do? You want it to repeat FindDTM and FindBspot until it banks? then you should just put 'Break;' after the Banking;
    The way u reverse the boolean its going to repeat twice and stop (false to true, then to false again)
    The way I formed it, it sometimes misclicks and wouldn't bank. It would go back to mine for gold and then back to bank, realizing the inventory is still full. The chance for it misclicking twice was super slim, so I altered my procedure so it would repeat twice to avoid the trip back and forth between gold deposit and bank. I could have it do the same thing with "inc," but that would have taken a little bit more code to do the same thing.


    Quote Originally Posted by p1ng View Post
    It should only repeat the things you put in before it, but you seem to call the 'Banking' procedure again at the bottom of that repeat loop? I think this is where the problem lies as it tries to complete the entire procedure again if that makes sense?
    Hmm.. That is a good theory. I suppose I could move the symbol clicking to the beginning (because there's no reason for that to repeat anyways) and remove "banking;." Though I have a bit of doubt because it only activates that if the walking to the banking spot doesn't work right and it can't see the bank. But it does only double the walking occasionally.. hmm.. That may mean that the walking might bring it to a spot where it can't see the bank occasionally and the failsafe would activate then which would make complete sense. I'll go check it out.

    Edit: Eureka! P1ng, you are a genius! It's so smooth now. :]
    Last edited by Parade; 07-03-2012 at 08:42 PM. Reason: reporting back
    ~Always remember that you are absolutely unique.
    Just like everyone else.

  12. #12
    Join Date
    Mar 2008
    Location
    ::1
    Posts
    915
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Parade View Post
    Thank you, guys. You really help out in a pinch.


    Edit: So I changed it just slightly. And I ran into a weird bug. (at least I think It's weird)

    PHP Code:
    procedure Banking;
    var
      
    trueBankBoolean;
    begin
      repeat
        trueBank 
    := not(trueBank)
        if (
    FindDTM(GoldOre,x,y,MIX1,MIY1,MIX2,MIY2)) then
          begin
            wait
    (500+Random(1000));
            if (
    FindBSpot(x,y)) Then
              begin
                Writeln
    ('Attempting to deposit Gold Ore ');
                
    ClickMouse2(True);
                
    Wait(RandomRange(22502750));
                if (
    FindDTM(GoldOrexyMSX1MSY1MSX2MSY2)) then
                  begin
                    Mouse
    (x,y,3,3,False);
                    
    Wait(RandomRange(700,850));
                    
    ChooseOption('ll');
                    
    wait(400 Random(150));
                  
    end
              
    end else
              
    begin
                SymbolAccuracy 
    := 0.35
                FindSymbol
    (x,y,'bank');
                
    Mouse(x,y,0,0,true);
                
    Wait(RandomRange(1000,1300));
                
    SymbolAccuracy := 0.80
                wait
    (1500+Random(1000));
                
    Banking;
              
    end;
          
    end;
      
    until(trueBank False)
      
    GoToGold;
    end
    What happens is that it will repeat "GoToGold;" too. I thought that putting "until(trueBank = False)" would repeat everything before it.
    Put a semicolon at the end of the "until" line.

    That should solve your problem!

    Records and Types Save Code (and make you look better)
    Quote Originally Posted by Wizzup? View Post
    Is it possible to make Runescape a 2D game with this?... That would greatly simplify... Just about anything.

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
  •