Results 1 to 18 of 18

Thread: What's wrong with my main loop

  1. #1
    Join Date
    Jul 2007
    Posts
    242
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default What's wrong with my main loop

    I feel like somethings wrong..

    SCAR Code:
    procedure MainLoop;
    begin
      ActivateClient;
      SetUpSRL;
      DeclarePlayers;
      LoginPlayer;
      SetupClient;
      repeat
        if not LoggedIn then NextPlayer(false);
         WalkToMaples;
         ChopMaples;
         WalkToBank;
         Bank;
         PlayerNext;
         Proggy;
        if (not (LoggedIn)) then NextPlayer(false);
        until(Loads >= Players[CurrentPlayer].Integers[0]) or not(LoggedIn);
        if (not (LoggedIn)) then NextPlayer(false);
    end;

    begin
    MainLoop;
    end.





  2. #2
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    You say you feel like somethings wrong. I need to know if it is wrong. A 'feel' cant tell us much.

    ->{Nauman}<-

  3. #3
    Join Date
    Jul 2007
    Posts
    242
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    this part

    SCAR Code:
    if (not (LoggedIn)) then NextPlayer(false);
        until(Loads >= Players[CurrentPlayer].Integers[0]) or not(LoggedIn);
        if (not (LoggedIn)) then NextPlayer(false);
    end;
     
    begin
    MainLoop;
    end.





  4. #4
    Join Date
    Sep 2007
    Location
    Canada Eh
    Posts
    79
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Zeta View Post
    this part

    SCAR Code:
    if (not (LoggedIn)) then NextPlayer(false);
        until(Loads >= Players[CurrentPlayer].Integers[0]) or not(LoggedIn);
        if (not (LoggedIn)) then NextPlayer(false);
    end;
     
    begin
    MainLoop;
    end.


    do you really need if (not (LoggedIn)) then NextPlayer(false); twice?

  5. #5
    Join Date
    Jul 2007
    Posts
    242
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    i don't know thats why i'm asking.. it seems like i need them both but idk





  6. #6
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    get rid of this in the bottom: if (not (LoggedIn)) then NextPlayer(false);
    next to the end;. You have already said it 2 times. Thats enough to make it stick on scar.


    ->{Nauman}<-

  7. #7
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    you have a problem yes, but i dont know how to explain, let me fix it for you...

  8. #8
    Join Date
    Jun 2007
    Posts
    785
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    if not LoggedIn then NextPlayer(true); // True to login aye?
         WalkToMaples;
         ChopMaples;
         WalkToBank;
         Bank;
         PlayerNext;
         Proggy;
        if (not (LoggedIn)) then NextPlayer(true); // again
        until(Loads >= Players[CurrentPlayer].Integers[0]) or not(LoggedIn);
    end;

    [22:20] <[-jesus-]> freddy, go uninstall yourself

  9. #9
    Join Date
    Aug 2007
    Posts
    429
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Shouldn't you have something to switch players after it does the designated number of loads?

    SCAR Code:
    procedure MainLoop;
    label
      Chopping;
    begin
      ActivateClient;
      SetUpSRL;
      DeclarePlayers;
      LoginPlayer;
      SetupClient;
      Chopping:  //goes to here
      repeat
        if not LoggedIn then NextPlayer(false);
         WalkToMaples;
         ChopMaples;
         WalkToBank;
         Bank;
         PlayerNext;
         Proggy;
      until(Loads >= Players[CurrentPlayer].Integers[0]) or not(LoggedIn);
      if ((CurrentPlayer + 1) >= HowManyPlayers) then TerminateScript else //if all players are done terminates script
      begin //if all players are NOT done then...
        NextPlayer(false);  //first switches players
        goto Chopping;    //and then goes back up there ^^ to repeat everything
      end;
    end;

  10. #10
    Join Date
    Jul 2007
    Posts
    242
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    man im gettin so confused...

    @ derek is this what you mean?

    SCAR Code:
    procedure PlayerNext;
    begin
      If (LoggedIn) and (Loads >= Players[CurrentPlayer].Integers[0])then
      Writeln('Number of loads to do has been met, logging in next player');
      begin
      Logout;
      end;
    end;





  11. #11
    Join Date
    Aug 2007
    Posts
    429
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Look above =]

  12. #12
    Join Date
    Jul 2007
    Posts
    242
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    okay.. i understand mostly everything except the chopping part, ive never heard of a label





  13. #13
    Join Date
    Aug 2007
    Posts
    429
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Here's a tut on them if you'd like.

    There are many different outlooks on goto statements but I personally don't like to listen to any of it =]

  14. #14
    Join Date
    Sep 2007
    Location
    England
    Posts
    80
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Hey Zeta Just stick to the simple what naumanakhlaq said.

    #SS

  15. #15
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Fixed it...


    SCAR Code:
    procedure MainLoop;
    begin
      ActivateClient;
      SetUpSRL;
      DeclarePlayers;
      LoginPlayer;
      SetupClient;
      repeat
        if (not(LoggedIn)) then NextPlayer(false);
        if(not(WalkToMaples)) then
        begin
          Logout;
          NextPlayer(false);   //added this failsafe, this way, it wont try to do the other things if one failed
          Continue;
        end;
        if(not(ChopMaples)) then
        begin
          Logout;
          NextPlayer(false);
          Continue;
        end;
        if(not(WalkToBank)) then
        begin
          Logout;
          NextPlayer(false);
          Continue;
        end;
        if(not(Bank)) then
        begin
          Logout;
          NextPlayer(false);
          Continue;
        end;
        Loads:=Loads +1  //You have to have the loads going up every load!
        if(Loads >= Players[CurrentPlayer].Integers[0]) then
        begin
          Logout;
          NextPlayer(True);  //its still active because it is not lost.
        end;
      until(Players[CurrentPlayer].Active=False);
      Proggy;  //only want progress report once!
    end;

    begin
    MainLoop;
    end.

    I don't know what playernext is, but what i did should work. I added a bunch of failsafes for you, and used continue, which restarts the loop, so that we dont try to do things when something is wrong. I also fixed your proggy, you had it in the loop, so it would have been printed many times (you may have wanted that, i dk). Finally, I fixed it so the loads goes up by one every time.

    Check to see if that is what you want, if you have any questions about what I did, or something else, please pm me or post them here.

  16. #16
    Join Date
    Aug 2007
    Posts
    429
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Macrosoft View Post
    Fixed it...


    SCAR Code:
    procedure MainLoop;
    begin
      ActivateClient;
      SetUpSRL;
      DeclarePlayers;
      LoginPlayer;
      SetupClient;
      repeat
        if (not(LoggedIn)) then NextPlayer(false);
        if(not(WalkToMaples)) then
        begin
          Logout;
          NextPlayer(false);   //added this failsafe, this way, it wont try to do the other things if one failed
          Continue;
        end;
        if(not(ChopMaples)) then
        begin
          Logout;
          NextPlayer(false);
          Continue;
        end;
        if(not(WalkToBank)) then
        begin
          Logout;
          NextPlayer(false);
          Continue;
        end;
        if(not(Bank)) then
        begin
          Logout;
          NextPlayer(false);
          Continue;
        end;
        Loads:=Loads +1  //You have to have the loads going up every load!
        if(Loads >= Players[CurrentPlayer].Integers[0]) then
        begin
          Logout;
          NextPlayer(True);  //its still active because it is not lost.
        end;
      until(Players[CurrentPlayer].Active=False);
      Proggy;  //only want progress report once!
    end;

    begin
    MainLoop;
    end.

    I don't know what playernext is, but what i did should work. I added a bunch of failsafes for you, and used continue, which restarts the loop, so that we dont try to do things when something is wrong. I also fixed your proggy, you had it in the loop, so it would have been printed many times (you may have wanted that, i dk). Finally, I fixed it so the loads goes up by one every time.

    Check to see if that is what you want, if you have any questions about what I did, or something else, please pm me or post them here.
    Are you sure that all his procedures are functions that return booleans though?

  17. #17
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    lol, got me there

    zeta, could you please post the whole script

    Derek, I fix other things besides that too

  18. #18
    Join Date
    Jul 2007
    Posts
    242
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    yeah heres the whole script...

    SCAR Code:
    /////////////-----------------------/////////////
    ////////////Zeta's Maple Masher v0.4////////////
    ///////////-------------------------///////////
    //////////-----Big thanks to...-----//////////
    /////////---------------------------/////////
    ////////-------------Town-----------////////
    ///////-----------------------------///////
    //////-----------Santa_Clause-------//////
    /////-------------------------------/////
    ////--------------Kevin Wolf--------////
    ///---------------------------------///
    //----------------------------------//

    {INSTRUCTIONS:
    -Start in seers bank
    -Fill out lines 22-56
    -Low detail
    -Highest brightness
    -Logged in or out
    -Axe weilded or not
    -32-bit color mode
    -Press play
    -Get maples
    -Post proggies!!}


    program ZetasMapleMasher;
    {.include SRL\SRL.scar}
    {.include SRL\SRL\Skill\Woodcutting.SCAR}

    const
      Maple = 19058; //the colors of the maples
      Maple2 = 16760;
      Maple3 = 9548;
      Tol = 10; //tolerance to find the maple
      AntiBanAmount= 40; //Set this for the chance of Antiban to do something.
      //40 is default, lower for more antiban, higher for less.

    var
    Loads:Integer;


    procedure DeclarePlayers;
    begin
      HowManyPlayers := 3; //How many players there are
      NumberOfPlayers(HowManyPlayers); //Leave this alone
      CurrentPlayer := 0;  //The player to start with

      Players[0].Name := ''; //Player's username
      Players[0].Pass := ''; //Player's password
      Players[0].Nick := ''; //3-4 characters of player's username, no capitals or spaces
      Players[0].Active := True; //Do you want to use this player?
      Players[0].Integers[0] := 2; //Loads for player to do


      Players[1].Name := '';
      Players[1].Pass := '';
      Players[1].Nick := '';
      Players[1].Active := True;
      Players[1].Integers[0] := 2;

      Players[2].Name := '';
      Players[2].Pass := '';
      Players[2].Nick := '';
      Players[2].Active := True;
      Players[2].Integers[0] := 2;
      NickNameBMP := CreateBitmapMaskFromText(Players[CurrentPlayer].Nick, UpChars);
      Writeln ('There are ' + Inttostr(HowManyPlayers)+ ' Players');
    end;


    function RadialToleranceWalk(TheColor: Integer; StartRadial, EndRadial: Integer;
      Radius: Integer; Xmod, Ymod, Tol: Integer): Boolean; // By Wizzup? and WT-Fakawi.
    var
      i, X1, Y1, x, y: Integer;
    begin
      if (RoadColorChecker) then
        if (DebugRadialRoad) then
          WriteLn(' THROUGH RADIALROADWALK=  ---> ' + IntToStr(RoadColor));
      if (StartRadial = EndRadial) then
      begin
        WriteLn('Using LinearRoadWalk, equal values.')
          if LinearRoadWalk(TheColor, StartRadial, Radius, Xmod, Ymod) then
          Result := True;
      end
      else if (StartRadial < EndRadial) then
      begin
        repeat
          for i := StartRadial to EndRadial do
          begin
            x1 := Round(Radius * Sine(i)) + 646;
            y1 := Round(-Radius * Cose(i)) + 84;
            if Not LoggedIn then Exit;
            if (FindColorTolerance(x, y, TheColor, X1, Y1, X1 + 1, Y1 + 1, Tol)) then
            begin
              MouseFindNoFlag(X,Y,Xmod,Ymod);
              Result := True;
              CountFlag(10);
              Exit;
            end;
          end;
          Radius := Radius - 4;
        until (Radius <= 1);
      end else
        if (StartRadial > EndRadial) then
        begin
          repeat
            for i := StartRadial downto EndRadial do
            begin
              x1 := Round(Radius * Sine(i)) + 646;
              y1 := Round(-Radius * Cose(i)) + 84;
              if Not LoggedIn then Exit;
              if (FindColorTolerance(x, y, TheColor, X1, Y1, X1 + 1, Y1 + 1, Tol)) then
              begin
                MouseFindNoFlag(X,Y,Xmod,Ymod);
                Result := True;
                CountFlag(10);
                Exit;
              end;
            end;
            Radius := Radius - 4;
          until (Radius <= 1);
        end
    end;

    function OpenBank3: Boolean; //Taken from old SRL bank.scar
    var
      x, y, fs, fs2: Integer;
    begin
      if not BankScreen then
        repeat
          if (FindObj(x, y, 'Use Bank', 4481658, 10)) then
            Mouse(x, y, 4, 4, False)
          else if (FindObj(x, y, 'Use Bank', 2842230, 10)) then
            Mouse(x, y, 4, 4, False)
          else if (FindObj(x, y, 'Use Bank', 12611, 10)) then
            Mouse(x, y, 4, 4, False);
          Wait(250);
          if (ClickOption('quickly', 1)) then
          begin
            FFlag(0);
            repeat
              Wait(100);
              Inc(fs);
            until (BankScreen) or (fs >= 50);
          end;
          Inc(fs2);
        until (BankScreen) or (fs2 > 5);
      Result := BankScreen;
    end;



    procedure SetupClient;
    begin
      if (not(LoggedIn)) then Exit;;
      Writeln('Setting chats and run');
      SetChat('on', 1);
      SetChat('off', 2);
      SetChat('off', 3);
      SetChat('off', 4);
      Setrun(true);
    end;

    Function FindFastRandoms: Boolean;    // By WT-Fakawi.
    Var
      i: Integer;
    Begin
    if not LoggedIn then Exit;
      For I := 1 To 10 Do
      Begin
        Case I Of
           1:  If FindDead Then
                 Result := True;
           2:  If FindMime Then
                 Result := True;
           3:  If FindMaze Then
                 Result := True;
           4:  If FindQuiz Then
                 Result := True;
           5:  If FindDemon Then
                 Result := True;
           6: Begin
                 If NoGameTab Then
                 Begin
                   Result := True;
                   Players[CurrentPlayer].loc := 'No GameTab';
                   Players[CurrentPlayer].Active := False;
                   Logout;
                   Exit;
                 End;
               End;
           7 : If RC Then
                  Result:=True;
           8 : If FindFight Then
                    Result := True;
           9 : If FindTalk Then
                 Result := True;
           10: If FindCerter Then
                 Result := True;
        End;
        Wait(1);
      End;
    End;

    procedure AntiRandoms;
    begin
        FindTalk;
        FindNormalRandoms;
        FindFastRandoms;
        FindLamp('Woodcutting');
        SolvePinball;
      if (FindFight) then
      begin
        MakeCompass('N');
        RunTo('W', True);
        Wait(6000 +Random(6423));
        RunBack;
      end;
    end;



    Procedure AntiBan1;
    begin
      if(not(LoggedIn))then NextPlayer(false);

      case Random(AntiBanAmount) of
        0: MMouse(300, 300, 200, 200);
        1: begin
             HoverSkill('Woodcutting',false);
             wait(2364+Random(413));
             GameTab(4);
           end;
        2: PickUpMouse;
        3: begin
             MakeCompass('N');
             wait(10+random(5));
             MakeCompass('S');
             wait(10+random(5));
             MakeCompass('N');
           end;
        4:   MMouse(300, 300, 200, 200);
        5: begin
             LowestAngle;
             wait(10+random(74));
             HighestAngle;
           end;
        6: SleepAndMoveMouse(5000+random(3000));
        7: MMouse(300, 300, 200, 200);
        8: GameTab(1 + Random(12));
        9: begin
             MakeCompass('N');
             wait(10+random(5));
             MakeCompass('S');
             wait(10+random(5));
             MakeCompass('N');
        end;
      end;
    end;


    Procedure Antiban2;
    begin
      if(not(LoggedIn))then NextPlayer(false);
       case Random(AntiBanAmount) of
       0: MMouse(300, 300, 200, 200);
       1: MMouse(300, 300, 200, 200);
       3: HoverSkill('Random', False);
       5: MMouse(300, 300, 200, 200);
       7: GameTab(1 + Random(12));
       9: MMouse(300, 300, 200, 200);
       end;
    end;



    procedure WalkToMaples;
    begin
      MakeCompass('N');
      HighestAngle;
      Antiban1;
      Writeln('Walking to maples..');
      RadialToleranceWalk(98061, 330, 384, 65, 10, 12, 18)
      Flag;
      Writeln('Correctly walked to maples');
    end;

    procedure ChopMaples;
    var
      x, y, ChopMark: Integer;
    begin
      if (not (LoggedIn)) then NextPlayer(false);
      repeat
        if FindObjCustom(x, y, ['aple tree'], [Maple, Maple2, Maple3], Tol) then
        begin
          Writeln('Found a maple... chopping');
          GetMousePos(x, y);
          Antiban1;
          Mouse(x, y, 0, 0, True);
          AntiRandoms;
          MarkTime(ChopMark);
          repeat
            Wait(500 + Random(250));
            AntiRandoms;
            Antiban2;
          until(TimeFromMark(ChopMark) >= (10000 + Random(5000))) or (InvFull) or (not (LoggedIn));
        end;
      until (InvFull);
    end;

    procedure WalkToBank;
    var
    x,y: integer;
    begin
      if (not(LoggedIn)) then NextPlayer(false);
        SymbolAccuracy:= 0.1;
        Makecompass('N');
        HighestAngle;
      begin
        if (FindSymbol(x, y, 'bank')) then
        begin
          Writeln('Found bank symbol... walking to bank');
          Mouse(x, y, 10, 10, true);
          Antiban1;
          AntiRandoms;
          Flag;
          Writeln('Correctly walked to bank');
        end;
      end;
    end;

    procedure Bank;
    begin
       Writeln('Trying to find bankbooth');
       OpenBank3;
       if (BankScreen) then
       Writeln('Found bankbooth... banking');
       FixBank;
       Deposit(2,28,2);
       Closebank;
       Loads:=Loads+1;
       Writeln('Correctly banked.');
    end;

    procedure PlayerNext;
    begin
      If (LoggedIn) and (Loads >= Players[CurrentPlayer].Integers[0])then
      Writeln('Number of loads to do has been met, logging in next player');
      begin
      Logout;
      end;
    end;


    procedure Proggy;
    begin
    Writeln('~!~Zetas Maple Masher Proggy Report~!~');
    Writeln('Script has run for '+TimeRunning);
    Writeln('Did ' + IntToStr(Loads)+ ' loads.');
    end;


    procedure MainLoop;
    begin
      ActivateClient;
      SetUpSRL;
      DeclarePlayers;
      LoginPlayer;
      SetupClient;
      repeat
        if not LoggedIn then NextPlayer(false);
         WalkToMaples;
         ChopMaples;
         WalkToBank;
         Bank;
         PlayerNext;
         Proggy;
        until(Loads >= Players[CurrentPlayer].Integers[0]) or not(LoggedIn);
        if (not (LoggedIn)) then NextPlayer(false);
    end;

    begin
    MainLoop;
    end.





Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Main loop???
    By cloutier15 in forum OSR Help
    Replies: 3
    Last Post: 05-11-2008, 09:53 PM
  2. Main Loop Issue
    By lefamaster in forum OSR Help
    Replies: 5
    Last Post: 03-22-2007, 09:11 PM
  3. main loop
    By syberium in forum OSR Help
    Replies: 5
    Last Post: 01-23-2007, 07:00 AM

Posting Permissions

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