Results 1 to 7 of 7

Thread: "out of string range" in fighting script

  1. #1
    Join Date
    Sep 2007
    Location
    Michigan
    Posts
    3,862
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default "out of string range" in fighting script

    SCAR Code:
    procedure FindMob;
    var
      MobColors: array[0..2] of integer;
      i, t: Integer;
      dir: string;
    begin
      Findtalk;
      if (not (LoggedIn)) or (infight) then
       Exit;
      MobColors[0] := color1;
      MobColors[1] := color2;
      MobColors[2] := color3;
      begin
       case Random(4) + 1 of
         3: dir := 'nswe';
         4: dir := 'wens';
         5: dir := 'sewn';
         6: dir := 'ewns';
       end;
      begin
      for i := 3 to 6 do
      for t := 0 to 2 do
        if (not (NAFfight(MonsterName, MobColors[t], 5))) then
          writeln('Rotating camera looking for Mob...')
          MakeCompass(StrGet(dir, i))
        end;
      end;
    end;

    MakeCompass(StrGet(dir, i))

    Says this line ^ is "Out of string range" now I googled this and searched what I could in the Tuts and couldn't find what exactly it means.

    I know that it happens after it rotates the screen and can't find the monster/object color.

    If you need more of the script I posted the working version that I was going to put this into here : http://www.villavu.com/forum/showthread.php?t=18513

    Thanks much if you look and help me out!

  2. #2
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    i isn't in the string. Your string is from 1 to 4 and you search from 3 to 6:

    Code:
    for i := 3 to 6 do
    So that should be

    Code:
    for i := 1 to 4 do //also can be 0 to 3, I forgot.
    You can also do

    Code:
    dir[i]
    Hup Holland Hup!

  3. #3
    Join Date
    Sep 2007
    Location
    Michigan
    Posts
    3,862
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    Still not working *scratches head*

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

    Default

    Try changing this:
    SCAR Code:
    case Random(4) + 1 of
         3: dir := 'nswe';
         4: dir := 'wens';
         5: dir := 'sewn';
         6: dir := 'ewns';
       end;
      begin
      for i := 3 to 6 do
    into this:
    SCAR Code:
    case Random(4) + 1 of
        1: dir := 'nswe';
        2: dir := 'wens';
        3: dir := 'sewn';
        4: dir := 'ewns';
       end;
      begin
      for i := 1 to 4 do

    Like Nielsie95 already mentioned

    Btw I remember this part in a fighting fucntion from a previous SRL version..
    Here's the function:
    SCAR Code:
    {*****************************************************************************
    function FindMonster(Color1, Color2, Color3, Tolerance: Integer; MonsterName: String): Boolean;
    By: XxKanexX
    Description: Rotates compass in all 4 directions and searches for monster. If monster
    is found will Attack the monster using "KAttackMonster" function.
    *****************************************************************************}


    function FindMonster(Color1, Color2, Color3, Tolerance: Integer; MonsterName:
      string): Boolean;
    var
      i: Integer;
      dir: string;
    begin
      case Random(4) + 1 of
        1: dir := 'nswe';
        2: dir := 'wens';
        3: dir := 'sewn';
        4: dir := 'ewns';
      end;
      for i := 1 to 4 do
        if (not (KAttackMonster(Color1, Color2, Color3, Tolerance + i, monsterName)))
          then
          MakeCompass(StrGet(dir, i))
        else
        begin
          Result := True;
          Exit;
        end;
    end;
    ^^ from SRL 7.0

    -Tsn.
    [QUOTE=Santa_Clause;277761]I love you too TSN :p[/QUOTE]
    [CENTER][URL="http://www.stats.srl-forums.com/sigs"][IMG]http://www.stats.srl-forums.com/sigs/1324.png[/IMG][/URL][/CENTER]

  5. #5
    Join Date
    Sep 2007
    Location
    Michigan
    Posts
    3,862
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    Yep i tried that, twice in fact.

    I ended up do a simple:
    Makecompass('e')
    and n s w, and doing random 4
    Works okish, but not what I totally want.

    Anyone know how to move it by degrees until findobj()?

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

    Default

    Quote Originally Posted by Narcle View Post
    Yep i tried that, twice in fact.

    I ended up do a simple:
    Makecompass('e')
    and n s w, and doing random 4
    Works okish, but not what I totally want.

    Anyone know how to move it by degrees until findobj()?
    You can use DownKey(); and UpKey.
    You will have to find theinteger values (it are actually charsI think).
    Then you can hold down an arrow key, wait 100 ms and then lift the arrowkey back up so your camera rotates a little bit.
    I'mat school atm, so Ialso can't checkwchat would be the best to use.
    If you read this message PM me for more info later today.

    Regards,

    Stijn.
    [QUOTE=Santa_Clause;277761]I love you too TSN :p[/QUOTE]
    [CENTER][URL="http://www.stats.srl-forums.com/sigs"][IMG]http://www.stats.srl-forums.com/sigs/1324.png[/IMG][/URL][/CENTER]

  7. #7
    Join Date
    Sep 2007
    Location
    Michigan
    Posts
    3,862
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    SCAR Code:
    case random(2) of
            1: begin
                KeyDown(VK_RIGHT);
                repeat
                  wait(50);
                until(NAFfight(MonsterName, MobColors[i], 5));
                KeyUp(VK_RIGHT);
               end;
            2: begin
               KeyDown(VK_Left);
               repeat
                wait(50);
               until(NAFfight(MonsterName, MobColors[i], 5));
               KeyUp(VK_Left);
              end;
          end;
    --------------------------------------------------------------------

    I did try this, only problem is triggering the "until" in time to stop the rotation.
    Whats nice is it will click while rotating which is what I want, but it does it to much. So I'm going to figure out a better way to implement this.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. "Invalid encrypted string"
    By flamineon7 in forum OSR Help
    Replies: 5
    Last Post: 01-16-2009, 01:45 AM
  2. action="www.site.com" method="post"
    By Jason2gs in forum General
    Replies: 4
    Last Post: 05-17-2007, 11:50 PM
  3. Replies: 3
    Last Post: 04-19-2007, 03:44 AM
  4. Replies: 5
    Last Post: 10-26-2006, 11:30 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
  •