Results 1 to 4 of 4

Thread: CoordsToItem

  1. #1
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default CoordsToItem

    So I'm having an issue with CoordsToItem in my alching script, I keep getting an error saying that the co-ordinates are out of bounds
    Progress Report:
    ** Warning in InvBox: Incorrect index: 0 **
    Warning! You passed a wrong xs to a finder function: -1. That is below 0, thus out of bounds. Setting the value to 0 for now.
    Warning! You passed a wrong ys to a finder function: -1. That is below 0, thus out of bounds. Setting the value to 0 for now.


    This is the procedure I am trying to use it in
    Simba Code:
    procedure ClickItem;
    var
      x,y,T: Integer;
    begin
      Status('ClickItem');
      if not LoggedIn then
        NextPlayer(False);
      if GameTab(Tab_Inv) then
      begin
        if ExistsItem(CoordsToItem(x,y)) then
        begin
          ClickMouse2(mouse_Left);
          Inc(Alch);
          WriteLn('Successfully clicked the item');
          MarkTime(T);
          repeat
          Wait(RandomRange(20,40));
          if FindDTM(Alchemy,x,y,MIX1,MIY1,MIX2,MIY2) or LvlInc then
            Break;
          until(TimeFromMark(T) > 8000);
        end else
        begin
          WriteLn('Item not found @ClickItem');
          NextPlayer(False);
        end;
      end else
      WriteLn('Not in inventory @ClickItem');
    end;

    Currently running Simba 991 and SMART v7.2
    So I developed a procedure to have a look at the InvBoxes, it seems that the SMART_DrawBoxEx function is drawing a square immediately above the correct invslot, but InvMouse is working appropriately.
    But CoordsToItem is returning 0 for every mouse position in the inventory.

    Try running this script and you will see what I mean.
    Simba Code:
    program P1ngScript;
    {$DEFINE SMART}
    {$i SRL/SRL.Simba}
    {$i SRL/SRL/Misc/SmartGraphics.Simba}

    procedure DeclarePlayers;
    begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;

      with Players[0] do
      begin
        Name         := '';          // Username
        Pass         := '';         // Password
        Active       := True;
      end;
    end;

    procedure SetupLogin;
    begin
      ClearDebug;
      {$IFDEF SMART}
        SRL_SixHourFix := True;
        Smart_FixSpeed := True;
      {$ENDIF}

      SetupSRL;
      DeclarePlayers;
      ActivateClient;
      if not LoggedIn then
        LoginPlayer;
    end;
    procedure DrawTheBox;
    var
      x,y,i: Integer;
      Color: Array of Integer;
    begin
      Color := [clWhite, clRed, clAqua, clYellow, clWhite, clRed, clAqua, clYellow, clWhite, clRed, clAqua, clYellow, clWhite, clRed, clAqua, clYellow, clWhite, clRed, clAqua, clYellow, clWhite, clRed, clAqua, clYellow, clWhite, clRed, clAqua, clYellow];
      SMART_ClearCanvas;
      for i := 0 to 27 do
      begin
        SMART_DrawBoxEx(False, False, InvBox(i + 1), Color[i]);
        InvMouse(i + 1,mouse_Move);
        Wait(RandomRange(800,1200));
        WriteLn(CoordsToItem(x,y));
      end;
    end;

    begin
      SetupLogin;
      DrawTheBox;
    end.

  2. #2
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    You didn't assign any integer value to ur x,y variables? You should call GetMousePos(x,y) to get the x,y coordinates first (after u move ur mouse there). Also you can just do 'for i:=1 to 28' instead of having to add 1 to i afterwards.

  3. #3
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    There is no I = 0 is what your error says:

    for i := 1 to 28 do
    I am Ggzz..
    Hackintosher

  4. #4
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    LOL! Dammit -.- GetMousePos(x,y) has fixed all my troubles. Thanks mate

    EDIT:
    @Brandon - If you look at the invmouse and drawboxex functions i have i + 1 as where it moves the mouse and what it draws the box of.
    EDIT2:
    @Riwu - GetMousePos fixed it. And with the i := 1 to 28 because I only have 28 colours in the 'Color' array and it took the first colour as 0 I was recieving an out of range error with i := 1 to 28
    Last edited by P1ng; 08-05-2012 at 07:33 AM.

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
  •