The Trial in Sarven driving me mad- Python


#1

I’m just not understanding the error I’m getting. It keeps saying it’s trying to call a function. I feel like in the code below that all I should need to finish the level is to input the rest of the variables for locations. I’m using limited length glasses. Don’t know if that matters. Thanks in advance.

locationIndex = 0
locations = [[132,24]]

while locationIndex < len(locations):
enemies = hero.findEnemies()
enemyIndex = 0
mushrooms = hero.findItems()
itemIndex = 0

if enemyIndex < len(enemies):
    enemy = hero.findNearest(enemies)
    if enemy:
        if enemy.health > 0:
            hero.attack(enemy)
        else:
            enemyIndex +=1
            
    
    
elif itemIndex < len(mushrooms) and enemyIndex == 0:
    mush = hero.findNearest(mushrooms)
    if mush:
        hero.moveXY(mush.pos.x,mush.pos.y)
        itemIndex += 1
    
            
else:
    hero.moveXY(locationIndex[locations[0]],locationIndex[locations[1]])
    locationIndex += 1

edit: I just realized a lot of this code, like the enemy and item arrays, might be excessive. Still, even if I took away the stuff and made it simpler, pretty sure it would perform the same.


#2

#not:
locationIndex = 0
locations = [[132,24]]
#but:
locationIndex = 0
locations = [[30,20],[41,21],[52,22],[63,23][74,24],[85,25],[96,26],[107,27],[118,28],[129,29],[132,24],…]


#3

#not:
hero.moveXY(locationIndex[locations[0]],locationIndex[locations[1]])
locationIndex += 1
#but:
hero.moveXY(locations[locationIndex][0], locations[locationIndex][1])
locationIndex += 1


#4

I need help with the “Attempted to invoke bookmark for [Function]”
:nevermind! Thanks Jack. I didn’t do exactly what you said, but you did prompt me to remember how to set up the array index affecting the location properly as it’s own value. I should be good now.