Results 1 to 10 of 10

Thread: Out of Global Vars range?

  1. #1
    Join Date
    Oct 2010
    Location
    Under a bridge
    Posts
    648
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Out of Global Vars range?

    Ok so it summer and im trying to write my first script again, and i think ill finish it this time as i have a lot of time but i have an error and need help

    I get
    Code:
    New window: 19071850
    [Hint] (106:10): Variable 'Result' never used at line 105
    [Hint] C:\Simba\Includes\SRL/SRL/core/SRLlog.scar(17:3): Variable 'THEFILE' never used at line 16
    Compiled succesfully in 998 ms.
    SRL Compiled in 31 msec
    Error: Out of Global Vars range at line 72
    The following DTMs were not freed: [SRL - Lamp bitmap, 1]
    The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap]
    and the script is

    Simba Code:
    program new;
    {$i SRL/SRL.scar}

    Type
        MonsterInfo = Record     // so that i can add more later
        MonName : String;
        SecoundName : String; // so if a monster in the same room has same colour
        MonColour : Integer;
        MonSat : Extended;
        MonHue : Extended;
        MonToll : Integer;
      End;

    Function SetMonster(TheName:String; Which:Integer):MonsterInfo;
    Begin

      Case TheName Of

      'zombie':Begin
                 Case Which Of
                   1:
                    With Result Do
                    Begin
                      MonName := 'Zombie';
                      SecoundName := 'Gaint rat';
                      MonColour := 3757940;
                      MonSat := 0.46;
                      MonHue := 0.07;
                      MonToll := 13;
                    End;
                  2:
                    With Result Do
                    Begin
                      MonName := 'Zombie';
                      SecoundName := 'GaintRat';
                      MonColour := 5198163;
                      MonSat := 0.02;
                      MonHue := 0.50;
                      MonToll := 17;
                    End;
                  3:
                    With Result Do
                      MonName := 'False';
                 End;
               End;

      End;

    End;


    Function FindMonster(TheName:String):Boolean;
    Var
        x,y,a,i:Integer;
        TheTPA:TPointArray;
        ATPA: TPointArrayArray;
        Click:TPoint;
    Begin

      If Not LoggedIn Then Exit;

                                                {
      Name1 := SetMonster(TheName).MonName;
      Name2 := SetMonster(TheName).SecoundName;
                                                }

      SetColorToleranceSpeed(2);

      a := 1;

      Repeat
      SetColorspeed2Modifiers(SetMonster(TheName,a).MonHue,SetMonster(TheName,a).MonSat); //as the colour can change
        If FindColorsSpiralTolerance(x,y,TheTPA,SetMonster(TheName,a).MonColour,MSX1,MSY1,MSX2,MSY2,SetMonster(TheName,a).MonToll) Then
          If Length(TheTPA)>1 Then
          Begin
            ATPA := TPAtoATPAEx(TheTPA,3,3);
              For I:= 0 to High(ATPA) Do
              Begin
                Click :=MiddleTPA(ATPA[I]);
                MMouse(Click.x,click.y,RandomRange(-3,3),RandomRange(-3,3));
                If (IsUpText(SetMonster(TheName,a).MonName) or IsUpText(SetMonster(TheName,a).SecoundName)) Then
                Begin
                  GetMousePos(x,y);
                  If Random(20) = 5 Then
                  Begin
                    Mouse(x,y,0,0,False);
                    If ChooseOption('Attack') Then
                    Begin
                      Result := True;
                      writeln('Found and click monster');
                      Exit;
                    End Else Begin
                      Mouse(x,y,0,0,True);
                      writeln('Found and clicked monster');
                      Result := True;
                      Exit;
                    End;
                  End;
                End;
              End;
            End;
            Inc(A);
      Until(False);
    End;

    Function Fighting:Boolean;
    Begin
              {
      Check for HP bar

      Check XP

               }


    End;




    begin
    SetupSRL;
    ActivateClient;
    FindMonster('zombie');
    end.

    Thanks for any help and your time Your all great here
    Quote Originally Posted by DD on IRC
    wanted to troll the troll

  2. #2
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Instead of calling SetMonster all those times, create a new variable!
    Simba Code:
    var
      monster: MonsterInfo;
    begin
      // blah blah..

      monster := SetMonster(theName, a);
      repeat
        SetColorspeed2Modifiers(monster.MonHue, monster.MonSat);
        // apply to the rest of the setMonster calls
    end;
    I bet that gets rid of your error.

  3. #3
    Join Date
    Jan 2008
    Location
    10° north of Hell
    Posts
    2,035
    Mentioned
    65 Post(s)
    Quoted
    164 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    Instead of calling SetMonster all those times, create a new variable!
    Simba Code:
    var
      monster: MonsterInfo;
    begin
      // blah blah..

      monster := SetMonster(theName, a);
      repeat
        SetColorspeed2Modifiers(monster.MonHue, monster.MonSat);
        // apply to the rest of the setMonster calls
    end;
    I bet that gets rid of your error.
    "a" changes.

    Dg's Small Procedures | IRC Quotes
    Thank Wishlah for my nice new avatar!
    Quote Originally Posted by IRC
    [22:12:05] <Dgby714> Im agnostic
    [22:12:36] <Blumblebee> :O ...you can read minds

  4. #4
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Then set "monster" after "a" is reset, or at the beginning of the loop.

  5. #5
    Join Date
    Oct 2010
    Location
    Under a bridge
    Posts
    648
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    Instead of calling SetMonster all those times, create a new variable!
    Simba Code:
    var
      monster: MonsterInfo;
    begin
      // blah blah..

      monster := SetMonster(theName, a);
      repeat
        SetColorspeed2Modifiers(monster.MonHue, monster.MonSat);
        // apply to the rest of the setMonster calls
    end;
    I bet that gets rid of your error.
    Thanks ive done that and it works, your great Also i love MSI

    Quote Originally Posted by Dgby714 View Post
    "a" changes.
    Yeah ive put the (monster := setmonster) in the loop

    Thanks your both great
    Quote Originally Posted by DD on IRC
    wanted to troll the troll

  6. #6
    Join Date
    Jan 2008
    Location
    10° north of Hell
    Posts
    2,035
    Mentioned
    65 Post(s)
    Quoted
    164 Post(s)

    Default

    Quote Originally Posted by Troll View Post
    Thanks ive done that and it works, your great Also i love MSI


    Yeah ive put the (monster := setmonster) in the loop

    Thanks your both great
    You're going to love the more "advanced" features of Lape/Titan (They both have it) would make this a lot more "elegant".

    Dg's Small Procedures | IRC Quotes
    Thank Wishlah for my nice new avatar!
    Quote Originally Posted by IRC
    [22:12:05] <Dgby714> Im agnostic
    [22:12:36] <Blumblebee> :O ...you can read minds

  7. #7
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Glad it worked; although, I still don't know why it throws an error. >.<

  8. #8
    Join Date
    Oct 2010
    Location
    Under a bridge
    Posts
    648
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Dgby714 View Post
    You're going to love the more "advanced" features of Lape/Titan (They both have it) would make this a lot more "elegant".
    Umm what is lape/Titan
    Quote Originally Posted by DD on IRC
    wanted to troll the troll

  9. #9
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by Troll View Post
    Umm what is lape/Titan
    Lape a Pascal Script alternative that Nielsie has been working on and Titan refers to SCAR Titan.

  10. #10
    Join Date
    Jan 2008
    Location
    10° north of Hell
    Posts
    2,035
    Mentioned
    65 Post(s)
    Quoted
    164 Post(s)

    Default

    =)

    This won't compile unless you move the internal functions out, but this is how I'd do it.

    Simba Code:
    program new;
    {$I SRL/SRL.scar}

    type
      TMonster = record
        Names: TStringArray;
        Color: TColor;
        Hue, Sat, Tol: Extended;
      end;
      TMonsterArr = array of TMonster;

    var
      MonsterArr: TMonsterArr;

    procedure LoadMonster(const Name: string);
      function Monster(const Name: TStringArray; const Color: TColor; const Hue, Sat, Tol: Extended): TMonster;
      begin
        Result.Name := Name;
        Result.Color := Color;
        Result.Hue := Hue;
        Result.Sat := Sat;
        Result.Tol := Tol;
      end;
    begin
      SetLength(MonsterArr, 0); //Reset

      case (Name) of
        'pig': begin
            SetLength(MonsterArr, 2);
            MonsterArr[0] := Monster([''], 0, 0.0, 0.0, 0.0);
            MonsterArr[1] := Monster([''], 0, 0.0, 0.0, 0.0);
          end;
        'cow': begin
            SetLength(MonsterArr, 2);
            MonsterArr[0] := Monster([''], 0, 0.0, 0.0, 0.0);
            MonsterArr[1] := Monster([''], 0, 0.0, 0.0, 0.0);
          end;
        'zombie': begin
            SetLength(MonsterArr, 2);
            MonsterArr[0] := Monster([''], 0, 0.0, 0.0, 0.0);
            MonsterArr[1] := Monster([''], 0, 0.0, 0.0, 0.0);
          end;
      end;
    end;

    procedure FindMonster();
      procedure _RandMArr(var Arr: TMonsterArr);
      begin
        //Didn't write this cause I'm lazy....
        //Results the same arr >..>
      end;
    var
      TempArr: TMonsterArr;
      oC, A, H, J, I: Integer;
      oH, oS: Extended;
      Point: TPoint;
      Points: TPointArray;
      Points2D: T2DPointArray;
    begin
      if (not (LoggedIn)) then
        Exit;

      TempArr := MonsterArr;
      _RandMArr(TempArr);

      oC := GetToleranceSpeed();
      GetToleranceSpeed2Modifiers(oH, oS);
      try
        SetColorToleranceSpeed(2);

        H := High(TempArr);
        for A := 0 to H do
          with TempArr[A] do
          begin
            SetToleranceSpeed2Modifiers(Hue, Sat);

            if (FindColorsSpiralTolerance(MSCX, MSCY, Points, Color, MSX1, MSY1, MSX2, MSY2, Tol)) then
              if (Length(Points) > 1) then
              begin
                Points2D := TPAtoATPAEx(Points, 3, 3);
                J := High(Points2D);

                for I := 0 to J do
                begin
                  Point := MiddleTPA(Points2D[I]);
                  MMouse(Point.X, Point.Y, RandomRange(-3, 3), RandomRange(-3, 3));

                  if (IsUpTextMultiCustom(Names)) then
                  begin
                    if (Random(5) <> 0) then
                      Continue;

                    WriteLn('Found Monster!');
                    GetMousePos(Point.X, Point.Y);
                    Mouse(Point.X, Point.Y, 0, 0, False);
                    if (not (ChooseOption('Attack'))) then
                      Mouse(Point.X, Point.Y, 0, 0, True);
                    Result := True;
                    Exit;
                  end;
                end;
              end;
          end;
      finally
        SetColorToleranceSpeed(oC);
        SetToleranceSpeed2Modifiers(oH, oS);
      end;
    end;

    begin
    end.

    Dg's Small Procedures | IRC Quotes
    Thank Wishlah for my nice new avatar!
    Quote Originally Posted by IRC
    [22:12:05] <Dgby714> Im agnostic
    [22:12:36] <Blumblebee> :O ...you can read minds

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
  •