Formatting the code, and letting us know what the issue is that you are seeing would be really good. You may also want to look at moving your character to the item, so it picks it up.
Sorry its been a while since i was on but my character doesnt do any thing but attack enemies i try to make him follow the flags and find the coins but still he does nothing, here is my code.
(Python)
loop:
flag = self.findFlag()
enemy = self.findNearest(self.findEnemies())
item = self.findNearest(self.findItems())
if flag:
self.pickUpFlag(flag)
elif enemy:
self.attack(enemy)
elif item:
self.findNearest(self.findItems())