Results 1 to 4 of 4

Thread: Useful Inventory item functions

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

    Default Useful Inventory item functions

    Recently came back from a long scripting break. I needed a procedure that moved a specific item to a specific inventory spot, and realized the reflection include didn't have anything for it (meanwhile aerolib did). Hehe... feel free to use ~ Js


    Simba Code:
    {
      Returns the inventory slot number of Item
      TReflectionInventory.GetItemSlot('Air rune');
    }


    function TReflectionInventory.getItemSlot(Item : String) : Integer;
    var
      inv : TReflectInvItem;
      i : Integer;
    begin
      result := -1;
      if inv.find(Item) then
        result := (inv.GetInvSlot());
      //writeln('Found ', Item, ' in slot ', inv.GetInvSlot());
    end;  

    {
      Moves Item to specific inventory spot
           MoveItemTo('Air rune', 5);
    }


    Procedure TReflectionInventory.moveItemTo(Item : string; targetSlot : Integer);
    var
      b, b2 : TBox;
      TheItem : TReflectInvItem;
      SX, SY, EX, EY: Integer;
    begin
      if (Reflect.Gametab.Current <> Gametab_Inventory) then
        Reflect.Gametab.Open(Gametab_Inventory);

      if (not TheItem.Find(item)) then
        exit;

      if (reflect.inv.GetItemSlot(item) = targetSlot) then
        exit;

      b  := reflect.inv.invBox(TheItem.getSlot);
      b2 := reflect.inv.invBox(targetSlot);

      Reflect.Mouse.Move(b);
      Wait(50 + Random(100));
      GetMousePos(SX, SY);
      HoldMouse(SX, SY, mouse_left);
      Wait(200 + Random(300));
      reflect.mouse.Move(b2);
      Wait(200 + Random(300));
      GetMousePos(EX, EY);
      Wait(50 + Random(100));
      ReleaseMouse(EX, EY, mouse_left);
    end;

    Simba Code:
    { Returns all slot(s) 'Item' is in,
        in the form of an array }


    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;
    useful for banking from a random slot ^

    Simba Code:
    //current one only returns hp if you are in combat

    function TReflectActor.GetHealth(): Integer; override;
    begin
      if (not (Player.IsLoggedIn)) then
        exit(-1);
      Result := StrToInt(Reflect.Widget.GetText(160, 5));
    end;
    Last edited by jstemper; 01-16-2017 at 07:11 PM. Reason: added some stuff :)

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

    Default

    O crap, can someone move this to
    Reflection (Old School RuneScape) -> Snippets

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

  4. #4
    Join Date
    Feb 2014
    Location
    UDFj-39546284
    Posts
    76
    Mentioned
    1 Post(s)
    Quoted
    43 Post(s)

    Default

    Perfect. Thanks a ton.

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
  •