Signal corpse help


#1

I need help with the signal corpse level. I’ve got the code, but my character doesn’t cleave when I place a black flag down. here is my code. if any one can tell me where iv’e gone wrong i would appreciate it.

while True:
green = self.findFlag(“green”)
black = self.findFlag(“black”)
nearest = self.findNearestEnemy()

if green:
    self.pickUpFlag(green)
elif black and self.isReady("cleave"):
    self.pickUpFlag(black)
    # Cleave!

self.cleave(enemy)
elif nearest and self.distanceTo(nearest) < 10:
self.attack(enemy)


#2

Did I not ask you to read the FAQ? Please format your code properly.

Is the command to cleave inside the elif-statement about the black flag? If not, you probably should put it in.


#3

Hi ! I need help. I stuck on this level, and dont know where is problem. Can somebody help me ? Is there any problem in the code ?

loop:
     green = self.findFlag("green")
     black = self.findFlag("black")
     nearest = self.findNearestEnemy()

    if green:
        self.pickUpFlag(green)
    elif black and self.isReady("cleave"):
        self.pickUpFlag(black)
        self.cleave(nearest)

    elif nearest and self.distanceTo(nearest) < 10:
        self.attack(nearest)

#4

We need more information than that if we are to help you. What happens wheb you run your code? Is there an error?


#5

Your code has a combination of tab and space before the lines:

<tab><space>green = self.findFlag("green")
<tab><space>black = self.findFlag("black")
<tab><space>nearest = self.findNearestEnemy()

Remove the spaces and it will work.

Question: Is this behavior documented?


#6

Here is my code:
loop:
green = self.findFlag(“green”)
black = self.findFlag(“black”)
nearest = self.findNearestEnemy()

if green:
    self.pickUpFlag(green)
elif black and self.isReady("cleave"):
    self.pickUpFlag(black)
    self.cleave()

if flag.color is violet and self.distanceTo() < 10:
    
    self.attack()
    self.attack()

It says “Try self.findFlag” but I can’t work please help.Thanks


#7

The compiler does not know the value of “flag” inside the instruction:

if flag.color is violet

Additionally you should not use a flag to attack: your hero can attack much faster than you can put flags.
Instead just use another elif:

elif self.distanceTo(nearest)<10:

Note that you had another error: self.distanceTo(nearest)


#8

I have edited but still, its some how wrong:
flag = self.findFlag()
if greenFlag:
self.pickUpFlag(greenFlag)
elif black and self.isReady(“cleave”):
self.pickUpFlag(black)
self.cleave()
elif self.distanceTo(nearest)<10:
self.attack()
self.attack()
elif purple and self.isReady(“electrocute”):
self.pickUpFlag(purple)
So can you please help, its not working.


#9

It says that I need to define that “greenFlag” but it won’t work


#10

That is because you have never defined greenFlag in your program.

Each time you use a variable, like

self.pickUpFlag(purple)

check if you have defined it already, that is if you are executing beforehand:

purple = some_value_here

In your case you want to do:

greenFlag= self.findFlag("green")
black=self.findFlag("black")
violet = sekf.findFlag("violet")

VIOLET, black, green give the VGB triangle on your keyboard so you can switch flags quickly with one finger, while using the mouse to set flag position


#11

Thanks I will try my best


#12

Hello! I have the same problem. Here is my code:

loop:
green = self.findFlag(“green”)
black = self.findFlag(“black”)
nearest = self.findNearestEnemy()

if green:
    self.pickUpFlag(green)

elif black and self.isReady("cleave"):
    self.pickUpFlag(black)
    self.cleave()

elif nearest and self.distanceTo(nearest) < 10:
    self.attack(nearest)
    pass

But i have this error.
Object doesn`t support property or method “attack”

Can you help me?


#13

Ok if I am correct, on the first elif statement, instead of:

elif black and self.isReady("cleave")
self.pickUpFlag(black)
self.cleave()

You need:

elif black and self.isReady("cleave")
self.cleave(nearest)

Hope this is some help to you!

Cheers :beers:


#14

Luke10, thanks, but it doesn’t work.


#15

Also, remember to use quotes around the word violet like this:
"violet" or any color for that matter(of the flags).

Another thing. Please format your code according to the discourse FAQ.


#16

Maybe you should try writing your code over again and include what I said:


#17

@Luke10 the reason it didn’t work is that the code that you said to use is missing an: after the elif statement.


#18

I need help my code is while(true) {
var green = hero.findFlag(“green”);
var black = hero.findFlag(“black”);
var nearest = hero.findNearestEnemy();

}

if (green) {
    hero.pickUpFlag(green);
} else if (black && hero.isReady("cleave")) {
    hero.pickUpFlag(black);
    var enemy = hero.findNearestEnemy();
    // Cleave
    if (hero.isReady("cleave")) {
        
    }
    hero.cleave(enemy);
} else if (nearest && hero.distanceTo(nearest) < 10) {
    // Attack
    if (enemy) {
                hero.attack(enemy);
    }

}

my hero doesn’t attack or try to pick up the flag… I need help! I play this for a school grade and my teacher won’t be back for a week and i am the highest level in my grade!