[SOLVED] Help! Coded Orders

I dont know if this is an error when you call your function shouldnt there be stuff inside the parenthesis

I believe I did that here
Lydia

I believe that is not the problem
Lydia

According to the error, you current pos.x on line 28 is “201”, it is supposed to be a number 201. It translates, but gets a number within a string.

1 Like
# Read the message on the sign to determine which units to summon and where to place them.
# Check the guide for instructions on interpreting the orders.

sign = hero.findByType("sign")[0]
message = sign.message

# Tip: parse the sign, then summon the units, then send each unit to the right position.
def code():
    for i in range(0, len(message), 5):
        character = message[i]
        if character == "a":
            hero.summon("archer")
            lastBuilt = hero.built[-1]
            int(message[i+1])
            int(message[i+2])
            int(message[i+3])
            int(message[i+4])
            xone = message[i+1]
            xtwo = message[i+2]
            yone = message[i+3]
            ytwo = message[i+4]
            archer = hero.findNearest(hero.findByType("archer"))
            xone = xone * 10
            x = xone + xtwo
            yone = yone*10
            y = yone + ytwo
            int(x)
            int(y)
            if archer:
                hero.command(archer, "move", {'x':x, 'y':y})
        if character == "s":
            hero.summon("soldier")
        if character == "p":
            hero.summon("peasant")
        if character == "g":
            hero.summon("griffin-rider")
        if character == "p":
            pass
        if character == "A":
            pass

while True:
    code()

Now it still says the same thing for the same line
Lydia

This is bit is perfect, good job:

Now you just need to combine these bits:

Instead of doing them separately just define the x and y variables as int(message[i+1])
So you can combine those sections. int() doesn’t do anything by itself, you need to apply it to a variable.
In the same vein, you can get rid of this:

After that, it should work, then you can copy that code and put it in all of the if statements. You also don’t need this:

1 Like

# Read the message on the sign to determine which units to summon and where to place them.
# Check the guide for instructions on interpreting the orders.

sign = hero.findByType("sign")[0]
message = sign.message

# Tip: parse the sign, then summon the units, then send each unit to the right position.
def code():
    for i in range(0, len(message), 5):
        character = message[i]
        if character == "a":
            hero.summon("archer")
            lastBuilt = hero.built[-1]
            x = int(message[i+1])
            y = int(message[i+2])
            
            if lastBuilt:
                hero.command(lastBuilt, "move", {'x':x, 'y':y})
        if character == "s":
            hero.summon("soldier")
            lastBuilt = hero.built[-1]
            x = int(message[i+1])
            y = int(message[i+2])
            
            if lastBuilt:
                hero.command(lastBuilt, "move", {'x':x, 'y':y})
        if character == "p":
            hero.summon("peasant")
            lastBuilt = hero.built[-1]
            x = int(message[i+1])
            y = int(message[i+2])
            
            if lastBuilt:
                hero.command(lastBuilt, "move", {'x':x, 'y':y})
        if character == "g":
            hero.summon("griffin-rider")
            lastBuilt = hero.built[-1]
            x = int(message[i+1])
            y = int(message[i+2])
            
            if lastBuilt:
                hero.command(lastBuilt, "move", {'x':x, 'y':y})
        if character == "p":
            pass
        if character == "A":
            pass

while True:
    code()

This is what it happening
Lydia

Isn’t that P supposed to be a capitol P

No
20 characyerssssss

yes since you already have a lowercase p for peasant

It doesn’t matter anyways since I can’t summon paladins
Lydia

I does matter since you will pass for peasants

No because even if it is still a lowercase p it still summons and commands peasant.

I’ve said this over and over, it doesn’t matter. And replacing pass with continue just does the same thing

I’m afraid it’s gone back a bit. Let me explain more clearly. This is good:

You were pretty much there.
The only thing you needed to change from the old version of the code is adding int() to the start of message here:

Like xone = int(message[i+1])
Apart from that you should put the old version back.
Just change this bit:

xone = message[i+1]
xtwo = message[i+2]
yone = message[i+3]
ytwo = message[i+4]

Adding int() to message.
And get rid of this bit (only):

int(message[i+1])
int(message[i+2])
int(message[i+3])
int(message[i+4])

As for you Milton, I don’t think just guessing random things to change will help, in fact I know it won’t. Nothing you have said touches on the actual issues. If you don’t understand the level (which you don’t because you used github code) then don’t try and help someone else, you’re just wasting your own time, and theirs.

3 Likes

Thanks so much! Now it works!
Lydia

1 Like

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