Don't Rush Be Quiet


#1

This is my code. Can someone help? I don’t know what is wrong with my code. My hero gets all gems, but dies shortly after.

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

def mod40(n):
# Use an if-statement to return the correct value.
item = hero.findNearestItem()
hero.moveXY(item.pos.x, item.pos.y)
hero.shield()
hero.shield()

return n

while True:
item = hero.findNearestItem()
items = hero.findItems()

time = hero.now()
x = mod30(time) + 25
y = mod40(time) + 10
hero.moveXY(item.pos.x, item.pos.y)

Thank You


#2

Function mod40(n) should return a value from 0 to 40.


#3

Can you explain that? I just started and I have no idea what that means. No offense.


#4

I explain it for Function mod30(n) ( should return a value from 0 to 30).

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

n=5 => else=> return 5
n=30=>else=> return 30
n=50=>if n>=30=> return 50-30 => return 20

return value is from 0 to 30 …


#5

Oh! Thanks! I understand now.


#6

I tried and it didn’t work. Thanks, though.