You never checked if there is an item to collect in the first place. Change the
you define item as self.findItems(), which returns a list. Your character is trying to move to all the items at the same time, in a sense. You need to find the nearest
Ill try it, thanks.
While using the command
move, you should be targeting a dictionary of coordinates, like this:
You are only targeting the numbers themselves.
OMG, THE TITLE SAYS MULTIPLAYER TREASURE GROVE PYTHON!!! Seriously, be more attentive.
Well, i think the error here is using finditems(). You should be using findnearestitem() and that would solve all.
This post is over a month old. Please keep the dead resting!
… Super Gamer What chronist said there is python. You are just using the compound boots, in that case get rid of
and just put
elif item: self.move(item.pos)
Did I not just say to keep the dead resting? SuperGamer has likely solved his issue by now, otherwise he would have continued posting.
It could be useful for someone else…
For example, for me. I didn’t realize that move could be used like that, nor that it behaves that way, until this post. (Even while the description is somewhat “clear”, sometimes you need to test it to understand)
The problem with this, is that it moves 1 step each iteration, so it’s not useful in every situation. I think that movexy should be usable with “item.pos” as argument, or that we should have some move command that doesn’t require the coordinates to work. Like receiveing an object for reference as argument.
This is my code can someone help me
enemy = self.findNearest(self.findEnemies()) flag = self.findFlag() item = self.findNearest(self.findItems() if flag: self.pickUpFlag(flag) elif enemy == True: if distance < 30: if self.isReady("cleave") : self.cleave(enemy) else: if self.isReady("bash") : self.bash(enemy) else: if self.isReady("elecrocute") : if self.canElectrocute(enemy) : self.electrocute(enemy) else: self.attack(enemy) self.shield() else: self.moveXY(item.pos.x, item.pos.y)
- Do not use
elif enemy == True
- You have way too many nested ifs. Instead just use continue It tells the code interpreter to skip the rest of the code in the loop and start the loop again.
if flag: self.pickUpFlag(flag) continue if enemy: if distance < 30: if self.isReady("cleave"): self.cleave(enemy) continue if self.isReady("bash"): self.bash(enemy) continue
and so on
Where are you giving a value to distance ?
your code shields after each attack. In practice shield is extremely circumstantial.
Do not shield unless something on that level require it.
thankyou but my hero isn’t collecting coins
If you have used continue after each other actions, then just add:
if item: self.moveXY(item.pos.x, item.pos.y)
at the end of the loop