Tried to set up a meeting between the hero and the pet in Medic School level. Replaced the default while loop with:
while True:
mushroom = hero.findByType("mushroom")[0]
if pet.target == 'Hero Placeholder':
hero.move(pet.pos)
elif mushroom:
hero.move(mushroom.pos)
and nothing happens…
The same code is working perfectly in javascript:
while (true){
var mushroom = hero.findByType("mushroom")[0];
if (pet.target == 'Hero Placeholder')
hero.move(pet.pos);
else if (mushroom)
hero.move(mushroom.pos);
}
Can somebody confirm my finding and is it a bug?(This is not an answer - the while loop is predefined )
I append my post because I think I’ve been not sufficiently clear. The original while loop in the level is equivalent to: ( Code in JavaScript)
while(true) {
var mushroom = hero.findByType("mushroom")[0];
if (mushroom)
hero.move(mushroom.pos);
}
And the result is:
Using the ‘enhanced’ version at the top the hero is running toward the pet and he/she is healed ( IMO ) a little bit faster. A split of a second is often the difference between life and death…
The question is:
Why the code is running in JavaScript and not in Python?