Error found in the level:
after running what looks like a problem-free code (although I believe that is not the problem). Anyone experienced the same thing?
Error found in the level:
after running what looks like a problem-free code (although I believe that is not the problem). Anyone experienced the same thing?
Actually, that is most likely a bug in your code, not the levelā¦please post your code so we can verify.
# Form up soldiers and archers in rectangle formations.
# The distance between units.
step = 8
# First form up soldiers.
sergeant = hero.findNearest(hero.findByType("soldier"))
# The coordinates of the bottom left corner.
soldierX = 8
soldierY = 8
# The width and height of the formation.
width = sergeant.rectWidth
height = sergeant.rectHeight
for x in range(soldierX, soldierX + width + 1, 8):
for y in range(soldierY, soldierY + height + 1, 8):
hero.summon("soldier")
lastUnit = hero.built[len(hero.built)-1]
# Command the last built unit by using the x/y variables:
hero.command(lastUnit, "move", x, y)
# Next form up archers.
sniper = hero.findNearest(hero.findByType("archer"))
# The coordinates of the bottom left corner.
archerX1 = 48
archerY1 = 8
# The coordinates of the top right corner.
archerX2 = sniper.archerX2
archerY2 = sniper.archerY2
for x in range(archerX1, archerX2 + 1, 8):
for y in range(archerY1, archerY2 + 1, 8):
# Summon an archer.
hero.summon('archer')
# Find the last built unit.
lastUnit = hero.built[len(hero.built) -1]
# Command the last built unit by using the x/y variables:
hero.command(lastUnit, "move", x, y)
pass
Can you send me the link to the level?
Andrei
How do I do that? I havenāt done it before.
The problem is here:
hero.command(lastUnit, "move", x, y)
Twiceā¦you have this statement in two places, which is fine, once it is corrected.
The āmoveā method is not expecting individual x/y componentsā¦it needs a vector, or ā.posā instead.
Here is the problem. Try to put this after āmoveā:
{"x": x, "y": y}
Andrei
Thanks a lot for the help ā it worked! However Idonāt understand why: the error appeared the first time and what it was saying; but also why I needed the format:
Could you explain?
The command āmoveā wants an position, not coordontes. x and y are cordonates, and {āxā: x, āyā: y} is an position. Do you understand?
Andrei
Yep, understood, what about āDonāt know how to transform: Setā ā is it just telling me that it doesnāt understand
?
That is correctā¦you sent it a āsetā of instructions that it does not know how to handle.
Thank you, all, for clarification!