Results 1 to 7 of 7

Thread: Stupid question

  1. #1
    Join Date
    Dec 2011
    Posts
    170
    Mentioned
    0 Post(s)
    Quoted
    37 Post(s)

    Default Stupid question

    I have a question...

    My loop is something like this:
    PHP Code:
    begin
    setupsrl
    ;
    repeat
    mainloop
    ;
    until (blabla)
    end
    In my main loop, it checks certain things and logs out for a few mins as a fail safe, this is in the middle of the procedure.
    Something like this:
    PHP Code:
    if (this) and (not (that)) then
    begin
    pause
    ;
    end else

    then it goes on 
    When my pause procedure is complete, it will jump back right, but do will it then exit the procedure? Or will it continue?
    I'm fairly sure (actually 99% sure) that it will exit the whole procedure and go back to my main loop thus beginning the whole thing again.

    And another question, if it wouldn't exit the procedure, could I just add "Exit;" and it would exit the procedure only jumping back to my main repeat thing but not back as far as setting up SRL again etc?

  2. #2
    Join Date
    Feb 2012
    Location
    Canada
    Posts
    1,164
    Mentioned
    26 Post(s)
    Quoted
    433 Post(s)

    Default

    Quote Originally Posted by shebee View Post
    And another question, if it wouldn't exit the procedure, could I just add "Exit;" and it would exit the procedure only jumping back to my main repeat thing but not back as far as setting up SRL again etc?
    Well, one thing that i can help you on is this... "Exit;" will exit the function/procedure and continue on with your mainloop and will not go back to setting up SRL.

    Now, another thing is that there are no such things as stupid questions when it comes to scripting. I have been told that quite a few times by a few members around here.

    But when it comes to your issue there, i am not 100% sure what you are asking. It is logging out, then logging in and stopping? or is there more the the procedure that it just skips?

  3. #3
    Join Date
    Mar 2013
    Posts
    224
    Mentioned
    1 Post(s)
    Quoted
    127 Post(s)

    Default

    Quote Originally Posted by core View Post

    You only exit a procedure/function when you call exit;, you reach the end of it, or you raise an exception. Hopefully my [terrible paint] picture helps visualize the normal flow of the program.
    Actually kinda good.


    You can only stop your loop if you specify; chane blablabla to whatever your heart desires.

  4. #4
    Join Date
    Dec 2011
    Posts
    170
    Mentioned
    0 Post(s)
    Quoted
    37 Post(s)

    Default

    Quote Originally Posted by core View Post

    You only exit a procedure/function when you call exit;, you reach the end of it, or you raise an exception. Hopefully my [terrible paint] picture helps visualize the normal flow of the program.
    Okay let me try and clarify my problem...

    My script logs out if my character has been out of combat for 160sec.
    It will the log back in after a few minutes, it's a fight cave script and it's just another failsafe if the monsters get stuck somewhere, I should spawn in front of the entrance after logging back in.
    Now this is my problem:
    After I check if my character has been out of combat for over 160sec, it then checks if my character has been out of combat for 35secs.
    This (actually) first failsafe will walk towards the middle of the cave in case the monsters are stuck.

    The thing is, when it logs out now, will it then exit the procedure or will it also check for the first failsafe?
    I know I should just turn the failsafes around so that it first checks whether the first one is true and then the second.
    But still my question remains:
    PHP Code:
    if (not (IsInCombat)) and (TimeFromMark(Combat) > 90000then
                        begin
                          Inc
    (LogOuts);
                          
    TakeBreak(12False);
                        
    end else
                          if 
    not (IsInCombat) and (TimeFromMark(Combat) > 35000then
                            begin
                              MakeCompass
    (185);
                              
    MMouse(580821015);
                              
    ClickMouse2(mouse_Left);
                              
    Inc(StuckMob);
                              
    Writeln('Antibugging mobs...');
                              
    //Writeln(IntToStr(TimeFromMark(Combat)));
                              
    Wait(randomRange(2000025000));
                            
    end else 
    Assuming combat (which is the time I've been out of combat) is over 90sec, it will increment LogOuts which is for my proggy to show how many times it has had to log out.
    Now if this is true, and it runs this bit of script, it will jump to my TakeBreak procedure, and jump back after it's done, but will it then continue to check the second bit of script (the ont that chekcs for combat > 35sec)?
    The problem here is that I think now when it takes a break, logs back in but if it should fail to detect that I'm not in the cave (IsInCave), the first thing it would do is start walking east (second if statement) right? Then it would repeat and I would find myself somewhere in thzaar city and I would've logged out loads of times...
    So I have to add Exit;?
    Last edited by shebee; 03-21-2013 at 01:46 PM.

  5. #5
    Join Date
    Dec 2010
    Posts
    89
    Mentioned
    4 Post(s)
    Quoted
    8 Post(s)

    Default

    Hey shebee I'm going to try to see if I can help you with your problem.

    I've never been to the Fight Caves (f2p only), so I'm not really sure what I'd be looking at, but I'll try to help you with some logical reasoning.

    So the snippet of code that you provided us starts with a codition. Easy. What that means is that nothing in the snippet will happen if the "if..then.." conditions aren't met. Meaning if your character does not meet Condition 1 and Condtion 2 then nothing will happen. If the conditions are met then we begin.

    First, we increase the (LogOut) count (which is for recording purposes only from my understanding). Then we are going to "TakeBreak". I don't know what your TakeBreak(); procedure does, but whatever is in that procedure will take place. From there... things get fuzzy. I think there are definitely better ways to implement what you want to do while:

    35000 < "TimeFromMark" < 90000;

    I think it will work better if you remove the "end else" rewrite the the code so that there is another "if..then" before the current one. Allow me to demonstrate with psuedo-code.
    Simba Code:
    procedure TakingTooLong;
    begin
      if not (InCombat) and (TimeFromMark > 35000) then
      begin
        DoAction1;
        DoAction2;
      end;

      if not(InCombat) and (TimeFromMark > 90000) then
      begin
        DoAction3;
        DoAction4;
      end;
    end;

    Quote Originally Posted by shebee
    Now if this is true, and it runs this bit of script, it will jump to my TakeBreak procedure, and jump back after it's done, but will it then continue to check the second bit of script (the ont that chekcs for combat > 35sec)?
    I'd have to test this a bit, but my gut feeling is that it will not check the second bit of the script because the first condition is never met. That's why it makes more sense to check for the second bit first, because the time requirements are less. See my psuedo-code example.

    Quote Originally Posted by shebee
    The problem here is that I think now when it takes a break, logs back in but if it should fail to detect that I'm not in the cave (IsInCave), the first thing it would do is start walking east (second if statement) right? Then it would repeat and I would find myself somewhere in thzaar city and I would've logged out loads of times...
    So I have to add Exit;?
    That sounds right actually. You'd want to put an Exit; after your TakeBreak(); so that it will "exit" the procedure. But it would only start walking when the second set of conditions have been met; if the script never detects that it is in the Cave and it never finds an enemy, then it will continue to keep the TimeMark and eventually you'll hit the >35s point and will start walking. So, in short, yes; what you said is logically sound.

    P.S. For next time, please use Simba tags when posting code for Simba. Thanks!
    Last edited by Valithor; 03-21-2013 at 09:51 PM.

  6. #6
    Join Date
    Dec 2011
    Posts
    170
    Mentioned
    0 Post(s)
    Quoted
    37 Post(s)

    Default

    Thanks for the reply.
    I actually just played around with if statements in simba. I now understand them better, I found out that the difference between end and end else is that if you use end, it will just keep on going after the end; but if you use end else it will not even go to the else part if the first condition is met.

    Now I just need to figure out whether a end else statement breaks or exits when it is met, or if it simply skips the next etc..
    Just found about the simba tags hehe, thanks.

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
  •