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

[SOLVED] Timber Guard "Don't know how to transform"

Every time I try to run my code it keeps saying, “Don’t know how to transform: Set.” I don’t even know which part of the code has an error because in other mistakes or errors I’ve made in code in other levels it always highlighted the error line in red. Can somebody help?

while True:
    # Collect gold.
    item = hero.findNearestItem()
    if item:
    # If you have enough gold, summon a soldier.
    if > hero.costOf("soldier"):
    # Use a for-loop to command each soldier.
    # For loops have two parts: "for X in Y"
    # Y is the array to loop over.
    # The loop will run once for each item in Y, with X set to the current item.
    for friend in hero.findFriends():
        if friend.type == "soldier":
            enemy = friend.findNearestEnemy()
            # If there's an enemy, command her to attack.
            if enemy:
                hero.command(friend, "attack", enemy)
            # Otherwise, move her to the right side of the map.
                hero.command(friend, "move", {79, 44})

Your final statement is not quite accurate.Try defining the position using a variable, and then command the ‘soldier’ to move there.

Something like: defendPos = {“x”: 79, “y”, 44}

and then, command(friend, “move”, defendPos)

1 Like