Results 1 to 5 of 5

Thread: My powerteleport procedure

  1. #1
    Join Date
    Feb 2007
    Posts
    66
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default My powerteleport procedure

    Hey,

    I started work on my teleporter a few days back and seems to be going well. (considering its my first).

    The main bulk of the code is the teleport procedure, and im having trouble with it.

    SCAR Code:
    procedure Teleport;
    var
    i : integer;
    begin
      jobDone := False;
      repeat
        writeln('first repeat');
        i := 0
        repeat
          writeln('sencond repeat');
          wait(100)
          if (not(FindFastRandoms)) then
          begin
            wait(500 + random(500));
            if (Cast(TeleportTo + ' Teleport')) then
            begin
              wait(500 + random(500));
              Teleported := Teleported + 1;
              writeln('Teleported = ' + inttostr(Teleported));
              wait(500 + random(500));
              i := i + 1;
              writeln('i = ' + inttostr(i));
              wait(2500 + random(500));
            end else
            begin
              if (FindFastRandoms) or (FindNormalRandoms) then
              begin
                NextPlayer(False);
                writeln('Stuck in an unsolvable random!')
                writeln('Unable to continue PowerTeleporting')
              end else
              begin
                NextPlayer(False);
              end;
            end;
          end else
          NextPlayer(False);
        until(i >= 1 + random(2));
        writeln('first repeat finished')
        writeln('FindFastRandoms');
        FindFastRandoms;
        wait(100);
        writeln('FindNormalRandoms');
        FindNormalRandoms;
        wait(100);
        checkLvlXP;
        wait(100);
        case TeleportUntil of
          'Certain Level' : if CurrentLevel >= Achieve then jobDone := True;
          'Certain XP'    : if CurrentXP >= Achieve then jobDone := True;
        end;
        writeln('CurrentLevel = ' + inttostr(CurrentLevel));
        writeln('CurrentXP = ' + inttostr(CurrentXP));
        writeln('Achieve = ' + inttostr(Achieve));
        if (jobDone) then writeln('jobDone = True');
      until(jobDone);
    end;

    All those writeln's are for debug as i didnt know why it wasnt working. Same with most waits.


    The second repeat untill(jobDone) doesnt work.
    jobDone is set to true (shown by the writeln) but it doesnt break out of the procedure.

    Can some1 have a look at see if they can see whats wrong with it.

    Thanks

  2. #2
    Join Date
    Apr 2007
    Posts
    220
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I can't get your script to work because I can't declare all of your variables. This is how for I got:
    SCAR Code:
    program New;
    {.include SRL/SRL.scar}
    {.include SRL\SRL\misc/trade.scar}
    {.include SRL\SRL\skill/magic.scar}
    var
    JobDone: boolean;
    TeleportTo:string;
    Teleported: integer;


    function FindFastRandoms: Boolean;
    var
      i: Integer;
    begin
      for i := 1 to 9 do
      begin
        case I of
          1: if FindDead then
              Result := True;
          2: if FindMod then
              Result := False;
          3: if FindMime then
              Result := True;
          4: if FindMaze then
              Result := True;
          5: if FindQuiz then
              Result := True;
          6: if FindDemon then
              Result := True;
          7: begin
              if NoGameTab then
              begin
                Result := True;
                Players[CurrentPlayer].loc := 'No GameTab';
                Logout;
                Exit;
              end;
            end;
          7: begin
              if InBlack then
              begin
                Result := True;
                Players[CurrentPlayer].loc := 'InBlack';
                Logout;
                Exit;
              end;
            end;
          8: If RC Then
              Result := True;
          9: if FindTalk then
              Result := True;
          10: If HandleTrade Then
               Result := True;
        end;
        wait(1);
      end;
    end;

    procedure Teleport;
    var
    i : integer;
    begin
      jobDone := False;
      repeat
        writeln('first repeat');
        i := 0
        repeat
          writeln('sencond repeat');
          wait(100)
          if (not(FindFastRandoms)) then
          begin
            wait(500 + random(500));
            if (Cast(TeleportTo + ' Teleport')) then
            begin
              wait(500 + random(500));
              Teleported := Teleported + 1;
              writeln('Teleported = ' + inttostr(Teleported));
              wait(500 + random(500));
              i := i + 1;
              writeln('i = ' + inttostr(i));
              wait(2500 + random(500));
            end else
            begin
              if (FindFastRandoms) or (FindNormalRandoms) then
              begin
                NextPlayer(False);
                writeln('Stuck in an unsolvable random!')
                writeln('Unable to continue PowerTeleporting')
              end else
              begin
                NextPlayer(False);
              end;
            end;
          end else
          NextPlayer(False);
        until(i >= 1 + random(2));
        writeln('first repeat finished')
        writeln('FindFastRandoms');
        FindFastRandoms;
        wait(100);
        writeln('FindNormalRandoms');
        FindNormalRandoms;
        wait(100);
        checkLvlXP; //How do I declare this?
        wait(100);
        case TeleportUntil of  //And teleportUntil?? and there are prolly more..
          'Certain Level' : if CurrentLevel >= Achieve then jobDone := True;
          'Certain XP'    : if CurrentXP >= Achieve then jobDone := True;
        end;
        writeln('CurrentLevel = ' + inttostr(CurrentLevel));
        writeln('CurrentXP = ' + inttostr(CurrentXP));
        writeln('Achieve = ' + inttostr(Achieve));
        if (jobDone) then writeln('jobDone = True');
      until(jobDone);
    end;

    begin
    setupSRL;
    Teleport;
    end.
    Can you plz declare the variables and include so that I can see what's wrong.. You can't just post a procedure without variables, then it's USELESS.

  3. #3
    Join Date
    Feb 2007
    Posts
    66
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Hey,
    Thanks for the help.
    I put in a writeln on the last line after the until(jobDone) to check if it breaks out of the until and it did.
    So from that I figured that for some reason it was just looping.

    I added NextPlayer(False); and it now logs out.
    Thats for the level.

    Need to test it for xp and so on, and then clear out all debug msgs, and prepare the script for a release

  4. #4
    Join Date
    Apr 2007
    Posts
    220
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by stylen View Post
    Hey,
    Thanks for the help.
    I put in a writeln on the last line after the until(jobDone) to check if it breaks out of the until and it did.
    So from that I figured that for some reason it was just looping.

    I added NextPlayer(False); and it now logs out.
    Thats for the level.

    Need to test it for xp and so on, and then clear out all debug msgs, and prepare the script for a release
    Np any more probs pm me Good luck with your script!

  5. #5
    Join Date
    Feb 2007
    Posts
    66
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Hey,

    Thanks.

    I just released my script.
    Be sure to have a look at it.

    http://www.villavu.com/forum/showthr...267#post119267

    Thanks

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Procedure Help...
    By impiwimpi in forum OSR Help
    Replies: 16
    Last Post: 01-08-2009, 06:20 PM
  2. Procedure TypeSendRandom & Procedure AutoResponder!
    By Ultra in forum Research & Development Lounge
    Replies: 12
    Last Post: 01-08-2008, 07:04 PM
  3. Replies: 8
    Last Post: 05-24-2007, 11:57 PM
  4. Procedure that calls random procedure?
    By Secet in forum OSR Help
    Replies: 2
    Last Post: 03-03-2007, 03:56 PM

Posting Permissions

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