The two flowers help plz

1 Like

So basically, when you want to “define” a function, you should always follow this format:

def nameOfFucntion(): 
    # Parameters are things you can pass into the parenthesis beside the functions name
    # They are totally optional
    # You can use the parameters inside the function
    # For example, you can pass enemy as a parameter instead of defining it inside the function
    # Apart from the parameters, you put in whatever commands you like inside the functipo

Then when you want to use this function, you “call” it using its name and you shouldn’t forget the parenthesis, like this:


A working example:

define attackEnemy(enemy):
    if enemy:

while True:
    enemy = hero.findNearestEnemy()
1 Like

Also, can we see what gear you are using?

i think the gear is fine

ok what code do put in like is the code that is in the screen shot right

you should change lines 8 and 10 and change them to look like what i said above

It may be but it would always be helpful to see what they have on and so the tips you gibe could be a little bit more helpful.

Could you copy the code and then format it correctly using the </> button.

extra hint for commandSoldiers:

  1. The first line should be this: def commandSoldiers():
  2. Inside the function, you should find the array of soldiers, you can use hero.findByType("soldier")
  3. You should iterate over the array using a for-loop and inside it command each soldier to maybe attack their nearest enemy

as for pickUpNearestCoin you just need to find the closest item, if it exists, move to its position

1 Like

ok i will try that. if it does not work i will let you know

Okay! We are still here if you need help

help me plz it wont work i do not know what to do so plz hep me.

try hero.findFriends()

You need to put your code for attacking enemies in your while-loop, or else it only runs once. Also, you need to command your soldiers to attack an enemy if it exists.

You should have this as your While true loop.

while True:

Copy your code on lines 8-11 and paste it in your while-loop. Then, add code in your while loop to command your soldiers to attack an enemy if it exists.

Isn’t that what I basically just said?

1 Like

it says to define the code of command solder

I think the purpose of this level is to practice writing functions like the comments said, so while loops aren’t meant to be used more than the main while-true loop