Results 1 to 4 of 4

Thread: Help with script order of procedures

  1. #1
    Join Date
    Jan 2011
    Posts
    350
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Question Help with script order of procedures

    My script doesn't compile/run because the procedure/function isnt above the procedure/function that needs it. Can someone put the procedures/functions
    in order so my script functions?

    Simba Code:
    program Login;
    {$i srl/srl/misc/smart.scar} // This is how we include SMART; it HAS to be included BEFORE SRL!
    {$i srl/srl.scar}

    procedure DeclarePlayers;
    begin
      HowManyPlayers := 1; // This is set to the total amount of players (more on multiplayer later ;)), for now, just keep it set as 1
      NumberOfPlayers(HowManyPlayers); // This is a procedure in SRL which sets up player arrays (also, more on that later), this will always be the same
      CurrentPlayer := 0; // This is the player to start with; the first player will always be 0 (you'll find out when you learn all about arrays)

      Players[0].Name := 'Username'; // Username
      Players[0].Pass := 'Password'; // Password
      Players[0].Nick := 'abcd'; // 3-4 lowercase letters from username; used for random event detection
      Players[0].Active := True; // Set to true if you want to use Player 0
      Players[0].Pin := ''; // Leave blank if the player doesn't have a bank pin
    end;

    function WalkToCoal: Boolean;
    begin
      If RadialWalkTolerance(7697271 , 65, 110, 73, 5, 5, 10) then // 10 is the tolerance
      begin
        Writeln('Walking to coal is working fine!');
        Exit;
      end else
        Writeln(' Walking to coal error finding road using backup method.)');
        begin
          Wait(2000 + Random(1100))
          Mouse(692,81,2,2,true);
          Writeln('Successfully completed backup walking.');
        end
       Writeln('Walked to coal!');
    end;

    function WalkToMith: Boolean;
    begin
       Mouse(558,76,7,5,true)
       Wait(1000 + Random(800))
       RadialWalkTolerance(6975090 , 295, 260, 65, 7, 7, 10) // 10 is the tolerance
       Writeln('Walking to Mith is working fine!');
     end;

    procedure MineCoal;
    var
      x, y : Integer;
    begin
      if not LoggedIn then Exit;
      if FindObjCustom(x, y, ['ine'], [1910054], 5) then // If the color (2042153) is found, the coordinates of where it was found is stored in the variables (x, y).
        Mouse(x, y, 4, 4, True) // This moves and clicks the mouse to x, y; 4, 4 is the randomness on x, y
      else

      begin
        Wait(800); // Remember 1000ms = 1s
        MakeCompass('w');
        Writeln('First FindColor failed, trying second...');
        if FindColorTolerance(x, y, 1778467, MSX1, MSY1, MSX2, MSY2, 20) then
          Mouse(x, y, 4, 2, True) // This moves AND left clicks the mouse with randomness 4, 4; 'True' = Left click; 'False' = Right click
        else

        begin
          Wait(900);
          Writeln('Second FindColor failed, trying third...');
          if FindColorTolerance(x, y, 1910310, MSX1, MSY1, MSX2, MSY2, 15) then
            Mouse(x, y, 4, 4, True)
          else

          begin
            Wait(900);
            MakeCompass('w');
            Writeln('Third FindColor failed, trying forth...');
            if FindColorTolerance(x, y, 2239532, MSX1, MSY1, MSX2, MSY2, 15) then
              Mouse(x, y, 4, 4, True)
            else

            begin
              Wait(1560);
              Writeln('Forth FindColors failed, walking to Mith');
              WalkToMith;
            end;
          end;
        end;
      end;
    end; // There are so many 'end's because each begin has to have an end, otherwise you will get an "Identifier expected..." error


    function InvyFulBankIt: Boolean;
    var
      x, y : Integer;
    begin
      if not LoggedIn then Exit;
      if (InvFull) then
      if FindObjCustom(x, y, ['eposit', 'ank'], [5791845, 6121068], 5) then//Notice how I used "[]".
      begin
        Writeln('Found deposit box!');
        Wait(700 + Random(700));
        Mouse(x, y, 6, 6, True);//MMouse and uptext check isn't needed becaue it's already built into FindObjCustom, understand?
        Result := True;//Returns true of the copper ore was clicked.
        Wait(3000 + Random(700));
        Mouse(350,278,15,7,true);// deposit stuff button
        Wait(1100 + Random(700));
        Mouse(434,41,5,1,true);// close deposit box button
        RepeatMineMith;
      end else
        //Find deposit box procedure

    end;

    procedure RepeatMineCoal;
    var
      numberOfMines: Integer;
    begin // Although 'repeat' acts like a 'begin', 'begin' is still needed here to signal the start of the procedure
      repeat
        Wait(5195);
        MineCoal;
        Inc(numberOfMines); // The Inc() command simply increases the var numberOfWaits by 1
        Writeln('We have mined ' + IntToStr(numberOfMines) + ' times');
      until(InvFull) or (numberOfMines = 15);
        Wait(1095 + random(400));
        InvyFulBankIt;
    end;

    procedure MineMith;
    var
      x, y : Integer;
    begin
      if not LoggedIn then Exit;
      if FindObjCustom(x, y, ['ine'], [7425099], 10) then // If the color (7425099) is found, the coordinates of where it was found is stored in the variables (x, y).
        Mouse(x, y, 4, 4, True) // This moves and clicks the mouse to x, y; 4, 4 is the randomness on x, y
      else

      begin
        Wait(1000); // Remember 1000ms = 1s
        MakeCompass('n');
        Writeln('First FindColor failed, trying second...');
        if FindColorTolerance(x, y, 7819343, MSX1, MSY1, MSX2, MSY2, 10) then
          Mouse(x, y, 4, 2, True) // This moves AND left clicks the mouse with randomness 4, 4; 'True' = Left click; 'False' = Right click
        else

        begin
          Wait(1000);
          Writeln('Second FindColor failed, trying third...');
          if FindColorTolerance(x, y, 6505026, MSX1, MSY1, MSX2, MSY2, 15) then
            Mouse(x, y, 4, 4, True)
          else

          begin
            Wait(1000);
            Writeln('Third FindColor failed, trying forth...');
            if FindColorTolerance(x, y, 6636611, MSX1, MSY1, MSX2, MSY2, 15) then
              Mouse(x, y, 4, 4, True)
            else

            begin
              Wait(1560);
              WalkToCoal;
              Writeln('Forth FindColors failed, logging out');
              Writeln('walk to coal'); //
              RepeatMineCoal;
            end;
          end;
        end;
      end;
    end; // There are so many 'end's because each begin has to have an end, otherwise you will get an "Identifier expected..." error

    procedure RepeatMineMith;
    var
      numberOfWaits: Integer;
    begin // Although 'repeat' acts like a 'begin', 'begin' is still needed here to signal the start of the procedure
      repeat
        Wait(10195);
        MineMith;
        Inc(numberOfWaits); // The Inc() command simply increases the var numberOfWaits by 1
        Writeln('We have mined ' + IntToStr(numberOfWaits) + ' times');
      until(InvFull) or (numberOfWaits = 6);
        Wait(1095 + random(400));
        InvyFulBankIt;
    end;

    begin
      // These 4 lines HAVE to be set BEFORE you call SetupSRL;
      Smart_Server := 16;
      Smart_Members := False;
      Smart_Signed := True;
      Smart_SuperDetail := False;

      ClearDebug;
      SetupSRL;
      DeclarePlayers; // Calls the procedure, you can't forget this!
      LoginPlayer; // You want your player to login, right?
      RepeatMineMith;
    end.

  2. #2
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Well I'm not going to do it for you =P

    But you should always put functions in chronological order so that if one function uses another its located below that one.

    There is always forwarding which allows you to do this

    SCAR Code:
    function FuncB: Boolean; forward;

    function FuncA: Boolean;
    begin
      Result := FuncB;
    end;

    function FuncB: Boolean;
    begin
      Result := True;
    end;

    begin
      WriteLn(BoolToStr(FuncA));
    end.

  3. #3
    Join Date
    Jan 2011
    Location
    Denver, CO
    Posts
    1,351
    Mentioned
    2 Post(s)
    Quoted
    72 Post(s)

    Default

    I don't understand why you are incapable of moving around the procedures to make your script work. You know what the problem is, now attempt to fix it

  4. #4
    Join Date
    Jan 2011
    Posts
    350
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    i tired moving them around but the function that i move up needs the one thats somewhere under it and if i move the one under it theed the one that was on top and so on.Will try forwarding

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
  •