Help with a script

Posted by Bakarus on Sun 17 Jun 2012 10:02 PM — 3 posts, 13,447 views.

#0
I am wanting to make a script to search corpses after I kill them and then loot the items that have a chance to be on them after searching.


What I'd like to do is to count the number of corpses in the room, then search that many.

a typical room would have several types, like this:

The corpse of a mage is lying here.
(2) The corpse of an apprentice is lying here.
(3) The corpse of the janitor is lying here.

so i'd need to count the corpses, which would be 6, then have it search the 6 corpses, i.e. search corpse, search 2.corpse etc.

the items that can be found by searching are:

conditionals:

You find a blue orb hidden in the corpse
You find an ancient relic of unknown origin hidden in the corpse
You find a gem of true seeing hidden in the corpse
You find a Mana Stone hidden in the corpse


then i'd need to get the items, like get all.relic all.corpse if it was found.

any help would be appreciated, i've looked through the lua scripting docs, i suppose i could use a trigger when i look at the room, not sure how to count up the corpses thou.
#1
I could possibly make a trigger like:

The corpse of a * is laying here.

then I need to loop through the corpses in the room, Need to check lua docs for how to do a foreach or do/while loop putting them into an array or table i think it is in lua

then search each corpse in the collection, and doing a get all.item if anything is found.

Time to do some more reading :)
#2
I changed my approach, instead i just searched corpses incrementally until i got the error message there is not *.corpse here, then made triggers for having found the various item, and looted them according to the incrementor. If anyone wants a copy of the plugin, let me know.