avatar
Forest Miners

luckyman 791 9th Jan, 2022

PYTHON 0.76 KB
                                           
                         # Check if the mines are safe for the workers.

def checkEnemyOrSafe(target):
    # If `target` (the parameter) exists:
    if target:
        # Then attack target.
        hero.attack(target)
    # Otherwise:
    else:
        # Use say() to call the peasants.
        hero.say("All clear!")

while True:
    # Move to, and check the top right X mark.
    hero.moveXY(64, 54)
    enemy1 = hero.findNearestEnemy()
    checkEnemyOrSafe(enemy1)
    
    # Move to the bottom left X mark.
    hero.moveXY(16, 14)
    # Save the result of findNearestEnemy() in a variable.
    enemy2 = hero.findNearestEnemy()
    # Call checkEnemyOrSafe, and pass the
    # result of findNearestEnemy as the argument.
    checkEnemyOrSafe(enemy2)
                      
                                       
To share this paste please copy this url and send to your friends
RAW Paste Data

Comments

Authentication required

You must log in to post a comment.

Log in
    There are no comments yet.