Results 1 to 14 of 14

Thread: Load info of all items in inventory

  1. #1
    Join Date
    Feb 2017
    Posts
    22
    Mentioned
    0 Post(s)
    Quoted
    11 Post(s)

    Default Load info of all items in inventory

    So, I've been trying to use "InventoryContent: TReflectInvItemArray;" and various forms of Find('*') etc. and still hasn't managed to do it. Reason why I'm trying to do that is to count how many empty spots there is in my inventory and later on for banking.

  2. #2
    Join Date
    Apr 2016
    Location
    New Zealand
    Posts
    76
    Mentioned
    0 Post(s)
    Quoted
    32 Post(s)

    Default

    Using Aerolib, you can use the getInvCount and isInvFull functions, should hopefully be what you are looking for. If you want to keep it reflection only, just use the reflection function to see if there is an item in the slot, and copy the Aerolib code in your script.

  3. #3
    Join Date
    Jun 2013
    Location
    Scranton
    Posts
    496
    Mentioned
    5 Post(s)
    Quoted
    220 Post(s)

    Default

    Simba Code:
    (28 - reflect.Inv.Count());

  4. #4
    Join Date
    Jan 2012
    Location
    Sydney, Australia
    Posts
    877
    Mentioned
    12 Post(s)
    Quoted
    368 Post(s)

    Default

    Would this work as well? (not a reflection guy).

    Simba Code:
    procedure YourProcedure;
    begin
      if (reflect.Inv.Count = 28) then
        Do stuff
      else
        Continue doing stuff;
    end;

  5. #5
    Join Date
    Apr 2013
    Posts
    680
    Mentioned
    13 Post(s)
    Quoted
    341 Post(s)

    Default

    maybe?

    Simba Code:
    procedure YourProcedure;
    begin
      if Reflect.Inv.IsFull then
        Do stuff
      else
        Continue doing stuff;
    end;

    Simba Code:
    procedure YourProcedure;
    begin
      while not Reflect.Inv.IsFull do
      begin
        Do stuff
      end else
        Continue doing stuff;
    end;

    <------------------>



  6. #6
    Join Date
    Jan 2012
    Location
    Sydney, Australia
    Posts
    877
    Mentioned
    12 Post(s)
    Quoted
    368 Post(s)

  7. #7
    Join Date
    Apr 2013
    Posts
    680
    Mentioned
    13 Post(s)
    Quoted
    341 Post(s)

    Default

    Well he wanted to be able to count an item for banking... some chores will have multiple items.

    mining - gems and ore
    wood cutting - woods and nests

    Just search for each as they are deposited
    Code:
     Writeln(Reflect.Inv.count('Coal'));
    This will output the number of Coal to the console...

    but instead just store it a value(integer) within a function

    <------------------>



  8. #8
    Join Date
    Feb 2017
    Posts
    22
    Mentioned
    0 Post(s)
    Quoted
    11 Post(s)

    Default

    Sorry for late reply,anyway "Reflect.Inv.IsFull" works just fine when trying to figure, if there's still empty space. So thanks for that. Yet to manage load info of all items in inventory to array, but during later consideration it would only make it more complicate to look up information from there and doesn't bring any value. Tried different commands and for some reason I've problems with loading even a mere array of specific item, be it with find or w/e. Code below gives right away "Error: Don't know which overloaded method to call with params (record [0]Int32; [4]Int32; [8]Int32; [12]Int32; end, Int32, Int32) at line 76" from line "Reflect.Mouse.Move(depositItemBox(number), 3, 3);"

    Simba Code:
    InventoryContent: TReflectInvItem;
    InventoryAll: TReflectInvItemArray;
    number: Integer;                  

    rocedure Banking(DepItem: string);
    Begin

    InventoryAll.Get(DepItem);
    if InventoryContent.Find(DepItem) then
       begin
        number := RandomRange(Low(InventoryAll),High(InventoryAll));
        Reflect.Mouse.Move(depositItemBox(number), 3, 3);
        if Reflect.Text.IsUpTextMulti(DepItem)then
            begin
              Reflect.mouse.Click(MOUSE_RIGHT);
              Reflect.Text.ChooseOption('Deposit-all');
            end;
       end;
    End;
    Last edited by mellower; 02-15-2017 at 11:18 PM. Reason: got bit further

  9. #9
    Join Date
    Apr 2013
    Posts
    680
    Mentioned
    13 Post(s)
    Quoted
    341 Post(s)

    Default

    Quote Originally Posted by mellower View Post
    Sorry for late reply,anyway "Reflect.Inv.IsFull" works just fine when trying to figure, if there's still empty space. So thanks for that. Yet to manage load info of all items in inventory to array, but during later consideration it would only make it more complicate to look up information from there and doesn't bring any value. Tried different commands and for some reason I've problems with loading even a mere array of specific item, be it with find or w/e. Code below gives right away "Error: Don't know which overloaded method to call with params (record [0]Int32; [4]Int32; [8]Int32; [12]Int32; end, Int32, Int32) at line 76" from line "Reflect.Mouse.Move(depositItemBox(number), 3, 3);"

    Simba Code:
    InventoryContent: TReflectInvItem;
    InventoryAll: TReflectInvItemArray;
    number: Integer;                  

    rocedure Banking(DepItem: string);
    Begin

    InventoryAll.Get(DepItem);
    if InventoryContent.Find(DepItem) then
       begin
        number := RandomRange(Low(InventoryAll),High(InventoryAll));
        Reflect.Mouse.Move(depositItemBox(number), 3, 3);
        if Reflect.Text.IsUpTextMulti(DepItem)then
            begin
              Reflect.mouse.Click(MOUSE_RIGHT);
              Reflect.Text.ChooseOption('Deposit-all');
            end;
       end;
    End;

    Try; excuse the poor standards.
    Code:
    Function Banking(DepItem: string):Boolean;
    var
    _items : TReflectInvItemArray;
    InventoryContent: TReflectInvItem;
    h: Integer;
    invBox: TBox;
    mousePoint: TPoint;
    Begin
      if InventoryContent.Find(DepItem) then
        begin
         _items.GetAll;
          for h:=0 to high(_items) do begin
           invBox := InventoryContent.GetBox;
            mousePoint := middleBox(invBox);
             Reflect.Mouse.Move(mousePoint,3, 3);
           if Reflect.Text.IsUpText(DepItem)then begin
            Reflect.mouse.Click(MOUSE_RIGHT);
            result:= Reflect.Text.ChooseOption('Deposit-all');
           end;
         end;
       end;
    end;
    edited a result in there; so you can use if statements against it later. for counting - fail safes etc

    <------------------>



  10. #10
    Join Date
    Jun 2013
    Location
    Scranton
    Posts
    496
    Mentioned
    5 Post(s)
    Quoted
    220 Post(s)

    Default

    Quote Originally Posted by mellower View Post
    Sorry for late reply,anyway "Reflect.Inv.IsFull" works just fine when trying to figure, if there's still empty space. So thanks for that. Yet to manage load info of all items in inventory to array, but during later consideration it would only make it more complicate to look up information from there and doesn't bring any value. Tried different commands and for some reason I've problems with loading even a mere array of specific item, be it with find or w/e. Code below gives right away "Error: Don't know which overloaded method to call with params (record [0]Int32; [4]Int32; [8]Int32; [12]Int32; end, Int32, Int32) at line 76" from line "Reflect.Mouse.Move(depositItemBox(number), 3, 3);"

    Simba Code:
    InventoryContent: TReflectInvItem;
    InventoryAll: TReflectInvItemArray;
    number: Integer;                  

    rocedure Banking(DepItem: string);
    Begin

    InventoryAll.Get(DepItem);
    if InventoryContent.Find(DepItem) then
       begin
        number := RandomRange(Low(InventoryAll),High(InventoryAll));
        Reflect.Mouse.Move(depositItemBox(number), 3, 3);
        if Reflect.Text.IsUpTextMulti(DepItem)then
            begin
              Reflect.mouse.Click(MOUSE_RIGHT);
              Reflect.Text.ChooseOption('Deposit-all');
            end;
       end;
    End;
    edit; that won't work
    I'm not even sure if this is what you are after, but this is what I do when I have multiple of the same item and I want to deposit from a random inv slot that one of the items is in
    Simba Code:
    function TReflectionInventory.getAllItemSlots(Item: string): TIntegerArray;
    var
      I, J: Integer;
      Items: TReflectInvItemArray;
      Arr: TIntegerArray;
    begin
      setLength(Arr, 0);
      Items.getAll();
      for J := 0 to high(Items) do
        if (Pos(Item, Items[J].GetName()) > 0) then
          for I := 1 to 28 do
          begin
            if (Items[J].GetInvSlot() = (I)) then
            begin
              SetLength(Arr, Length(Arr) + 1);
              Arr[High(Arr)] := I;
            end;
          end;
      result := Arr;
      //writeln('Found ', Item, ' in slot(s) ', Arr);
    end;

    Simba Code:
    var
      J: integer;
      L: TIntegerArray;
    begin    
      L := Reflect.Inv.GetAllItemSlots('Oak logs');
      if (Length(L) < 1) then exit;
      J := random(0, Length(L) - 1);
      case Length(L) of
        (Length(L) = 1): Reflect.Mouse.Move(Reflect.Inv.InvBox(L[0]), mouse_left);
        (Length(L) > 1):
        begin
          Reflect.Mouse.Move(Reflect.Inv.InvBox(L[J]), Mouse_Right);
          Reflect.Text.ChooseOption('Deposit-All');
        end;
      end;
    end;

  11. #11
    Join Date
    Apr 2013
    Posts
    680
    Mentioned
    13 Post(s)
    Quoted
    341 Post(s)

    Default

    I would have done the mouse movements/clicking very different.. But the rest should work.]

    i tried to re-use the structure; he was already using

    *** edit you weren't quoting me >.<

    <------------------>



  12. #12
    Join Date
    Jun 2016
    Posts
    17
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Quote Originally Posted by mellower View Post
    Sorry for late reply,anyway "Reflect.Inv.IsFull" works just fine when trying to figure, if there's still empty space. So thanks for that. Yet to manage load info of all items in inventory to array, but during later consideration it would only make it more complicate to look up information from there and doesn't bring any value. Tried different commands and for some reason I've problems with loading even a mere array of specific item, be it with find or w/e. Code below gives right away "Error: Don't know which overloaded method to call with params (record [0]Int32; [4]Int32; [8]Int32; [12]Int32; end, Int32, Int32) at line 76" from line "Reflect.Mouse.Move(depositItemBox(number), 3, 3);"

    Simba Code:
    InventoryContent: TReflectInvItem;
    InventoryAll: TReflectInvItemArray;
    number: Integer;                  

    rocedure Banking(DepItem: string);
    Begin

    InventoryAll.Get(DepItem);
    if InventoryContent.Find(DepItem) then
       begin
        number := RandomRange(Low(InventoryAll),High(InventoryAll));
        Reflect.Mouse.Move(depositItemBox(number), 3, 3);
        if Reflect.Text.IsUpTextMulti(DepItem)then
            begin
              Reflect.mouse.Click(MOUSE_RIGHT);
              Reflect.Text.ChooseOption('Deposit-all');
            end;
       end;
    End;
    Person number 3 ready to chime in!

    Your logic is fine, there are just a few minor things wrong. First of all, you need to solve that.

    This line here is what was throwing your initial error.

    Simba Code:
    Reflect.Mouse.Move(depositItemBox(number), 3, 3);

    When you get an error about not knowing what overload method to use, it means that your inputs into the function or procedure don't match with what the function can actually solve. So, if you go and take a look at the Reflection include and take a look at what the Reflect.Mouse.Move procedure takes as inputs, you will find that when moving to a TBox, it does not need the extra x and y values for the randomness, since it's clicking within a box. So if you remove the "3, 3", that will solve that problem. (There are about 5 different ways you can put inputs into the Move procedure if you look at the overloads)

    Next,you would throw a similar error for Reflect.Text.IsUpTextMulti. You're trying to input a string, when it takes an array of strings. So if you just change it to IsUpText, you're sweet.

    And finally, make sure when you're doing anything in game using text, it is case sensitive, so double check you have the correct case. So "Deposit-all", should be "Deposit-All".

    With those changes, I got your script working.

    Simba Code:
    Procedure Banking(DepItem: string);
    Begin

    InventoryAll.Get(DepItem);
    if InventoryContent.Find(DepItem) then
       begin
        number := RandomRange(Low(InventoryAll),High(InventoryAll));
        Reflect.Mouse.Move(depositItemBox(number));
        if Reflect.Text.IsUpText(DepItem)then
            begin
              Reflect.mouse.Click(MOUSE_RIGHT);
              Reflect.Text.ChooseOption('Deposit-All');
            end;
       end;
    End;

    One other thing though, it's not necessarily important but could help in future. There is an Interact procedure for TReflectInvItem. So if you were to take your InventoryAll array. An set InventoryContent to a random item from that array. Then use the Interact function with it, you could shorten your procedure quite a bit. And instead of using Item.Find to check if the item exists in the inventory. You can use the TReflectInventory.Contains(itemName) function. Just returns a boolean. The same kind of thing, but yeah. I'd recommend using it before you try and fill the InventoryAll array.

    Simba Code:
    MyInventory: TReflectInventory;

    Procedure Banking(DepItem: string);
    Begin
     if MyInventory.Contains(DepItem) then
     begin
      InventoryAll.Get(DepItem);    
      InventoryContent := InventoryAll[RandomRange(Low(InventoryAll),High(InventoryAll))];
      InventoryContent.Interact('Deposit-All');
     end;
    End;

    I know this is meant to like, a learning community, so I tried my best to provide some explanations rather than just give you an answer. Hope this helped!
    Last edited by Rangerxmage; 02-16-2017 at 05:11 AM.

  13. #13
    Join Date
    Feb 2017
    Posts
    22
    Mentioned
    0 Post(s)
    Quoted
    11 Post(s)

    Default

    Thanks for help guys. Especially Rangerxmage,that type of posts really helps people to undertand where they've made mistaken and can easily avoid same mistakes later on.

  14. #14
    Join Date
    Jun 2016
    Posts
    17
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Quote Originally Posted by mellower View Post
    Thanks for help guys. Especially Rangerxmage,that type of posts really helps people to undertand where they've made mistaken and can easily avoid same mistakes later on.
    No worries. One thing with programming, is as random as they may seem, error messages usually are pretty clear with what's gone wrong. If you can understand what the error means, it makes it a lot easier to debug and fix your script. Because usually it's something minor.

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
  •