Results 1 to 10 of 10

Thread: Reflection doesn't work on inv items with '-' hyphens

  1. #1
    Join Date
    May 2013
    Posts
    98
    Mentioned
    1 Post(s)
    Quoted
    33 Post(s)

    Default Reflection doesn't work on inv items with '-' hyphens

    Hi,

    Making a script using reflection/AL but using reflection.find on TReflectInvItems doesn't work when there is a hyphen "-" in the item's name, eg. anti-dragon shield or anti-venom potion won't be found.

    Is there a way around this or an aerolib method similar to reflection.find?

    Thanks.

  2. #2
    Join Date
    Feb 2013
    Location
    Rimmington
    Posts
    319
    Mentioned
    33 Post(s)
    Quoted
    183 Post(s)

    Default

    Hi,

    First of all always post your code, it saves time for the guy helping you to iron out any problems with your script.

    Try to debug all your inventory items and see what it tells you, easiest way to do this is to use a TReflecInvItemsArray and .GetAll and after that you simply Writeln all of the variables in the array..

    Best of luck





  3. #3
    Join Date
    May 2013
    Posts
    98
    Mentioned
    1 Post(s)
    Quoted
    33 Post(s)

    Default

    Thanks for your response @Fitta, i'll give an example of the code I was trying to use.

    Simba Code:
    procedure poisoned();
    var anti :TReflectInvItem;
    begin
      if (anti.Find('Anti-venom+(4)')) then
        begin
              Reflect.Mouse.Move(anti.GetPoint, 2, 2);
              fastClick(mouse_left);
        end else
              writeln('anti venom not found');

    When I run this function with an anti-venom+(4) potion in my inv, it doesnt find the potion. I use identical functions for eating food, which work. I also had trouble with another item with a hyphen "-", in it's name, so I think the problem lies there.


    Also I followed your advice and ran this

    Simba Code:
    var
    inv: TReflectInvItemArray;

    begin
    inv.GetAll
    writeln(inv);

    I'm not sure if I did something wrong, it returned a list of my inventory with IDs and references, but the names of all the inventory slots were blank.

    [{REFERENCE = 295051960, _INVSLOT = 1, _ID = 2444, _NAME = }, {REFERENCE = 295051960, _INVSLOT = 2, _ID = 3024, _NAME = }, {REFERENCE = 295051960, _INVSLOT = 3, _ID = 12913, _NAME = }, {REFERENCE = 295051960, _INVSLOT = 9, _ID = 2550, _NAME = }, {REFERENCE = 295051960, _INVSLOT = 11, _ID = 3144, _NAME = }, {REFERENCE = 295051960, _INVSLOT = 13, _ID = 385, _NAME = }, {REFERENCE = 295051960, _INVSLOT = 14, _ID = 3144, _NAME = }, {REFERENCE = 295051960, _INVSLOT = 15, _ID = 3144, _NAME = }, {REFERENCE = 295051960, _INVSLOT = 17, _ID = 385, _NAME = }, {REFERENCE = 295051960, _INVSLOT = 18, _ID = 3144, _NAME = }, {REFERENCE = 295051960, _INVSLOT = 19, _ID = 3144, _NAME = }, {REFERENCE = 295051960, _INVSLOT = 20, _ID = 385, _NAME = }, {REFERENCE = 295051960, _INVSLOT = 21, _ID = 385, _NAME = }, {REFERENCE = 295051960, _INVSLOT = 22, _ID = 385, _NAME = }, {REFERENCE = 295051960, _INVSLOT = 23, _ID = 385, _NAME = }, {REFERENCE = 295051960, _INVSLOT = 24, _ID = 385, _NAME = }, {REFERENCE = 295051960, _INVSLOT = 25, _ID = 12938, _NAME = }, {REFERENCE = 295051960, _INVSLOT = 26, _ID = 2560, _NAME = }, {REFERENCE = 295051960, _INVSLOT = 27, _ID = 385, _NAME = }, {REFERENCE = 295051960, _INVSLOT = 28, _ID = 385, _NAME = }]
    Last edited by EZ41; 06-13-2015 at 10:11 PM.

  4. #4
    Join Date
    Sep 2012
    Location
    Netherlands
    Posts
    2,752
    Mentioned
    193 Post(s)
    Quoted
    1468 Post(s)

    Default

    Quote Originally Posted by EZ41 View Post
    snip
    mmh same thing happend to me when searching for Menaphite thugs (npcs)
    edit: they have a Talk-to option maybe that breaks it?
    Last edited by Hoodz; 06-13-2015 at 10:37 PM.

  5. #5
    Join Date
    May 2013
    Posts
    98
    Mentioned
    1 Post(s)
    Quoted
    33 Post(s)

    Default

    hey hoodz,

    yeah that might well be it, seems there's a problem with reflection reading the hyphen/special characters.

    If anyone knows a way to search for a specific item in your inventory using aerolib or any other way in an AL/Reflection script other than bitmap/DTMs, which haven't worked very well in this situation, that'd be great.

  6. #6
    Join Date
    Aug 2007
    Posts
    539
    Mentioned
    20 Post(s)
    Quoted
    266 Post(s)

    Default

    Have you tried TReflectInvItem.GetName?

  7. #7
    Join Date
    May 2013
    Posts
    98
    Mentioned
    1 Post(s)
    Quoted
    33 Post(s)

    Default

    Quote Originally Posted by ineedbot View Post
    Have you tried TReflectInvItem.GetName?
    I just did that, heres my output:

    item 0 Magic potion(3)
    item 1 Super restore(4)
    item 2
    item 3 Shark
    item 4 Shark
    item 5 Shark
    item 6 Shark
    item 7 Shark
    item 8 Shark
    item 9 Shark
    item 10 Shark
    item 11 Shark
    item 12 Shark
    item 13 Ring of recoil
    item 14 Shark
    item 15 Shark
    item 16 Shark
    item 17 Shark
    item 18 Shark
    item 19 Shark
    item 20 Shark
    item 21 Shark
    item 22 Shark
    item 23 Shark
    item 24
    item 25 Ring of dueling(1)
    Notice items 2 and 25 were registered but .getName returned a blank string, those 2 items contained hyphens in their names (anti-venom, zul-andra teleport)
    Last edited by EZ41; 06-14-2015 at 02:49 AM.

  8. #8
    Join Date
    Feb 2013
    Location
    Rimmington
    Posts
    319
    Mentioned
    33 Post(s)
    Quoted
    183 Post(s)

    Default

    Simba Code:
    function isVenom: Boolean;
    var
      tInt: Integer;
    begin
      tInt := Reflect.Misc.GetSetting(102);
      Result := (tInt > 0);
      If tInt > 0 then
        Debug('GetSetting(102): ' + ToStr(Reflect.Misc.GetSetting(102)));
    end;

    procedure Venom;
    var
      S: TStringArray;
      I: Integer;
      Item: TReflectInvItem;
    begin
      If venomTimer.ElapsedTime < 4000 then
        Exit;

      If isVenom then
      begin
        Debug('We need to drink Anti-Venom');
        FTab(Gametab_Inventory);
        S := ['Anti-venom+(1)', 'Anti-venom+(2)', 'Anti-venom+(3)', 'Anti-venom+(4)'];
        For I:=0 to High(S)do
          If Item.Find(S[I])then
          begin
            interact(Item.GetBox, 'Drink', 'Drink', Mouse_Left);
            venomTimer.Restart;
          end;
      end;
    end;

    Mine works perfect, and has been for over 3 weeks.
    Most likely guys, is that you got a outdated itemdef.txt file

    I've asked elfyyy to pull a new one, but most likely he's on a boat somewhere enjoying life..

    Here's an itemdef.txt that contains a somewhat update version

    BE NOTED, as I've noticed that you're creating a zulrah script, you won't be able to see a grounditems stack if there's a mutagen in the stack, as mutagens are not in the itemdefs yet.
    The rest should be fine





  9. #9
    Join Date
    May 2013
    Posts
    98
    Mentioned
    1 Post(s)
    Quoted
    33 Post(s)

    Default

    Hey Fitta,

    Thanks, your help is really appreciated.

    I took a look at my 'itemdef' file, interestingly it actually did have anti-venoms on there, nevertheless I overwrote it with the one you linked (which does include mutagens at the very end, maybe it'll pick up your next one ). But when I run your code:

    Simba Code:
    S := ['Anti-venom+(1)', 'Anti-venom+(2)', 'Anti-venom+(3)', 'Anti-venom+(4)'];
        For I:=0 to High(S)do
          If Item.Find(S[I])then
             begin

    Item.Find(S[I]) still returns a negative result, even though I have multiple anti-venoms in my inv.

    EDIT: It seems your code will work for me, if I use item IDs rather than names, thanks Fitta


    PS Fitta, assuming you have your own zulrah script, how do you check your recoil is intact? chatbox to see the the message that it breaks? I tried with (wearingItem(15)), but that changes tab to look, so thats no good :/.
    Last edited by EZ41; 06-14-2015 at 03:40 PM.

  10. #10
    Join Date
    Feb 2013
    Location
    Rimmington
    Posts
    319
    Mentioned
    33 Post(s)
    Quoted
    183 Post(s)

    Default

    Quote Originally Posted by EZ41 View Post
    Hey Fitta,

    Thanks, your help is really appreciated.

    I took a look at my 'itemdef' file, interestingly it actually did have anti-venoms on there, nevertheless I overwrote it with the one you linked (which does include mutagens at the very end, maybe it'll pick up your next one ). But when I run your code:

    Simba Code:
    S := ['Anti-venom+(1)', 'Anti-venom+(2)', 'Anti-venom+(3)', 'Anti-venom+(4)'];
        For I:=0 to High(S)do
          If Item.Find(S[I])then
             begin

    Item.Find(S[I]) still returns a negative result, even though I have multiple anti-venoms in my inv.

    EDIT: It seems your code will work for me, if I use item IDs rather than names, thanks Fitta


    PS Fitta, assuming you have your own zulrah script, how do you check your recoil is intact? chatbox to see the the message that it breaks? I tried with (wearingItem(15)), but that changes tab to look, so thats no good :/.
    Just look for the text in chat box Clue: Use widgets





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
  •