Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

[SOLVED] Help with the level "Don't rush, Be Quiet"

Here is my code.

// Dodge the cannons and collect 8 gems.
// Watch out, cannons are ready to fire!
// Move slow along a special pattern to confuse them.

// This function returns a value from 0 to 30:
function mod30(n) {
    if (n >= 30) {
        return n - 30;
    } else {
        return n;
    }
}

// This function should return a value from 0 to 40:
function mod40(n) {
    // Use an if-statement to return the correct value.
    if (n >= 40) {
        n = n- 40;
        return n;
    } else {
        return n;
    }
}

// You don't need to change the following code:
while (true) {
    var time = hero.now();
    var x = mod30(time) + 25;
    var y = mod40(time) + 10;
    hero.moveXY(x, y);
}

Also, for some reason,

…That happens.

I can’t find anything wrong. Maybe your should change your equipments?
may you show me your equipments?

I have a friend who is stuck on this level with the same code as this.

What gear do they have equipped?

Nevermind he got it fixed but I got stuck on the level Mountain Mercenaries. In Cloudrip Mountain.

I don’t know what I’m doing wrong. I have the fastest boots.


Sorry for the Necro

Look closely at the comment instructions in line 12. Then compare to what you have for code in that function.

1 Like

Mod edit: Please do not request solutions. The purpose of this board is to assist people with their code. Simply providing solutions is counter productive to the learning process. There are many people here willing and able to assist you with your code but we do not just give the answers. Thanks.

here is my code

# Dodge the cannons and collect 8 gems.
# Watch out, cannons are ready to fire!
# Move slow along a special pattern to confuse them.

# This function returns a value from 0 to 30 (0 <= n < 30)
def mod30(n):
    if n >= 30:
        return n - 30
    else:
        return n

# This function should return a value from 0 to 40 (0 <= n < 40)
def mod40(n):
    # Use an if-statement to return the correct value.
    if n:
        return n

# You don't need to change the following code:
while True:
    time = hero.time
    x = mod30(time) + 25
    y = mod40(time) + 10
    hero.moveXY(25, 10)

But I am not moving

Compare your mod40(n): function with the mod30(n): function directly above it. Your mod40 function should be exactly like the mod30(n): function but with a value of 40 instead of 30.

Thank you, but I fixed it to the parts

1 Like

Hi. I can’t figure out whats wrong with my code:

# Dodge the cannons and collect 8 gems.
# Watch out, cannons are ready to fire!
# Move slow along a special pattern to confuse them.

# This function returns a value from 0 to 30 (0 <= n < 30)
def mod30(n):
    if n >= 30:
        return n - 30
    else:
        return n

# This function should return a value from 0 to 40 (0 <= n < 40)
def mod40(n):
    # Use an if-statement to return the correct value.
    if n >= 30:
        return n - 40
    else:
        return n

# You don't need to change the following code:
while True:
    time = hero.time
    x = mod30(time) + 25
    y = mod40(time) + 10
    hero.moveXY(25, 10)

P.S. I hope I formatted the code correctly :slight_smile:

1 Like

You said that it should be the exact same, just with a different value.

1 Like

Check your if statement. Do you see anything wrong with it? (and you formated the code right, well done!)

Andrei

1 Like

I think I should change the if n >= 30: to if n >= 40:. So the whole code is:

def mod30(n):
    if n >= 30:
        return n - 30
    else:
        return n

# This function should return a value from 0 to 40 (0 <= n < 40)
def mod40(n):
    # Use an if-statement to return the correct value.
    if n >= 40:
        return n - 40
    else:
        return n

# You don't need to change the following code:
while True:
    time = hero.time
    x = mod30(time) + 25
    y = mod40(time) + 10
    hero.moveXY(25, 10)

However, it still didn’t work… :confused:

1 Like

Can you show me your equipment?

Andrei

Gtg, I will let @Anna and @dedreous to help you more.

Andrei

1 Like

You have an error in your while true loop, @Rachel699 .

It should not be

time = hero.time

but

time = hero.now()

I’m pretty sure it said to not change those lines, and I didn’t, so it worked for me.

1 Like

Thanks for summoning me, @AnSeDra!

1 Like

No problem! Sorry for having to go away for now thought!

Andrei

1 Like