Sarven Sum Problem

# To disable the fire-traps add the lowest trap.value to the highest value.
# Move to the white X and say the answer to Kitty the cougar.
# Defeat all the ogres if you dare.
# Once all ogres are defeated move to the red X.
# Look out for potions to boost your health.
whiteX = {'x':27, 'y':42}
redX = {'x':151, 'y': 118}
while True:
    traps = hero.findByType("fire-trap")
    lowestTrap = None
    highestTrap = None
    minTrapVal = 0
    maxTrapVal = 999999
    trapIndex = 0
    while trapIndex < len(traps):
        if traps[trapIndex].value < maxTrapVal:
            lowestTrap = traps[trapIndex]
            maxTrapVal = lowestTrap.value
        if traps[trapIndex].value > minTrapVal:
            highestTrap = traps[trapIndex]
            minTrapVal = highestTrap.value
        trapIndex += 1
    hero.move(whiteX) # **This isn't working.** If I use hero.moveXY(27, 42) it works.
                     # What is the difference and why isn't whiteX working?
    hero.say(lowestTrap.value + highestTrap.value)

In the first part where movement is to hero.move(whiteX), the character says the answer (number) without moving and then just wanders into the active fire-traps. However, if I use hero.moveXY(27, 42) everything works fine. I can’t figure out why or what the difference is. Since whiteX is clearly defined I would think that either should work. I have the correct boots and the hero.move(redX) is working fine but hero.move(whiteX) is not. What am I doing wrong?


You’re using advanced boots.

hero.move(object w/ x, y properties) tells your hero to take a singular step towards x/y.
hero.moveXY(x, y) tells your hero to move to that location and not do anything else until they arrive.

You have a break in your while-true so after you take 1 step towards whiteX and say the lowest+highest trap value, you quit out of the loop and stop doing stuff.

Just understand the difference between move and moveXY and replace your hero.move(whiteX) with a moveXY instead.