``` HELP stuck on Rectangle formation

HELP please Rectangle formation!!!!!

Please post your code formatted (put ``` on a new line before and after the code)

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:
        

# 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:
        
        pass
i dont under stand the last bit 
 
 # Command the last built unit by using the  x/y variables:

hello yo there :question:
heeellllooooo?
is you there?
if you are there please help me

he might be idle or off right now so please do not do ask if they are there @happy390

1 Like

ok i will
:zipper_mouth_face:

he will respond when he can

Hi. Sorry about leaving suddenly.
To make the archers and soldiers move you use (this is an example, not the answer):

hero.command(unit, "move", {"x": 22, "y": 35})

Think about what variables you need to put in, in the place of unit, 22, and 35.
Danny

1 Like

Just a question. to make a peasant build decoy it would be hero.command(peasant,"buildXY","decoy", {whatever place}), right?

No, it would be hero.command(peasant,"buildXY","decoy", x,y)

Ok. thanks for the correction!

hello i am back so can you help me now

I have done. You have to use hero.command(unit, “move”, {“x”: 10, “y”: 10}) (but with different variables) as I said above.
Danny

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.