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.
# 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:
# 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.
Thanks so much! Now it works!
Lydia
This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.