Page 1 of 2

How to find a lost item - except revisiting each tile

Posted: Mon Jul 29, 2013 6:42 pm
by RobinSword
Hi there!

Seems to be a simple question, but I didn't find an answer to it with a quick search.

I dropped my bone amulets... considering them worthless... somewhere... I absolutely do not remember where... .
Now on level 9 I need one to open the iron door.
Is there any way - e.g. by using console commands - to find out where I dropped them or at least one of them?
I do not want to use the "spawn" command to spawn one because that's bad cheating.
But I really would like to know where the bone amulets are currently located so that I can go back and fetch them.
May be soft cheating, I know, but better than spawning. ;)
I tried the "findEntity" console command but it didn't work out.

Any help?

Thanks!

Re: How to find a lost item - except revisiting each tile

Posted: Mon Jul 29, 2013 7:21 pm
by Komag
You can do a huge search code. If you have NO map markers, the code can be much simpler:

Code: Select all

for i=1,9 do for j in allEntities(i) do if j.name="bone_amulet" then print(j.level,j.x,j.y) end end end
If you have map markers, you'll need to do more complex:

Code: Select all

for i=1,9 do for j=0,31 do for k=0,31 do for m in entitiesAt(i,j,k) do if m.name="bone_amulet" then print(m.level,m.x,m.y) end end end end end
I think that should work. Remember, coordinates 0,0 are the top left and 31,31 are the bottom right

Re: How to find a lost item - except revisiting each tile

Posted: Mon Jul 29, 2013 10:08 pm
by RobinSword
Thanks for the code!
Can I run this code directly from the console or how can I run this search script?

Thanks!

Re: How to find a lost item - except revisiting each tile

Posted: Mon Jul 29, 2013 10:21 pm
by Komag
yes, from console, all one line just as I gave it

Re: How to find a lost item - except revisiting each tile

Posted: Mon Jul 29, 2013 11:39 pm
by RobinSword
Hmm, does not work for me.
It says: [string "user-input"]:1: 'then' expected near '='

...for both scripts.

Re: How to find a lost item - except revisiting each tile

Posted: Tue Jul 30, 2013 12:16 am
by Komag
oops, need double == before name code

Re: How to find a lost item - except revisiting each tile

Posted: Tue Jul 30, 2013 8:33 am
by RobinSword
Great, it worked now! Thanks!

Re: How to find a lost item - except revisiting each tile

Posted: Tue Jul 30, 2013 8:52 am
by RobinSword
I tried the script with some other items and it seems not to work in some cases.
E.g. if an item lies in an alcove or behind an iron door it is not found.
Is it possible to adapt the script so that those places are also searched for?

Re: How to find a lost item - except revisiting each tile

Posted: Tue Jul 30, 2013 1:05 pm
by Komag
alcoves are different indeed (nothing to do with iron doors). You have to add even more complexity to the code, searching every item property so see if item.containedItems~=nil then for x in item.containedItems if x.name=="bone_amulet" blah blah blah

You can see this thread for that part:
viewtopic.php?f=14&t=5578

Re: How to find a lost item - except revisiting each tile

Posted: Tue Jul 30, 2013 6:32 pm
by RobinSword
Ok, I wrote now this script to search all the alcoves:

Code: Select all

for i=1,13 do for j=0,31 do for k=0,31 do for m in entitiesAt(i,j,k) do if m.containedItems~=nil then for x in m:containedItems() do if x.name=="lurker_hood" then print (x.level,x.name,m.x,m.y) end end end end end end end
It works fine for items lying inside the alcove on the shelf.
But the funny thing is: If an items lies in an alcove on the floor (not on the shelf!) it is not found! Neither by this script nor by the above.
So do I have to write a third script to search the alcove-floors and how would that look like?

Thanks for your continuous help!