1 Like
this guy says’'try hero pos ‘’
thats is what i say
1 Like
i dont get what is happenning i think you are on somethin else
Are you using Python or JS?
also it labels the coin
I'm pretty sure this defines the coin
coins = hero.findItems()
It tells the Hero that when you’re looking for Items, the item you want is a coin
So what you need to do is tell the Hero you wants to find coins/coin and then when it looks for coins/coin, you need to tell it to go to the coins position.
Hint
while coinIndex < len(coins):
coin = coins[coinIndex]
hero.moveXY(coin.pos.x, coin.pos.y)
here is my text
# Wait for ogres, defeat them and collect gold.
while True:
enemies = hero.findEnemies()
# enemyIndex is used to iterate the enemies array.
itemindex = 0
enemyIndex = 0
# While enemyIndex is less than len(enemies)
while enemyIndex < len(enemies):
# Attack the enemy at enemyIndex
enemy = enemies[enemyIndex]
hero.attack(enemy)
# Increase enemyIndex by one.
enemyIndex += 1
coins = hero.findItems()
# coinIndex is used to iterate the coins array.
items = hero.findItems()
x = coin.pos.x
y = coin.pos.y
while coinIndex < len(coins):
coin = coins[coinIndex]
hero.moveXY(coin.pos.x, coin.pos.y)
So what happens when you run it now?
same thing same thing
i edit it slightly
# Wait for ogres, defeat them and collect gold.
while True:
enemies = hero.findEnemies()
# enemyIndex is used to iterate the enemies array.
itemindex = 0
enemyIndex = 0
coinIndex = 0
# While enemyIndex is less than len(enemies)
while enemyIndex < len(enemies):
# Attack the enemy at enemyIndex
enemy = enemies[enemyIndex]
hero.attack(enemy)
# Increase enemyIndex by one.
enemyIndex += 1
coins = hero.findItems()
# coinIndex is used to iterate the coins array.
items = hero.findItem
while coinIndex < len(coins):
coin = coins[coinIndex]
hero.moveXY(coin.pos.x, coin.pos.y)
now it only picks up a coin once
Try putting this in the While
loop below it
oh ok rice runner il do that
here is my text
# Wait for ogres, defeat them and collect gold.
while True:
enemies = hero.findEnemies()
# enemyIndex is used to iterate the enemies array.
itemindex = 0
enemyIndex = 0
coinIndex = 0
# While enemyIndex is less than len(enemies)
while enemyIndex < len(enemies):
# Attack the enemy at enemyIndex
enemy = enemies[enemyIndex]
hero.attack(enemy)
# Increase enemyIndex by one.
enemyIndex += 1
coins = hero.findItems()
# coinIndex is used to iterate the coins array.
items = hero.findItem
while coinIndex < len(coins):
coin = coins[coinIndex]
while true:
hero.moveXY(coin.pos.x, coin.pos.y)
it only kills the enemys’
it also lags and says it is not done
That’s normal
I’d remove this
Remove the while true for here