pabstblueribbon
06-17-2009, 09:51 AM
Okay.
Preface: I know Gib has already done a box dropper in a similar thread. I stole some of the logic from it and I know it does the job. However I'm trying to learn how .scan and other things work so, here I am, trying to hack some of the logic from Gib's script and another script so it actually scans the contents of a container and empties anything in the container that is defined in an array.
The problem: For some reason it works awesome, up until there is only 1 of the items in my item array and then it wont take out the last item. Pointers as to why, how else to accomplish this, or if someone could actually explain whats going on I would be extremely grateful. (Learning to scan a containers contents would be really useful)
The definition:
def boxdrop
fput "drop right" if checkright =~ /(?:strong)?box|coffer|chest|trunk/
fput "stow right" if checkright
fput "drop left" if checkleft =~ /(?:strong)?box|coffer|chest|trunk/
fput "stow left" if checkleft
boxdb = ["coffer", "chest", "strongbox", "trunk", "box"]
fput "turn #{checkname} disk"
$boxcont.split(',').each { |boxcont|
fput("look in my #{boxcont}").scan(/\b(?:#{boxdb.join('|')})(?=,|\.)/).each { |box|
fput "take my #{box} from my #{boxcont}"
fput "drop my #{box}"
sleep 0.15
fput "drop my #{box}" if(checkright(box) or checkleft(box))
}
}
end
Preface: I know Gib has already done a box dropper in a similar thread. I stole some of the logic from it and I know it does the job. However I'm trying to learn how .scan and other things work so, here I am, trying to hack some of the logic from Gib's script and another script so it actually scans the contents of a container and empties anything in the container that is defined in an array.
The problem: For some reason it works awesome, up until there is only 1 of the items in my item array and then it wont take out the last item. Pointers as to why, how else to accomplish this, or if someone could actually explain whats going on I would be extremely grateful. (Learning to scan a containers contents would be really useful)
The definition:
def boxdrop
fput "drop right" if checkright =~ /(?:strong)?box|coffer|chest|trunk/
fput "stow right" if checkright
fput "drop left" if checkleft =~ /(?:strong)?box|coffer|chest|trunk/
fput "stow left" if checkleft
boxdb = ["coffer", "chest", "strongbox", "trunk", "box"]
fput "turn #{checkname} disk"
$boxcont.split(',').each { |boxcont|
fput("look in my #{boxcont}").scan(/\b(?:#{boxdb.join('|')})(?=,|\.)/).each { |box|
fput "take my #{box} from my #{boxcont}"
fput "drop my #{box}"
sleep 0.15
fput "drop my #{box}" if(checkright(box) or checkleft(box))
}
}
end