Results 1 to 4 of 4

Thread: Update/Change WithdrawItem/WithdrawItemEx to use TstringArray

  1. #1
    Join Date
    Mar 2012
    Posts
    78
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default Update/Change WithdrawItem/WithdrawItemEx to use TstringArray
    -
    This post was made as an issue

    Currently WidrawItem has the wrong documentation, it states that it uses a TStringArray, but this is incorrect, and a Type mismatch will occur.
    This is due to WithdrawItemEx taking a string (it's documentation is consistent in this)

    Could this be possibly updated to use a TStringArray instead, it has been practically done in a similar sort of function like in WithdrawEx.

    I tried a quick edit basing it off WithdrawEx, I have not tested/compiled as im going to bed now :P It's below the old

    OLD
    Simba Code:
    (*
    WithdrawItem
    ~~~~~~~~~~~~

    .. code-block:: pascal

        function WithdrawItem(Ident: integer; IdentType: string; Amount: integer;
                               UpText: TStringArray; Tol: TIntegerArray): boolean;

    Withdraws an item using WithdrawItemEx, but removes the Index check.

    .. note::

        Author: Nava2
        Last Modified: Unknown

    Example:

    .. code-block:: pascal

        if WithdrawItem(theColor, 'color', 27, ['ew log', 'ew l'], [3]) then
        CloseBank;
    *)

    function WithdrawItem(Ident: integer; IdentType: string; Amount: integer; UpText: String; Tol: TIntegerArray): boolean;
    var
      I : Integer;
    begin
      Result := WithdrawItemEx(Ident, IdentType, I, Amount, UpText, Tol);



    NEW:
    Simba Code:
    (*
    WithdrawItemEx
    ~~~~~~~~~~~~~~

    .. code-block:: pascal

        function WithdrawItemEx(Ident: integer; IdentType: string; var Index: integer;
                     Amount: integer; UpTexts: TStringArray; Tol: TIntegerArray): boolean;

    Withdraws an item from the bank by using "Ident" with tol[0]
    as color tolerance, tol[1] as contour tolerance in case of bmp
    masks, or the count of colors for TPA item finding.
    Valid IdentTypes are all in FindItem.

    Index:

        The Bank Index where the item is found, must be a variable.
        Speeds up future withdraws.

    Amount:

        Amount to withdraw from bank.

    UpText:

        The UpText which the function checks for.

    .. note::

        Author: Nava2  - modified IxilisI
        Last Modified: 19/01/13

    Example:

    .. code-block:: pascal

        if WithdrawItemEx(theColor, 'color', itemSlot, 27, ['ew','ogs'], [3]) then
        CloseBank;
    *)

    function WithdrawItemEx(Ident: integer; IdentType: string; var Index: integer; Amount: integer; Uptexts: TStringArray; Tol: TIntegerArray): Boolean;
    var
      x, y: integer;
      BPoint: TPoint;
      BankBox: TBox;
      Found: Boolean;
      t: TPointArray;
    label
      Start;
    begin
      Result := False;
      if not BankScreen then Exit;
      FixBank;

      if (Index = 0) then
      begin
        Start:
        for Index := 1 to 50 do
        begin
          if FindItemEx(x, y, IdentType, Ident, BankIndexToMSBox(Index), Tol) then
          begin
            MMouse(x, y, 4, 4);
            if (Length(Uptexts) > 0) then
            if (WaitUptextMulti(Uptexts, 400)) then
            begin
              Writeln('Found Item at Bank Slot ' + IntToStr(Index) + '.');
              Found := True;
              Break;
            end else
              Writeln('Found Incorrect Item, Moving to new Bank Spot.');
          end;
        end;
      end else
      begin
        BankBox := BankIndexToMSBox(Index);
        FindColors(t, srl_outline_black, BankBox.x1, BankBox.y1, BankBox.x2, BankBox.y2);
        BankBox := GetTPABounds(t);
        MouseBox(BankBox.x1, BankBox.y1, BankBox.x2, BankBox.y2, mouse_move);
        if (Length(Uptexts) > 0) then
        if (WaitUptextMulti(Uptexts, 400)) then
          Found := true
        else
        begin
          Writeln('Item Moved from Bank Slot ' + IntToStr(Index) + ', checking bank again.');
          goto Start;
        end;
      end;
      Wait(RandomRange(200, 350));
      if Found then
      begin
        BPoint := BankIndexToBankPoint(Index);
        //Writeln(IntToStr(BPoint.x) + ', ' + IntToStr(BPoint.y));
        Withdraw(BPoint.x, BPoint.y, Amount);
        Result := True;
      end else
      begin
        Index := 0;
        SRL_Warn('WithdrawItem', 'Could not Find ' + IdentType + ' in Bank. [Uptext: ' + UpText + ']', Warn_AllVersions);
      end;
    end;

    (*
    WithdrawItem
    ~~~~~~~~~~~~

    .. code-block:: pascal

        function WithdrawItem(Ident: integer; IdentType: string; Amount: integer;
                               UpText: TStringArray; Tol: TIntegerArray): boolean;

    Withdraws an item using WithdrawItemEx, but removes the Index check.

    .. note::

        Author: Nava2  - modified IxilisI
        Last Modified: 19/01/13

    Example:

    .. code-block:: pascal

        if WithdrawItem(theColor, 'color', 27, ['ew log', 'ew l'], [3]) then
        CloseBank;
    *)

    function WithdrawItem(Ident: integer; IdentType: string; Amount: integer; UpTexts: TStringArray; Tol: TIntegerArray): boolean;
    var
      I : Integer;
    begin
      Result := WithdrawItemEx(Ident, IdentType, I, Amount, UpTexts, Tol);
    end;
    Last edited by Ixilisi; 01-18-2013 at 02:17 PM. Reason: missed a semicolon!

  2. #2
    Join Date
    Mar 2012
    Posts
    78
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Of course I search for things after they have been posted , this has already been mentioned but never rectified: http://villavu.com/forum/showthread.php?t=90870

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

    Default

    Changing a parameter type would break all scripts that use the function, which is a big no-no for changes to the current SRL repo.
    So we can at the very most change the doc (or make a new function that uses TSA)

  4. #4
    Join Date
    Mar 2012
    Posts
    78
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Would this perhaps make it into SRL 6 then? I'm guessing that will support lape and hence overloading which would fix that problem

Thread Information

Users Browsing this Thread

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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •