Results 1 to 8 of 8

Thread: Main loop error or my error?

  1. #1
    Join Date
    Oct 2006
    Posts
    1,190
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default Main loop error or my error?

    i decided to make a superheater cos it seemed like a good idea, anyways im a fair way into it and im having alot of trouble with the the script running i think it might have something to do with my main loop

    SCAR Code:
    program SuperHeat;
    {.include SRL/SRL.scar}
    {.include SRL/SRL/skill/magic.scar}
    {
    ==========================================================================
                    This script superheats any Ores
    ==========================================================================
                   Created for scar 3.12 and SRL 4

     1. USE Runescape with Low Detail, Very Bright.
     2. Set your Screen to 32 bit TRUE color.
     3. Set Playernames and Passwords in DeclarePlayers.
     4. Set NumberOfPlayers.
     5. Position Players at Falador East Bank with fire staff equiped
        and Nature runes in inventory
     6. Make sure your Players have WithdrawOress and nature runes

     Version 1- Original release
    ==========================================================================
    }

    var
      l, loads, x, y, nat: integer;

    const
      StartPlayer = 0;             // Determines who will play first
      MSpeed = 10;                 //speed of the mouse...higher number slower speed, lower number higher speed
      // MySRLID       = '';       // Must be a string!
      // MySRLPassword = '';       // Must be a string!
      VersionNumber = 1;           // No need to change

    procedure DeclarePlayers;
    begin
      HowManyPlayers := 1;               // Set Number of Players here.
      NumberOfPlayers(HowManyPlayers);   // Sets the Players Array Length;
      CurrentPlayer := StartPlayer;      // CurrentPlayer = Array Index

      Players[0].Name := 'user';            //username
      Players[0].Pass := 'pass';            //password
      Players[0].Nick := 'nick';            //3-4 consecutive letters of your user name(NOT First letter)
      Players[0].Strings[0] := 'steel';     //type of bar bronze,iron,steel,mith,adamantite,runite,gold,silver,
      Players[0].integers[0] := 10;         //how many times to cast superheat
      Players[0].Active := True;            //are you going to use this player
    end;

    procedure WithdrawNats;
    begin
      if (not (Loggedin)) then exit;
      if (not (bankscreen)) then exit;
      nat := DTMFromString('78DA633CC5C0C090C980023A1BEAC1342394C' +
        'F781D4824A3AAD9BF7D1BAA9AF340A204554D656101AA9A7D4022' +
        '17558DA78309AA9A639876CD99381155CD4D209187AA66C5DC39A' +
        '86A8E008962543591C1C1286A00FD5E12FA');

      if FindDTM(nat, x, y, MSX1, MSY1, MSX2, MSY2) then
      begin;
        Mouse(x, y, 3, 3, false)
          wait(100 + random(50))
        begin
          ChooseOption('Withdraw X');
          Wait(1000 + Random(100));
          TypeSend(IntToStr(players[currentplayer].Integers[0]) + Chr(13));
          FreeDTM(nat);
        end;
      end;
    end;

    function FindOre(oreType: string; var rx, ry: integer; x1, y1, x2, y2: integer):
      boolean;
    var
      ore, oreColor: integer;
      oreMP: TDTMPointDef;
      oreSP: array of TDTMPointDef;
      oreSkel: TDTM;
    begin
      case lowercase(oreType) of
        'copper': oreColor := 3834079;
        'tin': oreColor := 8553356;
        'iron': oreColor := 2305869;
        'silver': oreColor := 11971499;
        'coal': oreColor := 2702653;
        'gold': oreColor := 1815515;
        'mithril': oreColor := 7425357;
        'adamantite': oreColor := 5268302;
        'runite': oreColor := 7958098;
      else
        begin
          writeln('ore type not found');
          exit;
        end;
      end;
      setarraylength(oreSP, 4);

      oreMP.x := 580;
      oreMP.y := 229;
      oreMP.areasize := 1;
      oreMP.areashape := 0;
      oreMP.color := oreColor;
      oreMP.tolerance := 15;

      oreSP[0].x := 576;
      oreSP[0].y := 227;
      oreSP[0].areasize := 0;
      oreSP[0].areashape := 0;
      oreSP[0].color := 65536;
      oreSP[0].tolerance := 0;

      oreSP[1].x := 574;
      oreSP[1].y := 229;
      oreSP[1].areasize := 0;
      oreSP[1].areashape := 0;
      oreSP[1].color := 65536;
      oreSP[1].tolerance := 0;

      oreSP[2].x := 563;
      oreSP[2].y := 230;
      oreSP[2].areasize := 0;
      oreSP[2].areashape := 0;
      oreSP[2].color := 65536;
      oreSP[2].tolerance := 0;

      oreSP[3].x := 592;
      oreSP[3].y := 227;
      oreSP[3].areasize := 0;
      oreSP[3].areashape := 0;
      oreSP[3].color := 65536;
      oreSP[3].tolerance := 0;

      oreSkel.MainPoint := oreMP;
      oreSkel.SubPoints := oreSP;
      ore := AddDTM(oreSkel);

      result := findDTM(ore, rx, ry, x1, y1, x2, y2);
      freeDTM(ore);
    end;

    procedure WithdrawOres;
    begin;
      l := 0
        if (not (Loggedin)) then exit;
      if (not (bankscreen)) then exit;
      case lowercase(players[currentplayer].Strings[0]) of
        'bronze':
          begin
            if findOre('copper', x, y, msx1, msy1, msx2, msy2) then
            else
            begin
              writeln('Can not find copper');
              terminatescript;
            end;
            begin
              mouse(x, y, 3, 3, false);
              wait(250 + random(100));
              if chooseOption('X') then
              begin
                wait(100 + random(100));
                typesend('13');
              end;
            end;
            wait(500 + random(500));
            if findOre('tin', x, y, msx1, msy1, msx2, msy2) then
            else
            begin
              writeln('Can not find tin');
              terminatescript;
            end;
            begin
              mouse(x, y, 3, 3, false);
              wait(100 + random(100));
              if chooseOption('X') then
              begin
                wait(250 + random(100));
                typesend('13');
              end;
            end;
          end;
        'iron':
          begin
            if findOre('iron', x, y, msx1, msy1, msx2, msy2) then
            else
            begin
              writeln('Can not find iron');
              terminatescript;
            end;
            begin
              mouse(x, y, 3, 3, false);
              wait(100 + random(100));
              chooseOption('All');
            end;
          end;
        'silver':
          begin
            if findOre('silver', x, y, msx1, msy1, msx2, msy2) then
            else
            begin
              writeln('Can not find silver');
              terminatescript;
            end;
            begin
              mouse(x, y, 3, 3, false);
              wait(100 + random(100));
              chooseOption('All');
            end;
          end;
        'steel':
          begin
            if findOre('iron', x, y, msx1, msy1, msx2, msy2) then
            else
            begin
              writeln('Can not find iron');
              terminatescript;
            end;
            begin
              mouse(x, y, 3, 3, false);
              wait(100 + random(100));
              if chooseOption('X') then
              begin
                wait(250 + random(100));
                typesend('8');
              end;
            end;
            wait(500 + random(500));
            if findOre('coal', x, y, msx1, msy1, msx2, msy2) then
            else
            begin
              writeln('Can not find coal');
              terminatescript;
            end;
            begin
              mouse(x, y, 3, 3, false);
              wait(100 + random(100));
              if chooseOption('X') then
              begin
                wait(250 + random(100));
                typesend('16');
              end;
            end;
          end;
        'gold':
          begin
            if findOre('gold', x, y, msx1, msy1, msx2, msy2) then
            else
            begin
              writeln('Can not find gold');
              terminatescript;
            end;
            begin
              mouse(x, y, 3, 3, false);
              wait(100 + random(100));
              chooseOption('All');
            end;
          end;
        'mithril':
          begin
            if findOre('mithril', x, y, msx1, msy1, msx2, msy2) then
            else
            begin
              writeln('Can not find mirhril');
              terminatescript;
            end;
            begin
              mouse(x, y, 3, 3, false);
              wait(100 + random(100));
              chooseOption('5');
            end;
            wait(500 + random(500));
            if findOre('coal', x, y, msx1, msy1, msx2, msy2) then
            else
            begin
              writeln('Can not find coal');
              terminatescript;
            end;
            begin
              mouse(x, y, 3, 3, false);
              wait(100 + random(100));
              if chooseOption('X') then
              begin
                wait(250 + random(100));
                typesend('20');
              end;
            end;
          end;
        'adamantite':
          begin
            if findOre('adamantite', x, y, msx1, msy1, msx2, msy2) then
            else
            begin
              writeln('Can not find adamantite');
              terminatescript;
            end;
            begin
              mouse(x, y, 3, 3, false);
              wait(250 + random(100));
              if chooseOption('X') then
              begin
                wait(250 + random(100));
                typesend('3');
              end;
            end;
            wait(500 + random(500));
            if findOre('coal', x, y, msx1, msy1, msx2, msy2) then
            else
            begin
              writeln('Can not find coal');
              terminatescript;
            end;
            begin
              mouse(x, y, 3, 3, false);
              wait(100 + random(100));
              if chooseOption('X') then
              begin
                wait(250 + random(100));
                typesend('18');
              end;
            end;
          end;
        'runite':
          begin
            if findOre('runite', x, y, msx1, msy1, msx2, msy2) then
            else
            begin
              writeln('Can not find runite');
              terminatescript;
            end;
            begin
              mouse(x, y, 3, 3, false);
              wait(100 + random(100));
              if chooseOption('X') then
              begin
                wait(250 + random(100));
                typesend('3');
              end;
            end;
            wait(500 + random(500));
            if findOre('coal', x, y, msx1, msy1, msx2, msy2) then
            else
            begin
              writeln('Can not find coal');
              terminatescript;
            end;
            begin
              mouse(x, y, 3, 3, false);
              wait(100 + random(100));
              if chooseOption('X') then
              begin
                wait(250 + random(100));
                typesend('24');
              end;
            end;
          end;
      end;
    end;

    procedure HighestBrightness;
    var
      x, y, SlideButton: integer;
    begin
      GameTab(11);
      SlideButton := DTMFromString('78DA633CC6C4C0F0920105083ACE673002D28' +
        'C40FC1F08180F01D5BC4155A3A0610957030260358FD1D4683BA0' +
        'AA398DA9465CC516530D9A5D920A3A286A003116104C');
      x := 707;
      y := 228;
      if (not FindDTM(SlideButton, x, y, x - 25, y - 25, x + 25, y + 25)) then
        Mouse(711, 233, 2, 2, true);
      FreeDTM(SlideButton);
    end;

    procedure CastSuperheats;
    begin
      if (not (Loggedin)) then exit;
      Gametab(7);
      Cast('Superheat Item');
      Wait(450 + random(150));
      if findOre(players[currentplayer].Strings[0], x, y, MIX1, MIY1, MIX2, MiY2)
        then
      else
      begin
        writeln('Can not find ore');
        exit;
      end;
      begin
        MMouse(x, y, 2, 2);
        wait(50 + random(150));
        if IsUpText('Ore') then
        begin
          Mouse(x, y, 5, 5, True);
          Wait(450 + random(150));
        end;
      end;
    end;

    procedure Bank;
    var
      Bar, time: Integer;
    begin
      Bar := DTMFromString('78DA63946660601062400113DBDB19B880342' +
        '310FF0702460520839B010D302291401A648E0C01353C40429880' +
        '1A652021825F0D00B24D0699');

      MarkTime(time);
      repeat
        if (not (Loggedin)) then break;
        OpenBankQuiet('feb')
      until (BankScreen or (TimeFromMark(time) > 120000));
      if Bankscreen then
         else terminatescript;
      begin
        IsUpText('Bar')
        Deposit(2, 3, 2);
        CloseBank;
        loads := l + 1
      end;
      FreeDTM(Bar);
    end;

    procedure ProgressReport;
    begin
      ClearDebug;
      Writeln('<|----------------------------------------------|>');
      Writeln(' AutoFighter version 1 by Bonfield ');
      Writeln('                                                  ');
      Writeln(' Worked for ' + TimeRunning);
      Writeln('                                                  ');
      Writeln(' Banked ' + inttostr(Loads) + ' times');
      Writeln('<|----------------------------------------------|>');
    end;

    procedure Setup;
    begin;
      SetupSRL;
      ActivateClient;
      Mousespeed := Mspeed;
      DeclarePlayers;
      LoginPlayer;
      MakeCompass('n');
      HighestBrightness;
      SetAngle(true);
      OpenBankQuiet('feb');
      WithdrawNats;
    end;

    begin
      setup;
      repeat
        OpenBankQuiet('feb');
        WithdrawOres;
        CastSuperheats;
        FindNormalRandoms;
        Bank;
        ProgressReport;
      until (Loads = Players[currentplayer].integers[0]);
      if (LoggedIn) then
        LogOut;
      if (Players[CurrentPlayer].Active = false) then
        terminatescript;
    end.



  2. #2
    Join Date
    Mar 2007
    Location
    Netherlands->Amersfoort.
    Posts
    1,615
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

  3. #3
    Join Date
    Oct 2006
    Posts
    1,190
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    yeah it compiles just when i run it it sorta gets stuck in a loop and doesnt do what i want it to do ie withdraw nats check brighntness cast superheats



  4. #4
    Join Date
    Jan 2008
    Location
    Alberta
    Posts
    727
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    What part of it is it getting stuck on? withdrawing?

    Also make dtm's instead of colors for the ores.

  5. #5
    Join Date
    Oct 2006
    Posts
    1,190
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    no it withdraws ores ok it doesnt withdraw nature runes, or do some pther procedures that i call in the main loop

    is there any chance someone could run it and try to explain to me what is happening



  6. #6
    Join Date
    Jan 2007
    Location
    Tennessee
    Posts
    642
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Use WriteLn('some message');
    Just put it in every few lines where it could be messing up.
    Look at the last thing it writes in the display box and that is where it is stopping.

  7. #7
    Join Date
    Oct 2006
    Posts
    1,190
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    i changed my dtms and everything withdraws now i cant seem to get the cast superheat to work, it is because the findore fuction i have can not find the ore in my inventory but i can not find a way to fix it

    here is the superheat function
    SCAR Code:
    procedure CastSuperheats;
    begin
      if (not (Loggedin)) then exit;
      Gametab(7);
      Cast('Superheat Item');
      Wait(450 + random(150));
      begin
        if players[currentplayer].Strings[0] = 'bronze' then
          findOre('copper', x, y, MIX1, MIY1, MIX2, MiY2);
        if players[currentplayer].Strings[0] = 'iron' then
          findOre('iron', x, y, MIX1, MIY1, MIX2, MiY2);
        if players[currentplayer].Strings[0] = 'steel' then
          findOre('iron', x, y, MIX1, MIY1, MIX2, MiY2);
        if players[currentplayer].Strings[0] = 'mithril' then
          findOre('mithril', x, y, MIX1, MIY1, MIX2, MiY2);
        if players[currentplayer].Strings[0] = 'adamantite' then
          findOre('adamantite', x, y, MIX1, MIY1, MIX2, MiY2);
        if players[currentplayer].Strings[0] = 'runite' then
          findOre('runite', x, y, MIX1, MIY1, MIX2, MiY2);
        if players[currentplayer].Strings[0] = 'gold' then
          findOre('gold', x, y, MIX1, MIY1, MIX2, MiY2);
        if players[currentplayer].Strings[0] = 'silver' then
          findOre('silver', x, y, MIX1, MIY1, MIX2, MiY2);
        MMouse(x, y, 2, 2);
        wait(50 + random(150));
        if IsUpText('Ore') then
        else
        begin
          writeln('Can not find ore');
          terminatescript;
        end;
        begin
          Mouse(x, y, 5, 5, True);
          Wait(450 + random(150));
          AntiRandoms;
        end;
      end;
    end;

    i know that this is where the error is from it, but te scrip doesnt change gametab the magic one before writing in 'can not find ore' any ideas because i can nt see y it doesnt change to game tab 7 select the spell then teminate because of no ore?



  8. #8
    Join Date
    Oct 2006
    Posts
    1,190
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    EDITED MY LAST POST

    new error its in the post above this one



Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Repeat loop runtime error??? Huh????
    By Pure1993 in forum OSR Help
    Replies: 7
    Last Post: 08-16-2008, 09:55 PM
  2. Main loop???
    By cloutier15 in forum OSR Help
    Replies: 3
    Last Post: 05-11-2008, 09:53 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
  •