I have been trying to get this to work but have no Idea what I am doing wrong. I am still learning and still figuring things out.
This is my code so far:
coinAmount = 0
loop:
while coinAmount < 20:
coin = self.findItems()
coins = self.findNearest(coin)
self.moveXY(coins.pos.x, coins.pos.y)
if coins.value == 1:
coinAmount += 1
if coins.value == 2:
coinAmount += 2
if coins.value == 3:
coinAmount +=3
while coinAmount >= 20:
towers = self.findByType(“arrow-tower”)
tower = self.findNearest(towers)
self.moveXY(tower.pos.x +6, tower.pos.y)
coinAmount -= 20
self.moveXY(self.pos.x +2, self.pos.y)
It collects the coins correctly and it goes to the tower correctly and makes a soldier but it doesn’t count the 20. It would wait till I had 40 coins than 50, 90, and 150.
I thought that coinAmount was resetting to 0 everytime so I moved it outside the loop so it never reset but it continued. I have tried various things and cant get it to sort itself out. please help me figure out what I am missing. I am sure it is a simple mistake that I am over looking.