Results 1 to 5 of 5

Thread: QuickSelect

  1. #1
    Join Date
    Dec 2011
    Location
    Hyrule
    Posts
    8,662
    Mentioned
    179 Post(s)
    Quoted
    1870 Post(s)

    Default QuickSelect

    So pretty much I wanted a faster way to select a world when you have the world already set as one of your favorites. So I created a function called QuickSelect - Which uses the worldinfo parameter and checks if it is one of your favorite worlds. I edited SelectWorld so that it would check for this first - If it finds the left spot, it will click that - If it finds the right spot, it will click that - If it doesn't find it at either spot, it will just selectworld the normal way.

    Tested it a couple of times and seems to work. Just copy all of this code over the selectworld function to test it. Maybe a good idea to add?

    Would like some testing from others as well. If I didn't make sense, lemme know

    Simba Code:
    (*
    QuickSelect
    ~~~~~~~~~~~

    .. code-block:: pascal

        Function QuickSelect(World: Integer): Boolean;

    Checks to see if desired world is in the favorites shortcut. Returns 1 if left spot successful, 2 if right spot successful.

    ..note::

        by Ashaman88 & Le Jingle

    Example:

    .. code-block:: pascal

    *)

    function QuickSelect(World: Integer): Integer;
    var
      txt : array [0..1] of String;
      i : integer;
    begin
      Result := -1;
      for i := 0 to 1 do
      begin
        if inRange(world, 1, 99) then
          txt[i] := GetTextAtExWrap(569+(i*43), 448, 597+(i*47), 472, 0, 5, 2, 12378347, 2, 'LoginChars')
        else
          txt[i] := GetTextAtExWrap(569+(i*43), 448, 597+(i*47), 472, 0, 5, 2, 12378347, 2, 'SmallCharsNS');
        txt[i] := Copy(txt[i], 0, High(txt[i]));
        if strToIntDef(txt[0], 0) = world then
          result := 1
        else if strToIntDef(txt[1], 0) = world then
          result := 2;
        if inrange(result, 1, 2) then exit;
      end;
    end;

    (*
    SelectWorld
    ~~~~~~~~~~~

    .. code-block:: pascal

        Function SelectWorld(W: Integer): Boolean;

    Switches to the specified world. Returns true if successful.

    ..note::

        by Narcle & ZephyrsFury - edited by Ashaman88

    Example:

    .. code-block:: pascal

    *)

    function SelectWorld(W: integer): boolean;
    var
      x, y, xx, yy, T, CurW: integer;
      WRec: TWorld;
    begin
      if not InRange(W, 1, 200) then
      begin
        srl_Warn('SelectWorld', 'Invalid World', warn_AllVersions);
        Exit;
      end;

      case QuickSelect(W) of
        -1:
          if OpenWorldScreen then
          begin
            T := GetSystemTime + 60000;
            Repeat
              Wait(100+random(100));
            until InRange(CountColorTolerance(SRL_WS_ARROWCOLOR, 0, 0, 716, 240, 1), 550, 650) or (GetSystemTime > T);
            if (GetSystemTime > T) then
            begin
              Writeln('World screen did not load after a minute, please refreash.');
              Exit;
            end;
            WS_CurrentWorld(CurW);
            if (W = CurW) then
            begin
              Result := True;
              WriteLn('Already on world ' + IntToStr(W));
              Exit;
            end;

            if FindWorld(W) then
            begin
              wait(100+random(100));
              if GetWorldInfo(W, WRec) then
              begin
                Writeln('World: '+inttostr(WRec.Number)+', Players: '+inttostr(WRec.PlayerNo)+', Members: '+Booltostr(WRec.Members)+', PvP: '+Booltostr(WRec.PVP));
                if FindText(x, y, ' '+inttostr(W)+' ', StatChars, 84, 134, 140, 440) then
                begin
                  MMouse(x, y, 500, 4);
                  GetMousePos(x, y);
                  wait(400+random(100));
                  if FindColor(xx, yy, 6316128, x-20, y-2, x+20, y+2) then
                  begin
                    GetMousePos(x, y);
                    Mouse(x, y, 0, 0, mouse_left);
                    if FindColor(xx, yy, 19890, x-20, y-2, x+20, y+2) then
                    begin
                      Writeln('World '+inttostr(W)+' selected.');
                      Result := true;
                    end;
                  end;
                end;
              end else
                if WRec.PlayerNo = -2 then
                  WriteLn('World ' + IntToStr(W) + ' is FULL.')
                else
                  WriteLn('World ' + IntToStr(W) + ' is OFFLINE.')
            end else
              WriteLn('Failed to find World ' + IntToStr(W) + '!');
            if (not(Result)) then TypeByte(vk_Escape);
          end;
      1:
        begin
          MouseBox(569, 498-50, 597, 522-50, Mouse_Left);
          Result:=True;
        end;
      2:
        begin
          MouseBox(614, 498-50, 643, 522-50, Mouse_Left);
          Result:=True;
        end;
      end;
    end;
    Last edited by Ashaman88; 01-01-2013 at 10:48 PM.

  2. #2
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    Looks cool! Never really thought about this, but it would indeed speed up world selecting (forgot you could have starred/saved/special/etc. worlds)

    To ensure my post isn't just a 'bump' and to follow the 'trends' of other peoples suggestions threads, I'll throw in a possible alternate version? (lucky if it works :laugh: )

    Simba Code:
    function QuickSelect(World: Integer): Integer;
    var
      txt : array [0..1] of String;
      i : integer;
    begin
      Result := -1;
      for i := 0 to 1 do
      begin
        if inRange(world, 1, 99) then
          txt[i] := GetTextAtExWrap(569+(i*43), 448, 597+(i*47), 472, 0, 5, 2, 12378347, 2, 'LoginChars')
        else
          txt[i] := GetTextAtExWrap(569+(i*43), 448, 597+(i*47), 472, 0, 5, 2, 12378347, 2, 'SmallCharsNS');
        txt[i] := Copy(txt[i], 0, High(txt[i]));
        if strToIntDef(txt[0], 0) = world then
          result := 1
        else if strToIntDef(txt[1], 0) = world then
          result := 2;
        if inrange(result, 1, 2) then exit;
      end;
    end;

    nonetheless, I like the function and it's purpose

  3. #3
    Join Date
    Dec 2011
    Location
    Hyrule
    Posts
    8,662
    Mentioned
    179 Post(s)
    Quoted
    1870 Post(s)

    Default

    Yes I thought about making it prettier but didnt feel like it hehe. I will test your version out!

    I just got tired of it taking a lot longer time to select my world when all it needed to do was click the favorite button!

    Edit: Worked for me - try to test it out yourself and see how much time it saves!
    Last edited by Ashaman88; 01-01-2013 at 02:08 PM.

  4. #4
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    I'm not even sure if my snippet is even any better

    But, I did test and it does work for me! (replaced the include selectWorld and added your method above it)

    Works great for those who utilize the quick select worlds

  5. #5
    Join Date
    Dec 2011
    Location
    Hyrule
    Posts
    8,662
    Mentioned
    179 Post(s)
    Quoted
    1870 Post(s)

    Default

    Quote Originally Posted by Le Jingle View Post
    I'm not even sure if my snippet is even any better

    But, I did test and it does work for me! (replaced the include selectWorld and added your method above it)

    Works great for those who utilize the quick select worlds
    Yeah and it wouldn't break or mess up anything else

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
  •