View Full Version : 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.
Fitta
06-13-2015, 01:07 PM
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 :)
Thanks for your response @Fitta, i'll give an example of the code I was trying to use.
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
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 = }]
Hoodz
06-13-2015, 10:13 PM
snip
mmh same thing happend to me when searching for Menaphite thugs (npcs)
edit: they have a Talk-to option maybe that breaks it?
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.
ineedbot
06-14-2015, 12:17 AM
Have you tried TReflectInvItem.GetName?
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)
Fitta
06-14-2015, 01:40 PM
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 :redface:
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 (https://raw.githubusercontent.com/Elfyyy/OSR-Reflection/master/lib/internal/definitions/ItemDefs.txt)
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 :)
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 :p). But when I run your 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 :/.
Fitta
06-14-2015, 05:07 PM
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 :p). But when I run your 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 ;)
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.